├── nagios-utils.ps1 ├── icinga2-commands.conf ├── check_exchange_health.ps1 ├── check_exchange_mailbox_databases.ps1 ├── README.md ├── check_exchange_edge_synchronization.ps1 ├── check_exchange_webservices.ps1 ├── check_exchange_queues.ps1 └── COPYING /nagios-utils.ps1: -------------------------------------------------------------------------------- 1 | $NagiosOk = 0 2 | $NagiosWarning = 1 3 | $NagiosCritical = 2 4 | $NagiosUnknown = 3 5 | 6 | $ErrorActionPreference = "Stop" 7 | $error.clear() 8 | 9 | # Return human readable state text 10 | function Plugin-State-Text ([int] $code) { 11 | switch ($code) { 12 | $NagiosOk {"OK"} 13 | $NagiosWarning {"WARNING"} 14 | $NagiosCritical {"CRITICAL"} 15 | $NagiosUnknown {"UNKNOWN"} 16 | } 17 | } 18 | 19 | function Perfdata-Label ([string] $name) { 20 | $name = $name -replace '[\s=\\]+', '_' 21 | $name = $name -replace "'", '' 22 | $name 23 | } 24 | 25 | function Plugin-Output ([int] $code, [string] $output) { 26 | if ($code -gt $NagiosUnknown) { $code = $NagiosUnknown } 27 | $state = Plugin-State-Text $code 28 | 29 | Write-Host "${state}: $output" 30 | foreach ($t in $args) { 31 | if ($t -isnot [array]) { 32 | $t = @($t) 33 | } 34 | foreach ($l in $t) { 35 | Write-Host $l 36 | } 37 | } 38 | } 39 | 40 | function Plugin-Performance-Output ($perfdata, [string] $prefix = '') { 41 | #if ($perfdata.Count -eq 0) { return } 42 | $text = "" 43 | if ($prefix -eq '') { $text += "|" } 44 | 45 | foreach ($key in $perfdata.Keys) { 46 | $label = Perfdata-Label $key 47 | $value = $perfdata[$key] 48 | 49 | if ($prefix) { 50 | $label = "${prefix}::${label}" 51 | } 52 | 53 | if ($value -is [string] -or $value -is [int]) { 54 | $text += " '${label}'=${value}" 55 | } elseif ($value -is [hashtable]) { 56 | $text += Plugin-Performance-Output $value $label 57 | } else { 58 | # ignoring invalid perfvalue 59 | } 60 | } 61 | 62 | if ($prefix) { 63 | return $text 64 | } else { 65 | Write-Host $text 66 | } 67 | } 68 | 69 | # Exit the plugin in a Nagios Plugin way 70 | function Plugin-Exit ([int] $code, [string] $output) { 71 | if ($output) { 72 | Plugin-Output $code $output @args 73 | } 74 | exit $code 75 | } 76 | -------------------------------------------------------------------------------- /icinga2-commands.conf: -------------------------------------------------------------------------------- 1 | object CheckCommand "powershell-base" { 2 | import "plugin-check-command" 3 | 4 | command = [ 5 | "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe" 6 | ] 7 | 8 | timeout = 1m 9 | 10 | arguments += { 11 | "-command" = { 12 | value = "try { & '$powershell_script$'" 13 | order = -1 14 | } 15 | ARGS = { 16 | value = "$powershell_args$" 17 | skip_key = true 18 | } 19 | END = { 20 | value = "; exit $$LastExitCode } catch { Write-Host ('UNKNOWN: ' + $$error); exit 3 }" 21 | order = 999 22 | skip_key = true 23 | } 24 | } 25 | } 26 | 27 | object CheckCommand "netways/exchange_edge_synchronization" { 28 | import "plugin-check-command" 29 | import "powershell-base" 30 | 31 | vars.powershell_script = "C:\\Icinga2Exchange\\check_exchange_edge_synchronization.ps1" 32 | } 33 | 34 | object CheckCommand "netways/exchange_health" { 35 | import "plugin-check-command" 36 | import "powershell-base" 37 | 38 | arguments += { 39 | "-Server" = "$exchange_server$" 40 | } 41 | vars.powershell_script = "C:\\Icinga2Exchange\\check_exchange_health.ps1" 42 | } 43 | 44 | object CheckCommand "netways/exchange_mailbox_databases" { 45 | import "plugin-check-command" 46 | import "powershell-base" 47 | 48 | arguments += { 49 | "-RequireReplication" = { 50 | set_if = "$exchange_mailbox_databases_requirereplication$" 51 | } 52 | } 53 | vars.powershell_script = "C:\\Icinga2Exchange\\check_exchange_mailbox_databases.ps1" 54 | } 55 | 56 | object CheckCommand "netways/exchange_queues" { 57 | import "plugin-check-command" 58 | import "powershell-base" 59 | 60 | arguments += { 61 | "-MaxCritical" = "$exchange_queues_critical$" 62 | "-MaxDeferredCritical" = "$exchange_queues_deferred_critical$" 63 | "-MaxDeferredWarn" = "$exchange_queues_deferred_warning$" 64 | "-MaxLockedCritical" = "$exchange_queues_locked_critical$" 65 | "-MaxLockedWarn" = "$exchange_queues_locked_warning$" 66 | "-MaxWarn" = "$exchange_queues_warning$" 67 | "-Server" = "$exchange_server$" 68 | } 69 | vars.powershell_script = "C:\\Icinga2Exchange\\check_exchange_queues.ps1" 70 | } 71 | 72 | object CheckCommand "netways/exchange_webservices" { 73 | import "plugin-check-command" 74 | import "powershell-base" 75 | 76 | arguments += { 77 | "-ClientAccessServer" = "$exchange_server$" 78 | "-MaxCrit" = "$exchange_webservices_maxcrit$" 79 | "-MaxWarn" = "$exchange_webservices_maxwarn$" 80 | "-TrustAnySSLCertificate" = { 81 | set_if = "$exchange_trustanyssl$" 82 | } 83 | } 84 | vars.powershell_script = "C:\\Icinga2Exchange\\check_exchange_webservices.ps1" 85 | } 86 | -------------------------------------------------------------------------------- /check_exchange_health.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NAME 3 | 4 | check_exchange_health 5 | 6 | .SYNOPSIS 7 | 8 | Checks the server health of Microsoft Exchange 9 | 10 | .SYNTAX 11 | 12 | check_exchange_health.ps1 -Server exchange01 13 | 14 | .PARAMETER Server 15 | 16 | Exchange Server to check against (Default: $env:COMPUTERNAME) 17 | 18 | . PARAMETER IgnoreDisabled 19 | 20 | Ignore Disabled monitors and don't mark them as Critical (DEFAULT: $true) 21 | #> 22 | 23 | param( 24 | [string] $Server = $env:COMPUTERNAME, 25 | [boolean] $IgnoreDisabled = $true, 26 | [switch] $Verbose 27 | ) 28 | 29 | . "$PSScriptRoot\nagios-utils.ps1" 30 | 31 | try { 32 | Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; 33 | } catch { 34 | Plugin-Exit $NagiosUnknown "Could not load Exchange PowerShell SnapIn: $error" 35 | } 36 | 37 | $state = @{} 38 | $performance = @{} 39 | 40 | try { 41 | if ($IgnoreDisabled -eq $true) { 42 | $objects = Get-ServerHealth -Identity $Server | ? alertvalue -ne disabled 43 | } else { 44 | $objects = Get-ServerHealth -Identity $Server 45 | } 46 | } catch { 47 | Plugin-Exit $NagiosUnknown "Get-ServerHealth failed: $error" 48 | } 49 | 50 | #$objects[0] | fl 51 | #exit 52 | 53 | try { 54 | foreach ($object in $objects) { 55 | if ($object.CurrentHealthSetState -eq 'NotApplicable') { continue } 56 | 57 | $id = $object.Name 58 | $state[$id] = $item = @{ 59 | Name = $id 60 | Object = $object 61 | Warnings = @() 62 | Criticals = @() 63 | Infos = @() 64 | State = $NagiosUnknown 65 | } 66 | 67 | if ($object.AlertValue -ne 'Healthy') { 68 | $item.Criticals += $object.AlertValue 69 | $item.Criticals += $object.Error 70 | } elseif ($Verbose) { 71 | $item.Infos += $object.AlertValue 72 | } 73 | 74 | <# 75 | $performance[$id] = @{ 76 | #latency = "${latency}ms;${MaxWarn};${MaxCrit};0" 77 | } 78 | #> 79 | 80 | if ($item.Criticals -gt 0) { 81 | $item.State = $NagiosCritical 82 | } elseif ($item.Warnings -gt 0) { 83 | $item.State = $NagiosWarning 84 | } else { 85 | $item.State = $NagiosOk 86 | } 87 | } 88 | 89 | $longOutput = @() 90 | $exitCode = $NagiosOk 91 | $problems = @{} 92 | 93 | foreach ($id in $state.Keys) { 94 | $item = $state[$id] 95 | 96 | $info = "" 97 | if ($item.Criticals -gt 0) { 98 | $info += " " + ($item.Criticals -join ", ") 99 | if ($exitCode -lt $NagiosCritical) { $exitCode = $NagiosCritical } 100 | $problems[$id] = 1 101 | } 102 | if ($item.Warnings -gt 0) { 103 | $info += " " + ($item.Warnings -join ", ") 104 | if ($exitCode -lt $NagiosWarning) { $exitCode = $NagiosWarning } 105 | $problems[$id] = 1 106 | } 107 | if ($item.Infos -gt 0) { 108 | $info += " " + ($item.Infos -join ", ") 109 | } 110 | 111 | $stateText = Plugin-State-Text $item.State 112 | if ($Verbose -or $info) { 113 | $longOutput += "[$stateText] ${id}:${info}" 114 | } 115 | } 116 | 117 | $pcount = $problems.Count 118 | $acount = $state.Count 119 | if ($pcount -gt 0) { 120 | $text = "$pcount of $acount scenarios are having issues: " + ($problems.Keys -join ", ") 121 | } else { 122 | $text = "All $acount scenarios are fine" 123 | } 124 | 125 | Plugin-Output $exitCode $text $longOutput 126 | 127 | if ($verbose) { 128 | $objects 129 | } 130 | 131 | #Plugin-Performance-Output $performance 132 | 133 | Plugin-Exit $exitCode 134 | } catch { 135 | Plugin-Exit $NagiosUnknown "Error during Powershell execution: $error" $error[0].ScriptStackTrace 136 | } 137 | -------------------------------------------------------------------------------- /check_exchange_mailbox_databases.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NAME 3 | 4 | check_exchange_mailbox_databases 5 | 6 | .SYNOPSIS 7 | 8 | Checks the availability and health of Exchange Databases 9 | 10 | .SYNTAX 11 | 12 | check_exchange_mailbox_databases.ps1 -Server exchange01 -RequireReplication 13 | 14 | .PARAMETER Server 15 | 16 | Select the Exchange Server to check (Default: $env:COMPUTERNAME) 17 | 18 | .PARAMETER RequireReplication 19 | 20 | All databases should have a replicated copy 21 | 22 | #> 23 | 24 | param( 25 | [string] $Server = $env:COMPUTERNAME, 26 | [switch] $RequireReplication, 27 | [switch] $Verbose 28 | ) 29 | 30 | . "$PSScriptRoot\nagios-utils.ps1" 31 | 32 | try { 33 | Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; 34 | } catch { 35 | Plugin-Exit $NagiosUnknown "Could not load Exchange PowerShell SnapIn: $error" 36 | } 37 | 38 | try { 39 | $databases = Get-MailboxDatabase -Server $server -Status 40 | } catch { 41 | Plugin-Exit $NagiosUnknown "Could not load Mailbox Databases: $error" 42 | } 43 | 44 | if ($databases.Count -eq 0) { 45 | Plugin-Exit $NagiosUnknown "No Mailbox Databases found on $server!" 46 | } 47 | 48 | $dbState = @{} 49 | $performance = @{} 50 | 51 | try { 52 | foreach ($database in $databases) { 53 | $id = $database.Identity.ToString() 54 | $dbState[$id] = $db = @{ 55 | Identity = $id 56 | Object = $database 57 | Warnings = @() 58 | Criticals = @() 59 | State = $NagiosUnknown 60 | } 61 | 62 | # For later consideration: 63 | # LastFullBackup 64 | # LastIncrementalBackup 65 | # LastDifferentialBackup 66 | # LastCopyBackup 67 | 68 | if ($database.Recovery -eq $true) { 69 | $db.Criticals += "in Recovery" 70 | } 71 | if ($database.Mounted -ne $true) { 72 | $db.Criticals += "not Mounted" 73 | } 74 | if ($database.InvalidDatabaseCopies.Count -gt 0) { 75 | $db.Criticals += "with InvalidDatabaseCopies" 76 | } 77 | if ($database.MountAtStartup -ne $true) { 78 | $db.Warnings += "no MountAtStartup" 79 | } 80 | if ($database.BackgroundDatabaseMaintenance -ne $true) { 81 | $db.Warnings += "no BackgroundDatabaseMaintenance" 82 | } 83 | if ($RequireReplication -and $database.DatabaseCopies.Count -lt 2) { 84 | $db.Warnings += "too few DatabaseCopies ($($database.DatabaseCopies.Count))" 85 | } 86 | 87 | $performance[$id] = @{ 88 | database_size = $database.DatabaseSize.ToMB().ToString() + "MB;;;0" 89 | available_space = $database.AvailableNewMailboxSpace.ToMB().ToString() + "MB;;;0" 90 | used_space = ($database.DatabaseSize - $database.AvailableNewMailboxSpace).ToMB().ToString() + "MB;;;0" 91 | } 92 | 93 | if ($db.Criticals -gt 0) { 94 | $db.State = $NagiosCritical 95 | } elseif ($db.Warnings -gt 0) { 96 | $db.State = $NagiosWarning 97 | } else { 98 | $db.State = $NagiosOk 99 | } 100 | } 101 | 102 | $longOutput = @() 103 | $state = $NagiosOk 104 | $problems = @{} 105 | 106 | foreach ($id in $dbState.Keys) { 107 | $db = $dbState[$id] 108 | 109 | $info = "" 110 | if ($db.Criticals -gt 0) { 111 | $info += " " + ($db.Criticals -join ", ") 112 | if ($state -lt $NagiosCritical) { $state = $NagiosCritical } 113 | $problems[$id] = 1 114 | } 115 | if ($db.Warnings -gt 0) { 116 | $info += " " + ($db.Warnings -join ", ") 117 | if ($state -lt $NagiosWarning) { $state = $NagiosWarning } 118 | $problems[$id] = 1 119 | } 120 | 121 | $stateText = Plugin-State-Text $db.State 122 | $longOutput += "[$stateText] ${id}" + $(if ($info) { ":${info}" }) 123 | } 124 | 125 | $pcount = $problems.Count 126 | $acount = $dbState.Count 127 | if ($pcount -gt 0) { 128 | $text = "$pcount of $acount databases having issues: " + ($problems.Keys -join ", ") 129 | } else { 130 | $text = "All $acount databases are fine" 131 | } 132 | 133 | Plugin-Output $state $text $longOutput 134 | 135 | if ($verbose) { 136 | $databases | fl 137 | } 138 | 139 | Plugin-Performance-Output $performance 140 | 141 | Plugin-Exit $state 142 | } catch { 143 | Plugin-Exit $NagiosUnknown "Error during Powershell execution: $error" $error[0].ScriptStackTrace 144 | } 145 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Icinga Check Microsoft Exchange 2 | =============================== 3 | 4 | This is a collection of Powershell Scripts designed to check a Microsoft Exchange Setup from 5 | Icinga 2 with the agent running on the Exchange Windows Servers. 6 | 7 | ## Checks 8 | 9 | For `CheckCommand` definitions see [icinga2-commands.conf](icinga2-commands.conf). 10 | 11 | ## Credentials 12 | 13 | ``` 14 | Get-Credential | Export-CliXml ".\MailboxCredential.xml" 15 | 16 | # Needs to be stored in: 17 | # $PSScriptRoot\MailboxCredential.xml 18 | 19 | # Can be adjusted with the parameter 'CredentialPath' 20 | ``` 21 | 22 | ### check_exchange_health 23 | 24 | Checks the server health of Microsoft Exchange by calling `Get-ServerHealth` 25 | 26 | ``` 27 | OK: All 159 scenarios are fine 28 | ``` 29 | 30 | ### check_exchange_queues 31 | 32 | ``` 33 | OK: All 10 queues are fine 34 | [OK] EX01\Submission: Ready, deferred (0), locked (0), messages (0) 35 | [OK] EX01\Shadow\6: Ready, deferred (0), locked (0), messages (32) 36 | [OK] EX01\50: Ready, deferred (0), locked (0), messages (0) 37 | [OK] EX01\Shadow\3: Ready, deferred (0), locked (0), messages (355) 38 | [OK] EX01\8: Ready, deferred (0), locked (0), messages (0) 39 | [OK] EX01\Shadow\7: Ready, deferred (0), locked (0), messages (33) 40 | [OK] EX01\4: Ready, deferred (0), locked (0), messages (0) 41 | [OK] EX01\Shadow\51: Ready, deferred (0), locked (0), messages (1) 42 | [OK] EX01\5: Ready, deferred (0), locked (0), messages (0) 43 | [OK] EX01\Shadow\58: Ready, deferred (0), locked (0), messages (1) 44 | | 'EX01_Submission::deferred'=0;5;10;0 'EX01_Submission::locked'=0;5;10;0 'EX01_Submission::count'=0;20;50;0 'EX01_Shadow_6::deferred'=0;5;10;0 'F 45 | R02641VMA_Shadow_6::locked'=0;5;10;0 'EX01_Shadow_6::count'=32;;;0 'EX01_50::deferred'=0;5;10;0 'EX01_50::locked'=0;5;10;0 'EX01_50::count'=0;20;5 46 | 0;0 'EX01_Shadow_3::deferred'=0;5;10;0 'EX01_Shadow_3::locked'=0;5;10;0 'EX01_Shadow_3::count'=355;;;0 'EX01_8::deferred'=0;5;10;0 'EX01_8:: 47 | locked'=0;5;10;0 'EX01_8::count'=0;20;50;0 'EX01_Shadow_7::deferred'=0;5;10;0 'EX01_Shadow_7::locked'=0;5;10;0 'EX01_Shadow_7::count'=33;;;0 'FR02 48 | 641VMA_4::deferred'=0;5;10;0 'EX01_4::locked'=0;5;10;0 'EX01_4::count'=0;20;50;0 'EX01_Shadow_51::deferred'=0;5;10;0 'EX01_Shadow_51::locked'=0;5; 49 | 10;0 'EX01_Shadow_51::count'=1;;;0 'EX01_5::deferred'=0;5;10;0 'EX01_5::locked'=0;5;10;0 'EX01_5::count'=0;20;50;0 'EX01_Shadow_58::deferred 50 | '=0;5;10;0 'EX01_Shadow_58::locked'=0;5;10;0 'EX01_Shadow_58::count'=1;;;0 51 | ``` 52 | 53 | ### check_exchange_mailbox_databases 54 | 55 | Checks the availability and health of Exchange Databases with `Get-MailboxDatabase` 56 | 57 | ``` 58 | OK: All 1 databases are fine 59 | [OK] Mailbox Database 123456 60 | ``` 61 | 62 | ### check_exchange_webservices 63 | 64 | Checks the availablitity of EWS and other web services with `Test-OutlookWebServices` 65 | 66 | **Note:** This require mailbox credentials - see script help inside. 67 | 68 | ``` 69 | OK: All 4 scenarios are fine 70 | [OK] OfflineAddressBook: Success 71 | [OK] AvailabilityService: Success 72 | [OK] ExchangeWebServices: Success 73 | [OK] AutoDiscoverOutlookProvider: Success 74 | | 'OfflineAddressBook::latency'=74ms;500;1000;0 'AvailabilityService::latency'=62ms;500;1000;0 'ExchangeWebServices::latency'=32ms;500;1000;0 'AutoDiscoverOutlookProvider 75 | ::latency'=98ms;500;1000;0 76 | ``` 77 | 78 | ### check_exchange_edge_synchronization 79 | 80 | Checks the status of Exchange Edge Synchronization by calling `Get-EdgeSubscription` and `Test-EdgeSynchronization` 81 | 82 | ``` 83 | OK: All 2 Edge Synchronizations are fine 84 | [OK] EX01: Normal, sync 1 minutes old 85 | [OK] EX02: Normal, sync 1 minutes old 86 | | 'EX01::sync_age'=28s;300;600;0 'EX02::sync_age'=28s;300;600;0 87 | ``` 88 | 89 | ## Known Issues 90 | 91 | ### Import-Clixml 92 | 93 | ``` 94 | Command: Get-Credential | Export-CliXml .\MailboxCredential.xml 95 | -> 96 | Import-Clixml : Key not valid for use in specified state 97 | ``` 98 | 99 | Solution: Needs to run as user "SYSTEM" (Example: via `PsExec`). 100 | 101 | ## Contributing 102 | 103 | Feel free to ask questions and open issues. Feedback is always welcome and appreciated. 104 | 105 | ## License 106 | 107 | Copyright (C) 2018 Markus Frosch 108 | 2018 NETWAYS GmbH 109 | 110 | This program is free software; you can redistribute it and/or modify 111 | it under the terms of the GNU General Public License as published by 112 | the Free Software Foundation; either version 2 of the License, or 113 | (at your option) any later version. 114 | 115 | This program is distributed in the hope that it will be useful, 116 | but WITHOUT ANY WARRANTY; without even the implied warranty of 117 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 118 | GNU General Public License for more details. 119 | 120 | You should have received a copy of the GNU General Public License along 121 | with this program; if not, write to the Free Software Foundation, Inc., 122 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 123 | -------------------------------------------------------------------------------- /check_exchange_edge_synchronization.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NAME 3 | 4 | check_exchange_edge_synchronization 5 | 6 | .SYNOPSIS 7 | 8 | Checks the status of Exchange Edge Synchronization 9 | 10 | .SYNTAX 11 | 12 | check_exchange_queues.ps1 -Server exchange01 13 | 14 | .PARAMETER Server 15 | 16 | Select the Exchange Server to check (Default: $env:COMPUTERNAME) 17 | 18 | .PARAMETER MaxCrit 19 | 20 | Maximum minutes the last sync can old before having a critical state 21 | 22 | .PARAMETER MaxWarn 23 | 24 | Maximum minutes the last sync can old before having a warning state 25 | 26 | #> 27 | 28 | param( 29 | [string] $Identity, 30 | [int] $MaxWarn = 5, 31 | [int] $MaxCrit = 10, 32 | [string] $VerifyRecipient, 33 | [switch] $Verbose 34 | ) 35 | 36 | . "$PSScriptRoot\nagios-utils.ps1" 37 | 38 | $ValidSyncStates = @('Normal', 'Synchronized', 'InProgress') 39 | $WarningSyncStates = @('Warning', 'Inconclusive') 40 | 41 | try { 42 | Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; 43 | } catch { 44 | Plugin-Exit $NagiosUnknown "Could not load Exchange PowerShell SnapIn: $error" 45 | } 46 | 47 | try { 48 | $options = @{} 49 | 50 | if ($Identity) { 51 | $options.Identity = $Identity 52 | } 53 | 54 | $objects = Get-EdgeSubscription @options 55 | } catch { 56 | Plugin-Exit $NagiosUnknown "Could not load Edge Subscriptions: $error" 57 | } 58 | 59 | if ($objects.Count -eq 0) { 60 | Plugin-Exit $NagiosUnknown "No Edge Subscriptions found!" 61 | } 62 | 63 | $state = @{} 64 | $performance = @{} 65 | 66 | try { 67 | foreach ($object in $objects) { 68 | $id = $object.Identity.ToString() 69 | $state[$id] = $item = @{ 70 | Identity = $id 71 | Object = $object 72 | Warnings = @() 73 | Criticals = @() 74 | Infos = @() 75 | State = $NagiosUnknown 76 | } 77 | 78 | $testOptions = @{ 79 | TargetServer = $id 80 | MaxReportSize = 10 81 | MonitoringContext = $true 82 | } 83 | 84 | #if ($VerifyRecipient) { 85 | # $testOptions.VerifyRecipient = $VerifyRecipient 86 | #} 87 | 88 | $item.Test = $test = Test-EdgeSynchronization @testOptions 89 | 90 | if ($test -eq $null) { 91 | $item.Criticals += "no test data!" 92 | continue 93 | } 94 | 95 | if ($test.SyncStatus -NotIn $ValidSyncStates) { 96 | $item.Criticals += "status $($test.SyncStatus)" 97 | } else { 98 | $item.Infos += $test.SyncStatus 99 | } 100 | 101 | if ($test.FailureDetail) { 102 | $item.Criticals += "failure detail: $($test.FailureDetail)" 103 | } 104 | 105 | $now = $test.UtcNow 106 | $lastSync = $test.LastSynchronizedUtc 107 | $diff = New-Timespan -Start $lastSync -End $now 108 | $minutes = $diff.Minutes 109 | $ageInfo = "sync ${minutes} minutes old" 110 | if ($minutes -lt 0) { 111 | $item.Critical += "sync ${minutes} minutes in the future!" 112 | } elseif ($minutes -gt $MaxCrit) { 113 | $item.Criticals += $ageInfo 114 | } elseif ($minutes -gt $MaxWarn) { 115 | $item.Warnings += $ageInfo 116 | } else { 117 | $item.Infos += $ageInfo 118 | } 119 | 120 | $performance[$id] = @{ 121 | sync_age = "$($lastSync.Second)s;$($MaxWarn * 60);$($MaxCrit * 60);0" 122 | } 123 | 124 | if ($item.Criticals -gt 0) { 125 | $item.State = $NagiosCritical 126 | } elseif ($item.Warnings -gt 0) { 127 | $item.State = $NagiosWarning 128 | } else { 129 | $item.State = $NagiosOk 130 | } 131 | } 132 | 133 | $longOutput = @() 134 | $exitCode = $NagiosOk 135 | $problems = @{} 136 | 137 | foreach ($id in $state.Keys) { 138 | $item = $state[$id] 139 | 140 | $info = "" 141 | if ($item.Criticals -gt 0) { 142 | $info += " " + ($item.Criticals -join ", ") 143 | if ($exitCode -lt $NagiosCritical) { $exitCode = $NagiosCritical } 144 | $problems[$id] = 1 145 | } 146 | if ($item.Warnings -gt 0) { 147 | $info += " " + ($item.Warnings -join ", ") 148 | if ($exitCode -lt $NagiosWarning) { $exitCode = $NagiosWarning } 149 | $problems[$id] = 1 150 | } 151 | if ($item.Infos -gt 0) { 152 | $info += " " + ($item.Infos -join ", ") 153 | } 154 | 155 | $stateText = Plugin-State-Text $item.State 156 | $longOutput += "[$stateText] ${id}" + $(if ($info) { ":${info}" }) 157 | } 158 | 159 | $pcount = $problems.Count 160 | $acount = $state.Count 161 | if ($pcount -gt 0) { 162 | $text = "$pcount of $acount Edge Synchronizations are having issues: " + ($problems.Keys -join ", ") 163 | } else { 164 | $text = "All $acount Edge Synchronizations are fine" 165 | } 166 | 167 | Plugin-Output $exitCode $text $longOutput 168 | 169 | if ($verbose) { 170 | $objects | fl 171 | } 172 | 173 | Plugin-Performance-Output $performance 174 | 175 | Plugin-Exit $exitCode 176 | } catch { 177 | Plugin-Exit $NagiosUnknown "Error during Powershell execution: $error" $error[0].ScriptStackTrace 178 | } 179 | -------------------------------------------------------------------------------- /check_exchange_webservices.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NAME 3 | 4 | check_exchange_webservices 5 | 6 | .SYNOPSIS 7 | 8 | Checks the availablitity of EWS 9 | 10 | .SYNTAX 11 | 12 | check_exchange_webservices.ps1 -Server exchange01 13 | 14 | .PARAMETER ClientAccessServer 15 | 16 | ClientAccessServer to check against (Default: $env:COMPUTERNAME) 17 | 18 | .PARAMETER Mailbox 19 | 20 | User Mailbox to check against 21 | 22 | .PARAMETER Password 23 | 24 | User Password to check against. PLEASE AVOID this and user CredentialPath 25 | 26 | .PARAMETER CredentialPath 27 | 28 | XML File with Mailbox/Password credential for the Mailbox, see examples how to store this. 29 | 30 | (Default: $PSScriptRoot\MailboxCredential.xml) 31 | 32 | .PARAMETER MaxCritical 33 | 34 | Maximum allowed latency (in milliseconds) before going to critical state 35 | 36 | .PARAMETER MaxWarn 37 | 38 | Maximum allowed latency (in milliseconds) before going to warning state 39 | 40 | .PARAMETER TrustAnySSLCertificate 41 | 42 | Do not require trust for the SSL Certificate, set this when common name or SAN does not match 43 | 44 | .EXAMPLE 45 | 46 | Create a stored credential like this: 47 | 48 | Get-Credential | Export-CliXml .\MailboxCredential.xml 49 | 50 | #> 51 | 52 | param( 53 | [string] $ClientAccessServer = $env:COMPUTERNAME, 54 | [string] $Mailbox, 55 | [securestring] $Password, 56 | [string] $CredentialPath = "$PSScriptRoot\MailboxCredential.xml", 57 | [int] $MaxWarn = 500, 58 | [int] $MaxCrit = 1000, 59 | [switch] $TrustAnySSLCertificate, 60 | [switch] $Verbose 61 | ) 62 | 63 | . "$PSScriptRoot\nagios-utils.ps1" 64 | 65 | try { 66 | Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; 67 | } catch { 68 | Plugin-Exit $NagiosUnknown "Could not load Exchange PowerShell SnapIn: $error" 69 | } 70 | 71 | # setup credential for authentication 72 | [PSCredential] $credential = $null 73 | 74 | if (-not $Mailbox -and -not $Password -and $(Test-Path $CredentialPath)) { 75 | try { 76 | $credential = Import-Clixml $CredentialPath 77 | } catch { 78 | Plugin-Exit $NagiosUnknown "Could not load mailbox credential from ${CredentialPath}: $error" 79 | } 80 | } elseif (-not $Mailbox) { 81 | Plugin-Exit $NagiosUnknown "No Mailbox set to check with!" 82 | } elseif (-not $Password) { 83 | Plugin-Exit $NagiosUnknown "No Password set to check mailbox ${Mailbox}" 84 | } else { 85 | try { 86 | $credential = New-Object System.Management.Automation.PSCredential($Mailbox, $Password) 87 | } catch { 88 | Plugin-Exit $NagiosUnknown "Could not build credential: $error" 89 | } 90 | } 91 | 92 | 93 | # Run the test 94 | $state = @{} 95 | $performance = @{} 96 | 97 | try { 98 | $tests = Test-OutlookWebServices ` -Identity $credential.UserName ` -ClientAccessServer $ClientAccessServer ` -MailboxCredential $credential ` 99 | -TrustAnySSLCertificate:$TrustAnySSLCertificate 100 | } catch { 101 | Plugin-Exit $NagiosUnknown "Test-OutlookWebServices failed: $error" 102 | } 103 | 104 | try { 105 | foreach ($object in $tests) { 106 | $id = $object.Scenario 107 | $state[$id] = $item = @{ 108 | Identity = $id 109 | Object = $object 110 | Warnings = @() 111 | Criticals = @() 112 | Infos = @() 113 | State = $NagiosUnknown 114 | } 115 | 116 | if ($object.Result -ne 'Success') { 117 | $item.Criticals += $object.Result 118 | $item.Criticals += ($object.Error -split "\n")[0] 119 | } else { 120 | $item.Infos += $object.Result 121 | } 122 | 123 | $latency = $object.Latency 124 | if ($latency -gt $MaxCrit) { 125 | $item.Criticals += "latency critical (${latency})" 126 | } elseif ($latency -gt $MaxWarn) { 127 | $item.Warnings += "latency warning (${latency})" 128 | } 129 | 130 | $performance[$id] = @{ 131 | latency = "${latency}ms;${MaxWarn};${MaxCrit};0" 132 | } 133 | 134 | if ($item.Criticals -gt 0) { 135 | $item.State = $NagiosCritical 136 | } elseif ($item.Warnings -gt 0) { 137 | $item.State = $NagiosWarning 138 | } else { 139 | $item.State = $NagiosOk 140 | } 141 | } 142 | 143 | $longOutput = @() 144 | $exitCode = $NagiosOk 145 | $problems = @{} 146 | 147 | foreach ($id in $state.Keys) { 148 | $item = $state[$id] 149 | 150 | $info = "" 151 | if ($item.Criticals -gt 0) { 152 | $info += " " + ($item.Criticals -join ", ") 153 | if ($exitCode -lt $NagiosCritical) { $exitCode = $NagiosCritical } 154 | $problems[$id] = 1 155 | } 156 | if ($item.Warnings -gt 0) { 157 | $info += " " + ($item.Warnings -join ", ") 158 | if ($exitCode -lt $NagiosWarning) { $exitCode = $NagiosWarning } 159 | $problems[$id] = 1 160 | } 161 | if ($item.Infos -gt 0) { 162 | $info += " " + ($item.Infos -join ", ") 163 | } 164 | 165 | $stateText = Plugin-State-Text $item.State 166 | $longOutput += "[$stateText] ${id}" + $(if ($info) { ":${info}" }) 167 | } 168 | 169 | $pcount = $problems.Count 170 | $acount = $state.Count 171 | if ($pcount -gt 0) { 172 | $text = "$pcount of $acount scenarios are having issues: " + ($problems.Keys -join ", ") 173 | } else { 174 | $text = "All $acount scenarios are fine" 175 | } 176 | 177 | Plugin-Output $exitCode $text $longOutput 178 | 179 | if ($verbose) { 180 | $objects | fl 181 | } 182 | 183 | Plugin-Performance-Output $performance 184 | 185 | Plugin-Exit $exitCode 186 | } catch { 187 | Plugin-Exit $NagiosUnknown "Error during Powershell execution: $error" $error[0].ScriptStackTrace 188 | } -------------------------------------------------------------------------------- /check_exchange_queues.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NAME 3 | 4 | check_exchange_queues 5 | 6 | .SYNOPSIS 7 | 8 | Checks the status of Exchange MailQueues 9 | 10 | .SYNTAX 11 | 12 | check_exchange_queues.ps1 -Server exchange01 13 | 14 | .PARAMETER Server 15 | 16 | Select the Exchange Server to check (Default: $env:COMPUTERNAME) 17 | 18 | .PARAMETER MaxCritical 19 | 20 | Maximum allowed messages in queue before going to critical state (Not applied to ShadowRedundancy queues) 21 | 22 | .PARAMETER MaxWarn 23 | 24 | Maximum allowed messages in queue before going to warning state (Not applied to ShadowRedundancy queues) 25 | 26 | .PARAMETER MaxDeferredCritical 27 | 28 | Maximum allowed deferred messages in queue before going to critical state 29 | 30 | .PARAMETER MaxDeferredWarn 31 | 32 | Maximum allowed deferred messages in queue before going to warning state 33 | 34 | .PARAMETER MaxLockedCritical 35 | 36 | Maximum allowed locked messages in queue before going to critical state 37 | 38 | .PARAMETER MaxLockedWarn 39 | 40 | Maximum allowed locked messages in queue before going to warning state 41 | 42 | #> 43 | 44 | param( 45 | [string] $Server = $env:COMPUTERNAME, 46 | [int] $MaxWarn = 20, 47 | [int] $MaxCrit = 50, 48 | [int] $MaxDeferredWarn = 5, 49 | [int] $MaxDeferredCrit = 10, 50 | [int] $MaxLockedWarn = 5, 51 | [int] $MaxLockedCrit = 10, 52 | [switch] $Verbose 53 | ) 54 | 55 | . "$PSScriptRoot\nagios-utils.ps1" 56 | 57 | try { 58 | Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; 59 | } catch { 60 | Plugin-Exit $NagiosUnknown "Could not load Exchange PowerShell SnapIn: $error" 61 | } 62 | 63 | try { 64 | $objects = Get-Queue -Server $server 65 | } catch { 66 | Plugin-Exit $NagiosUnknown "Could not load Mail Queues: $error" 67 | } 68 | 69 | if ($objects.Count -eq 0) { 70 | Plugin-Exit $NagiosUnknown "No Mail Queues found on $server!" 71 | } 72 | 73 | $state = @{} 74 | $performance = @{} 75 | 76 | try { 77 | foreach ($object in $objects) { 78 | $id = $object.Identity.ToString() 79 | $state[$id] = $item = @{ 80 | Identity = $id 81 | Object = $object 82 | Warnings = @() 83 | Criticals = @() 84 | Infos = @() 85 | State = $NagiosUnknown 86 | } 87 | 88 | if ($object.Status -ne 'Active' -and $object.Status -ne 'Ready') { 89 | $item.Criticals += "inactive" 90 | } else { 91 | $item.Infos += $object.Status 92 | } 93 | 94 | $deferred = $object.DeferredMessageCount 95 | if ($deferred -gt $MaxDeferredCrit) { 96 | $item.Criticals += "too many deferred (${deferred})" 97 | } elseif ($deferred -gt $MaxDeferredWarn) { 98 | $item.Warnings += "too many deferred (${deferred})" 99 | } else { 100 | $item.Infos += "deferred (${deferred})" 101 | } 102 | 103 | $locked = $object.LockedMessageCount 104 | if ($locked -gt $MaxLockedCrit) { 105 | $item.Criticals += "too many locked (${locked})" 106 | } elseif ($locked -gt $MaxLockedWarn) { 107 | $item.Warnings += "too many locked (${locked})" 108 | } else { 109 | $item.Infos += "locked (${locked})" 110 | } 111 | 112 | $messages = $object.MessageCount 113 | $notShadow = $object.DeliveryType -ne "ShadowRedundancy" 114 | if ($notShadow -and $messages -gt $MaxCrit) { 115 | $item.Criticals += "too many messages (${messages})" 116 | } elseif ($notShadow -and $messages -gt $MaxWarn) { 117 | $item.Warnings += "too many messages (${messages})" 118 | } else { 119 | $item.Infos += "messages (${messages})" 120 | } 121 | 122 | $performance[$id] = @{ 123 | count = if ($notShadow) { "${messages};${MaxWarn};${MaxCrit};0" } else { "${messages};;;0" } 124 | deferred = "${deferred};${MaxDeferredWarn};${MaxDeferredCrit};0" 125 | locked = "${locked};${MaxLockedWarn};${MaxLockedCrit};0" 126 | } 127 | 128 | if ($item.Criticals -gt 0) { 129 | $item.State = $NagiosCritical 130 | } elseif ($item.Warnings -gt 0) { 131 | $item.State = $NagiosWarning 132 | } else { 133 | $item.State = $NagiosOk 134 | } 135 | 136 | $nextHopDomain = $object.NextHopDomain 137 | if ($nextHopDomain.StartsWith("site:")) { 138 | $item.Infos += "To: " + $nextHopDomain.split(";")[0] 139 | } else { 140 | $item.Infos += "To: " + $nextHopDomain 141 | } 142 | } 143 | 144 | $longOutput = @() 145 | $exitCode = $NagiosOk 146 | $problems = @{} 147 | 148 | foreach ($id in $state.Keys) { 149 | $item = $state[$id] 150 | 151 | $info = "" 152 | if ($item.Criticals -gt 0) { 153 | $info += " " + ($item.Criticals -join ", ") 154 | if ($exitCode -lt $NagiosCritical) { $exitCode = $NagiosCritical } 155 | $problems[$id] = 1 156 | } 157 | if ($item.Warnings -gt 0) { 158 | $info += " " + ($item.Warnings -join ", ") 159 | if ($exitCode -lt $NagiosWarning) { $exitCode = $NagiosWarning } 160 | $problems[$id] = 1 161 | } 162 | if ($item.Infos -gt 0) { 163 | $info += " " + ($item.Infos -join ", ") 164 | } 165 | 166 | $stateText = Plugin-State-Text $item.State 167 | $longOutput += "[$stateText] ${id}" + $(if ($info) { ":${info}" }) 168 | } 169 | 170 | $pcount = $problems.Count 171 | $acount = $state.Count 172 | if ($pcount -gt 0) { 173 | $text = "$pcount of $acount queues are having issues: " + ($problems.Keys -join ", ") 174 | } else { 175 | $text = "All $acount queues are fine" 176 | } 177 | 178 | Plugin-Output $exitCode $text $longOutput 179 | 180 | if ($verbose) { 181 | $objects | fl 182 | } 183 | 184 | Plugin-Performance-Output $performance 185 | 186 | Plugin-Exit $exitCode 187 | } catch { 188 | Plugin-Exit $NagiosUnknown "Error during Powershell execution: $error" $error[0].ScriptStackTrace 189 | } 190 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------