Before monitor any server you need to install SNMP and RRDTool packages on monitor server and net-snmp package on server which you want to monitor.
lets assume server which has SNMP and RRDTool means monitor server has ip address 10.10.10.1
and server which you want to monitor has IP address 99.99.99.99
SNMP Installation
SNMP packages require for querring .
- type command at the prompt
#yum search snmp
It will show you different snmp packages.
You neet to install 2 packages
net-snmp
net-snmp-devel
type command
#yum install net-snmp
#yum install net-snmp-devel
RRDTool Installation
RRD store and display time-series data (i.e. network bandwidth, server load average). It stores the data in a very compact way that will not expand over time, and it presents useful graphs by processing the data to enforce a certain data density.
RRDTool 1.2.x has dependancies ,hence you need to install following packages.
* libart_lgpl-2.3.11-2.i386.rpm
* libart_lgpl-devel-2.3.11-2.i386.rpm
* freetype-2.1.3-6.i386.rpm
* freetype-devel-2.1.3-6.i386.rpm
* zlib-1.1.4-8.i386.rpm
* zlib-devel-1.1.4-8.i386.rpm
* libpng-1.2.2-16.i386.rpm
* libpng-devel-1.2.2-16.i386.rpm
Download RRDTool from http://ftp.idilis.ro/mirrors/rrdtool/
lets assume you have rrdtool-1.2.12.tar.gz
To extract RRDTool run this command:
#tar -xzvf rrdtool-1.2.12.tar.gz
then change directory:
#cd rrdtool-1.2.12
to compile ans install RRDTool type:
#./configure –disable-tcl
#make
#make install
Apply following step on server which you want to monitor means 99.99.99.99
Install net-snmp
Type following commands
#yum search snmp
#yum install net-snmp
then edit snmpd.conf file and create readonly community
#vi /etc/snmp/snmpd.conf
add following line in snmpd.conf file
rocommunity community_name ip_address_of_monitor_server
start snmpd service
/etc/init.d/snmpd start
Apply following step on monitor server means 10.10.10.1
To monitor bandwidth you need to create RRD file,which will store bandwidth data.
step 1
Create RRD file.
rrdtool create bandwidth.rrd -s 60 \
DS:in:COUNTER:300:U:U \
DS:out:COUNTER:300:U:U \
RRA:AVERAGE:0.5:1:10080
step 2
Update RRD file.
/usr/bin/rrdupdate bandwidth.rrd \
N:`/usr/bin/snmpget -v 1 -c community_name -Oqv 9.99.99.99 IF-MIB::ifInOctets.2`: \
`/usr/bin/snmpget -v 1 -c community_name -Oqv 99.99.99.99 IF-MIB::ifOutOctets.2`
Above command should be run with 1 or 5 minute interval as per your need,hence add above command in cronjob.
step 3
Generate graph from bandwidth.rrd file
rrdtool graph bandwidth.png \
–end now –start end-30h –width 400 \
–x-grid HOUR:1:HOUR:6:HOUR:2:0:%H \
–imgformat=PNG \
–title=”your title” \
–rigid \
–base=1000 \
–height=120 \
–width=500 \
–alt-autoscale-max \
–lower-limit=0 \
–vertical-label=”bits per second” \
DEF:a=bandwidth.rrd:in:AVERAGE \
DEF:b=bandwidth.rrd:out:AVERAGE \
VDEF:totin=a,TOTAL \
VDEF:totout=b,TOTAL \
CDEF:cdefa=a,8,* \
CDEF:cdeff=b,8,* \
AREA:cdefa#00CF00:”Incoming” \
GPRINT:cdefa:LAST:”Cur\:%6.2lf %sb/s” \
GPRINT:cdefa:AVERAGE:”Avg\:%6.2lf %sb/s” \
GPRINT:cdefa:MAX:”Max\:%6.2lf %sb/s” \
GPRINT:cdefa:MIN:”MIN\:%6.2lf %sb/s\l” \
LINE1.3:cdeff#0000FF:”Outgoing” \
GPRINT:cdeff:LAST:”Cur\:%6.2lf %sb/s” \
GPRINT:cdeff:AVERAGE:”Avg\:%6.2lf %sb/s” \
GPRINT:cdeff:MAX:”Max\:%6.2lf %sb/s” \
GPRINT:cdeff:MIN:”MIN\:%6.2lf %sb/s\l” \
GPRINT:totin:”Total IN\:%6.2lf %sb/s” \
GPRINT:totout:”Total OUT\:%6.2lf %sb/s” \
VRULE:1084777200#FF0000:”"
After firing above command, a file bandwidth.png will be in current direcoty which is bandwidth graph for server 99.99.99.99