Re: Bash script

From: Nick Wilkens (NWilkens@Holnam.com)
Date: 08/31/01


Message-Id: <sb8e859e.011@Holnam.com>
Date: Thu, 30 Aug 2001 18:27:28 -0400
From: "Nick Wilkens" <NWilkens@Holnam.com>
To: <sousaferreira@netcabo.pt>, <security-basics@securityfocus.com>
Subject: Re: Bash script

I have a script that mails me when a host goes down and sends an email alert based on ping, and ran by cron. I am sure you can use some of it to do what you want. Hope it helps a little.

*----------
pinger()
{

ping_host=$1
host_name=$2

ping ${ping_host} 1024 -n 5|grep packet|awk -F, '{ print $3 }'|grep "100%" >/dev/null
status=$?

        if [ "${status}" -eq "0" ] && [ -f /tmp/PINGER.${ping_host}.failed ]
        then
                return 0

        elif [ "${status}" -eq "0" ]
        then
                echo "WARNING: ${host_name} failed to respond to ping!" | mailx -s "Alert" user@hosname
                touch /tmp/PINGER.${ping_host}.failed

        elif [ "${status}" -ne "0" ] && [ -f /tmp/PINGER.${ping_host}.failed ]
        then
                echo "NOTICE: ${host_name} is NOW responding to ping!" | mailx -s "Alert" user@hosname
                rm /tmp/PINGER.${ping_host}.failed

        else
                return 0
        fi

}

pinger <hostname> <reference_name>
*-----------------

Nick Wilkens

>>> "Sousa Ferreira" <sousaferreira@netcabo.pt> 8/30/01 12:04:43 PM >>>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi ...

Long time reader, first time asker here!

Just wondering if someone could help with a "simple" script in $bash
i have to make.
I need a script that s pings a certain ip, reads the reply and ... if
there is any reply, it reschedules itself to ping the ip again in
lets say 60 secs.
Otherwise it starts a daemon, firewall, backup smb daemon, etc. .

My doubt is on how to get the script to read the ping awnser
(afirmative or not).

The main interest in this is that if the primary firewall fails (UPS
probs i m having and lack of $$ to other one ;) ) the backup one goes
off.

Sorry for the lamme question and thanks in advance for your opinions
on how can i do it.

______________________________________________//______________________
___________________________

As informações contidas neste email são confidenciais
e destinam-se apenas à(s) pessoa(s) para quem foi enviado.

PGP KeyID : 0xB7723B21

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBO45kGyNcH2C3cjshEQIHSwCfYbuVOFXRjOVM5/TcB/nhszIEwQUAn0O/
UDH6KJFEj0eFh6GskVHB0xSB
=GCeL
-----END PGP SIGNATURE-----



Relevant Pages

  • Re: [SLE] emailing myself when a ping command fails via crontab????
    ... but I have a perl script to monitor a webserver. ... First the script tries to ping it's DNS servers, ...
    (SuSE)
  • RE: Bash script
    ... Subject: Bash script ... This is the code fragment I use to check ping. ... PGP KeyID: 0xB7723B21 ...
    (Security-Basics)
  • RE: ICMP (Ping)
    ... script to locate vulnerabilities(example point and case: ... Is it good to allow UDP ping packets? ... Guys again, I am not saying that you disable pings and walk away, job ... 300K and you guys are right, it port scans like a freaking demon. ...
    (Security-Basics)
  • RE: Bash script
    ... bash-2.04$ ping www.yahoo.com ... packets transmitted, 1 packets received, 0% packet loss ... > Subject: Bash script ...
    (Security-Basics)
  • Trouble with Net::Ping
    ... And now here is what I get using ping manually: ... Approximate round trip times in milli-seconds: ... The manual execution of ping happened just before and just after my ... they are clearly accessable when manually invoking ping, the script ...
    (comp.lang.perl.misc)