Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-13-2005, 08:04 AM   #1 (permalink)
daleo
Recruit
 
Join Date: Nov 2005
Posts: 2
daleo is on a distinguished road
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 only 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!
daleo is offline   Reply With Quote
Old 11-13-2005, 09:45 AM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Maybe use perl and do something like
Code:
#!/usr/bin/perl 
open(PING, "ping -i 300 |");
while(<PING>) {
    if(m/"No route to host"/) {
        system("your_channel_closing script");
        system("your_channel_openning_script");
    }
}
If closing and rebonding the chanel takes more than five minutes you're going to get a false positive from the next ping response though, so be careful.
__________________
Stop intellectual property from infringing on me

Last edited by teknomage1; 11-13-2005 at 10:21 AM.
teknomage1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird Image Scrolling Script...Please Help mark4man HTML, XML, Javascript, AJAX 3 06-14-2005 07:51 AM
My first Perl script. Admin All Other Coding Languages 2 05-19-2005 11:09 AM
Executing a server script from PHP sde PHP 4 02-05-2005 11:12 AM
running a script at designated time tzarin PHP 5 05-12-2004 07:11 PM


All times are GMT -8. The time now is 01:44 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting