Page 1 of 1

Nagios does not run my scrips

Posted: Tue Jul 07, 2015 5:28 pm
by danox40997
if you run this script runs out of nagios smoothly, but has problems running with nagios
why?? :(
#! /bin/bash
y=$(echo q | htop | aha --black --line-fix --title "Jobo web 1" | grep "[0-9]%" | sed 's/[a-z,A-Z,>,<,\,,=,\;,\",\|,\/,:,-]//g' | grep -o "\[.*\]" | tr -d ' ,[,%,]' | awk ' BEGIN { s = 0 ;} { s = s + $ 1; } END {print s /NR; } ')
#echo $y > /tmp/check_procesos
#echo $y
echo "Carga del procesador: %$y"
if [ $(echo "$y>90" |bc) -eq 1 ]; then
exit 2
elif [ $(echo "$y>80" | bc) -eq 1 ]; then
exit 1
else
exit 0
fi

Re: Nagios does not run my scrips

Posted: Wed Jul 08, 2015 9:05 am
by jdalrymple
Is it executable by the nagios user?

Code: Select all

chmod 755
then verify with su

Code: Select all

su -c /path/to/script/myscript nagios
Is selinux enabled - it will interfere with the Nagios process's ability to fork new processes.

Re: Nagios does not run my scrips

Posted: Wed Jul 22, 2015 2:48 pm
by danox40997
I use chmod 777

Re: Nagios does not run my scrips

Posted: Wed Jul 22, 2015 3:07 pm
by tgriep
How are you trying to run this script as a command or as an event handler?
Can you show how you have this setup in XI and are you receiving any errors?