700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > mrtg监控linux主机的甚至 依赖SNMP的MRTG监控--linux

mrtg监控linux主机的甚至 依赖SNMP的MRTG监控--linux

时间:2018-08-15 07:08:41

相关推荐

mrtg监控linux主机的甚至 依赖SNMP的MRTG监控--linux

监控

Mrtg(Multi Router Traffic

Grapher,MRTG)是一个监控网络链路流量负载的工具软件,它通过snmp协议从设备得到设备的流量信息,并将流量负载以包含PNG格式的图形的HTML文档方式显示给用户,以非常直观的形式显示流量负载。

可移植性:目前可以运行在大多数 Unix 系统和 Windows 之上。

源码开放:mrtg 是用 perl 编写的,源代码完全开放。

高可移植性的SNMP支持:mrtg 采用了 Simon Leinen 编写的具有高可移植性的 SNMP

实现模块,从而不依赖于操作系统的SNMP模块支持。

支持SNMPv2c:MRTG 可以读取 SNMPv2c

的64位记数器,从而大大减少了记数器回转次数。可靠的接口标识:被监控设备的接口可以以IP地址、设备描述、SNMP对接口的编号 及

Mac 地址来标识。

常量大小的日志文件:MRTG 的日志不会变大,因为这里使用了独特的数据合并算法。

自动配置功能:MRTG 自身有配置工具套件,使得配置过程非常简单。

性能:时间敏感的部分使用 C 代码编写,因此具有很好的性能。

PNG格式图形:图形采用 GD 库直接产生 PNG 格式。

可定制性:MRTG 产生的 web 页面是完全可以定制的。

1,安装SNMPsnmp server -->

yum install -y net-snmp*

它可以支持的监控类型:network, cpu, disk, menory .. others ....

2,修改配置文件

vim /etc/snmp/snmpd.conf (配置的是被监控的主机)

com2sec notConfigUser10.1.1.0/24public(允许监控的主机)

#com2sec notConfigUserdefaultpublic

accessnotConfigGroup ""anynoauthexactallnone none

view allincluded.180

disk /

disk /vm

disk /usr/local

disk /usr/src

disk /home(允许监控的磁盘)

snmpwalk -v1 x.x.x.x -c public监控的命令

=============================================================

3,安装MRTG

web server ( 不要 php , mysql

)[ mrtg --> db

]--> 文本

yum install -y mrtg

network traffic 网络流量;网络业务;网络通信量

cfgmaker--global "WorkDir: /www/network"

--global "language: chinese" --global "Options[_]: growright,bits"

--show-op-down --ifref=nr --ifdesc=descr

--output=/etc/mrtg/mrtg.cfg public@10.1.1.X

global "WorkDir:

/www/network"设置全局的工作目录配置,即存MRTG的图像的地址

--global "Options[_]:

growright,bits"设置网络显示

--output=/etc/mrtg/mrtg.cfg所输出的配置文件的地址

public@10.1.1.X监控的主机

create index page(根据你的输出配置文件,形成一个网页文件)

indexmaker --output=/www/network/index.html /etc/mrtg/mrtg.cfg

create db file ---> (生成流量)

LANG=C mrtg /etc/mrtg/mrtg.cfg

===============================================================

监控cpu

snmpwalk -v1 10.1.1.159-c public

enterprises..11.11.0

UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 99

snmpwalk -v1 10.1.1.159-c public

enterprises..11.9.0

UCD-SNMP-MIB::ssCpuUser.0 = INTEGER: 0

#!/bin/bash

snmpwalk -v1 10.1.1.159-c public

enterprises..11.11.0 | awk '{print $NF}'

snmpwalk -v1 10.1.1.159-c public

enterprises..11.9.0 | awk '{print $NF}'

/etc/mrtg/cpu.cfg

EnableIPv6: no

WorkDir: /www/cpu(要在你的网页下创建在这个文件)

language: chinese

Options[_]: growright,bits

Target[10.1.1.159-snmp-cpu]: `/etc/mrtg/cpu159.sh`

PageTop[10.1.1.159-snmp-cpu]:

10.1.1.159

CPU usage

Title[10.1.1.159-snmp-cpu]: CPU on 10.1.1.159

Maxbytes[10.1.1.159-snmp-cpu]: 100

Options[10.1.1.159-snmp-cpu]: gauge

YLegend[10.1.1.159-snmp-cpu]: percent

ShortLegend[10.1.1.159-snmp-cpu]: %

LegendI[10.1.1.159-snmp-cpu]: cpu:

Legend1[10.1.1.159-snmp-cpu]: CPU usage

Legend3[10.1.1.159-snmp-cpu]: Peak CPU usage

routers.cgi*Options[10.1.1.159-snmp-cpu]: noo, nopercent,

nototal

routers.cgi*InOut[10.1.1.159-snmp-cpu]: no

routers.cgi*ShortDesc[10.1.1.159-snmp-cpu]:CPU

Target[10.1.1.10-cpu]: `/etc/mrtg/cpu10.sh`

PageTop[10.1.1.10-cpu]:

