[asterisk-users] Nagios under *

Steve Edwards asterisk.org at sedwards.com
Fri Jun 19 14:40:51 CDT 2009


On Fri, 19 Jun 2009, Sriram wrote:

> I tried your script :
>
>        STATUS=$(sudo asterisk -rnx "pri show span 1"\
>                 | awk '/Status/ {print $3}'\
>                 )
>
>         if      [ "Up," == "${STATUS}" ]
>         then    echo "PRI UP"
>                 exit 0
>         else    echo "PRI DOWN"
>                 exit 2
>         fi
>
> but still i get PRI down in the Nagios web interface while if i execute 
> this command from command line i get PRI UP...i m really going mad..did 
> a clean install again but still same problem..

> Iv;e also given permission of 777 to the script

Always a bad idea and a clear indication of a newbie -- sorry.

So, let's think about this. It runs when you (probably running as root -- 
also AABIAACIOAN) run it from a shell, but not when Nagios runs it. So, 
what's the difference:

) What username does Nagios run the script as?

) Is that user authorized to run Asterisk as root (or whatever username is 
running Asterisk) in /etc/sudoers?

Be sure to use visudo to make changes to /etc/sudoers. Also, at some 
point, sudo introduced "requiretty" which broke a lot of my cron scripts. 
If you have "requiretty" set in sudoers, try commenting it out.

) What PATH does the script have when run by the Nagios process?

) Are there any permissions issues on the directories in the path to the 
script?

Not having ever run Nagios, I'm shooting from the hip a bit. I'm guessing 
these commands may shed some light:

) Get the username running Nagios.

 	ps -aef | grep --ignore-case nagios

) What output do you get from a command like:

 	cd /tmp/
 	sudo -u <username-running-Nagios> <full-path-of-script>

Thanks in advance,
------------------------------------------------------------------------
Steve Edwards      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                             Fax: +1-760-731-3000



More information about the asterisk-users mailing list