700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > mrtg监控linux主机的甚至 windows上mrtg监控linuxcpu 内存

mrtg监控linux主机的甚至 windows上mrtg监控linuxcpu 内存

时间:2021-10-08 20:13:27

相关推荐

mrtg监控linux主机的甚至 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

# nameincl/excl subtreemask(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 allincluded .1.3.6

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

找到这行:

####

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

# groupcontext 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:public@10.180.0.123:

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]:

eth0

#双网卡如下添加

Target[eth0_lan]: /10.180.0.111:public@10.180.0.123:

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]:

eth0

#cpu使用和空间查看

Target[cpuload]: .1.3.6.1.4.1..11.50.0&1.3.6.1.4.1..11.53.0:public@10.180.0.123:

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]:

CPU[user+ldle]

#内存使用和空闲查看

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:public@10.180.0.123:

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]:

Mem%[Mem+Swap]

#tcp连接数

Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@10.180.0.123:

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]:

TCP Connections

#系统进程查看

Target[process]: .1.3.6.1.2.1.25.1.6.0&.1.3.6.1.2.1.25.1.6.0:public@10.180.0.123:

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]:

System processes

五,给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..6.1.1.1.2.0&1.3.6.1.4.1..6.1.1.1.4.0

(-01-28)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。