10.1.1.10

CPU usage

Title[10.1.1.10-cpu]: CPU on 10.1.1.10

Maxbytes[10.1.1.10-cpu]: 100

Options[10.1.1.10-cpu]: gauge

YLegend[10.1.1.10-cpu]: percent

ShortLegend[10.1.1.10-cpu]: %

LegendI[10.1.1.10-cpu]: cpu:

Legend1[10.1.1.10-cpu]: CPU usage

Legend3[10.1.1.10-cpu]: Peak CPU usage

routers.cgi*Options[10.1.1.10-cpu]: noo, nopercent, nototal

routers.cgi*InOut[10.1.1.10-cpu]: no

routers.cgi*ShortDesc[10.1.1.10-cpu]:CPU

create index page

indexmaker --output=/www/cpu/index.html /etc/mrtg/cpu.cfg

create db file --->

LANG=C mrtg /etc/mrtg/cpu.cfg

======================================================

snmpwalk -v1 10.1.1.159-c public

enterprises..11.3.0

UCD-SNMP-MIB::ssSwapIn.0 = INTEGER: 0 kB

snmpwalk -v1 10.1.1.159-c public

enterprises..11.4.0

UCD-SNMP-MIB::ssSwapOut.0 = INTEGER: 0 kB

这里可以做监控 磁盘io读写

snmpwalk -v1 10.1.1.159-c public

enterprises..11.5.0 (磁盘io读写)

UCD-SNMP-MIB::ssIOSent.0 = INTEGER: 0 blocks/s

snmpwalk -v1 10.1.1.159-c public

enterprises..11.6.0

UCD-SNMP-MIB::ssIOReceive.0 = INTEGER: 0 blocks/s

=========================================================

剩余内存监控

snmpwalk -v1 10.1.1.10-c public

enterprises..4.4.0

UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 4095992 kB

snmpwalk -v1 10.1.1.10-c public

enterprises..4.6.0

UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 3425844 kB

#!/bin/bash

snmpwalk -v1 10.1.1.10-c public

enterprises..4.6.0 | awk '{print $4 }'

snmpwalk -v1 10.1.1.10-c public

enterprises..4.4.0 | awk '{print $4 }'

EnableIPv6: no

WorkDir: /www/memory

language: chinese

Options[_]: growright,bits

Target[$router_name-snmp-memory]: `/etc/mrtg/mem10.sh`

PageTop[$router_name-snmp-memory]:

$router_name

Memory Available

Title[$router_name-snmp-memory]: Available Memory on

$router_name

SetEnv[$router_name-snmp-memory]: MRTG_INT_DESCR="Memory"

Factor[$router_name-snmp-memory]: 1024

# This should be set to your real memory size, in K

MaxBytes1[$router_name-snmp-memory]: 10000000

# This should be set to your swap size, in K

MaxBytes2[$router_name-snmp-memory]: 10000000

Options[$router_name-snmp-memory]: gauge

YLegend[$router_name-snmp-memory]: Bytes

ShortLegend[$router_name-snmp-memory]: b

LegendI[$router_name-snmp-memory]: real:

LegendO[$router_name-snmp-memory]: swap:

Legend1[$router_name-snmp-memory]: Available real memory

Legend2[$router_name-snmp-memory]: Available swap space

Legend3[$router_name-snmp-memory]: Peak available real

Legend4[$router_name-snmp-memory]: Peak available swap

routers.cgi*Options[$router_name-snmp-memory]: nototal

routers.cgi*Mode[$router_name-snmp-memory]: memory

routers.cgi*ShortDesc[$router_name-snmp-memory]: Memory

routers.cgi*Description[$router_name-snmp-memory]: Memory

available: $router_name

routers.cgi*InOut[$router_name-snmp-memory]: no

routers.cgi*InSummary[$router_name-snmp-memory]: yes

routers.cgi*InCompact[$router_name-snmp-memory]: yes

routers.cgi*Icon[$router_name-snmp-memory]: chip-sm.gif

routers.cgi*MBLegend[$router_name-snmp-memory]: 100% usage

create index page

indexmaker --output=/www/memory/index.html /etc/mrtg/memory.cfg

create db file --->

LANG=C mrtg /etc/mrtg/memory.cfg

======================================

======================================

tcp连接的监控

EnableIPv6: no

WorkDir: /www/tcplanguage: chinese

Options[_]: growright,bits

Target[tcpopen10]:.1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@10.1.1.10

Options[tcpopen10]: nopercent,growright,gauge,noinfo

Title[tcpopen10]: TCP connections

PageTop[tcpopen10]:

station10 TCP

connections

MaxBytes[tcpopen10]: 1000000

YLegend[tcpopen10]: # conns

ShortLegend[tcpopen10]: connections

LegendI[tcpopen10]:Connections:

LegendO[tcpopen10]:

Legend1[tcpopen10]: Open TCP connections

create index page

indexmaker --output=/www/tcp/index.html /etc/mrtg/tcp.cfg

create db file --->

LANG=C mrtg /etc/mrtg/tcp.cfg

=========================================================

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