小编教你Linux系统mrtg详细安装、设置说明。

MRTG(Multi Router Traffic Grapher)是一个监控网络链路流量负载的工具软件,通过SNMP协议获取路由器的流量信息,并将流量负载以包含PNG格式的图象的HTML文档方式显示给用户,以非常直观的形式显示流量负载。

小编教你Linux系统mrtg详细安装、设置说明。

(图片来源网络,侵删)

以下是在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 "vpn" # 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

本文来自投稿,不代表重蔚自留地立场,如若转载,请注明出处https://www.cwhello.com/444090.html

如有侵犯您的合法权益请发邮件951076433@qq.com联系删除

(0)
夏天夏天订阅用户
上一篇 2024年6月26日 07:36
下一篇 2024年6月26日 07:36

相关推荐

  • 关于linux修改ip地址命令。

    在Linux系统中,修改IP地址通常需要通过命令行来完成,以下是一些常用的步骤: 1. 打开终端,你可以通过搜索”Terminal”或者按下快捷键Ctrl+Alt+T来打开。 2. 查看当前网络接口名称,输入以下命令并回车…

    2024年6月20日
    05
  • 小编分享linux如何监视命令输出。

    您可以使用Linux中的watch命令来监视命令输出。watch命令允许您定期执行命令,并实时显示输出结果。这个命令在监控系统变量或进程状态时尤为有用。 Linux如何监视命令输出 在Linux中,我们可以使用重定向操作符将命…

    2024年7月16日
    06
  • 我来分享在linux命令行中使用计算器的命令有哪些。

    在 Linux 命令行中,有许多计算器工具,这些命令行计算器可以让我们执行科学计算、财务计算或者一些简单的计算。这里我们主要介绍5种命令行计算器:bc、calc、expr、gcalccmd和qalc。 在Linux命令行中使用计算器的…

    2024年7月9日
    03
  • 小编分享Linux中如何使用script命令。

    在Linux中,可以使用script命令来记录终端操作。默认情况下,直接输入script命令即可,会在当前目录自动创建一个typescript文件,之后你在此终端的所有操作都会被记录在这个文件里。 ,,以下是一些常用的选项:,-…

    2024年7月11日
    03
  • 分享安装完双系统linux无法进去。

    您好,如果您在安装完双系统后无法进入Linux系统,可能是由于没有做系统引导。Windows是不能引导Linux的,而Linux引导Windows非常容易。您可以尝试使用EasyBCD等工具来解决这个问题 。 问题描述 用户在安装Windows…

    2024年7月16日
    05
  • 我来分享linux终端的诡异命令有哪些内容。

    在Linux终端中,有许多命令可以用来执行各种任务,有些命令可能会让人感到困惑,因为它们的行为方式可能与预期不符,以下是一些可能会让人感到困惑的Linux终端命令: 1. `ls`命令:`ls`命令用于列出目录中的文件和…

    2024年6月14日
    00
  • 小编教你linux配置主机名字命令。

    在Linux系统中,hostname主机名配置文件/etc/hosts是一个非常重要的文件,它用于定义主机在Linux系统中,hostname主机名配置文件/etc/hosts是一个非常重要的文件,它用于定义主机名和IP地址之间的映射关系,本文将…

    2024年7月8日
    00
  • 我来教你linux shell 文件是否存在。

    在Shell脚本中,我们可以使用多种方式来检查一个文件夹是否存在,这些方法包括使用条件语句、测试命令和函数等,下面将详细介绍如何使用这些方法来判断文件夹是否存在。 1. 使用条件语句 在Shell脚本中,我们可以使…

    2024年6月20日
    00

联系我们

QQ:951076433

在线咨询:点击这里给我发消息邮件:951076433@qq.com工作时间:周一至周五,9:30-18:30,节假日休息