-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReturn-Nagios.ps1
More file actions
39 lines (37 loc) · 1.16 KB
/
Copy pathReturn-Nagios.ps1
File metadata and controls
39 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
.SYNOPSIS
Nagios to Powershell interface
.DESCRIPTION
This script provides an means for a PowerShell script to return data to Nagios or similar clones.
.PARAMETER NagiosStatusCode
This is the status code returned to Nagios.
0 = OK, No problems.
1 = Check is at a WARNING level.
2 = Check is at a CRITICAL level
3 = Check has failed or returned an unknown value or response.
.INPUTS
None
.OUTPUTS
None
.NOTES
Borrowed function from a coworker. Saving for later use.
.EXAMPLE
Return-Nagios -NagiosStatusCode 0 -NagiosMessage "Process completed successfully"
.EXAMPLE
Return-Nagios -NagiosStatusCode 2 -NagiosMessage "Something bad happened, please investigate"
#>
function Return-Nagios {
param(
[Parameter(mandatory=$true)]
[int] $NagiosStatusCode,
[string] $NagiosMessage="No data to display" )
# Output for Nagios
switch ($NagiosStatusCode)
{
0 {Write-Host "OK: " $NagiosMessage}
1 {Write-Host "WARNING: " $NagiosMessage}
2 {Write-Host "CRITICAL: " $NagiosMessage }
default {Write-Host "UNK: " $NagiosMessage}
}
exit $NagiosStatusCode
}