Sponsored Content
Full Discussion: Network Monitoring
Top Forums Shell Programming and Scripting Network Monitoring Post 302917015 by kannansoft1985 on Saturday 13th of September 2014 06:32:38 AM
Old 09-13-2014
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,
Code:
10.66.1.133  
10.66.6.133  
10.66.7.133   
10.66.0.133 
10.66.1.5     
10.66.2.133  
10.66.4.133  
10.66.3.133   
10.66.5.133   
10.66.2.5    
10.66.3.5    
10.66.7.5    
10.66.0.5    
10.66.6.5    
10.66.4.5    
10.66.5.5

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..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Network monitoring

Is there any way to check up the TCP/Ip port connectivity( healthiness ) without using ping or icmp calls ? (2 Replies)
Discussion started by: vikasdeshmukh
2 Replies

2. UNIX for Dummies Questions & Answers

monitoring network traffic

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)
Discussion started by: yls177
6 Replies

3. UNIX for Dummies Questions & Answers

network monitoring software

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)
Discussion started by: legato
1 Replies

4. UNIX for Advanced & Expert Users

Monitoring network traffic using snoop

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)
Discussion started by: mansoorulhaq
3 Replies

5. Infrastructure Monitoring

Network monitoring tool for Solaris 10

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)
Discussion started by: naw_deepak
7 Replies

6. HP-UX

Monitoring traffic in the network

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)
Discussion started by: systemoper
0 Replies

7. UNIX for Dummies Questions & Answers

Network monitoring at boot level.

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)
Discussion started by: pinga123
6 Replies

8. BSD

PF OpenBSD Network Monitoring

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)
Discussion started by: amithad
3 Replies
All times are GMT -4. The time now is 11:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy