Page 2 of 5
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 1:16 pm
by BanditBBS
Ben,
I am doing checks against a bunch of APC UPS in my environment, let me boot up my laptop and vpn(home working on a staircase) and see what I am doing.
Also, what is the end result you are looking for? Depending on what is returned this will be critical/warning/ok, right?
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 1:31 pm
by BanditBBS
I'm using a plugin called check_snmp_apcups that I can't seem to find online anywhere. I can always post here in code brackets if you want it. Nice thing is, I have a service check for all my APC UPS called "Health" and this script running against all of them and it returns everything I want.
Sample Output
Status is OK - Smart-UPS 1500 - BATTERY:(capacity 100%, temperature 24 C, runtime 59 minutes, 00.00) INPUT:(voltage 118 V, frequency 60 Hz) OUTPUT:(voltage 118 V, frequency 60 Hz, load 22%) SELF TEST:(Unknown on 05/18/2013) LAST EVENT:(Small spike)
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 1:34 pm
by benhank
the end result I am lookin for is to have the results that are displayed show in regular english instead nof the oid and the code number.
whould you happen to have that "health plugin available?
oh here is the one you cant find.
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 1:39 pm
by BanditBBS
benhank wrote:the end result I am lookin for is to have the results that are displayed show in regular english instead nof the oid and the code number.
whould you happen to have that "health plugin available?
oh here is the one you cant find.
That doesn't give you everything you need? Isn't it best to give them more than they asked

In the sample output I posted above, it is the "Last event" text.
If not, and you want just that on oid, I'l probably write a real quick perl script that does the check_snmp and returns in english what you want. It wouldn't take long at all to write that.
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 1:50 pm
by slansing
Yeah all you would really need to do is write a wrapper to go around the current script and strip things you don't need, or convert them to something you do need. We're using a plugin similar to the one bandit mentioned in house for our UPS monitoring and it works a treat.
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 1:53 pm
by benhank
dude asking me to write a perl script is like asking a brotha from down south to make kosher chinese food.... LOL BUT Ill look it up and try it. and trust me, I appreciate the help.
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 2:02 pm
by slansing
I think what Bandit was saying is that he might write one up, if you ask really nicely.

It should be silly simple to create one that will do what you need, so I don't think it would be difficult to try and do it yourself either.
Edit: Looks like sreinhardt is building an example for you.
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 2:06 pm
by BanditBBS
LOL, Kosher chinese food...guess I know where I'm going in a few minutes!
If Spenser's example doesn't help you out just let me know and I'll write the complete thing up for you....for now I am going to finish my word work.
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 2:07 pm
by sreinhardt
There is certainly no need to go the route of perl, save your self the headache. Bash would work just fine. It sounds like all you really want to do is a string replace on the oid and make it your label instead. something like:
Code: Select all
#!/bin/bash
#run check_snmp and store result
result=$(check_snmp -H 172.22.73.199 -C public -o .1.3.6.1.4.1.318.1.1.1.3.2.5.0)
#capture exit code from check_snmp
exitcode=$?
#replace the 9 | [oid]=0 with UPS self test
result=$(echo $result | sed 's/- 9 | iso.3.6.1.4.1.318.1.1.1.3.2.5.0=9/UPS self test/')
#print your result for nagios
echo $result
#exit with the same exitcode as check_snmp
exit $exitcode
This is an extremely brief example, and will only work provided your result is always the apc self check. However it could easily be expanded/changed to work with other codes as well.
Re: apc ups snmp check question
Posted: Fri Apr 18, 2014 2:27 pm
by BanditBBS
Keep in mind Ben, that with that example, as long as the check_snmp works, the exit code will always be OK.
EDIT: If your cable/satellite subscription gives you the HGTV channel, I highly recommend NEVER watching it! Too many ideas!