Install MRTG on Fedora

1.         yum install net-snmp

2.         vi /etc/snmp/snmpd.conf

view systemview included .1.3.6.1.2.1.1

view systemview included .1.3.6.1.2.1.25.1.1

Change to

view systemview included .1.3.6.1.2.1.1

view systemview included .1.3.6.1.2.1.2

view systemview included .1.3.6.1.2.1.25.1.1

Note: .1.3.6.1.2.1.1 = SNMPv2-MIB::system

.1.3.6.1.2.1.2 = IF-MIB::interfaces

Uncomment view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc //89th line

access notConfigGroup "" any noauth exact systemview none none   //62th line

Change to

access notConfigGroup "" any noauth exact mib2 none none

3.         chkconfig snmpd on

4.         service snmpd start

5.         yum install mrtg

6.         Generate cfg file for mrtg

cfgmaker --global "WorkDir:/var/www/mrtg" --output /etc/mrtg/mrtg.cfg public@localhost

Notice: if just monitor a ip address, use public@192.168.0.1 replace public@localhost

7.         Run mrtg /etc/mrtg/mrtg.cfg three times

8.         vi /etc/cron.d/mrtg to run mrtg every 5 minutes

0-59/5 * * * * root /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log

9.         run following command to generate index file

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

10.     vi /etc/httpd/conf.d/mrtg.conf

Alias /mrtg /var/www/mrtg

<Location /mrtg>

Order deny,allow

# Deny from all

Allow from all

Allow from localhost

# Allow from .example.com

</Location>

11.     restart httpd service

service httpd restart

12.     Monitor network from browser. http://ec2-72-44-49-114.z-1.compute-1.amazonaws.com/mrtg/

 

―――――――――――――――――――――――――――――

Monitor CPU

To monitor CPU, we need install sysstat suite first.

yum –y install sysstat

1.         Switch to super user

sudo -sH

2.         Make a CPU script as bellows.

#!/bin/bash

cpuusr=`/usr/bin/sar -u 1 3 | grep Average | awk '{print $3}'`

cpusys=`/usr/bin/sar -u 1 3 | grep Average | awk '{print $5}'`

UPtime=`/usr/bin/uptime | awk '{print $3""$4""$5}'`

echo $cpuusr

echo $cpusys

echo $UPtime

hostname

3.         Change the right to able to run it

chmod +755 /opt/mrtg/mrtg.cpu

4.         Modify /etc/mrtg.cfg and add the following lines at the end of file

Target[cpu]: `/opt/mrtg/mrtg.cpu`

MaxBytes[cpu]: 100

Options[cpu]: gauge, nopercent, growright

YLegend[cpu]: CPU loading (%)

ShortLegend[cpu]: %

LegendO[cpu]: &nbsp; CPU us;

LegendI[cpu]: &nbsp; CPU sy;

Title[cpu]: CPU Loading

PageTop[cpu]: <H1>CPU Loading</H1>

5.         Regenerate index page

indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

 

Monitor Memory

1.         Switch to super user

sudo -sH

2.         Make a memory script as bellows.

#!/bin/bash

# run this script to check the mem usage.

totalmem=`/usr/bin/free |grep Mem |awk '{print $2}'`

usedmem=`/usr/bin/free |grep Mem |awk '{print $3}'`

UPtime=`/usr/bin/uptime | awk '{print $3""$4""$5}'`

echo $totalmem

echo $usedmem

echo $UPtime

hostname

3.         Change the right to able to run it

chmod +755 /opt/mrtg/mrtg.ram

4.         Modify /etc/mrtg.cfg and add the following lines at the end of file

Target[ram]: `/opt/mrtg/mrtg.ram`

#Unscaled[ram]: dwym

MaxBytes[ram]: 2048000

Title[ram]:Memory

ShortLegend[ram]: &

kmg[ram]:kB,MB

kilo[ram]:1024

YLegend[ram]: &nbsp; Memory Usage :

Legend1[ram]: &nbsp; Total Memory :

Legend2[ram]: &nbsp; Used Memory :

LegendI[ram]: &nbsp; Total Memory :

LegendO[ram]: &nbsp; Used Memory :

Options[ram]: growright,gauge,nopercent

PageTop[ram]:<H1>Memory</H1>

5.         Regenerate index page

indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值