nagios não da retorno com plugin shell script

1. nagios não da retorno com plugin shell script

Taffarel
xikara

(usa Outra)

Enviado em 19/11/2014 - 14:20h

Os Plugins nativos funciona.Mais eu precisei criar um plugin.Se eu colocar ./plugin.sh ele funciona na maquina loca. Mas no servidor nagios ele aparece como ok mas esta errado pois na hora que eu executo no linux local ele da STATE_CRITICAL e mostra os dados

Alguém poderia me ajudar


#!/bin/bash
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
R2br=0
GSM=0
FXO=0
FXS=0
U_R2br=0
M_R2br=0
S_R2br=0
U_GSM=0
M_GSM=0
S_GSM=0
U_FXO=0
M_FXO=0
S_FXO=0
U_FXS=0
M_FXS=0
S_FXS=0
#exec 3<> /home/rafael/workspace/Nagios/khomp/exemploKhomp.txt
exec 3< <(sudo asterisk -rx "khomp channels show")
while read var <&3; do
linha=1
primeiro=${var#*|}
segundo=${primeiro#*|}
terceiro=${segundo#*|}
quarto=${terceiro%|*}
tipo=${quarto##*|}
tipo=$(echo $tipo | awk '{print $1}')
call=${quarto%%|*}
call=$(echo $call | awk '{print $1}')
quinto=${quarto#*|}
canal=${quinto%%|*}
canal=$(echo $canal | awk '{print $1}')

if [ "$tipo" = "R2br" ]; then
R2br=`expr $R2br + 1`
if [ "$call" = "Failure" ]; then
F_R2br=`expr $F_R2br + 1`
fi
if [ "$canal" = "Unreacheable" ]; then
U_R2br=`expr $U_R2br + 1`
elif [ "$canal" = "Modem" ]; then
M_R2br=`expr $M_R2br + 1`
elif [ "$canal" = "SIM" ]; then
S_R2br=`expr $S_R2br + 1`
elif [ "$canal" = "Ongoing" ]; then
O_R2br=`expr $O_R2br + 1`
else
ok1=`expr $ok1 + 1`
fi

fi
if [ "$tipo" = "GSM" ]; then
GSM=`expr $GSM + 1`
if [ "$call" = "Failure" ]; then
F_GSM=`expr $F_GSM + 1`
fi
if [ "$canal" = "Unreacheable" ]; then
U_GSM=`expr $U_GSM + 1`
elif [ "$canal" = "Modem" ]; then
M_GSM=`expr $M_GSM + 1`
elif [ "$canal" = "SIM" ]; then
S_GSM=`expr $S_GSM + 1`
elif [ "$canal" = "Ongoing" ]; then
O_GSM=`expr $O_GSM + 1`
else
ok2=`expr $ok2 + 1`
fi


fi
if [ "$tipo" = "FXO" ]; then
FXO=`expr $FXO + 1`
if [ "$call" = "Failure" ]; then
F_FXO=`expr $F_FXO + 1`
fi
if [ "$canal" = "Unreacheable" ]; then
U_FXO=`expr $U_FXO + 1`
elif [ "$canal" = "Modem" ]; then
M_FXO=`expr $M_FXO + 1`
elif [ "$canal" = "SIM" ]; then
S_FXO=`expr $S_FXO + 1`
elif [ "$canal" = "Ongoing" ]; then
O_FXO=`expr $O_FXO + 1`
else
ok3=`expr $ok3 + 1`
fi

fi
if [ "$tipo" = "FXS" ]; then
FXS=`expr $FXS + 1`
if [ "$call" = "Failure" ]; then
F_FXS=`expr $F_FXS + 1`
elif [ "$canal" = "Unreacheable" ]; then
U_FXS=`expr $U_FXS + 1`
elif [ "$canal" = "Modem" ]; then
M_FXS=`expr $M_FXS + 1`
elif [ "$canal" = "SIM" ]; then
S_FXS=`expr $S_FXS + 1`
elif [ "$canal" = "Ongoing" ]; then
O_FXS=`expr $O_FXS + 1`
else
ok4=`expr $ok4 + 1`
fi
fi

done
#Failure: $F_R2br
#Failure: $F_GSM
#Failure: $F_FXO
#Failure: $F_FXS

if [ $R2br -ne 0 ]; then
echo "[ $R2br Tipos:R2br][Unreachabele:$U_R2br][Modem error:$M_R2br][SIM Error:$S_R2br][Ongoing:$O_R2br][outros:$ok1]"
fi
if [ $GSM -ne 0 ]; then
echo "[ $GSM Tipos:GSM][Unreachabele:$U_GSM][Modem error:$M_GSM][SIM Error:$S_GSM][Ongoing:$O_GSM][outros:$ok2]"
fi
if [ $FXO -ne 0 ]; then
echo "[ $FXO Tipos:FXO][Unreachabele:$U_FXO][Modem error:$M_FXO][SIM Error:$S_FXO][Ongoing:$O_FXO][outros:$ok3]"
fi
if [ $FXS -ne 0 ]; then
echo "[ $FXS Tipos:FXS][Unreachabele:$U_FXS][Modem error:$M_FXS][SIM Error:$S_FXS][Ongoing:$O_FXS][outros:$ok4]"
fi

if [ $U_R2br -gt 0 ] || [ $M_R2br -gt 0 ] || [ $S_R2br -gt 0 ]; then
exit ${STATE_CRITICAL}
elif [ $U_GSM -gt 0 ] || [ $M_GSM -gt 0 ] || [ $S_GSM -gt 0 ]; then
exit ${STATE_CRITICAL}
elif [ $U_FXO -gt 0 ] || [ $M_FXO -gt 0 ] || [ $S_FXO -gt 0 ]; then
exit ${STATE_CRITICAL}
elif [ $U_FXS -gt 0 ] || [ $M_FXS -gt 0 ] || [ $S_FXS -gt 0 ]; then
exit ${STATE_CRITICAL}
else
exit ${STATE_OK}
fi
exec 3<&-



  






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts