Nagios integration – sorta (1)
Posted by wim-ms on May 16, 2008
I didn’t really wanted to use Opsmgr to send sms notifications self because some of the monitors/rules really get out of hand and would be sending gazillion of smses, like the exchange disk free monitor for example. Other monitors/rules just send a New and Closed notification very quickly after eachother, like the LDAP search time thingies.
So I decided to let the alerts be processed by Nagios, which uses a backend for sms throttling/aggregation and is integrated in our own on-call system.
The setup at the opsmgr side is as follows:
I used NSCA win 32 client for send the alerts to Nagios
For example for the Exhange alerts, I created a Notification command Channel
* channel name: “NSCA Exchange Alerts”
* Full path to file: “c:\send_nsca_win32_bin\send.bat”
* Command line parameters: $Data/Recipients/To/Address/Address$ $Data/Context/DataItem/ResolutionStateName$ $Data/Context/DataItem/AlertName$
* Initial directory: “c:\send_nsca_win32_bin”
send.bat contains
set p1=%1
set p2=%2
set p3=%3
set p4=%4
set p5=%5
set p6=%6
set p7=%7
set p8=%8
set p9=%9
c:\windows\system32\cscript.exe c:\scom\send_nsca_win32_bin\sendnsca.vbs %p1% "%p2%: %p3% %p4% %p5% %p6% %p7% %p8% %p9%
This seemingly unnecessary complex batchfile is used because there is some issue in using quotes in the Command line parameters of the Notification channel. And I’m not the only one, it seems.
Ugly hack, but it works for me
sendnsca.vbs contains
Set oArgs = WScript.Arguments.Unnamed
Set WshShell = CreateObject("WScript.Shell")
cmd="c:\windows\system32\cmd.exe /c echo scom.mydomain.com "&oArgs.Item(0)&" 2 """ & oArgs.Item(1) & ".""" & "|C:\send_nsca_win32_bin\send_nsca.exe -H nagios.domain.com -c C:\send_nsca_win32_bin\send_nsca.cfg"
WshShell.Run(cmd)
Ofcourse scom.domain.com and nagios.domain.com must be changed to your own.
Now to create a Recipient
* New notification recipient
* Choose: general
o Notification recipient display name: "Nagios Exchange Alerts Recipient"
o [x] always send notifications
* Choose: Notification Devices
* Choose: Add
o Channel - Notification Channel: "Nagios Exchange Alerts"
o Delivery address: "exchange"
* Choose: Next
o Schedule: [x] Always send notifications
* Choose: Next
o General - Notification device name: "Nagios Exchange Alerts Device"
And now you can create a subscription for Exchange alerts where you can add this recipient to.
So what happens, if you have an Exchange alert about LDAP search time, it will be sent like this ‘exchange New: LDAP Search Time – sustained for 5 minutes’
$Data/Recipients/To/Address/Address$ = exchange
$Data/Context/DataItem/ResolutionStateName$ = New
$Data/Context/DataItem/AlertName$ = LDAP Search Time – sustained for 5 minutes
The notification command will sent the alert message to send.bat which will call sendnsca.vbs which will actually start the nsca client which will send the alert to nagios which will process the alert which ultimately send you a sms.
The nagios configuration will be done in another post
name said
Hello!,
Marc said
I am doing something similar to your send.bat wrapper for my notification channel to send thru Telalert. I had the same problem with quotes. But what I discovered is when passing the alert description, sometimes the alert description in the cluster and exchange mp’s, may contain quotes itself. That throws off my total number of arguments.
Daniele Muscetta said
Steve Rachui is using a similar approach to send notification thru TelAlert: http://blogs.msdn.com/steverac/archive/2008/12/02/telalert-and-opsmgr.aspx