TranslateProject/published/201406/How to set up a web-based lightweight system monitor on Linux.md
wxy a71aa7de9e renamed: 10 Database Tools For Linux Users To Use!.md -> 201406/10 Database Tools For Linux Users To Use!.md
renamed:    10 Linux Platforms Meant For Embedded Systems.md -> 201406/10 Linux Platforms Meant For Embedded Systems.md
	renamed:    20140527 4MLinux 9.0 Beta Is a 55 MB Operating System That Has It All.md -> 201406/20140527 4MLinux 9.0 Beta Is a 55 MB Operating System That Has It All.md
	renamed:    20140527 A Complete Historical Timeline of Linux Evolution.md -> 201406/20140527 A Complete Historical Timeline of Linux Evolution.md
	renamed:    20140528 Setup Backup Server Using Bacula And Webmin On Ubuntu 14.04.md -> 201406/20140528 Setup Backup Server Using Bacula And Webmin On Ubuntu 14.04.md
	renamed:    20140528 Why We Shouldn't Accept Bad Linux Ports.md -> 201406/20140528 Why We Shouldn't Accept Bad Linux Ports.md
	renamed:    20140529 Add Windows Like Bottom Taskbar In Ubuntu Unity 14.04.md -> 201406/20140529 Add Windows Like Bottom Taskbar In Ubuntu Unity 14.04.md
	renamed:    20140529 Command Line Tuesdays--The Introductory.md -> 201406/20140529 Command Line Tuesdays--The Introductory.md
	renamed:    20140529 How To Share Disks In VirtualBox Between Linux Guest OS.md -> 201406/20140529 How To Share Disks In VirtualBox Between Linux Guest OS.md
	renamed:    20140529 Install RainLoop Webmail (A Web Based Email Client) using 'Nginx and Apache' in Arch Linux.md -> 201406/20140529 Install RainLoop Webmail (A Web Based Email Client) using 'Nginx and Apache' in Arch Linux.md
	renamed:    20140529 What is a good terminal emulator on Linux.md -> 201406/20140529 What is a good terminal emulator on Linux.md
	renamed:    20140529 Why No Flash Support for Linux Is Good for Open Source.md -> 201406/20140529 Why No Flash Support for Linux Is Good for Open Source.md
	renamed:    20140530 Fix 'Cannot Add PPA' Error In Ubuntu 14.04 and Linux Mint.md -> 201406/20140530 Fix 'Cannot Add PPA' Error In Ubuntu 14.04 and Linux Mint.md
	renamed:    20140530 How To Install Linux On A MacBook Pro Retina.md -> 201406/20140530 How To Install Linux On A MacBook Pro Retina.md
	renamed:    20140530 Linux script command--A recorder inside your Terminal.md -> 201406/20140530 Linux script command--A recorder inside your Terminal.md
	renamed:    20140603 App Grid Is A Superior Ubuntu Software Center Alternative.md -> 201406/20140603 App Grid Is A Superior Ubuntu Software Center Alternative.md
	renamed:    20140603 Linux Foundation to donate portion of membership fees to Code.org.md -> 201406/20140603 Linux Foundation to donate portion of membership fees to Code.org.md
	renamed:    20140603 Write your first Linux Kernel module.md -> 201406/20140603 Write your first Linux Kernel module.md
	renamed:    20140604 Command line secrets.md -> 201406/20140604 Command line secrets.md
	renamed:    20140604 Setup Virtual Hosts In Apache On Ubuntu 14.04 LTS.md -> 201406/20140604 Setup Virtual Hosts In Apache On Ubuntu 14.04 LTS.md
	renamed:    20140607 Cup 2014 Brazil--Watch FIFA World Cup 2014 Competition in Your Linux Desktop.md -> 201406/20140607 Cup 2014 Brazil--Watch FIFA World Cup 2014 Competition in Your Linux Desktop.md
	renamed:    20140607 How To Extract Images From Videos Using ffmpeg.md -> 201406/20140607 How To Extract Images From Videos Using ffmpeg.md
	renamed:    20140607 How To Install iCup 2014 In Linux.md -> 201406/20140607 How To Install iCup 2014 In Linux.md
	renamed:    20140607 Linux--Bash Delete All Files In Directory Except Few.md -> 201406/20140607 Linux--Bash Delete All Files In Directory Except Few.md
	renamed:    20140607 New OpenSSL breach is no Heartbleed-but needs to be taken seriously.md -> 201406/20140607 New OpenSSL breach is no Heartbleed-but needs to be taken seriously.md
	renamed:    20140607 Nuvola Player 2.4.0 Released -- A Online Cloud Music Player for Linux.md -> 201406/20140607 Nuvola Player 2.4.0 Released -- A Online Cloud Music Player for Linux.md
	renamed:    20140607 Practical Interview Questions and Answers on Linux Shell Scripting.md -> 201406/20140607 Practical Interview Questions and Answers on Linux Shell Scripting.md
	renamed:    20140607 Steam Hits The Big 500 For Linux Games.md -> 201406/20140607 Steam Hits The Big 500 For Linux Games.md
	renamed:    20140607 Ubuntu One Formally Shuts Down.md -> 201406/20140607 Ubuntu One Formally Shuts Down.md
	renamed:    20140609 How To Know If Your System Has USB 3.0 Port In Linux [Quick Tip].md -> 201406/20140609 How To Know If Your System Has USB 3.0 Port In Linux [Quick Tip].md
	renamed:    20140609 Open Source LDAP Solutions.md -> 201406/20140609 Open Source LDAP Solutions.md
	renamed:    "20140609 OpenELEC 4.0.4 \347\216\260\345\267\262\345\217\221\345\270\203, \345\237\272\344\272\216 XBMC 13.1 \342\200\234Gotham\342\200\235.md" -> "201406/20140609 OpenELEC 4.0.4 \347\216\260\345\267\262\345\217\221\345\270\203, \345\237\272\344\272\216 XBMC 13.1 \342\200\234Gotham\342\200\235.md"
	renamed:    20140610 How to set up Internet connection sharing with iptables on Linux.md -> 201406/20140610 How to set up Internet connection sharing with iptables on Linux.md
	renamed:    20140610 IPFire 2.13 Core 78 Linux Firewall OS Receives OpenSSL Fixes.md -> 201406/20140610 IPFire 2.13 Core 78 Linux Firewall OS Receives OpenSSL Fixes.md
	renamed:    20140610 Open Source SDN Project OpenDaylight Adds New Members.md -> 201406/20140610 Open Source SDN Project OpenDaylight Adds New Members.md
	renamed:    20140610 Top 7 Desktop Environment For Linux.md -> 201406/20140610 Top 7 Desktop Environment For Linux.md
	renamed:    20140611 HTG Explains--What' s the Difference Between Linux and BSD.md -> 201406/20140611 HTG Explains--What' s the Difference Between Linux and BSD.md
	renamed:    20140611 How to Prevent Other Users From Accessing Your Home Directory in Ubuntu 14.04.md -> 201406/20140611 How to Prevent Other Users From Accessing Your Home Directory in Ubuntu 14.04.md
	renamed:    20140612 Command Line Tuesdays--Part One.md -> 201406/20140612 Command Line Tuesdays--Part One.md
	renamed:    20140612 Dpkg Vulnerabilities Closed in Ubuntu 14.04.md -> 201406/20140612 Dpkg Vulnerabilities Closed in Ubuntu 14.04.md
	renamed:    20140616 How To Install Numix Icon Theme In Fedora 20.md -> 201406/20140616 How To Install Numix Icon Theme In Fedora 20.md
	renamed:    20140616 Ubuntu Desktop Next 14.10 Images Available to Download.md -> 201406/20140616 Ubuntu Desktop Next 14.10 Images Available to Download.md
	renamed:    20140616 Ubuntu for Phones Activated on 10,000 Devices.md -> 201406/20140616 Ubuntu for Phones Activated on 10,000 Devices.md
	renamed:    20140617 14 Apps To Boost Ubuntu.md -> 201406/20140617 14 Apps To Boost Ubuntu.md
	renamed:    20140619 Improve Battery Life with Laptop Mode Tools 1.65.md -> 201406/20140619 Improve Battery Life with Laptop Mode Tools 1.65.md
	renamed:    20140619 Red Hat to Acquire eNovance, Focus Together on OpenStack.md -> 201406/20140619 Red Hat to Acquire eNovance, Focus Together on OpenStack.md
	renamed:    20140620 Celebrating 30 Years of X.md -> 201406/20140620 Celebrating 30 Years of X.md
	renamed:    20140620 ENCRYPT DNS TRAFFIC IN LINUX WITH DNSCRYPT (VIA OPENDNS).md -> 201406/20140620 ENCRYPT DNS TRAFFIC IN LINUX WITH DNSCRYPT (VIA OPENDNS).md
	renamed:    20140620 How to enable testing and unstable repository on Debian.md -> 201406/20140620 How to enable testing and unstable repository on Debian.md
	renamed:    20140625 Canonical Debuts 'Orange Box' for Ubuntu OpenStack Cloud Demos.md -> 201406/20140625 Canonical Debuts 'Orange Box' for Ubuntu OpenStack Cloud Demos.md
	renamed:    8 examples of findmnt command to check mounted file systems on Linux.md -> 201406/8 examples of findmnt command to check mounted file systems on Linux.md
	renamed:    Bash Getopts--Scripts with Command Line Options.md -> 201406/Bash Getopts--Scripts with Command Line Options.md
	renamed:    Collectl--An Advanced All-in-One Performance Monitoring Tool for Linux.md -> 201406/Collectl--An Advanced All-in-One Performance Monitoring Tool for Linux.md
	renamed:    Fix Adobe Flash Player Issue In Chromium In Ubuntu 14.04.md -> 201406/Fix Adobe Flash Player Issue In Chromium In Ubuntu 14.04.md
	renamed:    Guide To Install Ubuntu 14.04 In Dual Boot Mode With Windows 8 Or 8.1 UEFI.md -> 201406/Guide To Install Ubuntu 14.04 In Dual Boot Mode With Windows 8 Or 8.1 UEFI.md
	renamed:    How To Install 'California' Calendar App in Ubuntu 14.04.md -> 201406/How To Install 'California' Calendar App in Ubuntu 14.04.md
	renamed:    How To Remove Drive Icons From Unity Launcher In Ubuntu 14.04 [Beginner Tips].md -> 201406/How To Remove Drive Icons From Unity Launcher In Ubuntu 14.04 [Beginner Tips].md
	renamed:    How to Install Windows 8.1 and Ubuntu 14.04 LTS on the Same Computer.md -> 201406/How to Install Windows 8.1 and Ubuntu 14.04 LTS on the Same Computer.md
	renamed:    How to download webcomics from the command line on Linux.md -> 201406/How to download webcomics from the command line on Linux.md
	renamed:    How to launch applications differently with Gnome-Pie on Linux desktop.md -> 201406/How to launch applications differently with Gnome-Pie on Linux desktop.md
	renamed:    How to manage Linux containers with Docker on Ubuntu.md -> 201406/How to manage Linux containers with Docker on Ubuntu.md
	renamed:    How to manage ip addresses and subnets with phpIPAM.md -> 201406/How to manage ip addresses and subnets with phpIPAM.md
	renamed:    How to manage passwords from the command line on Linux.md -> 201406/How to manage passwords from the command line on Linux.md
	renamed:    How to monitor Nginx web server from the command line in real time.md -> 201406/How to monitor Nginx web server from the command line in real time.md
	renamed:    How to set up a web-based lightweight system monitor on Linux.md -> 201406/How to set up a web-based lightweight system monitor on Linux.md
	renamed:    How to take a screenshot from the command line on Linux.md -> 201406/How to take a screenshot from the command line on Linux.md
	renamed:    How to take full length screenshots of websites via terminal.md -> 201406/How to take full length screenshots of websites via terminal.md
	renamed:    How to use LVM in Linux.md -> 201406/How to use LVM in Linux.md
	renamed:    How to verify DDOS attack with netstat command on Linux Terminal.md -> 201406/How to verify DDOS attack with netstat command on Linux Terminal.md
	renamed:    Install SoundCloud In Ubuntu 14.04.md -> 201406/Install SoundCloud In Ubuntu 14.04.md
	renamed:    Linux Pros' Top Command Line Secrets.md -> 201406/Linux Pros' Top Command Line Secrets.md
	renamed:    Linux Terminal--Dstat monitoring tools.md -> 201406/Linux Terminal--Dstat monitoring tools.md
	renamed:    Making Linux Feel at Home.md -> 201406/Making Linux Feel at Home.md
	renamed:    Open Source's Cult Of Personality Is Dying--Thankfully.md -> 201406/Open Source's Cult Of Personality Is Dying--Thankfully.md
	renamed:    Pros' Secrets and Red Hat 7 and PCLinuxOS 2014.05 Reviews.md -> 201406/Pros' Secrets and Red Hat 7 and PCLinuxOS 2014.05 Reviews.md
	renamed:    Start Practising Linux ip command and Avoid the Habit of Using ifconfig.md -> 201406/Start Practising Linux ip command and Avoid the Habit of Using ifconfig.md
	renamed:    TechView--Linus Torvalds Inventor of Linux.md -> 201406/TechView--Linus Torvalds Inventor of Linux.md
	renamed:    Turn Off Bluetooth By Default In Ubuntu 14.04 [Quick Tip].md -> 201406/Turn Off Bluetooth By Default In Ubuntu 14.04 [Quick Tip].md
	renamed:    Ubuntu Linux Community Manager Jono Bacon Leaves Canonical.md -> 201406/Ubuntu Linux Community Manager Jono Bacon Leaves Canonical.md
	renamed:    What Heartbleed Teaches Us--Be An Open Source Contributor, Not Just A User.md -> 201406/What Heartbleed Teaches Us--Be An Open Source Contributor, Not Just A User.md
	renamed:    Why htop Command Compete Linux top Command.md -> 201406/Why htop Command Compete Linux top Command.md
