Using MRTG for monitoring host CPU, memory, disk etc.

From Notes_Wiki

Home > CentOS > CentOS 6.x > Monitoring tools > MRTG configuration > Using MRTG for monitoring host CPU, memory, disk etc.

Use of cacti is recommended over trying to use MRTG

First configure SNMP server on Linux host as explained at SNMP server configuration for Linux hosts. Then use following steps to monitor CPU, memory, disk etc.:

  1. Use following configuration file:
    # File: /etc/mrtg/server-info.cfg
    # Configuration file for non bandwidth server statistics
    # Define global options
    LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt
    workdir: /var/www/html/
    # CPU Monitoring
    # (Scaled so that the sum of all three values doesn't exceed 100)
    Target[server.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost
    Title[server.cpu]: Server CPU Load
    PageTop[server.cpu]: <h1>CPU Load - System, User and Nice Processes</h1>
    MaxBytes[server.cpu]: 100
    ShortLegend[server.cpu]: %
    YLegend[server.cpu]: CPU Utilization
    Legend1[server.cpu]: Current CPU percentage load
    LegendI[server.cpu]: Used
    Options[server.cpu]: growright,nopercent
    Unscaled[server.cpu]: ymwd
    # Memory Monitoring (Total Versus Available Memory)
    Target[server.memory]: memAvailReal.0&memTotalReal.0:public@localhost
    Title[server.memory]: Free Memory
    PageTop[server.memory]: <h1>Free Memory</h1>
    MaxBytes[server.memory]: 100000000000
    ShortLegend[server.memory]: B
    YLegend[server.memory]: Bytes
    LegendI[server.memory]: Free
    LegendO[server.memory]: Total
    Legend1[server.memory]: Free memory, not including swap, in bytes
    Legend2[server.memory]: Total memory
    Options[server.memory]: gauge,growright,nopercent
    kMG[server.memory]: k,M,G,T,P,X
    # Memory Monitoring (Percentage usage)
    Title[server.mempercent]: Percentage Free Memory
    PageTop[server.mempercent]: <h1>Percentage Free Memory</h1>
    Target[server.mempercent]: ( memAvailReal.0&memAvailReal.0:public@localhost ) * 100 / ( memTotalReal.0&memTotalReal.0:public@localhost )
    options[server.mempercent]: growright,gauge,transparent,nopercent
    Unscaled[server.mempercent]: ymwd
    MaxBytes[server.mempercent]: 100
    YLegend[server.mempercent]: Memory %
    ShortLegend[server.mempercent]: Percent
    LegendI[server.mempercent]: Free
    LegendO[server.mempercent]: Free
    Legend1[server.mempercent]: Percentage Free Memory
    Legend2[server.mempercent]: Percentage Free Memory
    # New TCP Connection Monitoring (per minute)
    Target[server.newconns]: tcpPassiveOpens.0&tcpActiveOpens.0:public@localhost
    Title[server.newconns]: Newly Created TCP Connections
    PageTop[server.newconns]: <h1>New TCP Connections</h1>
    MaxBytes[server.newconns]: 10000000000
    ShortLegend[server.newconns]: c/s
    YLegend[server.newconns]: Conns / Min
    LegendI[server.newconns]: In
    LegendO[server.newconns]: Out
    Legend1[server.newconns]: New inbound connections
    Legend2[server.newconns]: New outbound connections
    Options[server.newconns]: growright,nopercent,perminute
    # Established TCP Connections
    Target[server.estabcons]: tcpCurrEstab.0&tcpCurrEstab.0:public@localhost
    Title[server.estabcons]: Currently Established TCP Connections
    PageTop[server.estabcons]: <h1>Established TCP Connections</h1>
    MaxBytes[server.estabcons]: 10000000000
    YLegend[server.estabcons]: Connections
    LegendI[server.estabcons]: In
    Legend1[server.estabcons]: Established connections
    Options[server.estabcons]: growright,nopercent,gauge
    # Disk Usage Monitoring
    #Target[server.disk]: dskPercent.1&dskPercent.2:public@localhost
    #Title[server.disk]: Disk Partition Usage
    #PageTop[server.disk]: <h1>Disk Partition Usage /home and /var</h1>
    #MaxBytes[server.disk]: 100
    #ShortLegend[server.disk]: %
    #YLegend[server.disk]: Utilization
    #LegendI[server.disk]: /home
    #LegendO[server.disk]: /var
    #Options[server.disk]: gauge,growright,nopercent
    #Unscaled[server.disk]: ymwd
    Replace localhost with 'server IP' and 'public' with community name. Also change workdir appropriately.
  2. Use command 'env LANG=C /usr/bin/mrtg /etc/mrtg/' to collect statictics. Same command with '--logging' option can be used in crontab.
  3. Create index using 'indexmaker --output=/var/www/html/ /etc/mrtg/mrtg.cfg /etc/mrtg/' command.


Home > CentOS > CentOS 6.x > Monitoring tools > MRTG configuration > Using MRTG for monitoring host CPU, memory, disk etc.