Syed Jahanzaib Personal Blog to Share Knowledge !

October 31, 2013

Monitoring Mikrotik with Linux base MRTG [References]

Filed under: Linux Related, Mikrotik Related — Tags: , , , , — Syed Jahanzaib / Pinochio~:) @ 2:23 PM

Following post is about how to monitor Mikrotik Ssytem / Routerboard to create live graphs with history for every aspect, like CPU, Memory, Voltage, Amps, Interface etc. It comes very useful when you remotely administrating the system and you need to know what happens over the period of time and have an overview on every internal instance of the system.

I wrote another article that explains well on howto install MRTG in Ubuntu and monitor anything with it, but WORDPRESS coding ruins the code badly, but still you can get idea from it from following URL.

https://aacable.wordpress.com/tag/mrtg-installation-on-ubuntu/

So basically you have to first install MRTG on linux, then you can use that mrtg installation to monitor any devices in your network (which supports snmp that includes mikrotik as well)


1- MIKROTIK SECTION

 

# Enabling SNMP on Mikrotik

First Enable SNMP service (with public as community string or whatever you like on your mikrotik. Make sure no firewall rule is blocking SNMP traffic from/to the monitoring server.

Open Terminal in mikrotik and paste the following command. Or you can configure it via going to IP > SNMP


/snmp community
set [ find default=yes ] addresses=0.0.0.0/0 authentication-password="" authentication-protocol=MD5 encryption-password="" encryption-protocol=DES name=public read-access=yes \
security=none write-access=no

/snmp
set contact=Syed-Jahanzaib enabled=yes engine-id="" location=aacable-wordpress-com trap-community=public trap-generators="" trap-target="" trap-version=1

Now proceed further 🙂


 

1. Monitoring Mikrotik Simple Queue with Linux base MRTG (for monitoring performance and track purposes)

To monitor simple QUEUE via Linux base MRTG, you can use following config as an example 😀

First you have to check your simple queue OID (numeric value which is used by MRTG to poll specific data from the remote server) in mikrotik. for example you have a queue to allow 100M for proxy cached marked packets.

sq-ch

Open Terminal and print OID for Simple Queue number 0 (your can be changed, but in general Queue for proxy hit packets should be on ** TOP ** )


[admin@MikroTik] /queue simple print

Flags: X - disabled, I - invalid, D - dynamic

0    ;;; Simple Queue for squid Proxy CACHE HIT Packet Allow Unlimited Bandwidth
name=SQ-for-cache-hit interface=all parent=none packet-marks=Cache direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=100M/100M burst-limit=0/0
burst-threshold=0/0 burst-time=0s/0s total-queue=default-small

Now check its OID value which will be used in MRTG to graph the values. Do remember, If you move/delete/add particular Queue , the oid value will change, simply note down new value and recreate graphs with the new values. Also on every system these OIDs are different, simply take a print oid to use them.


[admin@MikroTik] /queue simple print oid

Flags: X - disabled, I - invalid, D - dynamic

0    ;;; Simple Queue for squid Proxy CACHE HIT Packet Allow Unlimited Bandwidth
name=.1.3.6.1.4.1.14988.1.1.2.1.1.2.12534 bytes-in=.1.3.6.1.4.1.14988.1.1.2.1.1.8.12534 bytes-out=.1.3.6.1.4.1.14988.1.1.2.1.1.8.12534 packets-in=.1.3.6.1.4.1.14988.1.1.2.1.1.10.12534
packets-out=.1.3.6.1.4.1.14988.1.1.2.1.1.11.12534 queues-in=.1.3.6.1.4.1.14988.1.1.2.1.1.12.12534 queues-out=.1.3.6.1.4.1.14988.1.1.2.1.1.13.12534

As showed in the image below . . .

qu-oid

Now we have to take bytes-in and bytes-out value for graphing purposes. which is in our case are

.1.3.6.1.4.1.14988.1.1.2.1.1.8.12534
.1.3.6.1.4.1.14988.1.1.2.1.1.9.12534

Now you can simply use the below CFG file to create Graphs for the mikrotik simple queue.


Target[mikrotik-simple-queue-in-out]: .1.3.6.1.4.1.14988.1.1.2.1.1.8.12534&.1.3.6.1.4.1.14988.1.1.2.1.1.9.12534:public@10.0.0.1
MaxBytes[mikrotik-simple-queue-in-out]: 100000000
#Options[mikrotik-simple-queue-in-out]: bits
Title[mikrotik-simple-queue-in-out]: Mikrotik QUEUE for Cache HIT
PageTop[mikrotik-simple-queue-in-out]: <H1>Mikrotik QUEUE for Cache HIT</H1>
#Maintainer: Syed Jahanzaib

 

SAMPLE GRAPH FOR THE SIMPLE QUEUE MONITORING VIA MRTG (AS SHOWED ABOVE)

QUEUE-SAMPLE


Sample Graphs for ccr_1036

Following are sample graphs showing various aspects of Mikrotik CCR 1036.

 

1- cpu

 

active users

 

combined wan usage for 3 dsl

 

cpu tempr

 

memory monitor

 

ping status

 

rb amp

 

rb fan-2 speed rpm

 

rb tempr

 

rb voltage

 

rb watts

 


 

SAMPLE CFG FILES (WORKING GOOD WITH MIKROTIK CCR_1036  ROUTERBOARD MODEL.

 

Mikrotik CCR General  OID’s


active-fan: .1.3.6.1.4.1.14988.1.1.3.9.0
voltage: .1.3.6.1.4.1.14988.1.1.3.8.0
temperature: .1.3.6.1.4.1.14988.1.1.3.10.0
processor-temperature: .1.3.6.1.4.1.14988.1.1.3.11.0
current: .1.3.6.1.4.1.14988.1.1.3.13.0
power-consumption: .1.3.6.1.4.1.14988.1.1.3.12.0
psu1-state: .1.3.6.1.4.1.14988.1.1.3.15.0
psu2-state: .1.3.6.1.4.1.14988.1.1.3.16.0
18.0 is i guess fan2 rpm oid, not mentioned in print oid.</pre>
<pre>uptime: .1.3.6.1.2.1.1.3.0
total-memory: .1.3.6.1.2.1.25.2.3.1.5.65536
used-memory: .1.3.6.1.2.1.25.2.3.1.6.65536
cpu-frequency: .1.3.6.1.4.1.14988.1.1.3.14.0
build-time: .1.3.6.1.4.1.14988.1.1.7.6.0


 


# 192.168.100.2 is Mikrotik RB IP Address
# MRTG sample cfg files for Mikrotik CCR Routerboard monitoring
# Syed Jahanzaib
# Last Modified at 14th-JAN-2016

### MIKROTIK CCR_1036 192.168.100.2 CPU load ###
Target[192.168.100.2_cpu]: 1.3.6.1.2.1.25.3.3.1.2.1&1.3.6.1.2.1.25.3.3.1.2.1:public@192.168.100.2
AbsMax[192.168.100.2_cpu]: 100
MaxBytes[192.168.100.2_cpu]: 100
Title[192.168.100.2_cpu]: MIKROTIK CCR_1036 CPU load
PageTop[192.168.100.2_cpu]: <H1>MIKROTIK CCR_1036 CPU load</H1>
Options[192.168.100.2_cpu]: gauge,growright,nopercent, noo
YLegend[192.168.100.2_cpu]: CPU load
ShortLegend[192.168.100.2_cpu]: %
LegendI[192.168.100.2_cpu]: CPU load (percentage)


# MIKROTIK CCR_1036 PPPoE ACTIVE Users
Target[mtPPPoEusers]: 1.3.6.1.4.1.9.9.150.1.1.1.0&1.3.6.1.4.1.9.9.150.1.1.1.0:public@192.168.100.2
Title[mtPPPoEusers]: Active PPPoE Users on MIKROTIK CCR_1036
PageTop[mtPPPoEusers]: <H1>Active PPPoE Users on MIKROTIK CCR_1036</H1>
MaxBytes[mtPPPoEusers]: 1000
Colours[mtPPPoEusers]: B#8888ff,B#8888ff,B#5398ff,B#5398ff
Options[mtPPPoEusers]: gauge,nopercent,noo,integer,growright
LegendI[mtPPPoEusers]: Active PPPoE Users on MT
LegendO[mtPPPoEusers]:
YLegend[mtPPPoEusers]: Active PPPoE Users on MT
Legend1[mtPPPoEusers]: Active PPPoE Users on MT
Legend2[mtPPPoEusers]:


### MONITORING MIKROTIK CCR_1036 CPU TEMP ###
Target[mt.cpu.temp]: 1.3.6.1.4.1.14988.1.1.3.11.0&1.3.6.1.4.1.14988.1.1.3.11.0:public@192.168.100.2 / 10
Options[mt.cpu.temp]: gauge, growright, nopercent, noinfo
MaxBytes[mt.cpu.temp]: 100
Colours[mt.cpu.temp]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt.cpu.temp]: dwmy
YLegend[mt.cpu.temp]: CPU Temprature
Title[mt.cpu.temp]: MIKROTIK CCR_1036 RB CPU Temprature
PageTop[mt.cpu.temp]: <H1>MIKROTIK CCR_1036 RB CPU Temprature</H1>
ShortLegend[mt.cpu.temp]: c
LegendI[mt.cpu.temp]:
LegendO[mt.cpu.temp]: CPU Temp
Legend1[mt.cpu.temp]: CPU Temprature
Legend2[mt.cpu.temp]: CPU Temprature


### MONITORING MIKROTIK CCR_1036 RB TEMP ###
Target[mt.rb.temp]: 1.3.6.1.4.1.14988.1.1.3.10.0&1.3.6.1.4.1.14988.1.1.3.10.0:public@192.168.100.2 / 10
Options[mt.rb.temp]: gauge, growright, nopercent, noinfo
MaxBytes[mt.rb.temp]: 100
Colours[mt.rb.temp]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt.rb.temp]: dwmy
YLegend[mt.rb.temp]: RB Temprature
Title[mt.rb.temp]: MIKROTIK CCR_1036 Router Board Temprature
PageTop[mt.rb.temp]: <H1>MIKROTIK CCR_1036 Router Board Temprature</H1>
ShortLegend[mt.rb.temp]: c
LegendI[mt.rb.temp]:
LegendO[mt.rb.temp]: RB Temp
Legend1[mt.rb.temp]: RB Temprature
Legend2[mt.rb.temp]: RB Temprature

### MONITORING MIKROTIK CCR_1036 VOLTAGE Monitor ###
Target[mt-voltage]: .1.3.6.1.4.1.14988.1.1.3.8.0&1.3.6.1.4.1.14988.1.1.3.8.0:public@192.168.100.2 / 10
Options[mt-voltage]: gauge, growright, nopercent, noinfo
MaxBytes[mt-voltage]: 1000
Colours[mt-voltage]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-voltage]: dwmy
YLegend[mt-voltage]: Voltaeg Monitor
Title[mt-voltage]: MIKROTIK CCR_1036 Cloudcore RB VOLTAGE Monitor
PageTop[mt-voltage]: <H1>MIKROTIK CCR_1036 Cloudcore RB VOLTAGE Monitor</H1>
ShortLegend[mt-voltage]: c
LegendI[mt-voltage]:
LegendO[mt-voltage]: Voltage
Legend1[mt-voltage]: Voltage
Legend2[mt-voltage]: Voltage


### MONITORING MIKROTIK CCR_1036 power.consumption Watt Usage Monitor ###
Target[mt-powerconsumption]: .1.3.6.1.4.1.14988.1.1.3.12.0&.1.3.6.1.4.1.14988.1.1.3.12.0:public@192.168.100.2 / 10
Options[mt-powerconsumption]: gauge, growright, nopercent, noinfo
MaxBytes[mt-powerconsumption]: 1000
Colours[mt-powerconsumption]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-powerconsumption]: dwmy
YLegend[mt-powerconsumption]: Watts USAGE Monitor
Title[mt-powerconsumption]: MIKROTIK CCR_1036 Cloudcore RB Watts Usage Monitor
PageTop[mt-powerconsumption]: <H1>MIKROTIK CCR_1036 Cloudcore RB Watts Usage Monitor</H1>
ShortLegend[mt-powerconsumption]: W
LegendI[mt-powerconsumption]:
LegendO[mt-powerconsumption]: power.consumption.wts
Legend1[mt-powerconsumption]: power.consumption.wts
Legend2[mt-powerconsumption]: power.consumption.wts

