TUT:MRTG - fenner/net-snmp-wiki-experiment GitHub Wiki

Broadly speaking, there are two basic techniques for monitoring a system using SNMP. Either the agent can be configured to watch for certain values or events, and report to a management station when something significant happens. Alternatively, some external application can be set up that will poll the agent regularly, and collect the information of interest.

The DisMan Monitoring page describes the first approach - this tutorial will concentrate on the second, using the Multi Router Traffic Grapher tool.

Note that this does not attempt to be a complete tutorial on the use of MRTG, or even cover monitoring network traffic. Such topics are comprehensively covered on the MRTG site already. This page is specifically concerned with discussing other values that can be monitored using MRTG.

Monitoring CPU load

There are several ways to try to monitor CPU usage, because the system maintains several CPU counters: Idle, System, User, Nice. As MRTG does not allow you to graph more than two values at a time, it is possible to select any two values and graph against each other. It is also possible to compute a combined value.

User vs Idle CPU usage

The MRTG configuration would look something like

   LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt        Target[kontor.cpu]:ssCpuRawUser.0&ssCpuRawIdle.0:[email protected]    RouterUptime[kontor.cpu]: [email protected]    MaxBytes[kontor.cpu]: 100    Title[kontor.cpu]: CPU LOAD    PageTop[kontor.cpu]: 

User CPU Load %

   Unscaled[kontor.cpu]: ymwd    ShortLegend[kontor.cpu]: %    YLegend[kontor.cpu]: CPU Utilization    Legend1[kontor.cpu]: User CPU in % (Load)    Legend2[kontor.cpu]: Idle CPU in % (Load)    Legend3[kontor.cpu]:    Legend4[kontor.cpu]:    LegendI[kontor.cpu]:  User    LegendO[kontor.cpu]:  Idle    Options[kontor.cpu]: growright,nopercent

User vs System CPU usage

The MRTG configuration would look something like

   LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt

   Target[kontor.usrsys]:ssCpuRawUser.0&ssCpuRawSystem.0:[email protected]    RouterUptime[kontor.usrsys]: [email protected]    MaxBytes[kontor.usrsys]: 100    Title[kontor.usrsys]: CPU LOAD    PageTop[kontor.usrsys]: 

CPU (user and system) Load %

   Unscaled[kontor.usrsys]: ymwd    ShortLegend[kontor.usrsys]: %    YLegend[kontor.usrsys]: CPU Utilization    Legend1[kontor.usrsys]: User CPU in % (Load)    Legend2[kontor.usrsys]: System CPU in % (Load)    Legend3[kontor.usrsys]:    Legend4[kontor.usrsys]:    LegendI[kontor.usrsys]:  User    LegendO[kontor.usrsys]:  System    Options[kontor.usrsys]: growright,nopercent

Active CPU usage

This example sums User, System and Nice and plots it as a single value.

The corresponding MRTG configuration is

   LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt

   Target[kontor.cpusum]:ssCpuRawUser.0&ssCpuRawUser.0:[email protected] + \                          ssCpuRawSystem.0&ssCpuRawSystem.0:[email protected] + \                          ssCpuRawNice.0&ssCpuRawNice.0:[email protected]    RouterUptime[kontor.cpusum]: [email protected]    MaxBytes[kontor.cpusum]: 100    Title[kontor.cpusum]: CPU LOAD    PageTop[kontor.cpusum]: 

Active CPU Load %

   Unscaled[kontor.cpusum]: ymwd    ShortLegend[kontor.cpusum]: %    YLegend[kontor.cpusum]: CPU Utilization    Legend1[kontor.cpusum]: Active CPU in % (Load)    Legend2[kontor.cpusum]:    Legend3[kontor.cpusum]:    Legend4[kontor.cpusum]:    LegendI[kontor.cpusum]:  Active    LegendO[kontor.cpusum]:    Options[kontor.cpusum]: growright,nopercent

Monitoring Disk space

