Monitorix是一个开源、免费且功能最强大的轻量级工具,旨在监控 Linux 中的系统和网络资源。它定期收集系统和网络数据,并使用自己的 Web 界面(侦听端口 8080/TCP)以图表形式显示信息。
Monitorix允许监控整体系统性能,还有助于检测瓶颈、故障、不需要的长响应时间和其他异常活动。

Monitorix – Linux 系统和网络监控工具
它通常包含两个程序:一个名为monitorix的收集器,它是一个像任何其他系统服务一样自动启动的 Perl 守护程序,以及一个名为monitorix.cgi的 CGI 脚本。
它是用Perl语言编写的,并根据FSF(自由软件基金会)发布的GNU(通用公共许可证)条款获得许可。它使用RRDtool生成图形并使用 Web 界面显示它们。
这个工具是专门为监控基于 Red Hat 的发行版和基于 Debian 的发行版而创建的,但现在它可以在许多不同风格的GNU/Linux发行版上运行,甚至可以在OpenBSD、NetBSD和FreeBSD等UNIX系统上运行。
Monitorix的开发目前处于活跃状态,并添加了新功能、新图形、新更新和修复错误,为 Linux 系统/网络管理提供了一个很好的工具。
Monitorix 功能
- 系统负载平均值、活动进程、每个处理器的内核使用情况、全局内核使用情况和内存分配。
- 监控磁盘驱动器温度和运行状况。
- 文件系统的使用和文件系统的 I/O 活动。
- 网络流量使用最多 10 个网络设备。
- 系统服务包括 SSH、FTP、Vsftpd、ProFTP、SMTP、POP3、IMAP、POP3、VirusMail 和 Spam。
- MTA 邮件统计信息,包括输入和输出连接。
- 网络端口流量包括 TCP、UDP 等。
- FTP 服务器的日志文件格式的 FTP 统计信息。
- 本地或远程服务器的 Apache 统计信息。
- 本地或远程服务器的 MySQL 统计信息。
- Squid 代理 Web 缓存统计信息。
- Fail2ban 统计。
- 监控远程服务器(多主机)。
- 能够以图表或纯文本表格形式查看每天、每周、每月或每年的统计数据。
- 能够缩放图表以获得更好的视图。
- 能够定义每行的图形数量。
- 内置 HTTP 服务器。
有关新功能和更新的完整列表,请查看官方功能页面:
- https://www.monitorix.org/
在 RHEL/CentOS/Fedora Linux 上安装 Monitorix
要安装最新版本的 Monitorix,您需要在系统上启用 EPEL 存储库,如下所示。
---------- On RHEL 9 Based Systems ----------
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
---------- On RHEL 8 Based Systems ----------
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
---------- On RHEL 7 Based Systems ----------
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
安装 EPEL后,您可以使用yum 命令安装以下所需的软件包。
# yum install rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-CGI perl-DBI perl-XML-Simple perl-Config-General perl-IO-Socket-SSL perl-HTTP-Server-Simple wget
接下来,从EPEL存储库安装最新版本的“ Monitorix ”包,如下所示。
# yum install monitorix

安装成功后,请查看主配置文件 /etc/monitorix/monitorix.conf ,根据您的系统添加一些额外的设置并启用或禁用图形。
# vi /etc/monitorix/monitorix.conf

Monitorix 配置设置
最后,将Monitorix服务添加到系统启动中,并使用以下命令启动该服务。
# systemctl enable monitorix
# systemctl start monitorix
# systemctl status monitorix

启动 Monitorix 服务
启动服务后,程序将根据 /etc/monitorix/monitorix.conf 文件中设置的配置开始收集系统信息,几分钟后,你将开始在浏览器上看到系统图。
http://localhost:8080/monitorix/
或
http://Server-IP:8080/monitorix/

Monitorix Linux 监控
如果您的SELinux处于启用状态,则图表不可见,并且您将在 /var/log/messages 或 /var/log/audit/audit.log 文件中收到大量关于拒绝访问的错误消息RRD数据库文件。要消除此类错误消息和可见图表,您需要禁用SELinux。
要关闭SELinux,只需将 /etc/selinux/config 文件中的 enforcing 行更改为 disabled 即可。
SELINUX=disabled
以上将暂时禁用SELinux,直到您重新启动机器。如果您希望系统以始终禁用模式启动,则需要重新启动系统。
在 Ubuntu/Debian/Linux Mint 上安装 Monitorix
新版本上的Monitorix安装应使用以下apt 命令完成。
$ sudo apt install monitorix
旧版本中的用户可以使用 Izzy 存储库,这是一个实验性存储库,但该存储库中的包应该适用于所有版本的Ubuntu、Debian等。
但是,不提供任何保证——因此风险由您承担。如果您仍想通过apt-get添加此存储库以进行自动更新,只需按照以下提供的步骤进行自动安装。
将以下行添加到您的 /etc/apt/sources.list 文件中。
deb http://apt.izzysoft.de/ubuntu generic universe
获取此存储库的GPG密钥,您可以使用wget 命令获取它。
# wget http://apt.izzysoft.de/izzysoft.asc
下载后,使用命令“ apt-key ”将此GPG密钥添加到 apt 配置中,如下所示。
# apt-key add izzysoft.asc
最后,通过存储库安装包。
# apt-get update
# apt-get install monitorix
使用 .Deb 包手动安装
手动下载最新版本的.deb包并安装它,同时注意所需的依赖项,如下所示。
# apt-get update
# apt-get install rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl libio-socket-ssl-perl
# wget https://www.monitorix.org/monitorix_3.14.0-izzy1_all.deb
# dpkg -i monitorix_3.14.0-izzy1_all.deb
在安装期间,将进行 Web 服务器配置。因此,您需要重新加载Apache Web 服务器以生效新配置。
# service apache2 restart [On SysVinit]
# systemctl restart apache2 [On SystemD]
Monitorix带有默认配置,如果您想更改或调整某些设置,请查看 /etc/monitorix.conf 中的配置文件。完成更改后,重新加载服务以使新配置生效。
# service monitorix restart [On SysVinit ]
# systemctl restart monitorix [On SystemD ]
现在将您的浏览器指向 http://localhost:8080/monitorix 并开始观看系统的图表。只有当您希望允许访问远程IP时,才能从localhost访问它。只需打开 /etc/apache2/conf.d/monitorix.conf 文件并将 IP 添加到 Allow from 子句。例如,见下文。
<Directory /usr/share/monitorix/cgi-bin/>
DirectoryIndex monitorix.cgi
Options ExecCGI
Order Deny,Allow
Deny from all Allow from 172.16.16.25
</Directory>
对上述配置进行更改后,不要忘记重新启动Apache。
# service apache2 restart [On SysVinit]
# systemctl restart apache2 [On SystemD]
Monitorix 截图
请查看以下屏幕截图:
Monitorix主页

Monitorix主页
监控 Linux 平均负载

系统负载平均、活动进程和内存分配
监控 Linux 内核使用情况

全局内核使用
监控 Linux 内核处理器

每个处理器内核使用情况
监控 Linux 磁盘运行状况

磁盘驱动器温度和运行状况
监控 Linux 文件系统和磁盘 I/O 读取

文件系统使用情况和 I/O 活动
监控 Linux 网络流量

eth0 接口流量
监控 Linux 系统服务

系统服务需求
监控 Linux 网络端口流量

网络端口流量
监控 Linux Apache 统计信息

Apache统计
监控 MySQL/MariaDB 统计数据

MySQL 统计