### MONITORING MIKROTIK CCR_1036 FAN-2 Speed Monitor ###
Target[mt-FAN2-speed]: 1.3.6.1.4.1.14988.1.1.3.18.0&1.3.6.1.4.1.14988.1.1.3.18.0:public@192.168.100.2
Options[mt-FAN2-speed]: gauge, growright, nopercent, noinfo
MaxBytes[mt-FAN2-speed]: 10000
Colours[mt-FAN2-speed]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-FAN2-speed]: dwmy
YLegend[mt-FAN2-speed]: Watts USAGE Monitor
Title[mt-FAN2-speed]: MIKROTIK CCR_1036 Cloudcore RB FAN-2 Speed Monitor
PageTop[mt-FAN2-speed]: <H1>MIKROTIK CCR_1036 Cloudcore RB FAN-2 Speed Monitor</H1>
ShortLegend[mt-FAN2-speed]: RPM
LegendI[mt-FAN2-speed]:
LegendO[mt-FAN2-speed]: fan-2.rpm.speed
Legend1[mt-FAN2-speed]: fan-2.rpm.speed
Legend2[mt-FAN2-speed]: fan-2.rpm.speed


### MONITORING MIKROTIK CCR_1036 AMP Monitor ###
Target[mt-amp-mon]: 1.3.6.1.4.1.14988.1.1.3.13.0&1.3.6.1.4.1.14988.1.1.3.13.0:public@192.168.100.2 / 1000
Options[mt-amp-mon]: gauge, growright, nopercent, noinfo
MaxBytes[mt-amp-mon]: 10000
Colours[mt-amp-mon]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-amp-mon]: dwmy
YLegend[mt-amp-mon]: AMP USAGE Monitor
Title[mt-amp-mon]: MIKROTIK CCR_1036 Cloudcore RB AMP Monitor
PageTop[mt-amp-mon]: <H1>MIKROTIK CCR_1036 Cloudcore RB AMP Monitor</H1>
ShortLegend[mt-amp-mon]: amp
LegendI[mt-amp-mon]:
LegendO[mt-amp-mon]: amp.speed
Legend1[mt-amp-mon]: amp.speed
Legend2[mt-amp-mon]: amp.speed


