Monitor Exchange

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Monitor Exchange

Post 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.
Former Nagios employee
https://www.mcapra.com/
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Re: Monitor Exchange

Post 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.
Attachments
Recovery.PNG
NagiosFile.txt
(6.34 KiB) Downloaded 204 times
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Re: Monitor Exchange

Post 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!"
}
Last edited by tmcdonald on Wed Apr 12, 2017 12:38 pm, edited 1 time in total.
Reason: Please use [code][/code] tags around long output
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: Monitor Exchange

Post 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.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Monitor Exchange

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Re: Monitor Exchange

Post 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
Attachments
NagiosError.PNG
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Monitor Exchange

Post by dwhitfield »

It sounds like your issue is resolved. Is that correct?
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Re: Monitor Exchange

Post 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
Attachments
Alert.PNG
Last edited by aajewole on Wed Apr 12, 2017 5:53 pm, edited 1 time in total.
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Re: Monitor Exchange

Post 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.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Monitor Exchange

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked