Community discussions

MikroTik App
 
atuxnull
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Tue Feb 07, 2017 10:02 pm

MRTG OIDs for Mikrotik

Fri Jan 21, 2022 3:16 pm

I got a Linux server in my LAN that runs MRTG and i monitor all Linux boxes for ethernet traffic, cpu, ram. I would like to add my Mikrotik Router in the MRTG and monitor traffic for each port, CPU, RAM.
I got confused how to write the mrtt.cfg for each element eg from a Remote Linux machine:
Target[CPU]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@192.168.1.15:::::2
MaxBytes[CPU]: 100
Unscaled[CPU]: dwmy
Options[CPU]: gauge, growright, nopercent
YLegend[CPU]: Load Average
ShortLegend[CPU]: (%)
LegendI[CPU]: Load Average 1 min
LegendO[CPU]: Load Average 5 min
Legend1[CPU]: Load Average 1 min
Legend2[CPU]: Load Average 5 min
Title[CPU]: CPU Load Average
PageTop[CPU]: <h1>CPU Load Average of machine .15</h1>
here are the Mikrotik router's OIDs
####### Interfaces ###########
[b][u] /interface print oid[/u][/b]
 
0 	 R name=.1.3.6.1.2.1.2.2.1.2.1 actual-mtu=.1.3.6.1.2.1.2.2.1.4.1 
       mac-address=.1.3.6.1.2.1.2.2.1.6.1 admin-status=.1.3.6.1.2.1.2.2.1.7.1 
       oper-status=.1.3.6.1.2.1.2.2.1.8.1 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.1 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.1 
       discards-in=.1.3.6.1.2.1.2.2.1.13.1 errors-in=.1.3.6.1.2.1.2.2.1.14.1 
       bytes-out=.1.3.6.1.2.1.31.1.1.1.10.1 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.1 
       discards-out=.1.3.6.1.2.1.2.2.1.19.1 errors-out=.1.3.6.1.2.1.2.2.1.20.1 



 1   S name=.1.3.6.1.2.1.2.2.1.2.2 actual-mtu=.1.3.6.1.2.1.2.2.1.4.2 
       mac-address=.1.3.6.1.2.1.2.2.1.6.2 admin-status=.1.3.6.1.2.1.2.2.1.7.2 
       oper-status=.1.3.6.1.2.1.2.2.1.8.2 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.2 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.2 
       discards-in=.1.3.6.1.2.1.2.2.1.13.2 errors-in=.1.3.6.1.2.1.2.2.1.14.2 
       bytes-out=.1.3.6.1.2.1.31.1.1.1.10.2 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.2 
       discards-out=.1.3.6.1.2.1.2.2.1.19.2 errors-out=.1.3.6.1.2.1.2.2.1.20.2 

 2   S name=.1.3.6.1.2.1.2.2.1.2.3 actual-mtu=.1.3.6.1.2.1.2.2.1.4.3 
       mac-address=.1.3.6.1.2.1.2.2.1.6.3 admin-status=.1.3.6.1.2.1.2.2.1.7.3 
       oper-status=.1.3.6.1.2.1.2.2.1.8.3 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.3 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.3 
       discards-in=.1.3.6.1.2.1.2.2.1.13.3 errors-in=.1.3.6.1.2.1.2.2.1.14.3 
       bytes-out=.1.3.6.1.2.1.31.1.1.1.10.3 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.3 
       discards-out=.1.3.6.1.2.1.2.2.1.19.3 errors-out=.1.3.6.1.2.1.2.2.1.20.3 

 3   S name=.1.3.6.1.2.1.2.2.1.2.4 actual-mtu=.1.3.6.1.2.1.2.2.1.4.4 
       mac-address=.1.3.6.1.2.1.2.2.1.6.4 admin-status=.1.3.6.1.2.1.2.2.1.7.4 
       oper-status=.1.3.6.1.2.1.2.2.1.8.4 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.4 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.4 
       discards-in=.1.3.6.1.2.1.2.2.1.13.4 errors-in=.1.3.6.1.2.1.2.2.1.14.4 
       bytes-out=.1.3.6.1.2.1.31.1.1.1.10.4 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.4 
       discards-out=.1.3.6.1.2.1.2.2.1.19.4 errors-out=.1.3.6.1.2.1.2.2.1.20.4
	   
	   
	   
 4  RS name=.1.3.6.1.2.1.2.2.1.2.5 actual-mtu=.1.3.6.1.2.1.2.2.1.4.5 
       mac-address=.1.3.6.1.2.1.2.2.1.6.5 admin-status=.1.3.6.1.2.1.2.2.1.7.5 
       oper-status=.1.3.6.1.2.1.2.2.1.8.5 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.5 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.5 
       discards-in=.1.3.6.1.2.1.2.2.1.13.5 errors-in=.1.3.6.1.2.1.2.2.1.14.5 
       bytes-out=.1.3.6.1.2.1.31.1.1.1.10.5 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.5 
       discards-out=.1.3.6.1.2.1.2.2.1.19.5 errors-out=.1.3.6.1.2.1.2.2.1.20.5 

 5  R  name=.1.3.6.1.2.1.2.2.1.2.6 actual-mtu=.1.3.6.1.2.1.2.2.1.4.6 
       mac-address=.1.3.6.1.2.1.2.2.1.6.6 admin-status=.1.3.6.1.2.1.2.2.1.7.6 
       oper-status=.1.3.6.1.2.1.2.2.1.8.6 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.6 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.6 
       discards-in=.1.3.6.1.2.1.2.2.1.13.6 errors-in=.1.3.6.1.2.1.2.2.1.14.6 
       bytes-out=.1.3.6.1.2.1.31.1.1.1.10.6 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.6 
       discards-out=.1.3.6.1.2.1.2.2.1.19.6 errors-out=.1.3.6.1.2.1.2.2.1.20.6 

 6  R  name=.1.3.6.1.2.1.2.2.1.2.7 actual-mtu=.1.3.6.1.2.1.2.2.1.4.7 
       mac-address=.1.3.6.1.2.1.2.2.1.6.7 admin-status=.1.3.6.1.2.1.2.2.1.7.7 
       oper-status=.1.3.6.1.2.1.2.2.1.8.7 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.7 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.7 
       discards-in=.1.3.6.1.2.1.2.2.1.13.7 errors-in=.1.3.6.1.2.1.2.2.1.14.7 
       bytes-out=.1.3.6.1.2.1.31.1.1.1.10.7 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.7 
       discards-out=.1.3.6.1.2.1.2.2.1.19.7 errors-out=.1.3.6.1.2.1.2.2.1.20.7 
