Page 3 of 5
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 10:28 am
by sreinhardt
Bandit is correct, and if it does not exit normally, you would not get a message, but would still get the error\warning exit code sent to nagios.
hgtv....? I don't even want to know.
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 1:18 pm
by BanditBBS
Ben and I were talking in PMs.
Attached in my try at the script. There are two variables you can change near the top that will change the exit text and whether they are ok, crit or warning. Let me know how this works out for you! I know you said this is all informational, but knowing your bosses, they will want some changed to warning status after you get it all setup.....enjoy!
check_apc_lastevent.pl
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 2:06 pm
by rseiwert
You might get there doing it the way you are but you would need the APC MIB properly resolving the values and the output option of snmpget to be correct to show a value then you still need to check it.
A simple script off nagios exchange does the same thing. This is what I use and even gives more info when on battery.
http://exchange.nagios.org/directory/Pl ... le/details
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 2:12 pm
by BanditBBS
rseiwert wrote:You might get there doing it the way you are but you would need the APC MIB properly resolving the values and the output option of snmpget to be correct to show a value then you still need to check it.
A simple script off nagios exchange does the same thing. This is what I use and even gives more info when on battery.
http://exchange.nagios.org/directory/Pl ... le/details
The problem is, he wants to check just this one OID and this OID only. Well, his bosses, not him. My plugin does that and no need for the mib as I tested it against a number of APC and it works fine and exits with the text he wanted, so not sure I understand your comment about the mib.
Regardless, his needs were very specific, other wise he had a plugin that did everything he'd like, but again, his bosses came into the picture, lol.
EDIT: Unless your reply was to the bash script, if so, disregard my comment in regards to the mib
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 3:43 pm
by benhank
i meant the scropt. I know it works. I think i need to plug in the community string, but I dont know where to insert it.
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 3:46 pm
by BanditBBS
benhank wrote:i meant the scropt. I know it works. I think i need to plug in the community string, but I dont know where to insert it.
You mean my perl script? do a -h for help.
Code: Select all
./check_apc_lastevent.pl -H ipaddress -C community
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 4:42 pm
by rseiwert
What I was saying about the MIB is that it will give you English no programming required
Example
./check_snmp -H 10.1.4.40 -o .1.3.6.1.4.1.318.1.1.1.3.2.5.0
SNMP OK - 1 | iso.3.6.1.4.1.318.1.1.1.3.2.5.0=1
Now we add the MIB
./check_snmp -H 10.1.4.40 -o .1.3.6.1.4.1.318.1.1.1.3.2.5.0 -m +PowerNet-MIB
SNMP OK - noTransfer(1) |
I almost never use check_snmp as this case illustrates the results are not a warn and crit range and need code to determine if to alert or not
The script I linked showed how to query one oid and control what is output and what exit code you want for each in about 15 lines of code.
Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 4:52 pm
by BanditBBS
rseiwert wrote:What I was saying about the MIB is that it will give you English no programming required
Example
./check_snmp -H 10.1.4.40 -o .1.3.6.1.4.1.318.1.1.1.3.2.5.0
SNMP OK - 1 | iso.3.6.1.4.1.318.1.1.1.3.2.5.0=1
Now we add the MIB
./check_snmp -H 10.1.4.40 -o .1.3.6.1.4.1.318.1.1.1.3.2.5.0 -m +PowerNet-MIB
SNMP OK - noTransfer(1) |
I almost never use check_snmp as this case illustrates the results are not a warn and crit range and need code to determine if to alert or not
The script I linked showed how to query one oid and control what is output and what exit code you want for each in about 15 lines of code.
Ahh, that would work fine for ben as it is just for informational reasons(until his bosses say to start alerting). I never noticed you could give check_snmp the mib. So until his bosses tell him to send alerts this will work fine, then he can use my perl script...so he has options

Re: apc ups snmp check question
Posted: Mon Apr 21, 2014 5:09 pm
by rseiwert
Sorry Bandit, I was replying to the original post and didn't see your solution. I wonder if the OP realized that this was the last failure condition. The last failure for my unit dates back years. Alerting on this would be bad since it will always be the last failure.
snmpwalk -v2c -c public 10.1.4.40 .1.3.6.1.4.1.318.1.1.1.3.2.5.0 -Oq
PowerNet-MIB::upsAdvInputLineFailCause.0 noTransfer
snmpwalk -v2c -c public 10.1.4.40 .1.3.6.1.4.1.318.1.1.1.4.1.1.0 -m +PowerNet-MIB -Oq
PowerNet-MIB::upsBasicOutputStatus.0 onLine
Re: apc ups snmp check question
Posted: Tue Apr 22, 2014 9:48 am
by benhank
ok fellas its time to make the donuts. I had to call it a day yesterday, but I will be putting these solutions to work and reprting the successful results later! hoo HAH!