System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Script for monitoring the Network connection of Server's

 
SOLVED
Go to solution
Narendra Uttekar
Regular Advisor

Script for monitoring the Network connection of Server's

Hi,
Is there anyone having the script to monitor the network connection of Server's is UP. If network goes down or server goes down it should send the message as "Request timed out"

Thanks,
Narendra
2 REPLIES
Nido
Trusted Contributor
Solution

Re: Script for monitoring the Network connection of Server's

Hello Narendra,

You can have your own script which will check the network connectivity of the server by sending ping request.

There are many scripts available; one of them is below:

Here in this script, You can review the hosts which are not reachable by ping request in /tmp/pnaidu/NOTOK.

Modify the script at your wish.


#!/bin/ksh
clear
echo "Do you want to flush the log data before running ping test (y/n): "
read choice
case $choice in
y)
cat /dev/null > /tmp/pnaidu/err.txt
cat /dev/null > /tmp/pnaidu/ok
cat /dev/null > /tmp/pnaidu/NOTOK

for A in `awk '{print $1}' /script/testpnhost.txt`
do
ping ${A} -n 1 >>/tmp/pnaidu/out.txt 2>>/tmp/pnaidu/err.txt
if [ $? = 0 ]; then
{
echo "${A} is able to connect" >> /tmp/pnaidu/ok
}
else
{
echo "${A} NOT able to connect" >> /tmp/pnaidu/NOTOK
}
fi
done
echo "Hosts which couldn't ping throw them all from the 7th Floor"
echo "Check the log files under /tmp/pnaidu \n "


;;

n)
echo "Bye Bye for Now"
exit 0
;;
*)
echo "Invalid Choice "
echo "Exiting....... Wake up and get a cup of coffee"
exit 1
esac




Cheers!!
" Let Villagers Be Happy!! "
Narendra Uttekar
Regular Advisor

Re: Script for monitoring the Network connection of Server's

Thanks for the solution.