<HTML>
<HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="Esfera Mail" name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
buenas eso si lo hace.
<br />
<br /> <font size="2"><b>
<br />On Tue, 22 Apr 2008 12:16:14 -0300, Guille wrote</b>
<br />> Lo que deberias hacer es verificar si los datos son traidos ejecutando el script con el usuario de nagios ya que es el que usa el NRPE.
<br />>
<br />> Saludos!.
<br />>
<br />> El día 22 de abril de 2008 12:08, Fequay <<a href="mailto:fequay@esfera.cl">fequay@esfera.cl</a>> escribió:
<br />>
<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 />>
Tengo el siguiente shell script configurados en una maquina
<br />>
Linux, al ejecutar el script en la maquina local, me trae
<br />>
los datos al pasarlos por el NRPE hacia la maquina con
<br />>
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 />>
function retorna_estado {
<br />>
##############################################################################################
<br />>
<br />>
status=$(/usr/sbin/asterisk -rx "core show channels" | grep
<br />>
"active calls" | awk '{ print $3" "$2" "$1}')
<br />>
register=$(/usr/sbin/asterisk -rx "sip show peers " | grep
<br />>
"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
<br />>
Chanels No Activos: $libres"
<br />>
<br />>
##############################################################################################
<br />>
<br />>
prused=$(echo "$usadas - $libres" | bc -l | sed -e
<br />>
"s/\(^.....\).*/\1/g" )
<br />>
#echo $register
<br />>
echo "Call OK: Totalles $(echo "$usadas")x, Registros
<br />>
$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
<br />>
"$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,
<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 target="_blank" href="http://lists.centos.org/mailman/listinfo/centos-es">http://lists.centos.org/mailman/listinfo/centos-es</a>
<br />>
</blockquote>
<br />>
<br clear="all" />
<br />> --
<br />> Take it easy
<br />> Guille
<br />
<br />
<br />Atte.
<br />
Fernando Quil Ayala
<br />
<br />
</font>
</BODY>
</HTML>