Zenoss - Update Min/Max Thresholds via SNMP
There was a recent post on the Zenoss Users forum about updating Min/Max thresholds via SNMP. A user wanted to update a temperature threshold from a value obtained via SNMP. What’s the point in making the change in two spots, when you can just update it on your device and have Zenoss automatically catch the update and configure the threshold accordingly? Here’s how to do it.
Download The Script
Download zensetsnmpthreshold.py (right click and save link as)
Copy the script to your Zenoss server. I’ll use /home/zenoss/scripts for this example, but you can stick the script anywhere.
$ scp zensetsnmpthreshold.py zenoss@server:/home/zenoss/scripts
$ ssh zenoss@server
$ chmod 755 ~/scripts/zensetsnmpthreshold.py
Configure Zenoss
This section assumes that you have a template bound and in place for the server you wish to set the Min/Max threshold value for. If not, create your template and bind it to the device.
- Navigate to the device which you want the Min/Max values updated on.
- Click the breadcrumb (upside down triangle next to the ‘Status’ tab) and select ‘More’ -> ‘Templates’
- If the template you want to modify isn’t there, bind it. Once bound or it if it’s already present, click ‘Create Local Copy’.
- Click on the template name to modify the newly created local copy.
- Click the breadcrumb next to Datasources and select ‘Add Datasource’.
- Set ‘Type’ to ‘Command’ and give it a meaningful name; e.g. - testMinMax, where ‘test’ is the name of the threshold you’re modifying.
- You can leave all the defaults set or adjust them to your needs.
- Under the ‘Command Template’ section add:
/home/zenoss/scripts/zensetsnmpthreshold.py \ --hostname ${device/manageIp} \ --snmpversion <1|2c|3> \ --minoid <OID> \ --maxoid <OID> \ --snmpcommunity ${device/zSnmpCommunity} \ --template "Template Name" \ --threshold "Threshold Name" \ >> /usr/local/zenoss/log/zensetsnmpthreshold.log - Be sure to correctly set the values for your environment. Let’s say I have a template called “NTP Response” and I’ve got a threshold called “response_time” and my SNMP community is v2c. Here’s what it would look like:
/home/zenoss/scripts/zensetsnmpthreshold.py \ --hostname ${device/manageIp} \ --snmpversion 2c \ --snmpcommunity ${device/zSnmpCommunity} \ --minoid .1.3.6.1.2.1.25.3.2.1.1.768 \ --maxoid .1.3.6.1.2.1.25.3.2.1.1.771 \ --template "NTP Response" \ --threshold "response_time" \ >> /usr/local/zenoss/log/zensetsnmpthreshold.log - Note that you can enter only –minoid or –maxoid if you only wish to update one value, instead of both.
- You can test this against the device if you wish. Just enter the name of the device in the ‘test’ field and click ‘Test’.
- Navigate back to the template, click on the threshold and verify that the Min/Max values have been set correctly.
- Repeat these steps for every threshold you wish to have updated on this template.
- You can also check the log file at /usr/local/zenoss/log/zensetsnmpthreshold.log. Entries look like this:
Fri Oct 3 18:56:07 EDT 2008 - MinVal set to 768 for threshold response_time, template NTP Response on 10.3.239.38
Fri Oct 3 18:56:08 EDT 2008 - MaxVal set to 771 for threshold response_time, template NTP Response on 10.3.239.38
Write a comment
You need to login to post comments!