ºìÁªLinuxÃÅ»§
Linux°ïÖú

FreeBSDÏÂÓÃmrtg¼à¿Ø±¾»úÁ÷Á¿¡¢ÄÚ´æ¡¢cpuʹÓÃÂÊ¡¢ÕûÍøÁ÷Á¿

·¢²¼Ê±¼ä:2007-02-08 00:48:41À´Ô´:ºìÁª×÷Õß:Mischievous
¾­³£¿´µ½ËµmrtgµÄ£¬ËµÂÛ̳ÀïÃæµÄ×ÊÁϲ»¶Ô£¬Æäʵ²»ÊDz»¶Ô£¬ÊÇÓÐЩ˵µÄ²»Ïêϸ¶øÒÑ£¬ÎÒ¸Õ¿ªÊ¼×÷µÄʱºòÒ²ÊÇ·ÑÁ˲»ÉÙʱ¼äµÄ£¬ÕûÀíһϣ¬·¢µ½ÕâÀï°É£¬Ï£ÍûÄÜΪºóÀ´µÄÐÖµÜÃÇÊ¡ÏÂʱ¼ä
Ç°ÑÔ£ºÎÒʵÑéµÄ»úÆ÷ÊÇFreeBSD4.10£¬ÆäËû°æ±¾µÄÓ¦¸ÃÒ²Ò»Ñù£¬ÆäËûunix likeϵͳ¹À¼ÆÒ²ÊÇ¿ÉÒԵģ¬ÒòΪÎÒÖ»ÓùýFreeBSD£¬²»¸Ò¿Ï¶¨¡£ÁíÍâÎÒÕâƪÎÄÕµÄÇ°ÌáÊÇÄãµÄ»úÆ÷ÉÏÒѾ­°²×°ÁËapache£¬²¢ÄÜÕý³£Ê¹Óã¬Èç¹ûûÓÐÇë²Î¿¼ÍøÉÏÆäËûÎÄÕ°²×°£¬±¾ÎľͲ»ÔÙ׸Êö¡£
Ò»£ºÏȽéÉÜÈçºÎÓÃmrtgÀ´¼à¿Ø±¾»úµÄÁ÷Á¿
1£º°²×° snmp
cd /usr/ports/net-mgmt/p5-SNMP
make install clean
µ±Öлá½ÐÄãÌîдÄãµÄemail¡¢²Ù×÷ϵͳµÈµÈ£¬Ö±½Ó»Ø³µ¼´¿É¡£
¿ÉÒÔÓÃÒÔÏÂÃüÁîÆô¶¯snmp£¬/usr/local/etc/rc.d/snmpd.sh start
2£º°²×° mrtg
cd /usr/ports/net-mgmt/mrtg
make install clean
3£ºÅäÖà index.cfgÎļþ¼à¿Ø·þÎñÆ÷Á÷Á¿
/usr/local/bin/cfgmaker --output=/usr/www/mrtg/index.cfg public@192.168.0.1
È»ºóÐÞ¸Äindex.cfgÎļþ,Ö÷ÒªÐÞ¸ÄÒÔÏÂÄÚÈÝ£¬ÒÔ·ûºÏÄãµÄʵ¼ÊÇé¿ö£¬´Ë´¦µÄ192.168.0.1ÊÇÄãÒª¼à¿ØµÄÍø¿¨µÄipµØÖ·¡£
WorkDir: /usr/www/mrtg
Options[_]: growright, bits
Language:GB2312
########################ÈÃËû5·ÖÖÓÖ´ÐÐÒ»´Î##############
RunAsDaemon: Yes
Refresh:300
######»òÕß¿ÉÒÔÕâÑù£º#################################
crontab -e
*/5 * * * * /usr/local/bin/mrtg /usr/www/mrtg/index.cfg
½¨ÒéʹÓúóÃæµÄ·½·¨£¬ÒòΪǰÕßÓÃRunAsDaemonµÄ·½Ê½²¢²»ÄÜʹMRTG¿ª»ú×Ô¶¯ÔËÐÐ
#########################################
ÏÂÃæ½Ó×Å£º
/usr/local/bin/mrtg /usr/www/mrtg/index.cfg
Õâ¸öÐèÒªÔËÐÐ3´Î£¬Ç°Á½´Î¶¼»á±¨´í£¬²»ÓÃÈ¥Àí»áËû£¬µÚ3´Î¾ÍÓ¦¸ÃûÓдíÎóÁË£¬²»¹ý£¬
ÈôÊÇÓÐÎÊÌâµÄ»°£¬¾ÍÐèÒª¸Äindex.cfg£¬ÔÙÖ´ÐÐÖ±µ½Ã»ÓдíÎó·¢ÉúΪֹ¡£
ÖÆ×÷Ê×Ò³index.html£º
/usr/local/bin/indexmaker --output=/usr/www/mrtg/index.html /usr/www/mrtg/index.cfg
ÕâÑùÒÔºó¾Í¿ÉÒÔͨ¹ý£ºhttp://******/mrtg/index.html¿´ÄãµÄ´úÀíµÄÁ÷Á¿ÁË£¬×¢Òâ´Ë´¦ÊÇÒÔÄãµÄapacheÖ÷Ŀ¼ÉèÖÃΪ/usr/wwwÀ´ËµµÄ£¬Äã¿ÉÒÔ¸ù¾Ýʵ¼ÊÇé¿öÐ޸ġ£
¶þ¡¢¼à¿ØRAM-SWAPʹÓÃÇé¿ö
ÔÚ/usr/www/traffic/ramϽ¨Á¢ram.cfg,ÄÚÈÝΪ£º
LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[ramswap]: memAvailReal.0&memAvailSwap.0:public@192.168.0.1
##192.168.0.1ÊDZ¾»úµÄipµØÖ·
Options[ramswap]: nopercent,growright,gauge,noinfo
Title[ramswap]: RAM & SWAP ʹÓÃ×´¿ö
PageTop[ramswap]: RAM & SWAP ʹÓÃ×´¿ö
MaxBytes[ramswap]: 1000000000
kMG[ramswap]: k,M,G,T,P,X
Ylegend[ramswap]: Octets
ShortLegend[ramswap]: octets
LegendI[ramswap]: RAM ¿ÉʹÓÃ
LegendO[ramswap]: Swap ¿ÉʹÓÃ
Legend1[ramswap]: RAM ¿ÉʹÓõ¥Î»
Legend2[ramswap]: Swap ¿ÉʹÓõ¥Î»
Language:Chinese
WorkDir:/usr/www/traffic/ram
˵Ã÷:ÓëÒ»°ãMRTGÁ÷Á¿É趨µµ´óͬСÒ죬ΨһµÄ²î?ÊÇÀ´Ô´ÊýÖµ¡£
memTotalSwap È«²¿µÄswap¿Õ¼ä
memAvailSwap Ê£Óà(¿ÉʹÓÃ)µÄswap
memTotalReal È«²¿µÄÄÚ´æ¿Õ¼ä
memAvailReal Ê£Óà(¿ÉʹÓÃ)µÄÄÚ´æ
È»ºóÖ´ÐУº
/usr/local/bin/mrtg /usr/www/traffic/ram/ram.cfg
½«»áÔÚ/usr/www/traffic/ramÏÂÉú³Éramswap.htmlµÈÎļþ¡£
ÕâÑùÒÔºó¾Í¿ÉÒÔͨ¹ý£ºhttp://******/traffic/ram/ramswap.html¿´ÄãµÄ»úÆ÷µÄÄÚ´æʹÓÃÇé¿öÁË¡£
ÏÂÃæÔÙÈÃËü5·ÖÖÓÖ´ÐÐÒ»´Î£º
crontab -e
*/5 * * * * /usr/local/bin/mrtg /usr/www/traffic/ram/ram.cfg
Èý¡¢ÔÙÀ´¼à¿ØcpuʹÓÃÂÊ
°²×°bsdsarÕâ¸ö³ÌÐòÀ´ÏÔʾcpuµÄʹÓÃ״̬
cd /usr/ports/sysutils/bsdsar/
make install
×¢Òâ´æµµ£¨/var/log/bsdsar.dat£©»áÒ»Ö±µÄ±ä´ó£¬ËùÒÔ²ÉÓÃÕâ¸öbsdsar±ØÐëÒªÊÊʱµÄ½«µµ°¸ÒÆÍùËû´¦¡£²¢¸üÃûÒÔ×÷ΪÈÕºóµÄ²éѯ֮Óã¬ÎÒÊÇ°ÑËüɾ³ýµÄ£¬¿´¿´µ±Ç°µÄ¾ÍºÃÁËJ
crontab -e
0 0 * * * /bin/rm /var/log/bsdsar.dat
ÔÚ/usr/www/traffice/cpuϽ¨Á¢cpu.cfg,ÄÚÈÝΪ£º
Target[CPU]: `/usr/www/traffic/cpu/mrtg-cpu`
MaxBytes[CPU]: 100
Title[CPU]: CPU-Loading MRTG
PageTop[CPU]: CPU-Loading MRTG
Options[CPU]: gauge,growright
YLegend[CPU]: CPU Loading (%)
ShortLegend[CPU]: £¥
WorkDir:/usr/plog/traffic/cpu
LegendO[CPU]: CPUϵͳ¸ºÔØ
LegendI[CPU]: CPUʹÓÃÕ߸ºÔØ
Language:Chinese
˵Ã÷:Target ÄËÊÇ×ÊÁϵÄÈ¡µÃ·½Ê½ ÈçͬMRTG²âÁ÷Á¿Ê±µÄpublic@community.
MaxBytes:ÏÞÖÆ»æͼµÄ×î´ó Loading Öµ,CPU Loading µÄ×î¸ßÖµ¾ÍÊÇ 100% .
Title: HTML ÍøÒ³µÄtitle .
PageTop: ÍøÒ³Ò³ÃæµÄ*±êÌâ*.
Options: ²ÉÓñê×¼¸ñʽ,²¢ÇÒÈÃMRTGÓÉÓÒÍù×ó»æͼ.
YLegend: ͼ±íµÄYÖáÃû³Æ.
ShotLegend: ¶¨Òå×îСµÄµ¥Î»(%).
WorkDir: ¹¤×÷ÇøÓò Ò²¾ÍÊÇÏÔʾͼ±íµÄλÖÃ.
Language: ÓüòÌåÖÐÎÄ
LegendO[CPU] & LegendI[CPU]: Ï·½µÄ˵Ã÷
É趨MRTG-CPU Loading µÄÊý¾ÝÈ¡µÃµµ°¸Ö´Ðеµ:
/usr/local/www/data/mrtg/cpu/mrtg-cpu
´ËµµÈ¨ÏÞÐèΪ¿ÉÖ´ÐÐÈôÓÃrootÖ´ÐÐÔòΪ700£¬ÄÚÈÝ:
#!/usr/bin/perl
$cpu_orig=`/usr/local/bin/bsdsar -u >; /usr/www/traffic/cpu/bsdsar.tmp`;
$cpu_str=`/usr/bin/tail -1 /usr/www/traffic/cpu/bsdsar.tmp`;
$val=(split(' ',$cpu_str))[1];
$val2=(split(' ',$cpu_str))[2];
$val=int($val);
$val2=int($val2);

