(1)必须安装snmp
3 | #vim /etc/snmp/snmpd.conf |
(2) 安装mrtg
(3)配置mrtg
002 | HtmlDir: /data/wwwroot/mrtg |
003 | ImageDir: /data/wwwroot/mrtg |
005 | ThreshDir: / var /lib/mrtg |
009 | Target[eth0_lan]: /118.244.182.176: public @localhost |
010 | Options[eth0_lan]:growright |
012 | Directory[eth0_lan]:eth1 |
013 | MaxBytes[eth0_lan]: 5000000 |
014 | Title[eth0_lan]: eht0流入流出图 |
016 | YLegend[eth0_lan]:Bytes per Second |
017 | ShortLegend[eth0_lan]:B/s |
018 | Legend1[eth0_lan]:每秒流入量 |
019 | legend2[eth0_lan]:每秒流出量 |
022 | PageTop[eth0_lan]: <H1>网卡流入流程图</H1> |
023 | PageFoot[eth0_lan]:<a href= "www.widuu.com" >Widuu Inc</a> |
027 | Target[cpuload]:.1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.53.0: public @localhost: |
028 | Options[cpuload]:nopercent,growright |
030 | Directory[cpuload]:cpu |
032 | Unscaled[cpuload]:dwym |
033 | Ylegend[cpuload]:CPU Utilization |
034 | Shortlegend[cpuload]:% |
035 | legend1[cpuload]:CPU用户负载(%) |
036 | legend2[cpuload]:CPU闲置(%) |
040 | PageTop[cpuload]:<h1>Cpu负载【用户+闲置】</h1> |
041 | PageFoot[cpuload]:<a href= "www.widuu.com" >Widuu Inc</a> |
045 | Target[memory]:.1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0: public @localhost: |
046 | Options[memory]:gauge,growright |
049 | MaxBytes1[memory]:514908 |
050 | MaxBytes2[memory]:2096472 |
054 | YLegend[memory]:Memory Btyes |
056 | Legend1[memory]:已用Mem(Bytes) |
057 | Legend2[memory]:已用Swap(Bytes) |
058 | LegendI[memory]:已用Mem: |
059 | LegendO[memory]:已用Swap |
061 | PageTop[memory]:<h1>内存使用量(Mem+Swap)</h1> |
062 | PageFoot[memory]:<a href= "www.widuu.com" >Widuu Inc</a> |
066 | 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: |
067 | Options[disk]:gauge,growright |
070 | MaxBytes1[disk]:13102744 |
071 | MaxBytes2[disk]:41279536 |
074 | Ylegend[disk]:Disk Bytes |
076 | legend1[disk]:系统磁盘已用空间 |
081 | PageTop[disk]:<h1>硬盘空间[系统盘+数据盘]</h1> |
082 | PageFoot[disk]:<a href= "www.widuu.com" >Widuu Inc</a> |
083 | #================================================================================ |
085 | #================================================================================ |
086 | 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: |
087 | Options[systemload]: gauge,nopercent,growright |
088 | Directory[systemload]: load |
089 | MaxBytes[systemload]: 3000 |
090 | YLegend[systemload]: System Load |
091 | ShortLegend[systemload]: |
092 | Legend1[systemload]: 最近1分钟系统负载(x100) |
093 | Legend2[systemload]: 最近15分钟系统负载(x100) |
094 | LegendI[systemload]: 1分钟负载: |
095 | LegendO[systemload]: 15分钟负载: |
096 | Title[systemload]: 系统负载(x100)[1分钟+15分钟] |
097 | PageTop[systemload]:<h1>系统负载(x100)[1分钟+15分钟]</h1> |
098 | #================================================================================ |
100 | #================================================================================ |
101 | Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0: public @localhost: |
102 | Options[tcpopen]: gauge,nopercent,growright |
103 | Directory[tcpopen]: tcpopen |
104 | MaxBytes[tcpopen]: 1000 |
105 | YLegend[tcpopen]: Tcp Connections |
106 | ShortLegend[tcpopen]: 个 |
107 | Legend1[tcpopen]: 打开的TCP连接数(个) |
109 | LegendI[tcpopen]: TCP连接数: |
111 | Title[tcpopen]: TCP连接数[TCP连接数] |
112 | PageTop[tcpopen]:<h1> TCP连接数[TCP连接数]</h1> |
(4)设置启动和corntab
mrtg安装好后就已经在 /etc/cron.d/下有一个mrtg的文件了 我们只需要修改
1 | */2 * * * * root 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 |
第一次执行会有错误 所以我们必须手动执行三次 没错误就可以了
1 | 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 |
(5)我们到目录下生成index文件
1 | /usr/local/mrtg/bin/indexmaker /etc/mrtg/mrtg.cfg --output=/data/wwwroot/mrtg/index.html --title= "自己起名" |
效果如下
转载网址
http://www.widuu.com/archives/12/867.html