There are two tables that can be used when monitoring disk space, UCD-SNMP-MIB:dskTable and HOST-RESOURCES-MIB:hrStorageTable. There are two noticeable differences bwtween these tables: UCD-SNMP-MIB:dskTable requires a configuration directive in snmpd.conf, but it also gives a direct measure of the percentage of free space

On the system I used for these examples, I have the following disks:

   $ df    Filesystem            Size  Used Avail Use% Mounted on    /dev/hda6             289M   56M  218M  21% /    /dev/hda1             7.3G  3.2G  4.1G  44% /mnt/windows    /dev/hda7             1.7G  1.2G  429M  74% /usr    /dev/hdc1              19G  6.7G   11G  37% /space    

and I have put the following lines into snmpd.conf:

   disk    /   100000    disk    /usr    100000    disk    /space  100000

Monitoring dskTable

This plots the usage of the root and /usr partitions in one graph

   LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt

   Target[kontor.root]:dskPercent.1&dskPercent.2:[email protected]    RouterUptime[kontor.root]: [email protected]    MaxBytes[kontor.root]: 100    Title[kontor.root]: DISK USAGE    PageTop[kontor.root]: 

DISK / and /usr Usage %

   Unscaled[kontor.root]: ymwd    ShortLegend[kontor.root]: %    YLegend[kontor.root]: DISK Utilization    Legend1[kontor.root]: Root disk    Legend2[kontor.root]: /usr disk    Legend3[kontor.root]:    Legend4[kontor.root]:    LegendI[kontor.root]:  Root disk    LegendO[kontor.root]:  /usr disk    Options[kontor.root]: growright,gauge,nopercent

Monitoring hrStorageTable

This plots the partition size as one value, and the used space as another.

Note: the values returned here are in units of hrStorageUnits, which, dependent on the file system type, may or may not be 1K.

   LoadMIBs: /usr/local/share/snmp/mibs/HOST-RESOURCES-MIB.txt

   Target[kontor.hrroot]:hrStorageSize.1&hrStorageUsed.1:[email protected]    RouterUptime[kontor.hrroot]: [email protected]    MaxBytes[kontor.hrroot]: 300000    Title[kontor.hrroot]: DISK / USAGE    PageTop[kontor.hrroot]: 

DISK / Usage

   ShortLegend[kontor.hrroot]: B    kMG[kontor.hrroot]: k,M,G,T,P    kilo[kontor.hrroot]: 1024    YLegend[kontor.hrroot]: DISK / Utilization    Legend1[kontor.hrroot]: Root disk size    Legend2[kontor.hrroot]: Root disk usage    Legend3[kontor.hrroot]:    Legend4[kontor.hrroot]:    LegendI[kontor.hrroot]:  Root disk size    LegendO[kontor.hrroot]:  Root disk usage    Options[kontor.hrroot]: growright,gauge,nopercent    

Other Monitoring Examples

Two further examples that have been offered:

Monitoring TCP connections

   Target[tcpopen]:     .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@localhost     Options[tcpopen]: nopercent,growright,gauge,noinfo     Title[tcpopen]: Open TCP connections     PageTop[tcpopen]: Open TCP connections    MaxBytes[tcpopen]: 1000000     YLegend[tcpopen]: # conns     ShortLegend[tcpopen]: connections     LegendI[tcpopen]:  Connections:     LegendO[tcpopen]:     Legend1[tcpopen]: Open TCP connections 

Monitoring Free Memory

   Target[freemem]:     .1.3.6.1.4.1.2021.4.11.0&.1.3.6.1.4.1.2021.4.11.0:public@localhost     Options[freemem]: nopercent,growright,gauge,noinfo     Title[freemem]: Free Memory     PageTop[freemem]: Free Memory    MaxBytes[freemem]: 1000000     kMG[freemem]: k,M,G,T,P,X     YLegend[freemem]: bytes     ShortLegend[freemem]: bytes     LegendI[freemem]:  Free Memory:     LegendO[freemem]:     Legend1[freemem]: Free memory, not including swap, in bytes


⚠️ **GitHub.com Fallback** ⚠️