Nagios Bash Script Help
-
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: Nagios Bash Script Help
it seem i still need to give the warning and critical values in original format w/o AWK command
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios Bash Script Help
Oh yeah you're right I also missed that. Your warning and critical values need to be undivided numbers, as all we are doing is altering the returned result.spyder13337 wrote:it seem i still need to give the warning and critical values in original format w/o AWK command
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: Nagios Bash Script Help
so that fixed the issue but it is not changing from OK to CRITICAL or WARNING just start green
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios Bash Script Help
So you need to go back to this command:
Replace xxx and yyy with real values.
Run the command
Then run echo $? after the command
Do you get 1 when warning and 2 when critical?
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 xxx -c yyy
Run the command
Then run echo $? after the command
Do you get 1 when warning and 2 when critical?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: Nagios Bash Script Help
ok i ran this command line /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 60 -c 80
the result where
SNMP WARNING - *65* | iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=65;60;80;60;80;
echo $?
(1) which is a warning that is working fine
and i also get a critical (2) when i adjust variables
the result where
SNMP WARNING - *65* | iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=65;60;80;60;80;
echo $?
(1) which is a warning that is working fine
and i also get a critical (2) when i adjust variables
Re: Nagios Bash Script Help
What are you adjusting and to what value are you using to generate the critical message?
Be sure to check out our Knowledgebase for helpful articles and solutions!
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios Bash Script Help
Can you post your current script please. I've tested and the snmp_exit_code is working correctly, so I suspect there is something wrong in your script.
FYI, going all the way back to your previous forum thread where you wanted to simply divide the number ... this was somewhat simple, and didn't have any warning and critical requirements. The answer provided was to show it could be done and give you the commands on how to do it.
Now that you are doing a warning and critical, it is going to complicate things, because the performance data is going to have the undivided warning and critical numbers and won't make sense in performance graphs. You'll need to work on this yourself, as it's getting out of scope of "helping you get the monitoring working" and is moving into "custom development".
FYI, going all the way back to your previous forum thread where you wanted to simply divide the number ... this was somewhat simple, and didn't have any warning and critical requirements. The answer provided was to show it could be done and give you the commands on how to do it.
Now that you are doing a warning and critical, it is going to complicate things, because the performance data is going to have the undivided warning and critical numbers and won't make sense in performance graphs. You'll need to work on this yourself, as it's getting out of scope of "helping you get the monitoring working" and is moving into "custom development".
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: Nagios Bash Script Help
here is my script
#!/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 $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]/10;}'
i believe this is getting more complicated than careto go i am not a developer but somewhat understand Nagios runs in the background i think the issue occurs with the AWK command which throws Nagios for a Loop
i would think that the script pass the Variable to the command and the command pass the variable to service config file and there it would take Warn and Crit
#!/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 $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]/10;}'
i believe this is getting more complicated than careto go i am not a developer but somewhat understand Nagios runs in the background i think the issue occurs with the AWK command which throws Nagios for a Loop
i would think that the script pass the Variable to the command and the command pass the variable to service config file and there it would take Warn and Crit
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios Bash Script Help
The script should be like this:
Code: Select all
#!/bin/bash
snmp_output=$(/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)
snmp_exit_code=$?
final_output=$(echo "$snmp_output" | 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;}')
echo "$final_output"
exit $snmp_exit_code
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 68
- Joined: Tue Oct 06, 2015 9:50 pm
Re: Nagios Bash Script Help
i ran the script and i got this i believe it should still show the value rather than 0
SNMP WARNING - 0| iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=7.2
and echo $?
gave me 1
SNMP WARNING - 0| iso.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1=7.2
and echo $?
gave me 1