Community discussions

MikroTik App
 
ncats
newbie
Topic Author
Posts: 31
Joined: Mon Apr 23, 2018 9:37 pm

List of Queues with Name, Number, and OID

Fri May 12, 2023 7:14 pm

I would like to generate a list of my simple queues and their OIDs. I can do this with:
simple queue print oid

However, this list only provides me the queue number and not the name of the queue. Additionally, I only need to see bytes-in and bytes-out if at all possible.

I can generate a list like this:
:foreach i in=[/queue simple find] do={:global name [/queue simple get $i name]; :put $name;}

But I do not know the command to get the oid of a specific queue.

What I'm looking for is something like this (which obviously doesn't work):
:foreach i in=[/queue simple find] do={:global name [/queue simple get $i name]; :global oid-bytes-in [/queue simple get $i oid-bytes-in]; :global oid-bytes-out [/queue simple get $i oid-bytes-out]; :put ($name . " " . $oid-bytes-in . " " . $oid-bytes-out);}

Any help would be appreciated!
 
ncats
newbie
Topic Author
Posts: 31
Joined: Mon Apr 23, 2018 9:37 pm

Re: List of Queues with Name, Number, and OID

Tue May 16, 2023 9:27 pm

I'm not sure if I'll make it back to this thread. I ended up running two simple commands and combining them with perl:

/queue simple print brief
/queue simple print oid

The first command allows me to associate the queue name with an index number.
The second command allows me to associate and index number with an oid.

There doesn't seem to be any way to query the oid's based on the queue's ids. I can only output the entire list.

Not ideal, but it got me what I needed.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: List of Queues with Name, Number, and OID

Wed May 17, 2023 2:44 pm

I state that it sucks for me to use "print" in scripts....
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: List of Queues with Name, Number, and OID  [SOLVED]

Wed May 17, 2023 3:01 pm

work with 6.48.6 without print code

{
    /queue simple
    :local itname ""
    :local decID  0
    :local OIDin  ".1.3.6.1.4.1.14988.1.1.2.1.1.8"
    :local OIDout ".1.3.6.1.4.1.14988.1.1.2.1.1.9"
    :foreach item in=[find] do={
        :set itname [get $item name]
        :set decID [:tonum ("0x$[:pick $item 1 [:len $item]]")]
        :put "$itname $OIDin.$decID $OIDout.$decID"
    }
}

work on 6.48.6 with print code

{
    /queue simple
    :local itname ""
    :local search [:toarray ""]
    :local OIDin  ""
    :local OIDout ""
    :foreach item in=[find] do={
        :set itname [get $item name]
        :set search [print oid as-value where .id=$item]
        :set OIDin  ($search->0->"bytes-in")
        :set OIDout ($search->0->"bytes-out")
        :put "$itname $OIDin $OIDout"
    }
}
 
ncats
newbie
Topic Author
Posts: 31
Joined: Mon Apr 23, 2018 9:37 pm

Re: List of Queues with Name, Number, and OID

Wed May 17, 2023 3:31 pm

Thank you rextended, this is perfect!

Who is online

Users browsing this forum: No registered users and 20 guests