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,安装SNMP snmp server -->

yum install -y net-snmp*

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

2,修改配置文件

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

com2sec notConfigUser 10.1.1.0/24 public(允许监控的主机)

#com2sec notConfigUser default public

access notConfigGroup "" any noauth exact all none none

view all included .1 80

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.2021.11.11.0

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

snmpwalk -v1 10.1.1.159 -c public

enterprises.2021.11.9.0

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

#!/bin/bash

snmpwalk -v1 10.1.1.159 -c public

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

snmpwalk -v1 10.1.1.159 -c public

enterprises.2021.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.2021.11.3.0

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

snmpwalk -v1 10.1.1.159 -c public

enterprises.2021.11.4.0

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

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

snmpwalk -v1 10.1.1.159 -c public

enterprises.2021.11.5.0 (磁盘io读写)

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

snmpwalk -v1 10.1.1.159 -c public

enterprises.2021.11.6.0

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

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

剩余内存监控

snmpwalk -v1 10.1.1.10 -c public

enterprises.2021.4.4.0

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

snmpwalk -v1 10.1.1.10 -c public

enterprises.2021.4.6.0

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

#!/bin/bash

snmpwalk -v1 10.1.1.10 -c public

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

snmpwalk -v1 10.1.1.10 -c public

enterprises.2021.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/tcp language: 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]: station10.cluster.com 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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
STG (SNMP Traffic Grapher) version 1.4.5 Copyright (C) 2000 Leonid Mikhailov This freeware utility allows monitoring of supporting SNMPv1 and SNMPv2c devices including Cisco, Livingstone, Riverstone etc. Intended as fast aid for network administrators who need prompt access to current information about state of network equipment. Copyright In brief: You may use STG for any commercial and non commercial purpose. You may distribute STG for free. You may charge a fee for the physical act of transferring a copy only. This program is distributed WITHOUT ANY WARRANTY. Use it at your own risk. I cannot guarantee accuracy of displayed data. I am not liable to you for any possible damages etc... Source code is not available. Features: Single graph displays changes of two configurable SNMP variables with display of Current, Average, Maximum values. Screen snapshot: http://www.chat.ru/~leonidvm/stg.jpg Could be downloaded from: http://www.chat.ru/~leonidvm/ ftp://ftp.naytov.com/pub/stg/ Newer versions will be there too. STG was written as an add-on for MRTG application by Tobias Oetiker. MRTG (http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html) is absolutely necessary for every network and system administrator. It provides SNMP monitoring of any number devices simultaneously. However during my duties I often have to check state of ports on different routers that are not always in my domain and setting MRTG configuration takes some time. And does not allow to see last second changes in traffic. That's why STG was written. It allows monitoring of SNMP devices with different update periods starting from 0.01s so you could see what's happening right now. Also STG could be useful during network problems troubleshooting. It runs on MS Windows 2000, Windows NT 4.0, Windows 98 and Windows Millenium. To run it on WinNT 4.0 you may need mgmtapi.dll and mib.bin (see below) To run it on Win98 and Millenium you will need mg
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值