1、安装snmp
rpm -qa|grep snmp* //查看是否安装了snmp
yum -y install snmp* //安装snmp
#vim /etc/snmp/snmpd.conf
rocommunity public //配置snmpv1模式
disk / 13102744 //配置系统的大小
disk /data 41279536 //配置数据盘的大小
service snmpd start //配置开启snmp
chkconfig snmpd on //设置开机启动
2、安装mrtg
yum -y install mrtg*
3、配置mrtg
vi /etc/mrtg/mrtg.cfg
HtmlDir: /var/www/mrtg
ImageDir: /var/www/mrtg
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg
#
#[网络流入流出图]
#
Target[eth0_lan]: /118.244.182.176:public@localhost
Options[eth0_lan]:growright
Language:utf8
Directory[eth0_lan]:eth1
MaxBytes[eth0_lan]: 5000000
Title[eth0_lan]: eht0流入流出图
Kmg[eth0_lan]:K,M,G
YLegend[eth0_lan]:Bytes per Second
ShortLegend[eth0_lan]:B/s
Legend1[eth0_lan]:每秒流入量
legend2[eth0_lan]:每秒流出量
legendI[eth0_lan]:流入
legendO[eth0_lan]:流出
PageTop[eth0_lan]: <H1>网卡流入流程图</H1>
PageFoot[eth0_lan]:<a href="www.jb51.net">jb51 Inc</a>
#
#[CPU的负载]
#
Target[cpuload]:.1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.53.0:public@localhost:
Options[cpuload]:nopercent,growright
Language:utf8
Directory[cpuload]:cpu
MaxBytes[cpuload]:100
Unscaled[cpuload]:dwym
Ylegend[cpuload]:CPU Utilization
Shortlegend[cpuload]:%
legend1[cpuload]:CPU用户负载(%)
legend2[cpuload]:CPU闲置(%)
legendI[cpuload]:用户
legendO[cpuload]:闲置
Title[cpuload]:CPU负载
PageTop[cpuload]:<h1>Cpu负载【用户+闲置】</h1>
PageFoot[cpuload]:<a href="www.jb51.net">jb51 Inc</a>
#
#[内存使用]
#
Target[memory]:.1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@localhost:
Options[memory]:gauge,growright
Directory[memory]:mem
Language:utf8
MaxBytes1[memory]:514908
MaxBytes2[memory]:2096472
Kmg[memory]:K,M,G
kilo[memory]:1024
Unscaled[memory]:dwym
YLegend[memory]:Memory Btyes
ShortLegend[memory]:B
Legend1[memory]:已用Mem(Bytes)
Legend2[memory]:已用Swap(Bytes)
LegendI[memory]:已用Mem:
LegendO[memory]:已用Swap
Title[memory]:内存使用率
PageTop[memory]:<h1>内存使用量(Mem+Swap)</h1>
PageFoot[memory]:<a href="www.jb51.net">jb51 Inc</a>
#
#[硬盘使用率]
#
Target[disk]:.1.3.6.1.4.1.2021.9.1.8.1&.1.3.6.1.4.1.2021.9.1.8.2:public@localhost:
Options[disk]:gauge,growright
Language:utf8
Directory[disk]:disk
MaxBytes1[disk]:13102744
MaxBytes2[disk]:41279536
Kmg[disk]:K,M,G
Kilo[disk]:1024
Ylegend[disk]:Disk Bytes
Shortlegend[disk]:B
legend1[disk]:系统磁盘已用空间
legend2[disk]:数据盘已用空间
legendI[disk]:系统已用
legendO[disk]:数据已用
Title[disk]:硬盘空间使用率
PageTop[disk]:<h1>硬盘空间[系统盘+数据盘]</h1>
PageFoot[disk]:<a href="www.jb51.net">jb51 Inc</a>
#================================================================================
#监控系统负载[1分钟+15分钟]
#================================================================================
Target[systemload]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.3:public@localhost:
Options[systemload]: gauge,nopercent,growright
Directory[systemload]: load
MaxBytes[systemload]: 3000
YLegend[systemload]: System Load
ShortLegend[systemload]:
Legend1[systemload]: 最近1分钟系统负载(x100)
Legend2[systemload]: 最近15分钟系统负载(x100)
LegendI[systemload]: 1分钟负载:
LegendO[systemload]: 15分钟负载:
Title[systemload]: 系统负载(x100)[1分钟+15分钟]
PageTop[systemload]:<h1>系统负载(x100)[1分钟+15分钟]</h1>
#================================================================================
#监控打开的TCP连接数[TCP连接数]
#================================================================================
Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@localhost:
Options[tcpopen]: gauge,nopercent,growright
Directory[tcpopen]: tcpopen
MaxBytes[tcpopen]: 1000
YLegend[tcpopen]: Tcp Connections
ShortLegend[tcpopen]: 个
Legend1[tcpopen]: 打开的TCP连接数(个)
Legend2[tcpopen]:
LegendI[tcpopen]: TCP连接数:
LegendO[tcpopen]:
Title[tcpopen]: TCP连接数[TCP连接数]
PageTop[tcpopen]:<h1> TCP连接数[TCP连接数]</h1>
4、 cp /etc/cron.d/mrtg /etc/mrtg/
5、vi /etc/mrtg/mrtg,改为以下内容:
#!/bin/bash
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
6、
/etc/mrtg/mrtg
/etc/mrtg/mrtg
/etc/mrtg/mrtg
7、配置浏览界面
/usr/bin/indexmaker --output /var/www/mrtg/index.html --title="德生运维监控" /etc/mrtg/mrtg.cfg
8、/etc/httpd/conf.d/mrtg.conf 允许其他机器访问
9、重启httpd