小编教你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子目录是什么。

    网站子目录和Linux子目录是两个不同的概念,它们在计算机领域中有着不同的应用和作用。 让我们来了解一下网站子目录,在网站中,子目录是指一个主目录下的文件夹,用于组织和管理网站的不同部分或功能,通过创建子…

    2024年6月28日
    00
  • 聊聊linux 永久删除文件。

    你可以使用以下命令来永久删除文件:,,- rm -rf:强制删除文件和目录,不会询问用户。如果文件或目录被其他进程使用,则无法删除。 ,- shred:覆盖文件来隐藏内容。该命令会多次覆盖文件或目录中的数据,几乎不可…

    2024年7月24日
    00
  • linux 内存监控。

    您可以使用以下命令来监控Linux内存使用情况:,,- free:显示系统中可用和已使用的物理内存和交换空间。,- top:实时显示系统中各个进程的资源占用状况,包括内存。,- vmstat:收集和显示关于内存、进程、终端和分…

    2024年7月17日
    00
  • 分享Linux有什么常用命令。

    以下是一些常用的 Linux 命令:ls、cd、mkdir、touch、cp、mv、rm、pwd、chmod、nano 或 vim。 Linux操作系统以其强大的功能和灵活性受到许多开发者的喜爱,它提供了许多命令行工具,使得用户可以轻松地完成各种任…

    2024年7月20日
    00
  • 小编分享如何通过OTPW来用SSH安全登录Linux服务器。

    在现代的IT环境中,远程访问服务器已经成为了一项常见的任务,为了确保数据的安全,我们需要使用一种安全的方式来登录服务器,SSH(Secure Shell)是一种网络协议,用于计算机之间的安全登录和其他安全网络服务,OT…

    2024年7月4日
    00
  • 小编分享linux设置ssh密码,linux ssh自动输入密码2022年更新(linux ssh 自动输入密码)。

    SSH简介 Secure Shell(SSH)是一种网络协议,用于在不安全的网络环境中提供安全的远程登录服务,通过SSH协议,用户可以在不安全的网络中安全地执行命令,传输文件等操作,SSH协议最初是由美国国家安全局(NSA)开发的…

    2024年7月29日
    00
  • 分享如何理解Linux系统下的/dev目录。

    在Linux系统中,/dev目录是一个非常重要的目录,它包含了所有的设备文件,这些设备文件是一种特殊的文件,它们代表了系统上的硬件设备,如硬盘、光驱、鼠标等,通过这些设备文件,用户可以方便地与硬件设备进行交互…

    2024年7月14日
    00
  • 分享linux 容器。

    Linux容器是一种轻量级的虚拟化技术,可以在单台主机上同时运行多个隔离的虚拟环境。Linux容器提供了与系统其他部分隔离开的一个或一组进程,运行这些进程所需的所有文件都由另一个特定镜像提供,意味着从开发到测…

    2024年7月28日
    00

联系我们

QQ:951076433

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