# Percent of MIKROTIK CCR_1036 memory used
Target[ccr_server_mem_ram]: ( 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.100.2) * 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.100.2)
Title[ccr_server_mem_ram]: Memory usage for MIKROTIK CCR_1036 CCR Server
PageTop[ccr_server_mem_ram]: <H1>Memory usage for MIKROTIK CCR_1036 CCR Server</H1>
MaxBytes[ccr_server_mem_ram]: 100
ShortLegend[ccr_server_mem_ram]: %
YLegend[ccr_server_mem_ram]: % of Memory
Legend1[ccr_server_mem_ram]: Used Memory
LegendI[ccr_server_mem_ram]: Used :
LegendO[ccr_server_mem_ram]:
Options[ccr_server_mem_ram]: nopercent, gauge, integer, growright
Unscaled[ccr_server_mem_ram]: ymwd

 


 

 

Regard’s
Syed Jahanzaib

Advertisements

7 Comments »

  1. Good Work!

    Like

    Comment by Felipe Romero — October 31, 2013 @ 6:41 PM

  2. Jahanzaib ap ka Email id mil sakhta hai …?

    Like

    Comment by shani — December 23, 2013 @ 12:23 AM

  3. thank you Syed, it is really a great job.
    can we have an addition how to install MRTG for monitoring MikroTik devices

    Like

    Comment by Hatem Sabrey — November 20, 2014 @ 5:17 PM

    • You can do monitoring of your mikrotik devices as showed in this guide. What specifically you want to ask ? describe in details.

      Like

      Comment by Syed Jahanzaib / Pinochio~:) — November 21, 2014 @ 12:46 PM

      • bro can we make mrtg graph for pppoe users

        Like

        Comment by Muhammad Ismail — January 26, 2015 @ 12:47 PM

  4. Assalamualaikum,

    Hi, i have problem when create CPU load, error message shown:

    2017-03-22 07:34:34: ERROR: Target[cpu_load][_IN_] ‘#.1.3.6.1.2.1.25.3.3.1.2.1@.1.3.6.1.2.1.25.3.3.1.2. $target->[6]{$mode} ‘ did not eval into defined data
    2017-03-22 07:34:34: ERROR: Target[cpu_load][_OUT_] ‘#.1.3.6.1.2.1.25.3.3.1.2.1@.1.3.6.1.2.1.25.3.3.1.2. $target->[6]{$mode} ‘ did not eval into defined data

    can you help me for this issue?

    thank you.

    Like

    Comment by Levy — March 22, 2017 @ 5:37 AM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: