SNMP Divide...
-
spyder13337
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
SNMP Divide...
Hello Everybody
i need to monitor a APC switched i already config the ip and snmp community on the powerstrip AP7830 and AP7932 so i config snmp to monitor and i already it monitoring but the issue is i need to divide by 100 the output result since it is coming from snmp is there a way to divide the result by 100 or is this a plugin that works because i could not find one that seem to work
this is my service
define service{
use generic-service,srv-pnp
service_description Total Load
check_command check_snmp!1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1
max_check_attempts 3
check_interval 5
retry_interval 1
check_period workhours
hostgroup APC
notification_interval 60
notification_period workhours
contacts nagiosadmin
my command
# 'check_snmp' command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C XXXXXX -o $ARG1$
i get out result like this
./check_snmp -H x.x.x.x -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1
SNMP OK - 94 | iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=94
now the result need to be divided by 100 i.e 9.4 which is the most idea scenario
any feedback or help will be appreciated
i need to monitor a APC switched i already config the ip and snmp community on the powerstrip AP7830 and AP7932 so i config snmp to monitor and i already it monitoring but the issue is i need to divide by 100 the output result since it is coming from snmp is there a way to divide the result by 100 or is this a plugin that works because i could not find one that seem to work
this is my service
define service{
use generic-service,srv-pnp
service_description Total Load
check_command check_snmp!1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1
max_check_attempts 3
check_interval 5
retry_interval 1
check_period workhours
hostgroup APC
notification_interval 60
notification_period workhours
contacts nagiosadmin
my command
# 'check_snmp' command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C XXXXXX -o $ARG1$
i get out result like this
./check_snmp -H x.x.x.x -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1
SNMP OK - 94 | iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=94
now the result need to be divided by 100 i.e 9.4 which is the most idea scenario
any feedback or help will be appreciated
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: SNMP Divide...
You know I keep thinking that the check_snmp plugin needs a divide or multiple argument.
Anyway, today I learned how to use awk which can do what you want (my head hurts now
)
I'm not sure if this will affect the exit codes from Nagios if you introduced warning and critical thresholds.
This:
Should produce:
94 divide 10 = 9.4
Just change the /10 values if you want the decimal place shifted.
Anyway, today I learned how to use awk which can do what you want (my head hurts now
I'm not sure if this will affect the exit codes from Nagios if you introduced warning and critical thresholds.
This:
Code: Select all
./check_snmp -H x.x.x.x -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[1]"="array_right[2]/10;}'Code: Select all
SNMP OK - 9.4 | iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=9.4 Just change the /10 values if you want the decimal place shifted.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
spyder13337
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: SNMP Divide...
i got the our put of this
External command error with no output (return code: 3)- 0|=0
External command error with no output (return code: 3)- 0|=0
-
spyder13337
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: SNMP Divide...
nevermind it works you are the best i dont care what anybody said... it was my falut snmp config correct
-
spyder13337
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: SNMP Divide...
let me rephrase it work just like that but i need to see of nagios con take the command and display it as it should
Re: SNMP Divide...
You'll want to create a wrapper script, and have it run the check_snmp script. That way, it'll appear as you're looking for in the interface. For example -
check_snmp_apc_custom.sh -
Then, assign a command to Nagios so that it uses the above, and then assign that command to the specific service. You may need to write out a few different bash scripts (or integrate dynamic variables) for the different APC's.
Is that what you were looking for?
check_snmp_apc_custom.sh -
Code: Select all
#!/bin/bash
./check_snmp -H x.x.x.x -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[1]"="array_right[2]/10;}'
Is that what you were looking for?
Former Nagios Employee
-
spyder13337
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: SNMP Divide...
basically what i was looming for a more of a number that display like 9.4 amps instead of 94 which either way i can make adjustment but i prefer to use 9.4... but it seem you are telling me that you want me to create a wrapper script called "check_snmp_apc_custom.sh" which runs command "./check_snmp -H x.x.x.x -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[1]"="array_right[2]/10;}'"
then assign a command to it thru command.cfg and a service.cfg can i get a quick examples pf these i think i understand but would like some clarification on them. Once i understadn the process i can create i couple more
thank you for all your help everybody
then assign a command to it thru command.cfg and a service.cfg can i get a quick examples pf these i think i understand but would like some clarification on them. Once i understadn the process i can create i couple more
thank you for all your help everybody
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: SNMP Divide...
Command:
In your service you would have:
Basically the wrapper script means that you would need a separate script per device, as your script has hard coded in the address for the device.
You could submit $HOSTADDRESS$ as well, however then you would need to code the script to get the address provided to it.
Something like that.
Code: Select all
define command{
command_name check_snmp_apc_custom
command_line $USER1$/check_snmp_apc_custom.sh
}Code: Select all
check_command check_snmp_apc_customYou could submit $HOSTADDRESS$ as well, however then you would need to code the script to get the address provided to it.
Code: Select all
define command{
command_name check_snmp_apc_custom
command_line $USER1$/check_snmp_apc_custom.sh $HOSTADDRESS$
}Code: Select all
#!/bin/bash
hostaddress=$1
./check_snmp -H $hostaddress -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[1]"="array_right[2]/10;}'As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
spyder13337
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: SNMP Divide...
thank that worked perfectly you guys are the best
Re: SNMP Divide...
If you don't have any more questions, shall we close and lock this post?
Be sure to check out our Knowledgebase for helpful articles and solutions!