Page 2 of 5
Re: Nagios Bash Script Help
Posted: Wed May 11, 2016 11:11 am
by rkennedy
Please run the two commands that @Box293 mentioned above, and post the output. You just want to run 'echo $?' which will show us the exit code that check_snmp runs on -
Code: Select all
/usr/local/nagios/libexec/check_snmp -H xx.xx.xx.xx -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 -w one -c two
echo $?
Re: Nagios Bash Script Help
Posted: Wed May 11, 2016 11:37 am
by spyder13337
so when i run this command i get 0 when this be correct
/usr/local/nagios/libexec/check_snmp -H xx.xx.xx.xx -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 -w one -c two | echo $?
Re: Nagios Bash Script Help
Posted: Wed May 11, 2016 4:57 pm
by Box293
Don't run it all as one command.
Please run them as two separate commands and post the output of both commands.
Re: Nagios Bash Script Help
Posted: Wed May 11, 2016 5:02 pm
by spyder13337
i ran this
/usr/local/nagios/libexec/check_snmp -H xx.xx.xx.xx -C XXXXX -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 -w one -c two
and got this
SNMP OK - 67 | iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=67;one;two
then i ran echo $?
and got this
0
Re: Nagios Bash Script Help
Posted: Wed May 11, 2016 5:07 pm
by Box293
So the 0 means it is exiting as OK.
What do you want with the warning threshold of one and critical of two?
The response you are getting back is a number, so your warning and critical thresholds should be numbers.
Re: Nagios Bash Script Help
Posted: Thu May 12, 2016 10:14 am
by spyder13337
this is my script
i assume that -w $1 -c $2 $1 and $2 are variable if i change them to a -w 70 and -c 100 i get ouptput of
SNMP OK - 6.9| iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=6.9
/usr/local/nagios/libexec/check_snmp -H xx.xx.xx.xx -C xxxx -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 -w $1 -c $2 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[1]"="array_right[2]/1$
i run this script and get a output of SNMP WARNING - 0| iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=6.9
command
# '241_total_load' command definition
define command{
command_name 241_total_load
command_line $USER1$/241_total_load -w $ARG1$ -c $ARG2$
service
define service{
use generic-service,srv-pnp
host_name Metered Rack PDU 241
service_description APC Metered Total
check_command 241_total_load!-w 50 -c 100
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
contacts nagiosadmin
}
with these setting a get a snmp warning 0 but stay green
can you verify that these are the correct info thank you
Re: Nagios Bash Script Help
Posted: Thu May 12, 2016 3:18 pm
by rkennedy
What command are you running to produce this? -
Code: Select all
SNMP WARNING - 0| iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=6.9
Are you specifying a $1 and $2 variable? I don't think your check command needs to specify a -w and -c since you're already specifying that in the wrapper script. It just expects to be ran like this -
Which then passes $1 as 70, and $2 as 100, to the wrapper script, which then fills in $1 and $2 as 70 / 100.
Re: Nagios Bash Script Help
Posted: Thu May 12, 2016 4:23 pm
by spyder13337
i run this script
bash /usr/local/nagios/libexec/241_total_load
which contains
#!/bin/bash
/usr/local/nagios/libexec/check_snmp -H xx.xx.xx.xx -C xxxxx -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 -w 50 -c 100 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[$
Re: Nagios Bash Script Help
Posted: Thu May 12, 2016 4:44 pm
by rkennedy
Could you clarify what the issue is at this point, since you hard coded the -w and -c?
You should be able to change this from your command_line now for the command definition -
Code: Select all
$USER1$/241_total_load -w $ARG1$ -c $ARG2$
to -
Re: Nagios Bash Script Help
Posted: Thu May 12, 2016 5:28 pm
by spyder13337
the issue is that i dont received any email alert it done not show warning or critical it just show "SNMP WARNING - 0| iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=6.7"
what i would like for it to show is warring or critical and what the current level is so her is my lastest info
i run my script directly {as before i am specifying the Variable }
/usr/local/nagios/libexec/241_total_load
/usr/local/nagios/libexec/check_snmp -H xx.xx.xx.xx -C xxxxx -o .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1 -w $1 -c $2 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[1]"="array_right[2]/1$
here is my service.cfg
define service{
use generic-service,srv-pnp
host_name Metered Rack PDU 241
service_description APC Metered Total
check_command 241_total_load! 70 100 {do i specific the variable here or in the command } {and is this the right format}
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
contacts nagiosadmin
}
here is the command.cfg
# '241_total_load' command definition
define command{
command_name 241_total_load
command_line $USER1$/241_total_load {do i specific the variable here or in the command } {-w $ARG1$ -c $ARG2$} {is this the right format}
}
as stated in the previous comments i am not receiving email alert i did add AWK command function to it so that it display in 9.6 Amps instead of 96 which is more realistic i ams sorry for the mix up but i hope my point get across but if i remove the variable in the wrapper script the command function just fine and display it in the right format of 9.6 i am not 100 sure so i was changing thing around to see what result i would get