在 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 的技巧和提示。敬請期待!
廣告