Home My Howtos Setting up SNMP and MRTG to monitor Network, CPU, Memory, Disk and Load Average
Setting up SNMP and MRTG to monitor Network, CPU, Memory, Disk and Load Average PDF Print E-mail
User Rating: / 4
PoorBest 
Written by Muhammad Kamran Azeem   
Monday, 03 August 2009 23:09

This section / article will cover the SNMP (ver1) and MRTG configurations.

Install necessary packages:

 

yum -y install mrtg net-snmp net-snmp-perl net-snmp-utils

 

Edit snmpd.conf file to setup community strings and other monitors:-

 

[root@www mrtg]# vi /etc/snmp/snmpd.conf

com2sec notConfigUser default snmpsecret

group notConfigGroup v1 notConfigUser

view roview included .1

access notConfigGroup "" any noauth exact roview rwview none

syslocation SomewhereintheWorld

syscontact Root < This e-mail address is being protected from spambots. You need JavaScript enabled to view it >

disk /

load 12 14 14

pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat

[root@www mrtg]#


service snmpd restart

chkconfig --level 35 snmpd on

 

Create MRTG configuration file and manually edit it. Make sure to include extra (required) MIBs, using the LoadMIBs directive:-

 

[root@www mrtg]# /usr/bin/cfgmaker --global 'Options[_]: growright, bits,  unknaszero' --ifref=ip \

 --ifdesc=descr --noreversedns --global 'WorkDir: /var/www/mrtg' \

 --output=/etc/mrtg/mrtg.cfg snmpsecret@localhost

 

[root@www mrtg]# vi /etc/mrtg/mrtg.cfg

EnableIPv6: no

Options[_]: growright, bits, unknaszero

WorkDir: /var/www/mrtg


Target[localhost_10.1.2.3]: /10.1.2.3:snmpsecret@localhost:

SetEnv[localhost_10.1.2.3]: MRTG_INT_IP="10.1.2.3" MRTG_INT_DESCR="eth0"

MaxBytes[localhost_10.1.2.3]: 1250000

Title[localhost_10.1.2.3]: eth0 -- www.example.com

PageTop[localhost_10.1.2.3]: <h1>eth0 -- www.example.com</h1>

<div id="sysdetails">

<table>

...

[output snipped]

...

</table>

</div>


LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt, /usr/share/snmp/mibs/TCP_MIB.txt, /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt


Target[EXAMPLE_root]:dskPercent.1&dskPercent.1:snmpsecret@localhost

MaxBytes[EXAMPLE_root]: 100

Title[EXAMPLE_root]: DISK USAGE - /

PageTop[EXAMPLE_root]: <h1>DISK Usage in % (/)</h1>

Unscaled[EXAMPLE_root]: ymwd

ShortLegend[EXAMPLE_root]: %

YLegend[EXAMPLE_root]: DISK Utilization

Legend1[EXAMPLE_root]: /:

Legend2[EXAMPLE_root]: /:

Legend3[EXAMPLE_root]:

Legend4[EXAMPLE_root]:

LegendI[EXAMPLE_root]: /:

LegendO[EXAMPLE_root]: /:

Options[EXAMPLE_root]: growright, unknaszero, gauge,nopercent


Target[EXAMPLE_loadavg]: laLoad.2&laLoad.3:snmpsecret@localhost

MaxBytes[EXAMPLE_loadavg]: 5000

Title[EXAMPLE_loadavg]: Load Average

PageTop[EXAMPLE_loadavg]: <h1>Load Average</h1>

YLegend[EXAMPLE_loadavg]: Load Average

ShortLegend[EXAMPLE_loadavg]:  

Legend1[EXAMPLE_loadavg]: Load average 5 min

Legend2[EXAMPLE_loadavg]: Load average 15 min

LegendI[EXAMPLE_loadavg]: 5min load avg

LegendO[EXAMPLE_loadavg]: 15min load avg

Options[EXAMPLE_loadavg]: nopercent,growright,noinfo,gauge, unknaszero



Target[EXAMPLE_memory]: memTotalReal.0&memAvailReal.0:snmpsecret@localhost

Options[EXAMPLE_memory]: nopercent,growright,gauge,noinfo, unknaszero

Title[EXAMPLE_memory]: Free Memory

PageTop[EXAMPLE_memory]: <H1>Free Memory</H1>

MaxBytes[EXAMPLE_memory]: 2147483648

YLegend[EXAMPLE_memory]: bytes

ShortLegend[EXAMPLE_memory]: bytes

kMG[EXAMPLE_memory]: k,M

Legend1[EXAMPLE_memory]: Total Physical Memory

Legend2[EXAMPLE_memory]: Free Physical Memory

LegendI[EXAMPLE_memory]: Total Memory

LegendO[EXAMPLE_memory]: Free Memory

Target[cpusum]:ssCpuRawUser.0&ssCpuRawUser.0:snmpsecret@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:
snmpsecret@localhost + ssCpuRawNice.0&ssCpuRawNice.0:snmpsecret@localhost
MaxBytes[cpusum]: 100
Title[cpusum]: CPU Usage % (User+System+Nice)
PageTop[cpusum]: <H1>CPU Usage % (User+System+Nice)</H1>
ShortLegend[cpusum]: %
YLegend[cpusum]: CPU Usage
Legend1[cpusum]: CPU usage in %
Legend2[cpusum]:
Legend3[cpusum]:
Legend4[cpusum]:
LegendI[cpusum]:  Active
LegendO[cpusum]:
Options[cpusum]: growright,nopercent, unknaszero


[root@www mrtg]#

 

Create index pages:-

 

[root@www mrtg]# indexmaker --title="EXAMPLE server stats" --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

 

Run the following three times to generate data files:-

[root@www mrtg]# LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok


That's all. Try accessing the mrtg page by using: http://www.example.com/mrtg

The cron job for mrtg is already setup my mrtg RPM.

 

 

Regards,

Kamran

Last Updated on Sunday, 23 August 2009 16:44
 
Copyright © 2010 www.wbitt.com. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.