script don´t work if the host is down.

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
betobaracho
Posts: 21
Joined: Wed Feb 24, 2010 9:51 am

script don´t work if the host is down.

Post by betobaracho »

when a host is down the tool does not execute the command that calls the script of my DIM, but when the host is UP she does. when I login as cactiuser and can run the script normally independent of the host being down or up.

Has anyone had this problem?

my script:

#!/bin/bash
#verifica se o arquivo que armazena os dados referentes a perda de pacotes
dir=$(pwd);
dir=$dir;
if [ -e $dir/lost_pac_$1 ]
then
mes_arquivo=$(ls -lt $dir/lost_pac_$1 | cut -f6 -d" ");
else
touch $dir/lost_pac_$1
echo "0|0">$dir/lost_pac_$1;
fi;
mes_arquivo=$(ls -lt $dir/lost_pac_$1 | cut -f6 -d" ");
mes_atual=$(date | cut -f2 -d" ");

if [ $mes_atual != $mes_arquivo ]
then
echo "0|0">$dir/lost_pac_$1;
fi;

for ((i = 0 ; i < 2 ; i++ ))
do
total_ping=$(cat $dir/lost_pac_$1 | cut -f1 -d"|");
ping_perdido=$(cat $dir/lost_pac_$1 | cut -f2 -d"|")
ping=$(ping -B $1 -c 1 -W 1)

total_ping=$(($total_ping+1));
resultado=$(echo $ping | cut -f24 -d" ")
if [ $resultado != 1 ]
then
ping_perdido=$(($ping_perdido+1));
fi;
echo "$total_ping|$ping_perdido">$dir/lost_pac_$1;
done

ping_perdido=$(($ping_perdido*100));
perc_ping_perdido=$(expr $ping_perdido / $total_ping)
echo $perc_ping_perdido;
User avatar
Hyperlord
Cacti User
Posts: 211
Joined: Tue Feb 10, 2009 3:24 am
Location: Frankfurt (a.M.), Germany

Re: script don´t work if the host is down.

Post by Hyperlord »

betobaracho wrote:when a host is down the tool does not execute the command that calls the script of my DIM,
Could you point out where your script checks if the server is up and returns 0 or something?
Om Tat Sat
betobaracho
Posts: 21
Joined: Wed Feb 24, 2010 9:51 am

Post by betobaracho »

Other scripts that did are invoked when the host is running and if so returns a value (0 for example) and return U otherwise. in the case of this script, it is usually invoked when the host is up and returns a value normally, but when the host is inactive there is no record in the logs indicating that it was invoked, so he even returns U, because it was not invoked.

when the host is active in the log looks like this:

04/16/2010 08:30:06 AM - CMDPHP: Poller[0] Host[34] DS[990] CMD: /var/www/monitoramento_cinte/scripts/perc_ping_perdido.sh 172.16.110.52, output: 0
betobaracho
Posts: 21
Joined: Wed Feb 24, 2010 9:51 am

Post by betobaracho »

the only log I have on this host inactive is the following:

04/16/2010 08:55:15 AM - CMDPHP: Poller[0] Host[28] PING: ICMP ping Timed out

Only after that will log on the next collection
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: script don´t work if the host is down.

Post by gandalf »

betobaracho wrote:when a host is down the tool does not execute the command that calls the script of my DIM, but when the host is UP she does. when I login as cactiuser and can run the script normally independent of the host being down or up.
This is by design.
We won't poll a host a hundred times when it is dead. If it is not dead but cacti detetcs it as dead, please change the "downed host detection" settings for that very device
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest