1819870 Members
2705 Online
109607 Solutions
New Discussion юеВ

MRTG configuration

 
gerjam
Advisor

MRTG configuration

Hi,

Please help me how to configure MRTG to monitor CPU, memory and disk usage. I installed MRTG and by default, only i/f cards are defined. I cannot fully understand the guide :) and I don't know what is meant by SNMPOID. Kindly help and enlighten me.

Thank you very much in advance.
6 REPLIES 6
Geoff Wild
Honored Contributor

Re: MRTG configuration

Here's what I have setup:

In /opt/hpws/apache/mrtg/mrtg.cfg

Target[svr108.cpu]:.1.3.6.1.4.1.11.2.3.1.1.15.0&.1.3.6.1.4.1.11.2.3.1.1.13.0:public@svr108.mydomain.com + .1.3.6.1.4.1.11.2.3.1.1.16.0&.1.3.6.1.4.1.11.2.3.1.1.14.0:public@svr108.mydomain.com
Title[svr108.cpu]: CPU Load on svr108.mydomain.com
MaxBytes[svr108.cpu]: 100
Ylegend[svr108.cpu]: CPU Load
ShortLegend[svr108.cpu]: %
PageTop[svr108.cpu]:

CPU Load on svr108


Options[svr108.cpu]: integer, growright, nopercent
WithPeak[svr108.cpu]: wmy
LegendO[svr108.cpu]: User/System:  
LegendI[svr108.cpu]: Idle/Nice:  
Legend1[svr108.cpu]: Idle/Nice CPU Time
Legend2[svr108.cpu]: User/System CPU Time
Legend3[svr108.cpu]: Maximal Idle/Nice CPU Time
Legend4[svr108.cpu]: Maximal User/System CPU Time

Target[svr108.mem]: .1.3.6.1.4.1.11.2.3.1.1.7.0&.1.3.6.1.4.1.11.2.3.1.1.8.0:public@svr108.mydomain.com
Title[svr108.mem]: Memory on svr108.mydomain.com
MaxBytes[svr108.mem]: 1000000000
Ylegend[svr108.mem]: Memory Usage
ShortLegend[svr108.mem]:  
PageTop[svr108.mem]:

Memory on svr108


Options[svr108.mem]: integer, gauge, growright, nopercent
kilo[svr108.mem]: 1024
WithPeak[svr108.mem]: wmy
kMG[svr108.mem]: k,M,G
LegendO[svr108.mem]: Total:  
LegendI[svr108.mem]: Free:  
Legend1[svr108.mem]: Free System Memory
Legend2[svr108.mem]: Total Available System Memory
Legend3[svr108.mem]: Maximal Free System Memory
Legend4[svr108.mem]: Maximal Available System Memory

In cron:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/mrtg /opt/hpws/apache/mrtg/mrtg.cfg --logging /var/adm/mrtg.log >/dev/null 2>&1



Other waays instead of snmp, is to generate a file on the host to collect data from, then grab that file and process it:

#------------------------------------------

Target[dnsdnssvr01]: `cat /tmp/dnssvr01.named.stats.mrtg`
Options[dnsdnssvr01]: nopercent,growright,perhour
Title[dnsdnssvr01]: DNS: Requests per hour on dnssvr01
PageTop[dnsdnssvr01]:

DNS: Requests per hour on dnssvr01


MaxBytes[dnsdnssvr01]: 1000000000
YLegend[dnsdnssvr01]: reqs/hour
ShortLegend[dnsdnssvr01]: per hour
LegendI[dnsdnssvr01]:  Requests:
LegendO[dnsdnssvr01]:  Failures:
Legend1[dnsdnssvr01]: Requests per hour
Legend2[dnsdnssvr01]: Failures per hour
PageFoot[dnsdnssvr01]:
Note:
success is the number of successful queries the server handled.
failures is the number of queries the server received that resulted in
errors other than those covered by nxrrset and nxdomain.


Contents of file:
# cat /tmp/dnssvr01.named.stats.mrtg
4023416
371120
257 day(s) 13:20
dnssvr01

Cron on remote server:
# dns stats for mrtg
3,8,13,18,23,28,33,38,43,48,53,58 * * * * /usr/local/bin/mrtg-dns-stats >/dev/null 2>&1

cat /usr/local/bin/mrtg-dns-stats
#!/bin/sh
# generate mrtg file for dns stats
/usr/local/sbin/rndc stats
SERVER=`uname -n`
MRTG=/tmp/$SERVER.named.stats.mrtg
STATS=/etc/namedb/named.stats
#get success
tail -7 $STATS | head -1 |awk '{print $2}'>$MRTG
tail -2 $STATS | head -1 |awk '{print $2}'>>$MRTG
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTG
echo $SERVER >>$MRTG

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Cheryl Griffin
Honored Contributor

Re: MRTG configuration

this is a test for Geoff
"Downtime is a Crime."
Geoff Wild
Honored Contributor

Re: MRTG configuration

Let us see if this works now...
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
gerjam
Advisor

Re: MRTG configuration

Hi Geoff,

Thanks for the information. Unfortunately I tried copying your memory and cpu configs but it didn't worked out. I got an error

====
C:\mrtg-2.10.15\bin>perl mrtg mrtg.cfg
Daemonizing MRTG ...
Do Not close this window. Or MRTG will die
SNMP Error:
Received SNMP response with error code
error status: noSuchName
index 1 (OID: 1.3.6.1.4.1.9.2.1.58.0)
SNMPv1_Session (remote host: "172.30.240.250"
====

Is the SNMPOID standard for all servers? Thanks.
Geoff Wild
Honored Contributor

Re: MRTG configuration

Nope - that's just for HP-UX.

What system(s) are you monitoring?

You can also do it without snmp - on remote server:

# stats for mrtg
3,8,13,18,23,28,33,38,43,48,53,58 * * * * /usr/local/bin/mrtg-stats >/dev/null 2>&1

$ cat /usr/local/bin/mrtg-stats
#!/bin/sh
# generate mrtg file for stats
/usr/local/sbin/rndc stats
SERVER=`uname -n`
MRTG=/tmp/$SERVER.named.stats.mrtg
STATS=/etc/namedb/named.stats
#get success
tail -7 $STATS | head -1 |awk '{print $2}'>$MRTG
tail -2 $STATS | head -1 |awk '{print $2}'>>$MRTG
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTG
echo $SERVER >>$MRTG
#generate mrtg file for cpu
MRTGcpu=/tmp/$SERVER.cpu.stats.mrtg
idle="`/usr/bin/vmstat 1 2 | tail -1 | awk '{print $NF}'`"
usersys=`expr 100 - $idle`

echo $idle >$MRTGcpu
echo $usersys >>$MRTGcpu
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTGcpu
echo $SERVER >>$MRTGcpu


The first section does DNS - you won't need that - unless you are running a DNS server...

The next 1 does cpu...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Ganesh Babu
Honored Contributor

Re: MRTG configuration

hi