SUSE Conversations


Ping



By:

June 27, 2008 3:00 am

Reads:874

Comments:0

Score:Unrated

Print/PDF

License:
GPL

This script discovers if the network is down and the output is logged & emailed to <root>.

  1. Copy script to /usr/local/sbin/ping_network
  2. chmod 744 /usr/local/sbin/ping_network
  3. crontab -e
    * * * * 1-5 /usr/local/sbin/ping_network
  4. edit HOSTS
    #!/bin/sh
    # By Mr. Sontaya  Photibut
    # website http://www.susethailand.com
    # GPL License
    # 27/06/2008
    HOSTS=" 192.168.0.1 192.168.11.1 192.168.12.1 192.168.13.1 192.168.15.1 192.168.16.1 192.168.17.1 192.168.18.1 192.168.19.1 192.168.20.1 192.168.22.1 "
    
    for HOST in $HOSTS
    do
        ping -c1 -w1 $HOST > /dev/null
    
        if [ $? -ne 0 ]
                then
                    logger "ping: $HOST DOWN"
                    echo -n "$HOST DOWN on " && date +%d/%m/%Y-%H:%M:%S
        else
                    logger "ping: $HOST UP"
        fi
    
    done
                  
    exit 0
0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading...Loading...


Categories: Free Tools, Technical Solutions

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

Comment

RSS