print "$val\n";
print "$val2\n";
print "0\n";
print "0\n";
ÐÞ¸ÄȨÏÞ£ºchmod 700 mrtg-cpu
/usr/local/bin/mrtg /usr/www/traffic/cpu/cpu.cfg¾Í»áÉú³Écpu.htmlµÈÎļþÁË¡£
¿ÉÒÔͨ¹ýhttp://******/traffice/cpu/cpu.html¿´µ½cpuµÄʹÓÃÇé¿öÁË¡£
ÎÒÉ趨ÿ10·ÖÖÓrunÒ»´Î.
*/10 * * * * /usr/local/bin/mrtg /usr/www/traffic/cpu/cpu.cfg
ÓÉÓÚÎÒÊÇÿ¸ô10·ÖÖÓrunÒ»´Î,ËùÒÔÔ­ÏÈ×°ÉÏbsdsarÒÔºóϵͳԤÉèÿ¸ô20·ÖÖÓÖ´ÐÐÒ»´ÎµÄbsdsar_gatherÒ²ÒªÐÞÕý.
ÐÞ¸Ä /etc/crontab
#20,40 8-18 * * * root /usr/local/bin/bsdsar_gather
#0 * * * * root /usr/local/bin/bsdsar_gather
*/10 * * * * /usr/local/bin/bsdsar_gather
ËÄ¡¢ÏÂÃæÀ´½éÉÜÒ»ÏÂÈçºÎ¼à¿ØÕûÍøµÄÁ÷Á¿
ÎÒÃǵĺËÐĽ»»»ÊÇcisco6509£¬ÏÂÃæµÄ½»»»»úÊÇcisco3524£¬ÎÒÃÇûÓÐÆäËû½»»»»ú£¬ËùÒÔÏÂÃæÎÒ˵µÄÃüÁîÊÇÕë¶ÔciscoµÄ£¬ÆäËûµÄ¿É²Î¿¼ÊÖ²á×Ô¼º×÷ÏàÓ¦µÄÐ޸ġ£
ÔÚ6509µÄ¶þ²ãÉÏÉèÖãº
set snmp rmon enable
set snmp community read-only mrtg
ÔÚFreeBSD»úÆ÷ÉÏ£º
/usr/local/bin/cfgmaker --output=/usr/www/mrtg/6509.cfg mrtg@10.0.0.1
È»ºóÐÞ¸Ä6509.cfgÎļþ,Ö÷ÒªÐÞ¸ÄÒÔÏÂÄÚÈÝ£¬ÒÔ·ûºÏÄãµÄʵ¼ÊÇé¿ö£¬´Ë´¦µÄ10.0.0.1ÊÇ6509µÄipµØÖ·¡£
ee /usr/www/mrtg/6509.cfg
WorkDir: /usr/www/mrtg
Options[_]: growright, bits
Language:Chinese
/usr/local/bin/mrtg /usr/www/mrtg/6509.cfg
Õâ¸öÐèÒªÔËÐÐ3´Î£¬Ç°Á½´Î¶¼»á±¨´í£¬²»ÓÃÈ¥Àí»áËû£¬µÚ3´Î¾ÍÓ¦¸ÃûÓдíÎóÁË£¬²»¹ý£¬
ÈôÊÇÓÐÎÊÌâµÄ»°£¬¾ÍÐèÒª¸Ä6509.cfg£¬ÔÙÖ´ÐÐÖ±µ½Ã»ÓдíÎó·¢ÉúΪֹ¡£
ÖÆ×÷Ê×Ò³index.html£º
/usr/local/bin/indexmaker --output=/usr/www/mrtg/6509.html /usr/www/mrtg/6509.cfg
ÈÃËüÿ¸ô5·ÖÖÓÔËÐÐһϣº
crontab -e
*/5 * * * * /usr/local/bin/mrtg /usr/www/mrtg/6509.cfg
Îå¡¢¼à¿ØÏÂÃæ½»»»»úµÄÁ÷Á¿
·½·¨ÀàËÆ6509£¬Ö»ÊÇÃüÁîÓе㲻ͬ£º
snmp-server community mrtg ro£¬ÆäËûµÄÕÕ³­¸ÄÒ»ÏÂÎļþµÄÃû×Ö¾ÍÐÐÁË¡£
Áù¡¢ºó¼Ç£º
Æß¡¢FAQ£º
Q1£ºÎÒÔÚÓ¢ÎÄÏÂ
Max In: 935.6 kb/s (0.9%)
Max Out: 5306.4 kb/s (5.3%)
¿ÉÊÇÔÚÖÐÎÄÏÂÖ»ÏÔʾ
×î´ó Á÷Èë: 935.6 $1$2/Ãë (0.9%)
×î´ó Á÷³ö: 5306.4 $1$2/Ãë (5.3%)
ÕâÊÇÔõô»ØÊ£¿
A1:±à¼­/usr/local/lib/perl5/site_perl/5.8.5/locales_mrtg.pm
²éÕÒµ½sub gb2312µÄÏÂÃæ
Ô­À´ÊÇÕâÑùµÄ£º
´úÂë:
'([kMG]?)([bB])/s' =>; '$1$2/Ãë',
'([kMG]?)([bB])/min' =>; '$1$2/·Ö',
'([kMG]?)([bB])/h' =>; '$1$2/ʱ',
¸Ä³ÉÕâÑù£º
´úÂë:
'([kMG]?)([bB])/s' =>; '$1$2/Ãë',
'([kMG]?)([bB])/min' =>; '$1$2/·Ö',
'([kMG]?)([bB])/h' =>; '$1$2/ʱ',
A2:ÐÞ¸ÄÄãµÄmrtg.cfgÎļþ¡£°ÑÓïÑÔÒ»Ïî¸Ä³É:Chinese
Ò²¾ÍÊÇ:
Language:Chinese
Q2£ºÎÒÔËÐÐÁË/usr/local/bin/cfgmaker --output=/usr/mrtg/6509.cfg mrtg@10.0.0.1
ÒÔºóÉú³ÉÁËËÄÊ®¶à¸öTraffic Analysis for 1 -- 6509µÈµÈ£¬ÎÒÃǵÄ6509ÉÏÊǼÓÁ˸ö48¿ÚµÄ°å×Ó£¬
×ܹ²Ó¦¸ÃÓÐÎåÊ®¶à¸ö£¬ÏÖÔÚÖ»ÓÐËÄÊ®¶à¸öÊDz»ÊÇÒòΪÎÒÔÚÖ´ÐÐÕâ¸öÃüÁîµÄʱºòÖ»ÓÐÕâËÄÊ®¶à¸ö»ú
Æ÷ÊÇ¿ª×ŵģ¿ÒÔºóËûÃÇÔÙ¿ªµÄʱºò»á²»»á±»¼à¿Øµ½£¿»á×Ô¶¯¸øÎÒÉú³ÉTraffic Analysis for 1 -- 6509
ÕâÑùµÄ±íÂð£¿
A:ûÓд¦ÓÚconnectedµÄ¶Ë¿ÚÊDz»Äܱ»cfgmakerץȡµÄ¡£ÒªÏëʵÏÖ²»¿ª»úÁ÷Á¿Îª0£¬¿ª»úÒÔºó¾Í¿ªÊ¼¼à¿ØÁ÷Á¿£¬
ÐèÒª×Ô¼ºÊÖ¶¯¸ü¸ÄcfgÎļþ£¬°ÑËùÓÐδʹÓö˿ڵÄ×¢ÊÍÈ¥µô£¬×¢Òâ¿Õ¸ñºÍ¿ÕÐУ¬Ò»¶¨ÒªºÍcfgmakerÉú³ÉµÄÒ»Ö£¬
·ñÔòÊÇ×¥²»µ½µÄ£¬È»ºóÔÙÖ´ÐÐ/usr/local/bin/mrtg /usr/www/mrtg/6509.cfg¼´¿É¡£
Q3£ºÔÚÕâ¸ö»úÆ÷ÉÏÎÒÖ»¼à¿ØÈ«²¿½»»»»úÉϵÄÁ÷Á¿£¬²¢²»¼à¿Ø±¾ÉíµÄÁ÷Á¿£¬ÒòΪËüÒ²ÔÚ6509ÉϽÓ×Å£¬
ÊDz»ÊǾͲ»ÐèÒªÔËÐÐsnmpdÁË£¿
A£ºÊǽ»»»»úÉϵÄSNMPÄ£×éÔÚ×ö·þÎñ£¬ÓëÄãµÄÖ÷»úû¹Øϵ£¬ÄãµÄÖ÷»ú×ÔȻҲ¾Í²»ÓÃÔËÐÐSNMPDÁË£¬
µ«ÔÚ½»»»»úÖÐ×¥µ½µÄÄãµÄÕą̂Ö÷»úµÄÁ÷Á¿ÊÇ·´µÄ£¬£¨¼´Á÷ÈëºÍÁ÷³öÊÇÏà·´µÄ£¬Õâ¸öÊÇÏÔÈ»µÄÁË£©
Q4£ºÎÒmake installµÄʱºòÌáʾÓдíÎóCouldn't fetch it - please try to retrieve this £¬×°²»ÉÏÔõô°ì£¿
A£ºÄÇÊÇports°²×°µÄʱºòÐèÒªµÄÎļþδÄÜÏÂÔص½£¬ÇëÈ·¶¨ÄãµÄ»úÆ÷ÒѾ­Á¬µ½ÍøÉϲ¢ÄÜ·ÃÎʹú¼Ê»¥ÁªÍø£¬ÎÒÖªµÀºÜ¶àѧУ¶¼ÏÞÖÆÁË·ÃÎʹú¼ÊÍøÂ磬¿ÉÒÔͨ¹ý´úÀíÏÂÔص½ÄÇЩÎļþ·Åµ½/usr/ports/distfiles/ÏÂÃ棬ȻºóÖØÐÂÖ´ÐÐmake install¼´¿É
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