2014-06-30 21:53:24 +08:00

185 lines
8.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Monitorix :支持服务器和树莓派的轻量级系统监控系统
================================================================================
有时候,无论是普通用户还是系统管理员,都需要知道系统运行是否良好。与系统状态相关的许多问题,都可以通过检查运行的服务所生成的日志文件来获得答案。然而,即便对于干过几年的系统管理员而言,要检查日志文件的每个细节都不是件容易的事。这也是为什么他们依赖于监控软件的原因,监控软件能够从不同的源收集信息,并以易于理解的格式给出分析报告,如图表、可视化图像、统计数据等。
市面上流传着许多复杂的系统监控软件,诸如[Cacti][1], [Nagios][2], Zabbix, Munin此类。在本文中我们向您介绍一个轻量级的监控工具——Monitorix该工具设计用于在Linux/BSD上监控系统资源和许多熟知的第三方应用程序。由于专为资源有限的嵌入式系统而优化Monitorix以使用简单消耗内存资源少而著称。它内建了一个HTTP服务器用于提供web界面并使用RRDtool数据库来存储时间序列统计数据RRDtool可以很容易地和任何脚本语言整合如PerlPythonshell脚本Ruby等。
### 主要特性 ###
这里列出了Monitorix的主要特性。要查看完整列表请参阅[官方网站][3]
- 当前系统负载和系统服务
- CPU/GPU温度传感器
- 磁盘温度和健康度
- 网络/端口流量和网络状况统计
- 邮件统计
- Web服务器统计ApacheNginxLighttpd
- MySQL负载和统计
- Squid代理统计
- NFS服务器/客户端统计
- Raspberry Pi传感器统计
- Memcached统计
### 在Fedora, CentOS或者RHEL上安装并配置Monitorix ###
首先安装需要的软件包。注意在CentOS上你需要先设置 [EPEL][4]和[Repoforge][5]仓库。
$ sudo yum install rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-MIME-Lite perl-CGI perl-DBI perl-XML-Simple perl-Config-General perl-HTTP-Server-Simple perl-IO-Socket-SSL
完成上一步后可以通过以下命令来安装Monitorix
$ sudo yum install monitorix
要配置Monitorix打开`/etc/monitorix/monitorix.conf`配置文件并修改选项。关于Monitorix的配置文件细节可以查阅[http://www.monitorix.org/documentation.html][6]。
默认情况下内建的HTTP服务器监听8080端口。因此确保你的防火墙没有阻止TCP 8080端口。
要启动Monitorix只需输入以下命令
$ sudo service monitorix start
启动你喜爱的Web浏览器然后通过http://<host-ip-address>:8080/monitorix来访问Monitorix的Web界面。
### 在Archlinux上安装并配置Monitorix ###
在Archlinux上可以从[AUR][7]上下载Monitorix包。
默认情况下在Archlinux上是禁用了其内建HTTP服务器的。要启用内建的HTTP服务器请编辑/etc/monitorix.conf文件的如下区块。
<httpd_builtin>
enabled = y
host =
port = 8080
user = nobody
group = nobody
log_file = /var/log/monitorix-httpd
hosts_deny =
hosts_allow =
<auth>
enabled = n
msg = Monitorix: Restricted access
htpasswd = /var/lib/monitorix/htpasswd
</auth>
</httpd_builtin>
最后启动Monitorix服务。
打开你喜欢的Web浏览器然后通过http://<host-ip-address>:8080/monitorix来访问Monitorix的Web界面。
### 在Debian和Ubuntu上安装并配置Monitorix ###
对于Debian家族Monitorix可以通过两种方式安装手工安装或通过第三方软件仓库。
#### 手工安装(用于Debian) ####
首先安装所有依赖包。
$ sudo 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
从[http://www.monitorix.org/downloads.html][8]下载Monitorix包并安装。
$ sudo dpkg -i monitorix*.deb
在安装期间会要求你配置一个后端Web服务器。如果你正是用Apache确保重启Apache服务来重新加载Apache配置。
$ sudo service apache2 reload
#### 通过软件仓库安装 (用于Ubuntu) ####
在/etc/apt/source.list中添加以下行来启用Izzysoft仓库。
deb http://apt.izzysoft.de/ubuntu generic universe
下载并为软件仓库添加GPG密钥。
$ wget http://apt.izzysoft.de/izzysoft.asc
$ sudo apt-key add izzysoft.asc
使用apt-get安装Monitorix所有依赖包也将自动安装。
$ sudo apt-get update
$ sudo apt-get install monitorix
最后启动Monitorix服务。
$ sudo service monitorix start
要配置Monitorix请使用文本编辑器编辑`/etc/monitorix/monitorix.conf`并重启Monitorix服务。
$ sudo service monitorix restart
用于Ubuntu的内建Web服务器默认启用。要从Web查看监控结果在你喜爱的Web浏览器中访问http://<host-ip-address>8080/monitorix。
### 在Raspberry Pi上安装并配置Monitorix ###
如果想要在Raspberry Pi基于Debian上安装Monitorix你不能使用上面提到的Izzysoft仓库因为它不提供Monitorix的ARM移植。取而代之的是你可以参照如下基于Debian的手工安装。
首先,安装需要的软件包。
$ sudo 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
如果某些需要的软件包没有安装,我们需要使用此命令来强制安装。
$ sudo apt-get -f install
从[http://www.monitorix.org/downloads.html][9]下载Monitorix软件包(monitorix_x.x.x-izzy1_all.deb)。
使用下面的命令来安装Monitorix包。
$ sudo dpkg -i monitorix_x.x.x-izzy1_all.deb
安装完成后我们需要像下面这样对Monitorix配置稍作修改。
用你喜爱的文本编辑器打开`/etc/monitorix/monitorix.conf`,向下滚动文本直到你找到<graphs enable>。搜索“raspberrypi = n”并用“y”替换“n”这将启用对Raspberry Pi时钟频率、温度和电压的监控。
编辑完成后重启Monitorix服务。
$ sudo service monitorix restart
默认情况下Monitorix的内建HTTP Web服务器会被启用。要访问Monitorix的Web界面访问此地址http://<raspberrypi-ip-address>:8080/monitorix。
### Monitorix截图(Raspberry Pi上) ###
Monitorix主屏幕:
[![](https://farm6.staticflickr.com/5558/14215953893_69b546c473_z.jpg)][10]
系统平均负载和使用情况图示:
[![](https://farm6.staticflickr.com/5239/14009175290_6c5f9542b9_z.jpg)][11]
活动进程图示:
[![](https://farm3.staticflickr.com/2933/14195746084_1364bd1721_z.jpg)][12]
在主屏幕中选择“Raspberry Pi”部分下的“时钟频率”你会看到[Raspberry Pi][13]的时钟频率、温度和电压的图示:
[![](https://farm8.staticflickr.com/7330/14009143189_aeeee6a0e3_z.jpg)][14]
所有监控图示:
[![](https://farm3.staticflickr.com/2908/14192525721_d002b4e621_k.jpg)][15]
--------------------------------------------------------------------------------
via: http://xmodulo.com/2014/05/web-based-lightweight-system-monitor-linux.html
译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://xmodulo.com/2013/11/install-configure-cacti-linux.html
[2]:http://xmodulo.com/tag/nagios
[3]:http://www.monitorix.org/features.html
[4]:http://xmodulo.com/2013/03/how-to-set-up-epel-repository-on-centos.html
[5]:http://xmodulo.com/2013/01/how-to-set-up-rpmforge-repoforge-repository-on-centos.html
[6]:http://www.monitorix.org/documentation.html
[7]:http://aur.archlinux.org/packages.php?ID=33911
[8]:http://www.monitorix.org/downloads.html
[9]:http://www.monitorix.org/downloads.html
[10]:https://www.flickr.com/photos/xmodulo/14215953893/
[11]:https://www.flickr.com/photos/xmodulo/14009175290/
[12]:https://www.flickr.com/photos/xmodulo/14195746084/
[13]:http://xmodulo.com/go/raspberrypi
[14]:https://www.flickr.com/photos/xmodulo/14009143189/
[15]:https://www.flickr.com/photos/xmodulo/14192525721/