Find the answer to your Linux question:
Results 1 to 2 of 2
Hi! Got a problem. OS is Linux Mandrake 9.2 with special routing soft running on it. That soft handles several channels: two for source hosts and others for subscriber-hosts. All ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2005
    Posts
    2

    How to create a ping-tracking script..?


    Hi!

    Got a problem.
    OS is Linux Mandrake 9.2 with special routing soft running on it. That
    soft handles several channels: two for source hosts and others for subscriber-hosts. All hosts have ip-adresses, and the term "channel" is of logical nature. Those channels could be opened and closed from the command line with the appropriate commands (like " # chclose 123", where 123 - channel number). One of the source hosts is the main source host, the other source host - is reserved source host. Both source hosts are online (their ip-addresses could be pinged) but the channel for the main source host is up (opened).
    The idea is to write a script that will at some periods of time (every 5 sec. for example) ping the main source host and when it will go down (destination host unreachable) the script will execute a command for closing its channel and another command for opening channel for reserved source host . The script must continue pinging the main source host and , when it will be up again, the script should execute a command for closing channel of the reserved source host and a command for opening channel for main source host.

    Thank you!

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Well, you could start with something like
    Code:
    while /bin/ping -c1 -w1 yourhost 2>/dev/null
    do
        sleep 5
    done
    # ping failed, do some stuff
    ...
    Put that in a bigger loop and you're nearly there! You'll need a "while ! ping" to wait until the host comes back, and then drop out and restart from the top.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •