{"id":576,"date":"2009-03-10T22:00:16","date_gmt":"2009-03-10T14:00:16","guid":{"rendered":"http:\/\/www.liangliang.org.cn\/blog\/?p=576"},"modified":"2009-03-10T22:00:16","modified_gmt":"2009-03-10T14:00:16","slug":"debian%e4%b8%8b%e7%9a%84mrtg%ef%bc%8c%e5%ae%9e%e7%8e%b0%e7%bd%91%e7%bb%9c%e6%b5%81%e9%87%8f%e7%9b%91%e6%8e%a7%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.liangliang.org.cn\/?p=576","title":{"rendered":"debian\u4e0b\u7684mrtg\uff0c\u5b9e\u73b0\u7f51\u7edc\u6d41\u91cf\u76d1\u63a7\u3002"},"content":{"rendered":"<p>apt-get install mrtg snmpd<\/p>\n<p>\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u81ea\u52a8\u751f\u6210\/usr\/share\/mrtg   <br \/>ThinkPad:\/usr\/share\/mrtg# pwd    <br \/>\/usr\/share\/mrtg    <br \/>\u5e76\u4e14\u81ea\u52a8\u52a0\u5165\u8ba1\u5212\u4efb\u52a1\uff1a<\/p>\n<p>art@ThinkPad:\/etc$ cat \/etc\/cron.d\/mrtg   <br \/>*\/5 * * * * root if [ -x \/usr\/bin\/mrtg ] &amp;&amp; [ -r \/etc\/mrtg.cfg ]; then env LANG=C \/usr\/bin\/mrtg \/etc\/mrtg.cfg 2&gt;&amp;1 | tee -a \/var\/log\/mrtg\/mrtg.log ; fi<\/p>\n<p>vim \/etc\/cron.d\/mrtg<\/p>\n<p>0-55\/5 * * * * root if [ -x \/usr\/bin\/mrtg ] &amp;&amp; [ -r \/etc\/mrtg.cfg ]; then env LANG=C \/usr\/bin\/mrtg \/etc\/mrtg.cfg &gt;&gt; \/var\/log\/mrtg\/mrtg.log 2&gt;&amp;1; fi<\/p>\n<p>\u67e5\u770bsnmp\u8bbe\u7f6e\uff1a<\/p>\n<p>vim \/etc\/snmp\/snmpd.conf   <br \/># sec.name source community    <br \/># com2sec paranoid default public    <br \/>com2sec readonly default public    <br \/>#com2sec readwrite default private<\/p>\n<p>\u6ce8\u91ca   <br \/>com2sec paranoid default public    <br \/>\u53d6\u6d88\u6ce8\u91ca    <br \/>com2sec readonly default public<\/p>\n<p>\u542f\u52a8snmpd   <br \/>\/etc\/init.d\/snmpd restrat<\/p>\n<p>\u4f7f\u7528cfgmaker\u751f\u6210snmp\u8bbe\u5907\u7684mrtg\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>ThinkPad:\/etc\/snmp#<\/p>\n<p>cfgmaker --global 'WorkDir: \/usr\/share\/mrtg' --global 'Options[_]: bits,growright' --output \/etc\/mrtg.cfg public@127.0.0.1   <br \/>ThinkPad:\/etc\/snmp#<\/p>\n<p>\u751f\u6210index.html<\/p>\n<p>indexmaker --columns=1 --output=\/usr\/share\/mrtg\/index.html --title='Traffic Info' \/etc\/mrtg.cfg<\/p>\n<p>vim \/etc\/apache2\/conf.d\/mrtg.conf<\/p>\n<p>Alias \/mrtg \/usr\/share\/mrtg<\/p>\n<p>Options +FollowSymLinks   <br \/>AllowOverride All    <br \/>order allow,deny    <br \/>allow from all<\/p>\n<p>\u8bbf\u95ee:   <br \/>http:\/\/127.0.0.1\/mrtg<\/p>\n<p>BTW:<\/p>\n<p>Some of examples how to monitor cpu and memory usage<\/p>\n<p>CPU Usage<\/p>\n<p>\/etc\/mrtg\/cpu.cfg<\/p>\n<p>WorkDir: \/var\/www\/localhost\/htdocs\/mrtg   <br \/>LoadMIBs: \/usr\/share\/snmp\/mibs\/UCD-SNMP-MIB.txt    <br \/>Target[localhost.cpu]:ssCpuRawUser.0&amp;ssCpuRawUser.0:public@127.0.0.1+ ssCpuRawSystem.0&amp;ssCpuRawSystem.0:public@127.0.0.1+    <br \/>ssCpuRawNice.0&amp;ssCpuRawNice.0:public@127.0.0.1    <br \/>RouterUptime[localhost.cpu]: public@127.0.0.1    <br \/>MaxBytes[localhost.cpu]: 100    <br \/>Title[localhost.cpu]: CPU Load    <br \/>PageTop[localhost.cpu]:Active CPU Load %<\/p>\n<p>Unscaled[localhost.cpu]: ymwd   <br \/>ShortLegend[localhost.cpu]: %    <br \/>YLegend[localhost.cpu]: CPU Utilization    <br \/>Legend1[localhost.cpu]: Active CPU in % (Load)    <br \/>Legend2[localhost.cpu]:    <br \/>Legend3[localhost.cpu]:    <br \/>Legend4[localhost.cpu]:    <br \/>LegendI[localhost.cpu]: Active    <br \/>LegendO[localhost.cpu]:    <br \/>Options[localhost.cpu]: growright,nopercent<\/p>\n<p>Memory Usage<\/p>\n<p>\/etc\/mrtg\/mem.cfg<\/p>\n<p>LoadMIBs: \/usr\/share\/snmp\/mibs\/HOST-RESOURCES-MIB.txt   <br \/>Target[localhost.mem]: .1.3.6.1.4.1.2021.4.6.0&amp;.1.3.6.1.4.1.2021.4.6.0:public@localhost    <br \/>PageTop[localhost.mem]:Free Memory<\/p>\n<p>WorkDir: \/var\/www\/localhost\/htdocs\/mrtg   <br \/>Options[localhost.mem]: nopercent,growright,gauge,noinfo    <br \/>Title[localhost.mem]: Free Memory    <br \/>MaxBytes[localhost.mem]: 1000000    <br \/>kMG[localhost.mem]: k,M,G,T,P,X    <br \/>YLegend[localhost.mem]: bytes    <br \/>ShortLegend[localhost.mem]: bytes    <br \/>LegendI[localhost.mem]: Free Memory:    <br \/>LegendO[localhost.mem]:    <br \/>Legend1[localhost.mem]: Free memory, not including swap, in bytes<\/p>\n<p>Creating jobs for the above two examples<\/p>\n<p>CPU<\/p>\n<p>\/etc\/cron.mrtg\/cpu<\/p>\n<p>#!\/bin\/sh   <br \/>\/usr\/bin\/mrtg \/etc\/mrtg\/cpu.cfg<\/p>\n<p>Memory<\/p>\n<p>\/etc\/cron.mrtg\/mem<\/p>\n<p>#!\/bin\/sh   <br \/>\/usr\/bin\/mrtg \/etc\/mrtg\/mem.cfg<\/p>\n<p>Run each script 3 times (disregard the warnings)<\/p>\n<p>\/etc\/cron.mrtg\/cpu   <br \/>\/etc\/cron.mrtg\/mem<\/p>\n<p>Make the Index Files<\/p>\n<p>#\/usr\/bin\/indexmaker --output=\/var\/www\/mrtg\/index.html \\   <br \/>--title=&quot;Memory and CPU Usage :)&quot; \\    <br \/>--sort=name \\    <br \/>--enumerate \\    <br \/>\/etc\/mrtg\/cpu.cfg \\    <br \/>\/etc\/mrtg\/mem.cfg<\/p>\n<p>Make the mrtg.cfg file<\/p>\n<p>#cfgmaker --global &quot;WorkDir: \/var\/www\/mrtg\/&quot; \\   <br \/>--global &quot;Options[_]: growright,bits&quot; \\    <br \/>--ifref=ip \\    <br \/>public@localhost &gt; \/etc\/mrtg\/mrtg.conf<\/p>\n<p>Cronjob setup<\/p>\n<p>\/bin\/cat &gt;&gt; \/var\/spool\/cron\/crontabs\/root   <br \/>*\/5 * * * * \/bin\/run-parts \/etc\/cron.mrtg 1&gt; \/dev\/null<\/p>\n<p>Now you logon to your web browser and check you should see the graphs<\/p>\n","protected":false},"excerpt":{"rendered":"<p>apt-get install mrtg snmpd \u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u81ea\u52a8\u751f\u6210\/usr\/share\/mrtg ThinkPad:\/usr\/share\/mrtg# pwd \/usr\/share\/mrtg \u5e76&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-576","post","type-post","status-publish","format-standard","hentry","category-debian"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=576"}],"version-history":[{"count":0,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/576\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}