您的位置:首页 > Web前端

Install MRTG on Fedora

2007-08-28 09:45 423 查看
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]:   CPU us;
LegendI[cpu]:   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]:   Memory Usage :
Legend1[ram]:   Total Memory :
Legend2[ram]:   Used Memory :
LegendI[ram]:   Total Memory :
LegendO[ram]:   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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: