All pastes #570148 Raw Edit

bwscript

public text v1 · immutable
·published 2007-06-16 16:04 UTC
rendered paste body
alias -l _f return C:\WINDOWS\Temp\bandwidth.dat
alias -l _a .hadd -m _band $1 $2-
alias -l _b tokenize 32 $_p | return My BandWidth biatch: Down: $_s($1)   Up: $_s($2) ( $+ $_s($3) $+ )
alias -l _e .timer_BW off | .remove $_f
alias -l _g return $hget(_band,$1)
alias -l _l {
  var %e = echo $color(i) -a, %s = $str( ,2) | %e bandwidth info v2 by fortwunty loaded | %e NOTE: In order to customize the display for this script, modify the $_b alias (line 3 in bandwidth.mrc)
  %e  $_p %s returns the speed (in bytes) as DOWNLOAD UPLOAD TOTAL | %e  $_s %s returns bytes as kB/s or B/s | %e  /bw %s displays bandwidth info (echo or say; can be accessed through right-click menu)
}
alias -l _p {
  var %Nr = $_g(NEW_RCVD), %Ns = $_g(NEW_SENT), %Nt = $_g(NEW_TIME), %Or = $_g(OLD_RCVD), %Os = $_g(OLD_SENT), %Ot = $_g(OLD_TIME)
  return $calc((%Nr -%Or) /(%Nt -%Ot)) $calc((%Ns -%Os) /(%Nt -%Ot)) $calc(((%Nr -%Or) +(%Ns -%Os)) /(%Nt -%Ot))
}
alias -l _s {
  if ($1 isnum) && ($1 >= 1024) { var %x = $calc($1 /1024), %y, %z = $iif($2 isnum 0-5,$int($2),2) | if ($1 >= 1024) { %y = $round(%x,$iif(%z,%z,2)) } | return %y kB/s }
  if ($1 isnum) && ($1 < 1024) { return $int($1) B/s }
} 
alias -l _t .timer_BW -iom 0 500 _band
alias _band {
  if ($isid) { return } | var %t = $ticks, %f = $_f, %r, %c = $+(b,%t)
  if ($com(%c)) { .comclose %c } | .comopen %c WScript.Shell
  if (!$comerr) { .comclose %c $com(%c,Run,3,bstr,cmd /c netstat -e > %f,uint,0,bool,true) }
  %r = $read(%f,n,5) | tokenize 32 %r | _a OLD_RCVD $_g(NEW_RCVD) | _a NEW_RCVD $2 | _a OLD_SENT $_g(NEW_SENT) | _a NEW_SENT $3 | _a OLD_TIME $_g(NEW_TIME) | _a NEW_TIME $calc($ticks /1000) | .write -c %f
}
alias bw $iif((@* iswm $active) || (* * iswm $active) || (!$server),echo -a,say) $_b
MENU channel,query,status {
  Display Bandwidth:bw
}
ON *:EXIT:_e
ON *:LOAD:_l
ON *:START:_t
ON *:UNLOAD:_e