ANOA
Fresh Scripter
Registered: 2002-06-12
Posts: 19
Loc: UK
|
Yes I want a history report based on different timing parameters from the sleep period. I still want responses every say 60 seconds but it would be great if I had a 5 minutes ago column, 10 minutes ago column etc.
I have tried the following but I am missing something.
code:
break on cls ;-------------------------------------------------------------------------------------------------------- ;WanReport.kix ; ; This script will ping a list of ip#'s displaying the status of each connection. ; ; Create a comma delimited file in the following format. ; <Common name>,<ipadress> ; <Common name>,<ipadress> ; <Common name>,<ipadress> ; ... ; ; Example: (the numbers have been changed to protect the innocent, please use FULL IP#'s) ; Arlington Super Store,10.9.x.x ; Arrowhead Crossing,10.9.x.x ; Auburn Hills,10.9.191.x.x ; Baybrook Super Store,10.9.x.x ;-------------------------------------------------------------------------------------------------------- $file = "wanrouters.csv" ;CSV database of ip#'s to scan $sleep_Min = 5 ;Number of seconds between scans $timeOut = "3000" ;The max ping timeout $fast = 95 ;Ping time is MS, used for color codes $slow = 350 ;Ping time is MS, used for color codes $lasttime1 = 10 ;Historic data for time $lasttime2 = 20 ;Historic data for time
$temp = "%temp%\temp.dat" ;-------------------------------------------------------------------------------------------------------- $sleep_min = $sleep_Min $oldtime=0
:top CLS $line = 1 $col2 = 10 $col3 = 25 $col4 = 40 $col5 = 55
$laststore="15ms"
If exist($file) = 1 copy "$file" "%temp%\wanrouters.csv" else ? "Could not find $file. Script ending" exit endif
$nul = open(1,"%temp%\$file",2) $data = readline(1)
at($line,0) 'Press ' color y+/n '"CTRL-C"' color w/n ' to Exit, AUTO repeat set to $sleep_Min seconds' $line = $line + 1
do $Store = substr("$data",1,instr("$data",",")-1) $Store_Router = substr("$data",instr("$data",",")+1,len("$data")) Shell'%comspec% /c ping -n 1 -w $timeout $Store_Router | find "Reply" > "$temp"' $q = open(2,"$temp",2) $reply = readline(2) $q = close(2) if $reply <> "" $reply_time = substr("$reply",instr("$reply","time")+4,instr("$reply","TTL=")-instr("$reply","time")-5) at($line+1,0)" " at($line,0)color g/n "OK" color w/n select case val(substr("$reply_time",2,instr("$reply_time","ms"))) <= $fast color g+/n case val(substr("$reply_time",2,instr("$reply_time","ms"))) <= $slow color y+/n case val(substr("$reply_time",2,instr("$reply_time","ms"))) > $slow color r+/n endselect select case substr("$reply_Time",1,1) = "=" " " substr("$reply_Time",2,len("$reply_Time")-1) color w/n case substr("$reply_Time",1,1) = "<" " $reply_Time" color w/n endselect if ($stayon1=1) $laststore=ReadProfileString ("D:\laptop\cwie5\kix402\last15min.ini", "15_minutes_ago", "$Store") at($line,$col4)color g+/n "$laststore" color w/n endif if ($stayon2=1) $laststore2=ReadProfileString ("D:\laptop\cwie5\kix402\last30min.ini", "30_minutes_ago", "$Store") at($line,$col5)color g+/n "$laststore2" color w/n endif if (($oldtime=0) or ($oldtime=$lasttime1)) $writeit=WriteProfileString ("D:\laptop\cwie5\kix402\last15min.ini", "15_minutes_ago", "$Store", "$reply_time") endif if ($oldtime=$lasttime2) $writeit=WriteProfileString ("D:\laptop\cwie5\kix402\last30min.ini", "30_minutes_ago", "$Store", "$reply_time") endif at($line,$col2)"$store" At($line,$col3)"$Store_Router" $line = $line + 1 else at($line+1,0)" " if (($oldtime=0) or ($oldtime=$lasttime1)) $writeit=WriteProfileString ("D:\laptop\cwie5\kix402\last15min.ini", "15_minutes_ago", "$Store", "TIMEOUT!") endif if ($oldtime=$lasttime2) $writeit=WriteProfileString ("D:\laptop\cwie5\kix402\last30min.ini", "30_minutes_ago", "$Store", "TIMEOUT!") endif at($line,0)color r+/n "TIMEOUT!" color w/n at($line,$col2)"$store" at($line,$col3)"$Store_Router" $line = $line + 1 endif if ($oldtime=$lasttime1) $stayon1=1 endif if ($oldtime=$lasttime2) $stayon2=1 endif
$data = readline(1) until @error <> 0 $nul = close(1) del "$temp" color w/n ? "Sleeping for " $sleep_min " sec" Sleep $sleep_Min $oldtime=$oldtime+$sleep_Min
?$oldtime get $x goto top exit
|