windows上mrtg監控linuxcpu 記憶體

來源:互聯網
上載者:User

標籤:windows上mrtg監控linuxcpu 記憶體

    *網上95%都是linux安裝mrtg來做監控,windows來做監控機的很少,即使用也是輕輕點水很膚淺,下面是我親自在windows上安裝mrtg來做監控機的實驗,並且也已經開始運行在企業當中。mrtg的特點就是一目瞭然,配置也相對簡單,不需要資料庫,它與rrdtools、Nagios沒有好壞之分,看你需要用什麼了。


*在windows系統上安裝mrtg,監控linux機器(只要把此搞懂了,在linux安裝mrtg監控其他機器就更簡單了)


一、準備安裝環境


1. MRTG,

2. ActivePerl.msi

3. Windows服務安裝工具:SERANY.exe 和 INSTSRV.exe 1. MRTG,


二、安裝,配置監控機環境 

1. 安裝ActivePerl解 壓ActivePerl的包,然後雙擊運行安裝檔案即可。預設情況下Perl安裝在C:\Perl目錄下。

2. 安裝MRTG解壓MRTG的包,我用的是MRTG-2.12.2版本。將解壓後的目錄移到一個自訂的目錄下就行了,我用的是C:\MRTG。

3. 安裝,建立snmp。

在“控制台->增加/刪除程式->Windows組件安裝”中,安裝SNMP的組件。

添加snmp,開始-->管理工具-->服務-->SNMP Server,右鍵-->安全 添加public,唯讀

4,需要有iis來支援,網站目錄自己定(我這裡是c:\Inetpub\wwwroot\)

4.修改防火牆,開啟UDP 161連接埠。

5.設定監控機器的snmp


二,安裝,配置被監控機配置(ip:10.180.0.123):

1,安裝包

net-snmp-perl-5.1.2-11.EL4.6.x86_64.rpm

net-snmp-libs-5.1.2-11.EL4.6.x86_64.rpm

net-snmp-utils-5.1.2-11.EL4.6.x86_64.rpm

net-snmp-devel-5.1.2-11.EL4.6.x86_64.rpm

   !!需要預先安裝以下rpm包

   beecrypt-devel-3.1.0-6.x86_64.rpm

   elfutils-devel-0.97-5.x86_64.rpm(在第5張安裝光碟片上)

net-snmp-5.1.2-11.EL4.6.x86_64.rpm

net-snmp-utils-5.1.2-11.EL4.6.x86_64.rpm


2,修改/etc/snmp/snmpd.conf


找到這行:

# Make at least snmpwalk -v 1 localhost -c public system fast again

#       name           incl/excl     subtree         mask(optional)

view    systemview    included   .1.3.6.1.2.1.1

view    systemview    included   .1.3.6.1.2.1.25.1.1

在view幾行的下面,加上這段文字:

# For Mrtg Add start ####################################

view    all           included   .1.3.6

# For Mrtg Add end   ####################################

找到這行:

####

# Finally, grant the group read-only access to the systemview view.

#       group          context sec.model sec.level prefix read   write notif

access notConfigGroup ""      any       noauth    exact mib2   none   none

把 access notConfigGroup 裡的mib2(也可能是systemview) 更改為all



然後重啟snmp服務

# service snmpd restart


三,生產監控機器的檔案

1,

開啟DOS視窗,首先進入C:\mrtg\bin,然後輸入以下命令(生產主設定檔):

perl cfgmaker --global "WorkDir: C:\Inetpub\wwwroot" OutPut --output mrtg.cfg


2,生產首頁檔案

perl indexmaker mrtg.cfg>c:\Inetpub\wwwroot\index.htm



3,生產記錄檔(執行3次以上就不會有報錯了)

perl mrtg --logging=all.log all.cfg


4,啟動mrtg服務

perl mrtg mrtg.cfg



四,修改設定檔

(可以清空mrtg.cfg所有內容以上預設監控的只是流量,對其他服務的監控如下):


修改C:\mrtg\bin\mrtg.cfg


加入:

EnableIPv6: no

WorkDir: C:\Inetpub\wwwroot #監控機目錄

RunAsDaemon:yes

Interval:5    #5分鐘snmp查詢一次

#================================================================================

Language: gb2312

#HtmlDir: C:\Inetpub\wwwroot

ImageDir: C:\mrtg\bin

LogDir: C:\Inetpub\wwwroot

ThreshDir: C:\mrtg\bin

LoadMIBs:/usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt

#================================================================================

Target[eth0_lan]: /10.180.0.123:[email protected]:

Options[eth0_lan]: growright

Directory[eth0_lan]: eth0

MaxBytes[eth0_lan]: 100000000

Kmg[eth0_lan]: ,k,M,G,T,P

YLegend[eth0_lan]: Bytes per Second

