El día 3/04/08, Fequay fequay@esfera.cl escribió:
*buenas,
como usuario nagios me da estos errores:
sh check_pruebas
check_pruebas: line 1: asterisk: command not found check_pruebas: line 1: asterisk: command not found (standard_in) 2: parse error (standard_in) 2: parse error (standard_in) 1: parse error Call Simultaneas:, Registros:0, Free:,
y los permisos son: 777 para el archivo
-rwxrwxrwx 1 nagios nagios 3.9K Mar 26 16:25 check_pruebas
saludos,
On Thu, 3 Apr 2008 11:42:40 -0300, Guille wrote*
El día 3/04/08, Fequay fequay@esfera.cl escribió:
buenas,
estimados estoy realizando un script el cual me trae canales activos, cantidad de registros de cuentas conectados al asterisk.
Localmente me funciona pero al pasarselo al NRPE de donde se realiza la consulta no me lleva los datos "integer"
adjunto codigo:
#!/bin/bash
debug=$(echo "$@" | sed -e "s/.*(-D).*/\1/g")
if [ "$debug" = "-D" ]; then opcion=$( expr "$#" - 1 ) else opcion="$#" fi
function retorna_estado {
##############################################################################################
status=$(asterisk -rx "core show channels" | grep "active calls" | awk '{ print $3" "$2" "$1}') register=$(asterisk -rx "sip show peers " | grep "OK" | awk '{ print $3" "$2" "$1}' | wc -l) usadas=$(echo $status | awk '{ print $3 }') libres=$(echo "$register - $usadas" | bc)
##############################################################################################
prused=$(echo "$usadas - $libres" | bc -l | sed -e "s/(^.....).*/\1/g" )
if [ "$debug" != "-D" ]; then status="" else
status="| $(echo $status | awk '{ print
"Call=" expr $1 "KB;t=" $1 ";u=" $2 ";f=" $3 ";s=" $4 ";b=" $5 ";c="$6";" }' )"
fi
if [ "$1" = 0 ]; then
echo "Call Simultaneas:$(echo "$usadas * 1" | bc ), Registros:$(echo "$register" | bc ), Free:$(echo "$libres" | bc ), $status" exit 0 ################################## elif [ "$1" = 1 ]; then if [ "$libres" -le "$(echo "$2" | bc)" ]; then echo "Call WARNING Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status" exit 1 elif [ "$libres" -gt "$(echo "$2" | bc)" ];then echo "Call OK: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status" exit 0 fi #################################### elif [ "$1" = 2 ];then
if [ "$libres" -le "$(echo "$2" | bc)" ];then
echo "MEM CRITICAL: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status" exit 2 elif [ "$libres" -gt "$(echo "$2" | bc)" ];then
echo "MEM OK: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status" exit 0 fi #################################### elif [ "$1" = 3 ];then
if [ "$libres" -le "$(echo "$3" | b) " ];then
echo "MEM CRITICAL: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status" exit 2 elif [ "$libres" -le "$(echo "$2" | bc)" ];then
echo "MEM WARNING: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status" exit 1 elif [ "$libres" -gt "$(echo "$2" | bc)" ];then echo "MEM OK: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status" exit 0
fi
#################################### return 0 fi }
if [ "$1" = "-?" ];then
echo "" echo "uso: $0 -w INTEGER -c INTEGER -D" echo "-w : umbral de warning(INTEGER)" echo "-c : umbral de critical(INTEGER)" echo "-D : Debug de memoria(APAN)" echo "-? : esta ayuda" echo ""
elif [ "$#" = 1 ] && [ "$1" = "-D" ] || [ "$#" = 0
];then
retorna_estado 0 elif [ "$opcion" = 2 ];then if [ "$1" == "-w" ] && [ "$2" != "" ]; then retorna_estado 1 $2 elif [ "$1" == "-c" ] && [ "$2" != "" ];then retorna_estado 2 $2 else echo "$0: error de parametros" exit 4 fi elif [ "$opcion" = 4 ];then if [ "$1" == "-w" ] && [ "$2" != "" ] && [ "$3" ==
"-c" ] && [ "$4" != "" ];then retorna_estado 3 $2 $4 else echo "$0: error de parametros" exit 4 fi
else echo "$0: error en parametros" echo "" echo "uso: $0 -w INTEGER -c INTEGER" echo "-w : umbral de warning(INTEGER)" echo "-c : umbral de critical(INTEGER)" echo "-? : esta ayuda" echo ""
fi
Atte. Fernando Quil Ayala
CentOS-es mailing list CentOS-es@centos.org http://lists.centos.org/mailman/listinfo/centos-es
verifica si puedes ejecutar el script logueado como usuario de nagios,
si sigues con problemas seria bueno que envies el output del error.
Saludos!.
Take it easy Guille
Atte. Fernando Quil Ayala
CentOS-es mailing list CentOS-es@centos.org http://lists.centos.org/mailman/listinfo/centos-es
entonces deberas modificar tu script para que el usuario nagios pueda modificarlo ya que es de la forma en el que NRPE ejecuta los comandos.
Saludos!