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