#############################################################################################
[b][u] /system resource print oid [/u][/b]
    used-memory: .1.3.6.1.2.1.25.2.3.1.6.65536
    build-time: .1.3.6.1.4.1.14988.1.1.7.6.0
   total-memory: .1.3.6.1.2.1.25.2.3.1.5.65536
  cpu-frequency: .1.3.6.1.4.1.14988.1.1.3.14.0
#############################################################################################
How do i create this please?
 
User avatar
Amm0
Long time Member
Long time Member
Posts: 611
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: MRTG OIDs for Mikrotik

Fri Jan 21, 2022 3:42 pm

You need to enable SNMP, and inside the MRTG config file you need to specify the "credentials" (e.g. SNMP version and community in most cases) in the target line.

Google turned up this old blog post has the approach: http://learnithowabout.blogspot.com/201 ... -base.html
 
User avatar
Amm0
Long time Member
Long time Member
Posts: 611
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: MRTG OIDs for Mikrotik

Fri Jan 21, 2022 3:48 pm

Also, I presume you have reasons for using MRTG on a remote linux box. But Mikrotik internally uses MRTG in /tool/graphing so you can pretty easily get same charts from the Mikrotik itself (but they don't show the MRTG config they use, so not so easy to just "copy"). Also their Dude offers an even richer monitoring than MRTG and support monitoring Linux, so could do this the other way around too.
 
atuxnull
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Tue Feb 07, 2017 10:02 pm

Re: MRTG OIDs for Mikrotik

Fri Jan 21, 2022 6:13 pm

thanks for the reply.
i am aware of the internal feature of mikrotik, but i am already using for my LAN a Linux box to monitor everything. The Linux box is inside my LAN. Everything is monitored within my LAN region.
I got the snmp enabled and i am getting from Mikrotik router the CPU % usage. My confusion is how to get the info for each interface separately and RAM usage. I have printed the OIDs from each each interface, but i am unaware which ones to use for the config in comparison to the link you posted.
Any ideas, please?
 
mkx
Forum Guru
Forum Guru
Posts: 7689
Joined: Thu Mar 03, 2016 10:23 pm

Re: MRTG OIDs for Mikrotik

Fri Jan 21, 2022 6:25 pm

Mikrotik MIB (along others used) should give you information you need.
BR,
Metod
 
atuxnull
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Tue Feb 07, 2017 10:02 pm

Re: MRTG OIDs for Mikrotik

Sat Jan 22, 2022 12:20 am

As said iny initial post, i have the OIDs. I need a way to use them. Could someone help me configure the mrtg.cfg for Mikrotik, please?
 
aesmith
Member Candidate
Member Candidate
Posts: 260
Joined: Wed Mar 27, 2019 6:43 pm

Re: MRTG OIDs for Mikrotik

Sat Jan 22, 2022 9:58 am

I am all but certain that Mikrotik uses the standard MIB-II iftable OIDs. Firstly because I've never seen a decent router that doesn't, and secondly because I use the standard PRTG "SNMP Traffic" sensor without the need for any Mikrotik specific customisation. So although that doesn't in itself help with the detail of your MRTG configuration file, it suggests that examples of how to monitor interfaces on other brands would probably work for Mikrotik.
I don't know if this reference helps, when I've configured stuff in a more manual way I've used ifInOctets and ifOutOctets to get traffic stats. Obviously with the appropriate interface number as the suffix. These are counters so your traffic rate is the delta between readings ..
http://www.net-snmp.org/docs/mibs/interfaces.html

It may help to use an interactive MIB browser so you can see in real time what each variable returns.
 
User avatar
Amm0
Long time Member
Long time Member
Posts: 611
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: MRTG OIDs for Mikrotik

Sat Jan 22, 2022 3:16 pm

That's a good point:
I am all but certain that Mikrotik uses the standard MIB-II iftable OIDs.
The interface data be exposed in standard MIB-2 MIB file as well. The "print oid" command likely gives you a Mikrotik-specific OID, not the standard onesexposed by the standard MIB-2 or HOST-RESOURCES MIBs. The though is that some MRTG tool might be able to autogenerated the MRTG config files based on those.

MRTG seems to have have a "cfgmaker" tool: https://linux.die.net/man/1/cfgmaker
That seem like it generate the file in the right format, similar to the PRTG wizard but at the command line.

I haven't used MRTG in 20 years, so don't recall the specifics. But I seems the key is to get the "Target" line right in the file. You'll note it stores the community name and IP address there, so those have to match your router.
It may help to use an interactive MIB browser so you can see in real time what each variable returns.
Mikrotik Dude will browser MIBs. There is also a Java tool I use sometimes if you want to confirm the values/view MIBs: https://www.ireasoning.com/mibbrowser.shtml
 
atuxnull
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Tue Feb 07, 2017 10:02 pm

Re: MRTG OIDs for Mikrotik

Tue Jan 25, 2022 6:31 pm

i got it working for CPU, but for memory, it shows wrong info.
Here is what i have to poll Mikrotik via SNMP to get the % of memory used:
#Mikrotik memory used
LoadMIBs: /usr/share/snmp/mibs/mikrotik.mib
Target[Mikrotik_mem]: ( .1.3.6.1.2.1.25.2.3.1.6.65536&.1.3.6.1.2.1.25.2.3.1.6.65536:public@192.168.177.1) * 100 / ( .1.3.6.1.2.1.25.2.3.1.5.65536&.1.3.6.1.2.1.25.2.3.1.5.65536:public@192.168.177.1)
Title[Mikrotik_mem]: Mikrotik Router Memory usage
PageTop[Mikrotik_mem]: <H1>Mikrotik Router Memory usage</H1>
MaxBytes[Mikrotik_mem]: 100
ShortLegend[Mikrotik_mem]: %
YLegend[Mikrotik_mem]: % of Memory
Legend1[Mikrotik_mem]: Used Memory
LegendI[Mikrotik_mem]: Used :
LegendO[Mikrotik_mem]:
Options[Mikrotik_mem]: nopercent, gauge, integer, growright
Unscaled[Mikrotik_mem]: ymwd
and it shows 82% idle, while in WInbox i have 5%

Here is my system's OIDs:
/system resource print oid 
    used-memory: .1.3.6.1.2.1.25.2.3.1.6.65536
    build-time: .1.3.6.1.4.1.14988.1.1.7.6.0
   total-memory: .1.3.6.1.2.1.25.2.3.1.5.65536
  cpu-frequency: .1.3.6.1.4.1.14988.1.1.3.14.0


How do i fix the Memory used, please?
You do not have the required permissions to view the files attached to this post.
 
atuxnull
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Tue Feb 07, 2017 10:02 pm

Re: MRTG OIDs for Mikrotik

Tue Jan 25, 2022 9:36 pm

Also i have created the following:
Target[Mikrotik750_bridge1-in-out]: .1.3.6.1.2.1.31.1.1.1.6.1&.1.3.6.1.2.1.31.1.1.1.10.1:public@192.168.177.1
LoadMIBs: /usr/share/snmp/mibs/mikrotik.mib
MaxBytes[Mikrotik750_bridge1-in-out]: 100000000
Title[Mikrotik750_bridge1-in-out]: Mikrotik bridge1
PageTop[Mikrotik750_bridge1-in-out]: <H1>Mikrotik bridge1</H1>
which i am expecting to see bridge1 total traffic, taken from the OIDs of:
[admin@MikroTik] > interface print oid 
Flags: D - dynamic, X - disabled, R - running, S - slave 
 0  R  name=.1.3.6.1.2.1.2.2.1.2.1 actual-mtu=.1.3.6.1.2.1.2.2.1.4.1 
       mac-address=.1.3.6.1.2.1.2.2.1.6.1 admin-status=.1.3.6.1.2.1.2.2.1.7.1 
       oper-status=.1.3.6.1.2.1.2.2.1.8.1 bytes-in=.1.3.6.1.2.1.31.1.1.1.6.1 
       packets-in=.1.3.6.1.2.1.31.1.1.1.7.1 discards-in=.1.3.6.1.2.1.2.2.1.13.1 
       errors-in=.1.3.6.1.2.1.2.2.1.14.1 bytes-out=.1.3.6.1.2.1.31.1.1.1.10.1 
       packets-out=.1.3.6.1.2.1.31.1.1.1.11.1 discards-out=.1.3.6.1.2.1.2.2.1.19.1 
       errors-out=.1.3.6.1.2.1.2.2.1.20.1
but the traffic is a few kbps ~35kbps, while in Winbox it states 12.5MBps (Skype call). What is wrong with my config?
 
mkx
Forum Guru
Forum Guru
Posts: 7689
Joined: Thu Mar 03, 2016 10:23 pm

Re: MRTG OIDs for Mikrotik

Wed Jan 26, 2022 8:55 am

If the traffic is between two ports, members of bridge, then you won't see that traffic in bridge counters. Bridge in RouterOS has a few personatlities and one of them is bridge interface which is a connection between RouterOS (the software part) and bridge (the switch-like entity). The counters you're observing are counters for this personality and count only traffic directly handled by ROS (e.g. the management traffic).

If the traffic you're mentioning (skype call), is being routed by ROS, then it should show in SNMP output, because traffic does traverse bridge interface on the way to/from routing engine (the LAN leg of it ... assuming bridge is used to connect LAN ports together). Beware that some communication apps (e.g. skype, viber, ...) use direct connections between call parties and if both parties are local, bulk of traffic never leaves local network.
BR,
Metod
 
atuxnull
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Tue Feb 07, 2017 10:02 pm

Re: MRTG OIDs for Mikrotik

Wed Jan 26, 2022 10:55 pm

the traffic is from a user behind the Mikrotik to someone in a different country. No idea how to fix that so snmp could show the correct traffic.

Who is online

Users browsing this forum: danm and 62 guests