Hi
needing a script that do something like
simple queue print name, txbytes, rxbytes in the same command..
coz simple queue print prints the queue name, but the simple queue prin stats prints everything but name ..
thanks in advice.
Hi all
Thought you might be interested in my script. I have not tested it for dynamic queues as I only need it for static queues:
:log info "Starting QUEUE Statistics Checker"
#####DEFINE VARIABLES#####
:local slashchecker
:local slashcheckertotal
:local bytecountedup
:local bytecounteddown
:local megcountedup
:local megcounteddown
:local slashcounter
:local precalcbytes
:local pickbegin
:local pickend
:local slashcounted
:local slashcounted1
:local numberofqueues
:local test
:local interfacename
:local emailvariable
:local highsitename
:local fromemailaddress
:local toemailaddress
#####VARIABLES DEFINED#####
########## CHANGE INDIVIDUAL DETAILS HERE: ##########
:set fromemailaddress "highsite@domain.co.za"
:set toemailaddress "admin@domain.co.za"
########## END OF INDIVIDUAL DETAILS ##########
#####COUNT NUMBER OF QUEUES#####
:set numberofqueues [/queue simple print count-only]
:set highsitename [/system identity get name]
##ADD DETAILS TO E-MAIL VARIABLE##
:set emailvariable "QUEUE STATISTICS FOR:
$highsitename
TOTAL NUMBER OF QUEUES: $numberofqueues"
##ADD DETAILS TO E-MAIL VARIABLE DONE##
#####BEGIN MAIN LOOP FOR QUEUE PROCESSING#####
/queue simple
:foreach n in=[/queue simple find priority=8] do={
:local interfacename [/queue simple get [$n] name]
#####SEPERATE UP/DOWN BYTES FROM QUEUE#####
##PRESET VARIABLES##
:local precalcbytes [:pick [/queue simple get [$n] bytes] 0 30]
:set slashcheckertotal $precalcbytes
:set pickbegin 1
:set pickend 2
:set slashcounter 0
#####START SLASH CHECKER#####
/queue simple
:for i from=1 to=20 do={
:set pickbegin (pickbegin + 1)
:set pickend (pickend + 1)
:set slashchecker [:pick $slashcheckertotal $pickbegin $pickend]
:if ($slashchecker = "/") do={
:set slashcounted $pickbegin } else={ :set slashcounter ($slashcounter +1)}
}
#:log info "SLASHCOUNTED: $slashcounted"
#####SLASHCHECKER LOOP END#####
#####GOT SLASH PICK COUNT, STARTING BYTES UP AND DOWN SPLIT#####
:set slashcounted1 ($slashcounted + 1)
:set bytecountedup [:pick $precalcbytes 0 $slashcounted]
:set bytecounteddown [:pick $precalcbytes $slashcounted1 30]
:set megcountedup ($bytecountedup / 1000000)
:set megcounteddown ($bytecounteddown / 1000000)
#:log info "INTERFACE NAME: $interfacename"
#:log info "PRECALCBYTES: $precalcbytes"
#:log info "BYTECOUNTEDUP $bytecountedup BYTES"
#:log info "BYTECOUNTEDDOWN $bytecounteddown BYTES"
#:log info "MEGCOUNTEDUP $megcountedup MB"
#:log info "MEGCOUNTEDDOWN $megcounteddown MB"
#:log info " "
#:log info " "
##ADD ABOVE INFO TO EMAIL VARIABLE##
:set emailvariable "$emailvariable
QUEUE NAME:\t\t\t$interfacename
TOTAL BYTES:\t\t$precalcbytes
UPLOADED BYTES:\t\t$megcountedup MB
DOWNLOADED BYTES:\t\t$megcounteddown MB
"
##UPDATE OF EMAIL VARIABLE DONE##
}
#####END OF QUEUE PROCCESSOR LOOP#####
#####SENDING DETAIL TO EMAIL#####
:set emailvariable "$emailvariable
END OF QUEUE STATISTICS FOR: $highsitename"
/tool e-mail send from=$fromemailaddress to=$toemailaddress server=196.25.240.94 subject="$highsitename QUEUE Statistics" body=$emailvariable
#####END OF SENDING EMAIL#####
:log info "Total number of queues processed: $numberofqueues"
:log info "QUEUE Statistics Check DONE and E-Mailed to $toemailaddress"
ENJOY!
[admin@H] > /system script run script1
2
Script Error: cannot divide string by time interval
#####GOT SLASH PICK COUNT, STARTING BYTES UP AND DOWN SPLIT#####
:set slashcounted1 ($slashcounted + 1)
:set bytecountedup [:pick $precalcbytes 0 $slashcounted]
:set bytecounteddown [:pick $precalcbytes $slashcounted1 30]
#########################################################
:if ($bytecountedup ="0/0") do={
:set bytecountedup "0"
:set bytecounteddown "0"
}
#########################################################
:set megcountedup ($bytecountedup / 1000000)
:set megcounteddown ($bytecounteddown / 1000000)
#:log info "INTERFACE NAME: $interfacename"
#:log info "PRECALCBYTES: $precalcbytes"
#:log info "BYTECOUNTEDUP $bytecountedup BYTES"
#:log info "BYTECOUNTEDDOWN $bytecounteddown BYTES"
#:log info "MEGCOUNTEDUP $megcountedup MB"
#:log info "MEGCOUNTEDDOWN $megcounteddown MB"
#:log info " "
#:log info " "
##ADD ABOVE INFO TO EMAIL VARIABLE##
:set emailvariable "$emailvariable
COMPUTER IP:\t\t\t$interfacename
TOTAL BYTES:\t\t$precalcbytes
UPLOADED MEGABYTES:\t\t$megcountedup MB
DOWNLOADED MEGABYTES:\t\t$megcounteddown MB
"
/queue simple :local upload 0 :local download 0 :foreach i in=[find] do={ :local bytes [get $i bytes] :set upload ($upload + [:pick $bytes 0 [:find $bytes "/"]]) :set download ($download + [:pick $bytes ([:find $bytes "/"]+1) [:len $bytes]]) } /tool e-mail ... body="Queue Stats - u: $upload, d: $download"If you want to test it in the console, enclose the whole script in brackets { } and replace the "/tool email..." line with:
:put "u: $upload, d: $download"You can also view each queue's stats by putting this line after the ":set download..." line:
:put ([get $i name] . " - " . [:pick $bytes 0 [:find $bytes "/"]] . " / " . [:pick $bytes ([:find $bytes "/"]+1) [:len $bytes]])