/*************************/ OPTIONS RESULTS OPTIONS FAILAT 21 SIGNAL ON HALT SIGNAL ON BREAK_C SIGNAL ON IOERR PARSE ARG interface DEFAULT_ADDRESS = ADDRESS() /* Set that to the good full path endinf by '/' */ SRTG_PATH="miami:scripts/SRTG/" currConnectTime = 0 lastConnectTime = 0 currTransfBytes = 0 lastTransfBytes = 0 ping = 0 stepCount = (TIME(MINUTES)/5)*(1/12) Main: ADDRESS MIAMI.1 'ISONLINE' interface ADDRESS online = RC IF online THEN DO /* if your batclock is dead, */ /* set timeoffset to */ /* GetTimeOffSet() */ /* else set it to 0 */ timeOffset = 0 Call DoWhenOnLine() END ELSE DO Call DoWhenOffLine() ADDRESS COMMAND 'C:Wait 15' ADDRESS Call Main() END return 0 /*************************/ GetTransferedBytes: ADDRESS MIAMI.1 'GETTRANSFEREDBYTES' interface ADDRESS highbytes=word(result,1) lowbytes=word(result,2) tbytes=(highbytes*(2**32)+lowbytes) return tbytes GetTimeOffSet: OPEN('deltafile','ENV:NTPDelta','R') delta = READLN('deltafile') CLOSE('deltafile') return delta GetConnectTime: ADDRESS MIAMI.1 'GETCONNECTTIME' interface ADDRESS ct=result+timeOffset return ct WriteStatus: PARSE ARG speedRate pingAvg IF ~(OPEN('trafficfile',SRTG_PATH||'SRTG.dat','A')) THEN; OPEN('trafficfile',SRTG_PATH||'SRTG.dat','W') WRITELN('trafficfile', stepCount||' '||stepCount//24||' '||speedRate||' '||pingAvg) CLOSE('trafficfile') return 0 DoWhenOffLine: /* SAY OFFLINE */ Return 0 DoWhenOnLine: lastTransfBytes = currTransfBytes lastConnectTime = currConnectTime currTransfBytes = GetTransferedBytes() currConnectTime = GetConnectTime() s = currConnectTime deltaTransfBytes = currTransfBytes - lastTransfBytes deltaConnectTime = currConnectTime - lastConnectTime deltaSpeedRate = ((deltaTransfBytes/deltaConnectTime)/125) if s>0 then do d = s%86400; s = s-d*86400 h = s%3600; s = s-h*3600 m = s%60; s = s-m*60 if d=0 then tday=''; if d>1 then tday=d' days, '; if d=1 then tday=d' day, ' thour = left('00',2-length(h))h tmin = left('00',2-length(m))m tsec = left('00',2-length(s))s timeInfos = tday||thour':'tmin':'tsec avg = ((currTransfBytes/currConnectTime)%1.024)/1000 tavg = avg 'Kb/s' end else do day=''; hour=''; min='' t='-' avg = 0 tavg=t end if currTransfBytes>1048675 then tbytes = (currTransfBytes%1048.576)/1000' Mb' else if currTransfBytes>1023 then if currTransfBytes<1048576 then tbytes = (currTransfBytes%1.024)/1000' Kb' else tbytes = currTransfBytes' b' ADDRESS COMMAND 'MiamiPing -q -n -c5 62.4.16.242 >t:tmPing' 'grep avg t:tmPing >t:tmpPingAvg' 'cut -d/ -f4 t:tmpPingAvg > t:tpingAvg' ADDRESS OPEN('pingfile','t:tpingAvg') ping = READLN('pingfile') CLOSE('pingfile') Call WriteStatus(deltaSpeedRate ping) ADDRESS COMMAND 'gnuplot' SRTG_PATH||'SRTG.cmd' 'Wait 5 MINS' ADDRESS stepCount = (stepCount+(1/12)) Call DoWhenOnLine() Return 0 /*************************/ SYNTAX: SAY Syntax error return NOVALEUR: SAY Uninitialized var return HALT: BREAK_C: SAY Break Return IOERR: SAY IoError Return /*************************/