Re: Bash script
From: Nick Wilkens (NWilkens@Holnam.com)Date: 08/31/01
- Previous message: dewt: "Re: Bash script"
- Maybe in reply to: Sousa Ferreira: "Bash script"
- Next in thread: Russell Foster: "RE: Bash script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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-----
- Previous message: dewt: "Re: Bash script"
- Maybe in reply to: Sousa Ferreira: "Bash script"
- Next in thread: Russell Foster: "RE: Bash script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|