buenas,<br><br>Tengo el siguiente shell script configurados en una maquina Linux, al ejecutar el script en la maquina local, me trae los datos al pasarlos por el NRPE hacia la maquina con Nagios, no me lleva los datos.<br>
<br>Este el el programa:<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><br>function retorna_estado {<br>##############################################################################################<br><br>status=$(/usr/sbin/asterisk -rx "core show channels" | grep "active calls" | awk '{ print $3" "$2" "$1}')<br>
register=$(/usr/sbin/asterisk -rx "sip show peers " | grep "OK" | awk '{ print $3" "$2" "$1}' | wc -l)<br>usadas=$(echo $status | awk '{ print $3 }')<br>libres=$(echo "$register - $usadas" | bc)<br>
#echo "Call simultaneas: $usadas Total Registros: $register Chanels No Activos: $libres"<br><br>##############################################################################################<br><br>prused=$(echo "$usadas - $libres" | bc -l | sed -e "s/\(^.....\).*/\1/g" )<br>
#echo $register<br>echo "Call OK: Totalles $(echo "$usadas")x, Registros $register x, Free $libres x"<br>#echo $register<br>exit 0<br>if [ "$1" = 0 ]; then<br>echo "-"<br> ##################################<br>
 elif [ "$1" = 1 ]; then<br> if [ "$libres" -le "$(echo "$2" | bc)" ]; then<br> echo "Call WARNING:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status"<br>
       exit 1<br>  elif [ "$libres" -gt "$(echo "$2" | bc)" ];then<br>  echo "Call OK: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )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, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status"<br>
        exit 2<br>  elif [ "$libres" -gt "$(echo "$2" | bc)" ];then<br><br>  echo "MEM OK: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )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, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status"<br>
        exit 2<br>  elif [ "$libres" -le "$(echo "$2" | bc)" ];then<br><br>  echo "MEM WARNING: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status"<br>
            exit 1<br>  elif [ "$libres" -gt "$(echo "$2" | bc)" ];then<br> echo "MEM OK: Total:$(echo "$register" | bc )Kb, Used:$(echo "$usadas" | bc )Kb, Free:$(echo "$libres" | bc )Kb $status"<br>
         exit 0<br><br>fi<br><br>####################################<br>return 0<br>fi<br>}<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 ];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" == "-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><br><br>Atte.<br>Fernando Quil Ayala<br><br>