Code: Select all
contacts user, usersms
contact_groups CSEXC
Code: Select all
contacts user, usersms
contact_groups CSEXC
Code: Select all
param($server="",$critical="",$warning="")
#$server = ""
#$critical = ""
#$warning = ""
#Check if the param are set
if($server -eq "" -or $critical -eq "" -or $warning -eq "")
{
Write-Output "WARNING"
Write-Output "You have to set the CAS-SERVER, the CRITICAL threshold, and WARNING threshold"
exit
}
#Check and load Exchange Management PowerShell
if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
}
$NagiosStatus = "0"
$NagiosDescription = ""
ForEach ($Type in Get-Queue -Server $server )
{
if ($Type.MessageCount -gt "$warning")
{
# Look for threshold warning
if ($NagiosDescription -ne "")
{
# Format the output for Nagios
$NagiosDescription = $NagiosDescription + ", "
}
$NagiosDescription = $NagiosDescription + $Type.Identity + " = " + $Type.MessageCount
# Set the status to WARNING.
$NagiosStatus = "1"
}
if ($Type.MessageCount -gt "$critical")
{
# Look for threshold critical
if ($NagiosDescription -ne "")
{
# Format the output for Nagios
$NagiosDescription = $NagiosDescription
}
#$NagiosDescription = $NagiosDescription + $Type.Identity + " = " + $Type.MessageCount
# Set the status to failed.
$NagiosStatus = "2"
}
}
# Output, which string should we write to Nagios?
if ($NagiosStatus -eq "2")
{
Write-Host "CRITICAL: $NagiosDescription"
}
elseif ($NagiosStatus -eq "1")
{
Write-Host "WARNING: $NagiosDescription"
}
else
{
Write-Host "OK: all e-mail are gone!"
}
Code: Select all
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
Code: Select all
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
Code: Select all
command_line /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "$NOTIFICATIONTYPE$ Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTPAGER$
Code: Select all
command_line /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "$NOTIFICATIONTYPE$ Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTPAGER$