MRTG/Routers2: Adding a Linux Host

This post describes how to add a Linux machine to the MRTG/Routers2 monitoring server. First, the host must be able to process SNMP requests. Then, a *.cfg file for MRTG/Routers2 is created by running the “cfgmaker” tool with a host-template. Since a few values are wrong in the cfgmaker file, I also explain how to correct them. Finally, I am adding the mrtg-ping-probe lines to the configuration.

Installation of SNMP

Two packages are mandatory for SNMP: snmp which is the tool to send SNMP requests to a machine, and snmpd which is the daemon to listen on port 161 for incoming SNMP requests. On a Ubuntu machine, both packets can easily be installed with:

After that, the snmpd configuration must be customized in order to allow incoming SNMP requests. This slightly depends on whether these requests are sent from the localhost (e.g., if the MRTG machine wants to query itself), or from a remote host over the network (which is the normal case). In both cases, the snmpd.conf file must be opened with:

In the snmpd.conf, a paragraph called “AGENT BEHAVIOUR” specifies the listening state of snmpd. In order to allow incoming requests from any machine via IPv4, the following line fits:

In the paragraph called “ACCESS CONTROL” a line that allows an SNMP COMMUNITY for read-only access can be specified like this two examples:

Now restart the daemon with sudo service snmpd restart and test the configuration with the snmpwalk tool which runs through all (!) SNMP values the localhost presents: snmpwalk -v 2c -c public localhost .1.3.6 . If there are many hundreds lines flowing over the screen, everything is ok.

Creating the CFG File

I am creating my *.cfg files for Linux servers with the host-generic.htp from Steve Shipways forum here. The main command is the following:

This creates the “jw-vm01.cfg” file and customizes the settings. This file must then be copied into the “/etc/mrtg/” folder. MRTG will then query it. However, I advise to change the following lines:

  • Delete all lines under the “### Global Config Options” because they are not needed. Especially the “WorkDir:” value is wrong at this position since it is already specified in the global mrtg.cfg configuration file if it is installed due to my tutorial.
  • The memory values are wrongly calculated with the host template: They need to be multiplied with 1024. E.g., instead of
    it must be
  • The CPU, memory, and the filesystem graphs are not shown from “0 – 100 %” but only from “0 – current max value %”. In my opinion I get more information if the graph always shows up to 100 %. So I added the following lines to the appropriate sections of the CPU, memory, and all disks (replace “xy” by the disk value shown in the other lines):
  • I like all interfaces with a graph type of mirror. That is, for all interfaces:
  • Furthermore, I am always adding a ping to the node (which is not much interesting at the localhost in this example here, though). This requires to have the “mrtg-ping-probe” packaged installed. I listed the MRTG/Routers2 config here.
  • Finally, I have a recurrent coloring style, i.e., yellow for CPU, pink for processes, turquoise for users, and orange for RAM. So I added the following lines inside the appropriate sections:
     

Here is an example of my localhost *.cfg file with all the above mentioned changes:

 

Graphs

If everything is ok and MRTG stores the values correctly, the graphs should grow every five minutes and look like that:

 

[UPDATE] Raspberry Pi Temperature

When querying a Raspberry Pi you can also monitor the CPU temperature. This is the procedure: Extend the SNMP service on the Pi to hand out the temperature:

Walking the SNMP tree I found for example the following OID: 1.3.6.1.4.1.8072.1.3.2.3.1.1.11.116.101.109.112.101.114.97.116.117.114.101  or this one: 1.3.6.1.4.1.8072.1.3.2.4.1.2.5.116.101.115.116.51.1 . (I don’t know why they are different, but I don’t care.)

Add the MRTG target such as:

Note the HRule which inserts a line at 55 degree. Normally, a Pi should not exceed this temperature.

Leave a Reply

Your email address will not be published. Required fields are marked *