print simple queue name and stats in the same command..

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.

:foreach i in=[/queue simple find rate=8] do={:put (
“nome” . [/queue simple get $i name] . “TOTAL” . [/queue simple get $i total-byte
s]);}



just figured it out :slight_smile:

but theres any way to do something like “order by” total bytes?

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!

In the version 3.20 does not work
Please advice
Thanks

Hi pjotr

What exactly isn’t working with your script?

Are you aware of the fact that the SAIX IP address have changed? SAIX recommends you use smtp.saix.net instead of it’s IP, as certain segments of their network resolve to different addresses. If your problem is that the script won’t send out the mail, it’s probably due to the SMTP address, try pinging smtp.saix.net from the highsite and see where it resolves to.

If your problem is that the script won’t run due to something else we could further investigate.

I looked through the script real quick but couldn’t see any obvious problems.

Perhaps send us more info on what exactly doesn’t work.

My rule of thumb for trouble shooting is usually to # out most of the script and removing the # until it stop working. (or alternatively put :log error “script is here” messages in some lines, run the script, and move the :log entry down until you find where it stops…)

Hope the info was useful!

G

if the simple queue in one of the rules of any data statistics, so the script fails

If the number of> 1 queue simple, displays an error


[admin@H] > /system script run script1                                      
2
Script Error: cannot divide string by time interval

work

#####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
"

Hi Guys,

I know its an old topic but was wondering how to get this to work on ROS 6.5.

I just need to get the Total TX and RX bytes stats for all my queues.

My queues are static created, and all have Local - xxxxx or Management - xxxxx in the name section of the Queue. i havent used comments on any of the Queues.

any info would be greatly appreciated.

Regards
Wes

If you want the total bytes of ALL simple queues added together, try this (edit the /tool email line with your info):
/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]])