ShortLegend[eth0_lan]: B/s

Legend1[eth0_lan]: in b/s (Bytes)

Legend2[eth0_lan]: out b/s (Bytes)

LegendI[eth0_lan]: in:

LegendO[eth0_lan]: out

Title[eth0_lan]: eth0

PageTop[eth0_lan]: <H1>eth0</H1>


#雙網卡如下添加

Target[eth0_lan]: /10.180.0.111:[email protected]:

Options[eth0_lan]: growright

Directory[eth0_lan]: eth0

MaxBytes[eth0_lan]: 100000000

Kmg[eth0_lan]: ,k,M,G,T,P

YLegend[eth0_lan]: Bytes per Second

ShortLegend[eth0_lan]: B/s

Legend1[eth0_lan]: in b/s (Bytes)

Legend2[eth0_lan]: out b/s (Bytes)

LegendI[eth0_lan]: in:

LegendO[eth0_lan]: out

Title[eth0_lan]: eth0

PageTop[eth0_lan]: <H1>eth0</H1>


#cpu使用和空間查看

Target[cpuload]: .1.3.6.1.4.1.2021.11.50.0&1.3.6.1.4.1.2021.11.53.0:[email protected]:

Options[cpuload]: nopercent,growright

Directory[cpuload]: cpu

MaxBytes[cpuload]: 100

Unscaled[cpuload]: dwym

YLegend[cpuload]: CPU Utilization

ShortLegend[cpuload]: %;

Legend1[cpuload]: CPU used(%)

Legend2[cpuload]: CPU Idle(%)

LegendI[cpuload]: user:

LegendO[cpuload]: ldle:

Title[cpuload]: CPU[user+ldle]

PageTop[cpuload]: <h1>CPU[user+ldle]</h1>


#記憶體使用量和空閑查看

Target[memory]: .1.3.6.1.2.1.25.2.3.1.6.2&.1.3.6.1.2.1.25.2.3.1.6.3:[email protected]:

Options[memory]: gauge,growright

Directory[memory]: mem

MaxBytes1[memory]: 4138700

MaxBytes2[memory]: 5406712

Kmg[memory]: k,M,G,T,P

Kilo[memory]: 1024

Unscaled[memory]: dwym

YLegend[memory]: Bytes

ShortLegend[memory]: B

Legend1[memory]: used Mem (Bytes)

Legend2[memory]: used Swap(Bytes)

LegendI[memory]: used Mem :

LegendO[memory]: used Swap:

Title[memory]: Mem% [Mem+Swap]

PageTop[memory]: <h1>Mem%[Mem+Swap]</h1>


#tcp串連數

Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:[email protected]:

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 Open

PageTop[tcpopen]: <h1>TCP Connections</h1>


#系統進程查看

Target[process]: .1.3.6.1.2.1.25.1.6.0&.1.3.6.1.2.1.25.1.6.0:[email protected]:

Options[process]: gauge,nopercent,growright

Directory[process]: process

MaxBytes[process]: 1000

YLegend[process]: Processes

ShortLegend[process]: 個

Legend1[process]: 系統進程數(個)

Legend2[process]:

LegendI[process]: 進程數:

LegendO[process]:

Title[process]: 系統進程數[進程數]

PageTop[process]: <h1>System processes</h1>


五,給mrtg建立服務,來定時監控


1,

把SERANY.exe 和 INSTSRV.exe拷貝到c:\mrtg\bin下


2,

執行instsrv mrtg c:\mrtg\bin\srvany.exe


3,

建立檔案mrtg.reg,拷入:

Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\mrtg\Parameters]

"Application"="c:\\perl\\bin\\wperl.exe"

"AppParameters"="c:\\mrtg\\bin\\mrtg --logging=eventlog c:\\mrtg\\bin\\mrtg.cfg"

"AppDirectory"="c:\\mrtg\\bin\\"


雙擊mrtg.reg 進行合并。

這樣就可以關閉perl mrtg mrtg.cfg 命令了。


六,關於oid


一般使用windows來做監控機,需要知道被監控機器的oid,不同系統,不同主機oid相對來說也是不同的,不過一般都能使用查詢oid可以下載getif和getif-mibs,華為交換器cpu使用的oid是1.3.6.1.4.1.2011.6.1.1.1.2.0&1.3.6.1.4.1.2011.6.1.1.1.4.0

(2010-01-28)

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/7F/12/wKioL1cSYWazzoZ2AAPZRJC5V90083.jpg" title="mrtg.jpg" alt="wKioL1cSYWazzoZ2AAPZRJC5V90083.jpg" />

本文出自 “五片稜角” 部落格,請務必保留此出處http://hi289.blog.51cto.com/4513812/1764633

windows上mrtg監控linuxcpu 記憶體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.