在 Ubuntu 16.04 上使用 Monitorix 进行性能监控


Monitorix 是一款免费、开源、轻量级的系统监控工具,旨在监控尽可能多的服务和系统资源。它被创建用于 Linux/UNIX 服务器的生产环境,但由于其简单性和小巧的体积,也可以用于嵌入式设备。本文介绍如何在 Ubuntu 上安装 Monitorix。

添加 Monitorix 仓库

要添加 Monitorix 仓库,请打开 /etc/apt/sources.list 文件,如下所示:

$ sudo nano /etc/apt/sources.list

示例输出如下:

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://in.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://in.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://in.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://in.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://in.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://in.archive.ubuntu.com/ubuntu/ xenial universe

将光标移至文件末尾,并添加以下行:

deb http://apt.izzysoft.de/ubuntu generic universe

保存文件并退出。

添加 PGP 密钥

添加仓库后,我们必须下载(或添加)PGP 密钥并将其“安装”到系统中,如下所示:

$ wget http://apt.izzysoft.de/izzysoft.asc

示例输出如下:

--2016-05-24 11:35:47-- http://apt.izzysoft.de/izzysoft.asc
Resolving apt.izzysoft.de (apt.izzysoft.de)... 144.76.109.57
Connecting to apt.izzysoft.de (apt.izzysoft.de)|144.76.109.57|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1692 (1.7K) [text/plain]
Saving to: ‘izzysoft.asc’

izzysoft.asc 100%[=======================================================>] 1.65K --.-KB/s in 0s
2016-05-24 11:35:47 (212 MB/s) - ‘izzysoft.asc’ saved [1692/1692]

现在,我们必须转到保存 .asc 文件的目录,并打开终端窗口以运行以下命令:

$ sudo apt-key add izzysoft.asc

示例输出如下:

Ok

现在,更新软件包仓库,如下所示:

$ sudo apt-get update

安装 Monitorix

要安装 Monitorix,请使用以下命令:

$ sudo apt-get -y install monitorix apache2-utils

示例输出如下:

Reading package lists... Done
Building dependency tree
Reading state information... Done
apache2-utils is already the newest version (2.4.18-2ubuntu3).
apache2-utils set to manually installed.
The following packages were automatically installed and are no longer required:
apport-hooks-elementary contractor libgda-5.0-4 libgda-5.0-common libgranite-common libgranite3 libgsignon-glib1 libindicate5
libnoise-core0 libtagc0 mysql-server-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libconfig-general-perl libdbi-perl libdbi1 libemail-date-format-perl libhttp-server-simple-perl libmime-lite-perl
libmime-types-perl librrd4 librrds-perl libxml-libxml-perl libxml-namespacesupport-perl libxml-sax-base-perl
libxml-sax-expat-perl libxml-sax-perl libxml-simple-perl rrdtool
Suggested packages:
libmldbm-perl libnet-daemon-perl libsql-statement-perl default-mta | mail-transport-agent libmojolicious-perl
The following NEW packages will be installed:
libconfig-general-perl libdbi-perl libdbi1 libemail-date-format-perl libhttp-server-simple-perl libmime-lite-perl
.............................................................................................

配置 Monitorix

要配置 Monitorix,请打开 /etc/monitorix/monitorix.conf 文件,如下所示:

$ sudo nano /etc/monitorix/monitorix.conf

示例输出如下:

# Monitorix - configuration file
#
# See monitorix.conf(5) manpage for a detailed description of each option.
#
title = Place a title here
hostname =
theme_color = black
refresh_rate = 150
iface_mode = graph
enable_zoom = y
netstats_in_bps = n
disable_javascript_void = n
temperature_scale = c
show_gaps = n
global_zoom = 1
max_historic_years = 1
accept_selfsigned_certs = y
include_dir = /etc/monitorix/conf.d
.....................................................................................

搜索以下几行:

<auth>
   enabled = n
   msg = Monitorix: Restricted access
   htpasswd = /var/lib/monitorix/htpasswd
</auth>

将以上几行更改为如下所示:

<auth>
   enabled = y
   msg = Monitorix: Restricted access
   htpasswd = /var/lib/monitorix/htpasswd
</auth>

保存文件并退出。配置完成后,我们必须重新启动 monitorix 服务,如下所示:

$ sudo service monitorix restart

添加 Monitorix 登录的用户名和密码。在下面的示例中,我将使用用户名“admin”和密码“admin”:

$ sudo htpasswd -d -c /var/lib/monitorix/htpasswd admin

示例输出如下:

New password:
Re-type new password:
Adding password for user admin

打开您喜欢的浏览器并访问 https://:8080/monitorix/。输出应如下所示:

单击“确定”按钮。示例输出应如下所示:

阅读本文后,您将能够理解如何在 Ubuntu 上安装 Monitorix。在我们的下一篇文章中,我们将提供更多基于 Linux 的技巧和提示。敬请期待!

更新于:2020年1月17日

浏览量:175

开启您的职业生涯

完成课程获得认证

开始学习
广告
© . All rights reserved.