上一篇
Linux系统mrtg详细安装、设置说明
- 行业动态
- 2024-04-09
- 2
MRTG(Multi Router Traffic Grapher)是一个监控网络链路流量负载的工具软件,通过SNMP协议获取路由器的流量信息,并将流量负载以包含PNG格式的图象的HTML文档方式显示给用户,以非常直观的形式显示流量负载。
以下是在Linux系统下安装和设置MRTG的详细步骤:
安装SNMP相关工具
1、1 安装SNMP相关工具
sudo aptget update sudo aptget install snmp snmpd libsnmpdev
1、2 配置SNMP
编辑/etc/snmp/snmpd.conf文件,修改或添加以下内容:
rocommunity public localhost rocommunity public your_network_address
保存并退出。
安装MRTG
2、1 下载MRTG源码包
wget http://www.cacti.net/downloads/mrtg/mrtg2.17.tar.gz
2、2 解压源码包
tar zxvf mrtg2.17.tar.gz
2、3 进入解压后的目录
cd mrtg2.17
2、4 编译和安装MRTG
make clean all sudo make install
配置MRTG
3、1 创建MRTG配置文件目录
sudo mkdir /etc/mrtg sudo chmod 777 /etc/mrtg
3、2 创建默认配置文件模板
sudo cp /usr/local/share/mrtg/mrtg.cfg.example /etc/mrtg/mrtg.cfg
3、3 编辑MRTG配置文件
使用任何文本编辑器打开/etc/mrtg/mrtg.cfg文件,修改或添加以下内容:
Run as this userid: (required) set grunuser root The following options can be used to customize the appearance of the graphs: (optional) set gtitle "Your Network" #标题名称 set glogo "/path/to/your/logo" #Logo路径(如果需要的话) The following options define which interfaces should be monitored: (mandatory) include "interfaces" #包含的文件名,通常为"interfaces",该文件定义了要监控的网络接口。 The following options define which targets to send data to: (mandatory) include "targets" #包含的文件名,通常为"targets",该文件定义了将数据发送到的目标服务器。
保存并退出。
3、4 创建MRTG接口配置文件目录和模板文件
sudo mkdir /etc/mrtg/interfaces sudo chmod 777 /etc/mrtg/interfaces sudo touch /etc/mrtg/interfaces/all sudo chmod 666 /etc/mrtg/interfaces/all
3、5 编辑MRTG接口配置文件
使用任何文本编辑器打开/etc/mrtg/interfaces/all文件,修改或添加以下内容:
Run as this userid: (required) set daemon 20 # interval in seconds between each round of stats collection, default is every 15 minutes (900 seconds) include "workstations" # include files for devices on this network include "printers" # include files for devices on this network include "servers" # include files for devices on this network include "switches" # include files for devices on this network include "routers" # include files for devices on this network include "firewalls" # include files for devices on this network include "loadbalancers" # include files for devices on this network include "网络加密层" # include files for devices on this network include "peers" # include files for devices on this network include "misc" # include files for devices on this network target "my_network_monitoring_system" # name of target to send data to unwatched # do not create a graph entry for these devices, they are included by other files device "Workstations" url "/workstationsgraph.png" text "Workstations" icon "/workstationsicon.png" # device description template device_description "Workstations: $hostname ($location)" # device variables template device_vars "Workstations: $uptime$down{$ifdescr}" # device fetch template device_fetch "Workstations: workstationsconfig.pl host $hostname port $rrd_port name $device_descr"$location"" template $template file $datafile"" # device images directory device_imagedir "/path/to/your/images" # device log directory device_logdir "/var/log/mrtg" # device rrd database filename device_rrdfilename "workstationsrrd.rrd" # device rrd database update interval in seconds device_rrdupdate "600" # device rrd database heartbeat interval in seconds device_heartbeat "18000" # device rrd database DST adjustment factor device_dstfactor "0" # device rrd database low value threshold in bytes device_lowvalue "0" # device rrd database high value threshold in bytes device_highvalue "0" # device rrd database retention period in days (default is 30) device_rrdretention "30" # device rrd database archive file name template device_archivename "workstationsarchive%Y%m%d%H%M%S.png" # device rrd database archive directory template device_archivedir "/path/to/your/archive" # device rrd database archive URL template device_archiveurl "/path/to/your/archive%Y%m%d%H%M%S.png" target {Workstations} systemWorkstations url "/workstationsgraph.png" text "System Workstations" icon "/workstationsicon.png" imagedir "/path/to/your/images" logdir "/var/log/mrtg" rrdfilename "workstationsrrd.rrd" rrdupdate "600" heartbeat "18000" dstfactor "0" lowvalue "0" highvalue "0" rrdretention "30" archivename "workstationsarchive%Y%m%d%H%M%S.png" archivedir "/path/to/your/archive" archiveurl "/path/to/your/archive%Y%m%d%H%M%S.png" target {Workstations} internetWorkstations url "/internetworkstationsgraph.png" text "Internet Workstations" icon "/internetworkstationsicon.png" imagedir "/path/to/your/images" logdir "/var/log/mrtg" rrdfilename "internetworkstationsrrd.rrd" rrdupdate "600" heartbeat "18000" dstfactor "0" lowvalue "0" highvalue "0
本站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本站,有问题联系侵删!
本文链接:http://www.xixizhuji.com/fuzhu/254285.html