Who is this guide for?
-
You’ve already gone through the trouble of installing and configuring Zenoss.
-
You’ve since learned that things in your network - important things - occasionally break.
-
You would like to know when things do break. You have a mobile phone that can receieve SMS messages and can’t stop thinking “There must be a solution in here somewhere!”
What can be done?
Amazing. Now how can I do this for myself?
Prerequisites
-
All your monitored devices in Zenoss are well organised into Locations, Systems, Groups, Networks, and - most importantly - Classes. If not, take some time to do this and come back to this guide later.
-
You have an account with Nexmo. Nexmo “is a cloud-based SMS API that lets you send and receive high volume of messages at wholesale rates.” They’re also the most cost-effective solution I know of for this task. Create an account with them, top with a bit of credit and make note of your API key and password for later.
-
15 minutes
Get the code
Download the zenoss-nexmo code from github. There are two files of relevance:
nexmomessage.py
- marcuz/libpynexmo, a copy of which resides in zenoss-nexmo/3rdParty for safe keepingzen2nexmo
- integrates the Zenoss pager function with the API fromnexmomessage.py
Configure
Edit the hard-coded configuration details in nexmomessage.py
on lines 29-32:
try:
msg = sys.stdin.read()
r = "json"
u = "API key"
p = "password"
f = "BaseblackHQ"
payload = {'reqtype': r, 'password': p, 'from': f, 'to': t, 'username':u}
- change “API key” to the 8-character alphanumberic API key provided to you by Nexmo
- change “password” to the password you selected for your Nexmo account
- change “BaseblackHQ” to what you want to see in the From: field in SMS
- keep the quotation marks
- yes, you should never code passwords into config files much less code
-
Copy
nexmomessage.py
and your modifiedzen2nexmo
to thebin
directory beneath your$ZENHOME
Zenoss installation directory, i.e./opt/zenoss/zenoss/bin/
. -
In your Zenoss settings, point the “Page Command” to zen2nexmo with the command:
$ZENHOME/bin/zen2nexmo $RECIPIENT
-
Edit your user settings inside of Zenoss to include your mobile telephone number
-
Again in your user settings, add a new Alerting Rule for yourself. Click on Alerting Rules in the leftmost column then choose “Add Alerting Rule…” from the cog menu above.
-
I recommend starting with this settings:
This translates to “send me an SMS if a Critical event affecting a Production-class device remains unresolved for 2 minutes or longer. This is why it’s very important to have organised your devices into appropriate Device Classes: you don’t want to be SMS spammed and use all your Nexmo credit when things like laptops are shut down and awakened.
Job done!
This should be all you need. Test it by creating an event on one of your Production-class devices perhaps by raising a test SNMP trap. 120 seconds later you should be seeing an SMS on the mobile number configured in your Zenoss user account.
If you need more help or have any suggestions how this document can be improved, please leave feedback using the link below.
-Paul