My Office Hours between 10 A.M to 5 P.M .I am managing 16 client PCs which is remotely placed. I want to know the network status of every client PCs.I need an automatic trigger mail ,when the network connection is lost in any one of the Client PCs during office hours.I am a self study learner.I don't have an idea to develop the shell script.So Please give me a shell script. Please help me out of this problem.
Because Alert Mail concept is useful to monitor the network connections when the network connection is lost and I have to take necessary steps to solve this issue.Already I had developed a shell Script a for network monitoring about the current network status.But I want the Network status through one mail when the network connection is lost.
Code:
mail eg:
If the 10th client PC Network Connection is lost,then I want to get a mail like as,
Please check the network connection of this 10th client PC.
Last edited by kannansoft1985; 09-13-2014 at 06:21 AM..
Actually the plan is ,I want to ping 16 IP address and get the status through mail once when the connection is lost.I have mentioned the 16 IP addresses as follows,
I had developed a Network Monitoring script which is useful to monitoring the network and display the current network status of up and down.But I want to know the Network status through mail once when the connection is lost in any one of the 16 client PCs during office hours( 10.00 A.M to 5.00 P.M).My developed script is as follows, Can u develop the below script for Network monitoring through mail concept.I need a mail alert when the network connection is lost.Please help me out.
Code:
# My Developed script:
#!/bin/bash
ip=0
FilePath="/root/BranchIPMonitoring.txt"
UplistFilePath="/root/Uplist.txt"
DownlistFilePath="/root/Downlist.txt"
rm -rf $FilePath
rm -rf $UplistFilePath
rm -rf $DownlistFilePath
First_IPADDR()
{
#####753-TIRUNELVELIUNITI-10.66.1.133#####
ip=10.66.1.133
branchname="TIRUNELVELI UNIT I"
branchcode=753
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Second_IPADDR()
{
#####74P-TIRUNELVELIUNITII-10.66.6.133#####
ip=10.66.6.133
branchname="TIRUNELVELI UNIT II"
branchcode=74P
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Third_IPADDR()
{
#####74U-TIRUNELVELICAB-10.66.7.133#####
ip=10.66.7.133
branchname="TIRUNELVELI CAB"
branchcode=74U
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Fourth_IPADDR()
{
#####666-TENKASI-10.66.0.133#####
ip=10.66.0.133
branchname="TENKASI"
branchcode=666
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Fifth_IPADDR()
{
#####667-KOVILPATTI-10.66.1.5#####
ip=10.66.1.5
branchname="KOVILPATTI"
branchcode=667
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Sixth_IPADDR()
{
#####755-TUTICORIN-10.66.2.133#####
ip=10.66.2.133
branchname="TUTICORIN"
branchcode=755
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Seventh_IPADDR()
{
#####74B-THIRUCHENDURE-10.66.4.133#####
ip=10.66.4.133
branchname="THIRUCHENDURE"
branchcode=74B
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Eighth_IPADDR()
{
#####32A-SRIVAIKUNDAM-10.66.3.133#####
ip=10.66.3.133
branchname="SRIVAIKUNDAM"
branchcode=32A
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Nineth_IPADDR()
{
#####74G-VALLIOOR-10.66.5.133#####
ip=10.66.5.133
branchname="VALLIOOR"
branchcode=74G
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Tenth_IPADDR()
{
#####754-NAGERCOILUNITI-10.66.2.5#####
ip=10.66.2.5
branchname="NAGERCOIL UNIT I"
branchcode=754
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Eleventh_IPADDR()
{
#####7251-NAGERCOILUNITII-10.66.3.5#####
ip=10.66.3.5
branchname="NAGERCOIL UNIT II"
branchcode=7251
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Twelveth_IPADDR()
{
#####74S-THUCALAY-10.66.7.5#####
ip=10.66.7.5
branchname="THUCALAY"
branchcode=74S
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Thirteenth_IPADDR()
{
#####300-KUZHITHURAI-10.66.0.5#####
ip=10.66.0.5
branchname="KUZHITHURAI"
branchcode=300
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Fourteeenth_IPADDR()
{
#####74H-SANKARANKOIL-10.66.6.5#####
ip=10.66.6.5
branchname="SANKARANKOIL"
branchcode=74H
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Fifteenth_IPADDR()
{
#####32B-CHERANMAHADEVI-10.66.4.5#####
ip=10.66.4.5
branchname="CHERAN MAHADEVI"
branchcode=32B
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
Sixteenth_IPADDR()
{
#####74E-AMBAI-10.66.5.5#####
ip=10.66.5.5
branchname="AMBAI"
branchcode=74E
if ping -c 1 -W 1 $ip > /dev/null
then
echo "$branchcode $branchname of IPaddress $ip is up " >> $FilePath
else
echo "$branchcode $branchname of IPaddress $ip is down " >> $FilePath
fi
}
First_IPADDR
Second_IPADDR
Third_IPADDR
Fourth_IPADDR
Fifth_IPADDR
Sixth_IPADDR
Seventh_IPADDR
Eighth_IPADDR
Nineth_IPADDR
Tenth_IPADDR
Eleventh_IPADDR
Twelveth_IPADDR
Thirteenth_IPADDR
Fourteeenth_IPADDR
Fifteenth_IPADDR
Sixteenth_IPADDR
while :
do
clear
echo " ********************************************************************"
echo "** 1. How many branch IP connection is up and those details **"
echo "** 2. How many branch IP connection is down and those details **"
echo "** 3. Exit **"
echo " ********************************************************************"
echo " "
echo -n "Please select your choice [ 1 to 3 ] :: "
read choice
case "$choice" in
1) cat $FilePath | grep up > $UplistFilePath
uplistcount=`wc -l $UplistFilePath | cut -c1-2`
echo " "
echo " $uplistcount number of Branch Network connections are working fine "
echo " "
cat $FilePath | grep up
echo " "
echo "Press [enter] key to continue. . ."
read enterKey;;
2) cat $FilePath | grep down > $DownlistFilePath
downlistcount=`wc -l $DownlistFilePath | cut -c1-2`
echo " "
echo " $downlistcount number of Branch Network connections are down "
echo " "
if cat $FilePath | grep down
then echo " "
else
echo " No branch is down "
echo " "
fi
echo "Press [enter] key to continue. . ."
read enterKey;;
3) echo "Bye $USER"
exit 1;;
*) echo "$choice is an invaild option. Please select option between 1-3 only"
echo "Press [Enter] key to continue. . ."
read enterKey;;
esac
done
Last edited by kannansoft1985; 09-13-2014 at 07:52 AM..
10.66.1.133 TIRUNELVELI UNIT I 753
10.66.6.133 TIRUNELVELI UNIT II 74P
10.66.7.133 TIRUNELVELI CAB 74U
10.66.0.133 TENKASI 666
10.66.1.5 KOVILPATTI 667
10.66.2.133 TUTICORIN 755
10.66.4.133 THIRUCHENDURE 74B
10.66.3.133 SRIVAIKUNDAM 32A
10.66.5.133 VALLIOOR 74G
10.66.2.5 NAGERCOIL UNIT I 754
10.66.3.5 NAGERCOIL UNIT II 7251
10.66.7.5 THUCALAY 74S
10.66.0.5 KUZHITHURAI 300
10.66.6.5 SANKARANKOIL 74H
10.66.4.5 CHERAN MAHADEVI 32B
10.66.5.5 AMBAI 74E
, you could try
Code:
#!/bin/bash
UplistFilePath="/root/Uplist.txt"
DownlistFilePath="/root/Downlist.txt"
rm -rf $UplistFilePath
rm -rf $DownlistFilePath
while IFS="\t" read $ip $branchname $branchcode
do ping -c 1 -W 1 $ip > /dev/null && { RES=up; FN=$UplistFilePath; } || { RES=down; FN=$DownlistFilePath; }
printf "%s %s of IPaddress %s is %s.", $branchcode, $branchname, $ip, $RES > "$FN"
done < IPfile.txt
uplistcount=$(wc -l < $UplistFilePath)
downlistcount=$(wc -l < $DownlistFilePath)
while :
do clear
select CH in "How many branch IP connection is up and those details" \
"How many branch IP connection is down and those details" \
"Exit"
do case $REPLY in
1) echo " $uplistcount number of Branch Network connections are working fine "
echo " "
cat $UplistFilePath ;;
2) echo " $downlistcount number of Branch Network connections are down "
echo " "
[ "$downlistcount" -eq 0 ] && echo " No branch is down " || cat $DownlistFilePath ;;
3) echo "Bye $USER"
exit 1;;
*) echo "$REPLY is an invaild option. Please select option between 1-3 only" ;;
esac
done
echo " "
echo "Press [enter] key to continue. . ."
read enterKey
done
Replace the second while loop with e.g.
Code:
mail -s "IPs down" upload.XXX@example.com < $DownlistFilePath
First of all thanks to rudic for putting great effort to develop a script,
I think you are a genious
But I want to ping ip continuously from 10.00 A.M to 5.00 P.M, ( time specifications is important or else shell script continuously checking ip address to get a automatic triggering mail when network connection is lost)
When I am executing a shell script , I want to ping IP address morning 10.00 A.M to 5.00 P.M continuously,I want to get a mail once when the network connection is lost( for 16 IP address).( checking process continuously)
when I am executing a shell script ,I don't want to get the output from a terminal.But I just want to get a mail once when network connection is lost.This checking process is between 10 A.M to 5.00 P.M (continuous process)
Code:
sample example code for One IP Address :
if ping $ip > /dev/null
then
echo " " > /dev/null
else
echo " $branchcode-$branchname-$ip is down " >> mailcontent
mail -s " IPs down " upload.XXX@example.com < mailcontent
fi
Last edited by kannansoft1985; 09-14-2014 at 12:12 AM..
Hi,
Though I have some Linux background I'm new to BSD. Currently I'm administering an OpenBSD 5.3 firewall which based on PF.
I want to view my LAN's top talkers to the internet. If it is a graphical method that's better but I like to know whether it is possible through a command like pfctl.... (3 Replies)
Whenever i start my server it takes app 2 minutes to get into network (After starting the network service on boot).
I inquire the network guys for possible causes but they say it will need both side monitoring .
One is switch side and the second is server side.
I m not sure how do i check... (6 Replies)
I Colleagues,
Somebody can say me how to monitoring traffic in the network. also I am interested in monitoring memory. if somebody to know a guide with command advanced in unix welcome for me.
Thank you for adcanced. (0 Replies)
Hi All,
I was wondering if there is any Network Monitoring Tool for Solaris 10 to monitor a network having hybrid operating systems. I just googled it without success.
Hope, experts will guide me to get it.
Thanks,
Deepak (7 Replies)
I want to monitor network traffic. For this purpose i use snoop command. But snoop command only show those packets which are broadcasted or those packets which recieved by host. But I want to examine whole network traffic. Please tell me how to use snoop for monitoring whole network traffic or if... (3 Replies)
hi
can i know if there is any GUI interface software to help in monitoring the network of the servers i have? something like a web pages or a stock pages when a processes is down, a red colour is flashes. best if it is free ;) (1 Reply)
there are commands to monitor the memory, paging, io... how about network traffic. i mean commands to see whether the network traffic (LAN) is congested? the closest i got is netstat
thanks (6 Replies)