need script advance ping based

halo all, anyone can give me a clue, i want script that can sum the duration of downtime connection based on ping. the sum of downtime can be place on a file such downupconnection.log or something.

for example the output log is like this…

mon 17 August 2007 22:30PM down - mon 17 August 2007 22:37PM up, duration down 7 minutes
mon 17 August 2007 23:37PM up - mon 18 August 2007 00:50 down, duration up 73 minutes

also vice versa…
Is netwatch capable doing this? i’m sorry for my bad english. thanks before,


regards.

on netwatch Down:

:global downStart [ /system clock get time ];

on netwatch Up:

:if( $downStat != “” ) do={
:log warning ( "Down, duration " . ( [ /system clock get time ] - downStart ) ;
:set downStart “”;
}


Something like that

And if I want to create a logfile of these information how can I do it?

/log print file=filename will print logs to file

OK, my idea is use Netwatch for ping a host and when this host is down the alarm script in Netwatch is turned on. I need log in a file the date, hour and ip of the host:

My script:

:for c from=1 to=10 step=1  \

    do={ \
         :set i 15
          :set x 1900

         :do {\
                 :beep length=400ms frequency=$x; :delay 25ms
                 :set i ($i - 1);
                 :set x ($x +35)

               } \
                 while (($i <16) && ($i >0))
                :beep length=0 frequency=0
    }

I hope you can understand, my english is bad.

As far as i know it is not possible to get hosts IP from netwatch. Instead you can run a script from scheduler:

:if ([/ping 192.168.1.1 count=3] = 0) do={ … host is down issue alarm… };

something like that.

First add the scripts to handle the up and down events.

/ system script add name=netup source={ :log info ( $nethost . " is up" ) }
/ system script add name=netdown source={ :log info ( $nethost . " is down" ) }

Then add netwatch hosts like this

:foreach host in=192.168.1.2,192.168.1.3,192.168.1.4 do={
	/ tool netwatch add host=$host timeout=1s interval=5s \
		up-script=( "{ :global nethost " . $host . "; / system run script netup }" ) 
		down-script=( "{ :global nethost " . $host . "; / system run script netdown }" )
}

Would something like this work?