Script for Check Bulk IP Ping / Status / Health | Linux

Hello,

Sharing Basic script which I have shared in Some LUG before few months.

Sharing it here because it will help to people who wants to check PING of Bulk IP Addresses and check status and health by pinging the IP Address.

Again repeating this is very basic script and many changes required to improve, You can suggest me or you can send me improve one so i will update it over here. Your Suggestions are always welcome.

PING

PING

Requirements to run Script :-
1. One File which contains all IPs. One IP per line.
2. If you have different class, From system which you are running this script must contact those hosts. Routing must be through to get ping.
# Below is example file. which is containing IP List
[root@tejas-barot-lenovo ~]# cat /root/ping.txt
192.168.1.1
192.168.1.6
192.168.0.1
192.168.5.1
#Below is script which will helps you. Script is not dynamic with variable and all
[root@tejas-barot-lenovo ~]# cat /root/ping.sh
####### Script Starts from here ######
#!/bin/bash
# -c3 = is ping count, It will ping for 3 times, You can increase or decrease this number.
for PNG in $(cat /root/ping.txt)
do
ping -c3 $PNG > /dev/null 2>&1
VAL=$?
if [ $VAL = 0 ] ; then
echo “Success Ping… Host $PNG is up”
else
echo “No Ping…Host $PNG is Down”
fi
done
##### Script Ends here ##
You can also you fping :
As Normal User, fping will not allow you to specify -f, -f is allowed for root only.
As a Normal user you can try, even as root you can try following :-
$ fping < <file-name-with-ips>

# fping < <file-name-with-ips>

Hope this will helps you.
Enjoy Linux :) Enjoy Scripting :)  Enjoy Open Source :)
Content Protection by DMCA.com

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


2 Comments »

 
  • Tejas Barot says:

    Thanks, This is very basic write up which I have shared. Many Improvements can be done, but thanks for sharing.

  • RoseHosting says:

    hi, nice write up. the script you posted is helpful and ok but can be improved as in:

    #!/bin/bash
    while read IP; do
    ping -c3 ${IP} &> /dev/null;
    if [[ $? -eq 0 ]]; then
    echo "${IP} is UP"
    else
    echo "${IP} is DOWN"
    fi
    done < <(cat /tmp/ips.txt)

    thanks and keep up the good work ;)

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


5 − = four