MRTG监控Linux cup使用率、内存使用率、硬盘状况出问题
最近本人在Linux下搭建MRTG用来对系统进行相应的监控,搭建完成后,流量监控可以顺利执行,但是其他的cup、内存、硬盘都只有相应的页面,没有数据出现。
MRTG配置信息如下
# Created by # ./cfgmaker --global WorkDir:/var/www/html/mrtg --global "Options[_]:growright,bits" --ifref=ip --output /etc/mrtg.cfg public@10.207.6.64### Global Config Options# for UNIX# WorkDir: /home/http/mrtg# or for NT# WorkDir: c:\mrtgdata### Global Defaults# to get bits instead of bytes and graphs growing to the right# Options[_]: growright, bitsEnableIPv6: noWorkDir:/var/www/html/mrtgLanguage: gb2312RunAsDaemon:yesinterval:5####################################################################### System: MyBI.MyEnv.com# Description: Linux MyBI.MyEnv.com 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686# Contact: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)# Location: Unknown (edit /etc/snmp/snmpd.conf)######################################################################### Interface 2 >> Descr: 'eth0' | Name: 'eth0' | Ip: '10.207.6.64' | Eth: '00-13-72-18-10-d6' ###Target[10.207.6.64_10.207.6.64]: /10.207.6.64:public@10.207.6.64:SetEnv[10.207.6.64_10.207.6.64]: MRTG_INT_IP="10.207.6.64" MRTG_INT_DESCR="eth0"MaxBytes[10.207.6.64_10.207.6.64]: 125000000Title[10.207.6.64_10.207.6.64]: Traffic Analysis for 10.207.6.64 -- MyBI.MyEnv.comOptions[10.207.6.64_10.207.6.64]:growright,bitsLoadMIBs:/usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txtPageTop[10.207.6.64_10.207.6.64]: <h1>流量分析-10.207.6.64</h1> <div id="sysdetails"> <table> <tr> <td>系统:</td> <td>10.207.6.64 (edit /etc/snmp/snmpd.conf)</td> </tr> <tr> <td>Maintainer:</td> <td>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</td> </tr> <tr> <td>Description:</td> <td>eth0 </td> </tr> <tr> <td>ifType:</td> <td>ethernetCsmacd (6)</td> </tr> <tr> <td>ifName:</td> <td>eth0</td> </tr> <tr> <td>Max Speed:</td> <td>1000.0 Mbits/s</td> </tr> <tr> <td>Ip:</td> <td>10.207.6.64</td> </tr> </table> </div>################CPU###################### #EnableIPv6: no#WorkDir:/var/www/html/mrtg#Target[cpu]: '/opt/mrtg/cpu.sh' #MaxBytes[cpu]: 12500000 #Title[cpu]: CPU使用率监控#Options[cpu]: gauge,nopercent,growright #YLegend[cpu]: CPU loading (%) #ShortLegend[cpu]:% #LegendO[cpu]: CPU Used; #LegendI[cpu]: CPU Sys; #PageTop[cpu]: <H1>CPU使用率监控</H1>; WorkDir:/var/www/html/mrtgTarget[localhost_cpu]: `/opt/mrtg/cpuinfo.pl`Xsize[localhost_cpu]: 300Ysize[localhost_cpu]: 100Ytics[localhost_cpu]: 10MaxBytes[localhost_cpu]: 100Title[localhost_cpu]: CPU StatePageTop[localhost_cpu]: <H1>CPU State of Server</H1>ShortLegend[localhost_cpu]: %YLegend[localhost_cpu]: CPU (%)Legend1[localhost_cpu]: UsedLegend2[localhost_cpu]: TotalLegendI[localhost_cpu]: CPU UsedLegendO[localhost_cpu]: CPU IDELOptions[localhost_cpu]: growright,gauge,nopercent############### MEM 2G ################# EnableIPv6: noWorkDir:/var/www/html/mrtgTarget[managemem]:'/opt/mrtg/mem.sh'Unscaled[managemem]: dwym MaxBytes[managemem]: 2048000 Title[managemem]:内存使用率监控 ShortLegend[managemem]:kmg[managemem]:kB,MB kilo[managemem]:1024 YLegend[managemem]: Memory Usage Legend1[managemem]: Total Memory Legend2[managemem]: Used Memory LegendI[managemem]: Total Memory LegendO[managemem]: Used Memory Options[managemem]: growright,gauge,nopercent PageTop[managemem]:<H1内存使用率监控</H1>; ################### Swap 2G####################### EnableIPv6: noWorkDir:/var/www/html/mrtgTarget[swap]:'/opt/mrtg/swap.sh' Unscaled[swap]: dwym MaxBytes[swap]: 2048000 Title[swap]:Memory State of Server ShortLegend[swap]:kmg[swap]:kB,MB kilo[swap]:1024 YLegend[swap]: Swap Usage Legend1[swap]: Total Swap Legend2[swap]: Used Swap LegendI[swap]: Total Swap LegendO[swap]: Used Swap Options[swap]: growright,gauge,nopercent PageTop[swap]:<H1>Swap-------XMNLINUXTEST02</H1>; ################## Disk Space 480G ######################### EnableIPv6: noWorkDir:/var/www/html/mrtgTarget[disk]: '/opt/mrtg/df.pl' Title[disk]: 硬盘空间监控Unscaled[disk]: dwym MaxBytes[disk]: 465247550 kmg[disk]: KB,MB,GB LegendI[disk]: Total Disk Space LegendO[disk]: Used Disk Space Legend1[disk]: Total Disk Space Legend2[disk]: Used Disk Space YLegend[disk]: Megabytes ShortLegend[disk]:Options[disk]: growright,gauge,nopercent PageTop[disk]: <H1>硬盘空间监控</H1>;################## Disk I/O 100K/sec /DEV/SDA ########## # If you want monitor more disk, please copy below create # now monitor job, and copy & modify the diskperf.sh to setting disk. EnableIPv6: noWorkDir:/var/www/html/mrtgTarget[diskIO]: '/opt/mrtg/diskperf.sh'Title[diskIO]: Disk HDA I/O Utilization Report Unscaled[diskIO]: dwym MaxBytes[diskIO]: 100 PageTop[diskIO]: <H1>Disk I/O Utilization Report</H1>; kmg[diskIO]: KB,MB,GB LegendI[diskIO]: Disk I/O KBread/sec LegendO[diskIO]: Disk I/O KBwrite/sec Legend1[diskIO]: Disk I/O KBread/sec Legend2[diskIO]: Disk I/O KBwrite/sec YLegend[diskIO]: Megabytes ShortLegend[diskIO]:Options[diskIO]: growright,gauge,nopercent
#!/usr/bin/perlsystem ("/usr/bin/sar -u 1 3|grep Average >cpu_info_file"); #sar 输出写入文件cpu_info_fileopen (CPUINFO,"cpu_info_file"); #打开cpu_info_file 文件@cpuinfo=<CPUINFO>; # 读去文件内容close (CPUINFO); #关闭文件foreach $line(@cpuinfo) { #分别获得我们需要的@cpustatus=split(/ +/,$line); #每一个数值}$cpuused=$cpustatus[2]+$cpustatus[4];$cpuidle=$cpustatus[5];print "$cpuused\n"; #输出两个数值print "$cpuidle";system ("uptime");system ("uname -n");
#!/usr/bin/perl # output(df -kl) looks like this: # Filesystem 1k-blocks Used Available Use% Mounted on # /dev/md0 95645100 30401312 64272080 33% / # /dev/hde1 14119 1159 12231 9% /boot # # In which case, this script returns : # 95659219 # 30402503 # when run. foreach $filesystem (`df -kl | grep -v "Filesystem"`) { @df = split(//s+/,$filesystem); $total += $df[1]; $usage += $df[2]; } print "$total/n"; print "$usage/n"; hostname
#!/bin/bash # This script will monitor the KBread/sec &KBwriten/sec of Disk. # Creater: CCC IT loren ext:2288 2005/8/3 # As sda ,sdb,sdc,sdd,hda. # disk=sda hd=sda disk=/dev/$hd KBread_sec=`iostat -x $disk|grep $hd |awk '{print $8}'` KBwrite_sec=`iostat -x $disk|grep $hd |awk '{print $9}'` echo "$KBread_sec" echo "$KBwrite_sec" hostname
#!/bin/bash # This script to monitor the mem usage. totalmem=`/usr/bin/free |grep Mem |awk '{print $2}'` usedmem=`/usr/bin/free |grep Mem |awk '{print $3}'` echo "$totalmem" echo "$usedmem"
#!/bin/bash # This script to monitor the swap usage. totalswap=`/usr/bin/free |grep Swap |awk '{print $2}'` usedswap=`/usr/bin/free |grep Swap |awk '{print $3}'` echo "$totalswap" echo "$usedswap"