Monitorix is a free, open source, lightweight system monitoring tool. A good way to monitor the health of your server is knowing its baseline operation measured daily, weekly, monthly and yearly.
Monitor your server stats using Monitorix
My install has been done on Debian 7 Wheezy this has also been tried on Ubuntu 12.04 Server LTS.
Install needed dependencies
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 pflogsumm
Add Monitorix Repository
Adding this line into my package repository lists will allow us to install the package from APT. Whenever the package maintainer releases a new update we could also easily apply the update.
I added the following line to my Debian repository near the bottom.
vi /etc/apt/sources.list # Add the following line Monitorx IzzySoft Repo deb http://apt.izzysoft.de/ubuntu generic universe # Save the file :wq
Download the authors GPG key
cd /usr/local/src wget http://apt.izzysoft.de/izzysoft.asc apt-key add izzysoft.asc (Done as root user) # Refresh the repository apt-get update
apt-get install monitorix
Editing Monitorix configuration
These are just some of the settings I wanted to enable for my server.
Built-in server configuration
Change the following settings to suit your requirements.
Log files pathnames
I had to change some of the log paths to where Debian or Ubuntu expects it to be.
log_file = /var/log/monitorix secure_log = /var/log/auth.log mail_log = /var/log/mail.log milter_gl = /var/milter-greylist/greylist.db imap_log = /var/log/mail.log hylafax_log = /var/spool/hylafax/etc/xferfaxlog cups_log = /var/log/cups/page_log ftp_log = /var/log/proftpd/proftpd.log fail2ban_log = /var/log/fail2ban.log spamassassin_log = /var/log/mail.log clamav_log = /var/log/clamav/clamav.log cg_logdir = /var/CommuniGate/SystemLogs/ squid_log = /var/log/squid/access.log imap_log_date_format = %b %d secure_log_date_format = %b %e
Enable what you want tracked.
<graph_enable> system = y kern = y proc = y hptemp = n lmsens = n nvidia = n disk = n fs = y net = y serv = y mail = y port = y user = y ftp = y apache = y nginx = n lighttpd = n mysql = y squid = n nfss = n nfsc = n bind = n ntp = n fail2ban = n icecast = n raspberrypi = n phpapc = n memcached = y wowza = n int = y
If I change SSH to use a different port number I will change it here too.
max = 9 rule = 24000 list = 25, 21, 80, 8888, 110, 139, 3306, 53, 143 25 = SMTP, tcp, in, 0, 1000 21 = FTP, tcp, in, 0, 1000 80 = HTTP, tcp, in, 0, 1000 8888 = SSH, tcp, in, 0, 1000 110 = POP3, tcp, in, 0, 1000 139 = NETBIOS, tcp, in, 0, 1000 3306 = MYSQL, tcp, in, 0, 1000 53 = DNS, udp, in, 0, 1000 143 = IMAP, tcp, in, 0, 1000 graphs_per_row = 3
I changed mine from Sendmail to Postfix.
# MAIL graph # ----------------------------------------------------------------------------- mta = postfix greylist = milter-greylist rigid = 0, 0, 0, 0, 0 limit = 1, 1000, 1000, 1000, 1000 delvd_enabled = n delvd_timeintvl = 60 delvd_threshold = 100 # delvd_script = /path/to/script.sh mqueued_enabled = n mqueued_timeintvl = 3600 mqueued_threshold = 100 # mqueued_script = /path/to/script.sh
To have my server stats emailed to me each month this is where I change the settings.
enabled = n url_prefix = http://18.104.22.168:8080 smtp_hostname = localhost from_address = email@example.com enabled = n graphs = system, fs to = firstname.lastname@example.org enabled = n graphs = system, fs to = email@example.com enabled = y graphs = system, fs to = firstname.lastname@example.org enabled = n graphs = system, fs to = email@example.com
Non-Privileged MySQL user
Create a MySQL user with no rights to be used by Monitorix to use the MySQL socket for the graphs to work. You can use the Webmin MySQL module.
Restart monitorix to apply the new settings
Access your server stats
We should limit as to whom could view our server stats by creating an .htpasswd file.
Using Webmin’s directory protection module we can add an allowed user. From the Webmin menu > Others > Protected Web Directories > Add protection for new directories.
Enable authentication in monitorix.conf
vi /etc/monitorix.conf <httpd_builtin> enabled = y host = port = 8080 user = nobody group = nogroup log_file = /var/log/monitorix-httpd hosts_deny = hosts_allow = enabled = y msg = Monitorix: Restricted access htpasswd = /var/lib/monitorix/.htpasswd # Saved the file :wq # Restart monitorix /etc/init.d/monitorix restart
Add a user. Click create.
Anyone who tries to get access to your Monitorix link will be prompted for an account login.
Choose what duration of webs stats you’re interested to view
System load average usage for one day.
System load average usage for one week.
If I wanted to jump to Disk I/On activity for a week. I just need to choose the view from the drop down.
Which brings up the weekly activity stats.
You get the picture. Looking at logs is a boring but important task we can spiced it up a little bit by adding cool looking graphics to display our server stats. In addition to your command line monitoring tools top, iostat, netstat, etc now you can monitor your server stats using Monitorix the graphical way.