LINUX: mrtg CPU, RAM und Diskusage auf Debian

Installieren von mrtg und snmp

apt-get install mrtg mrtg-contrib mrtgutils snmp-mibs-downloader snmpd

bei ubuntu falls der downloader nicht gefunden wird: http://packages.ubuntu.com/trusty/all/snmp-mibs-downloader/download

SNMP

Konfiguration von snmp: /etc/snmp/snmp.conf

# As the snmp packages come without MIB files due to license reasons, loading
# of MIBs is disabled by default. If you added the MIBs you can reenable
# loaging them by commenting out the following line.
# mibs :

/etc/snmp/snmpd.conf

# raute vor dem folgenden enfernen
rocommunity public  localhost

MIBs in der /etc/default/snmpd aktivieren

# Don't load any MIBs by default.
# You might comment this lines once you have the MIBs downloaded.
#export MIBS=
export MIBS=/usr/share/mibs

Dienst neustarten

/etc/init.d/snmpd restart

 

 MRTG:

Konfigurationsdatei /etc/mrtg.conf

######################################################################
# Multi Router Traffic Grapher -- Sample Configuration File
######################################################################
# This file is for use with mrtg-2.5.4c

# Global configuration
WorkDir: /var/www/mrtg
WriteExpires: Yes
RunAsDaemon: yes

EnableIPv6: no
Options[_]: bits,growright
Interval: 5

Title[^]: Traffic Analysis for


#debian:
LoadMIBs: /usr/share/mibs/netsnmp/UCD-SNMP-MIB, /usr/share/mibs/ietf/HOST-RESOURCES-MIB, /usr/share/mibs/ietf/TCP-MIB

#ubuntu:
#LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt, /usr/share/mibs/ietf/HOST-RESOURCES-MIB, /usr/share/mibs/ietf/TCP-MIB

## CPU

Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1 + ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1
RouterUptime[localhost.cpu]: public@127.0.0.1
MaxBytes[localhost.cpu]: 100
Title[localhost.cpu]: CPU Load
PageTop[localhost.cpu]: <H1>Active CPU Load %</H1>
Unscaled[localhost.cpu]: ymwd
ShortLegend[localhost.cpu]: %
YLegend[localhost.cpu]: CPU Utilization
Legend1[localhost.cpu]: Active CPU in % (Load)
Legend2[localhost.cpu]:
Legend3[localhost.cpu]:
Legend4[localhost.cpu]:
LegendI[localhost.cpu]: Active
LegendO[localhost.cpu]:
Options[localhost.cpu]: growright,nopercent


## RAM 

Target[localhost.mem]: memAvailReal.0&memTotalReal.0:public@127.0.0.1
PageTop[localhost.mem]: <H1>Free Memory</H1>
Options[localhost.mem]: nopercent,growright,gauge,noinfo
Title[localhost.mem]: Free Memory
MaxBytes[localhost.mem]: 1000000
kMG[localhost.mem]: k,M,G,T,P,X
YLegend[localhost.mem]: bytes
ShortLegend[localhost.mem]: bytes
LegendI[localhost.mem]: Free Memory:
LegendO[localhost.mem]:
Legend1[localhost.mem]: Free memory, not including swap, in bytes


## DISKUSAGE
Target[localhost.root]: dskPercent.1&dskPercent.2:public@localhost
MaxBytes[localhost.root]: 100
Title[localhost.root]: DISK USAGE
PageTop[localhost.root]: <H1>DISK / Usage %</H1>
Unscaled[localhost.root]: ymwd
ShortLegend[localhost.root]: %
YLegend[localhost.root]: DISK Utilization
Legend1[localhost.root]: Root disk
Legend3[localhost.root]:
Legend4[localhost.root]:
LegendI[localhost.root]: Root disk
LegendO[localhost.root]:
Options[localhost.root]: growright,gauge,nopercent


Erstellen des index:

indexmaker -output=/var/www/mrtg/index.html /etc/mrtg.cfg

Starten von mrtg:

env LANG=C /usr/bin/mrtg /etc/mrtg.cfg --logging /var/log/mrtg.log

 

Wenn ein Webserver installiert ist, sollten nun unter http://ipadresse/mrtg/ die schönen Grafiken liegen.

CRON anpassen, falls via daemon genutzt

vim /etc/cron.d/mrtg

 

*/5 *   * * *   root    if ! [ -e /etc/mrtg.pid ] && [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ] && [ -d "$(grep '^[[:space:]]*[^#]*[[:space:]]*WorkDir' /etc/mrtg.cfg | awk '{ print $NF }')" ]; then env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1 | tee -a /var/log/mrtg.log ; fi

 

 

Debugging:

mit

snmpwalk -v 1 -c public localhost ssCpuRawUser

kann die Ausgabe von SNMP getestet werden, ansonsten gucken was in der /var/log/mrtg.log steht