Page 2 of 3
Re: Monitor Exchange
Posted: Tue Apr 11, 2017 3:36 pm
by mcapra
Can you show us the contact definitions for these items:
Code: Select all
contacts user, usersms
contact_groups CSEXC
As well as the command definitions used by your contacts'
service_notification_commands setting. There may be some differences in which contacts are using which notification commands.
Re: Monitor Exchange
Posted: Tue Apr 11, 2017 9:58 pm
by aajewole
Please see attached. Also, when doing recovery, everything comes up fine in email and text. Just during warning/critical that shows nothing in the body and attachment of bin while no text message show up on the phone, even though nagios notification log shows it sent to both.
Re: Monitor Exchange
Posted: Tue Apr 11, 2017 10:03 pm
by aajewole
Here is the powershell script nagios is running locally on the server.
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!"
}
Re: Monitor Exchange
Posted: Wed Apr 12, 2017 12:31 pm
by tacolover101
you'll need to modify the script to output properly. it's evident that's where the problem is since Write-Host "OK: all e-mail are gone!" is being displayed.
Re: Monitor Exchange
Posted: Wed Apr 12, 2017 4:16 pm
by tgriep
If looks like the Powershell script was edited and it has some errors in it and that is why the output is not working.
I suggest putting back the original Powershell script from the link in your first post and see if the output is correct after doing that.
Re: Monitor Exchange
Posted: Wed Apr 12, 2017 5:07 pm
by aajewole
I made changes to the powershell because it wasnt working. Even with critical number set to low, it still shows up as warning every time. Swapping critical for warning fixed the problem
Re: Monitor Exchange
Posted: Wed Apr 12, 2017 5:48 pm
by dwhitfield
It sounds like your issue is resolved. Is that correct?
Re: Monitor Exchange
Posted: Wed Apr 12, 2017 5:50 pm
by aajewole
Generating a custom notification with no alert from the web portal still dont come up right. These didnt even run the script I think
Re: Monitor Exchange
Posted: Wed Apr 12, 2017 5:52 pm
by aajewole
No its not. If I use the code straight out of the plugin site, The warning/critical gets mixed up, if I fix that by swapping them in the code, the notification do not come through right. Also, when it goes red "critical" on the nagios page, notifications are not sent instantly or even generated.
Re: Monitor Exchange
Posted: Thu Apr 13, 2017 2:56 pm
by tgriep
It looks you are missing a \n on the service email and service sms commands and that is probable the issue.
Edit the commands.cfg file find and edit the notify-service-by-email command and change the command line from
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$
to
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$
find and edit the notify-service-by-sms command and change the command line from
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$
to
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$
Save the file, restart nagios and see if that fixes the issue for the missing body in the emails.
If not, What type of email client are you using?
It looks like it is converting the body of the message to an attachment called ATT00001.bin.
Can you open that file in a text editor and see if there is valid information in it?