Added info on automatic startup of zabbix on boot.
Edit 2:
Looks like the scripts copied to /etc/init.d messed up things when running apt-get install... and similar commands. Adding INIT blocks fix this. Instructions below updated accordingly.
Ok, so I have a few more computers at home than most people, including a couple of always-on servers that deal with things like email and a home automation system that log environmental data as well as control lights etc. Things that I really want to be up and running 24/7.
After messing around with various monitoring solutions (I kind of like Monit for the simplicity of it, but it is also somewhat limited in what it can do) I figured it was time to go all in and set up a proper monitoring tool.
Nagios has been around for ever, but more recently lots of people speak well about Zabbix. Both would solve 99% of every monitoring problem you could think of, but for various reasons I went with Zabbix.
The big question was whether it would run on a b2. Turns out it does - at least if you don't mind waiting a few seconds for web pages to load. I don't usually fancy waiting, but still find it ok in this case, so it isn't that bad.
The easy way to get started is of course to sudo to root, then do an apt-get install zabbix-server.
Turns out that will give you a very old version. Plan B is to build from source.
Steps to build Zabbix from source on b2 (should work for b3 as well. Pls note that some minor steps might be missing, I am writing some of this from memory...):
------------
I have recently reinstalled my b2 with latest OS, but the locales were not properly set up. Fix this:
Code: Select all
apt-get install debconf
apt-get remove locales-all
apt-get install locales
dpkg-reconfigure locales
Code: Select all
su
cd
mkdir code
cd code
wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.0.2/zabbix-2.0.2.tar.gz
Code: Select all
apt-get install build-essential mysql-server libmysqlclient15-dev php5 php5-gd php5-mysql snmp libsnmp-dev snmpd libcurl4-openssl-dev fping libiksemel3 libiksemel-dev
Code: Select all
tar xvf zabbix-2.0.2.tar.gz
cd zabbix-2.0.2
./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-net-snmp --with-jabber --prefix=/root/code/zabbix-2.0.2 --sysconfdir=/usr/local/etc
make install
Zabbix is now installed, but need to be configured before it can be used
Code: Select all
mkdir /usr/share/zabbix/
cp -a ./frontends/php/* /usr/share/zabbix/
mv /usr/share/zabbix/conf/zabbix.conf.php.example /usr/share/zabbix/conf/zabbix.conf.php
Zabbix stores all configuration parameters etc in a database. In this case we're using MySql, but PostgreSQL and other dbs are also supported.
First, create a MySQL user for Zabbix. Pls refer to MySQL docs if unsure how this is done.
Next, edit Zabbix config file as follows (this will use the MySQL instance on the b2 itself)
Code: Select all
nano /usr/share/zabbix/conf/zabbix.conf.php
<?php
// Zabbix GUI configuration file
global $DB;
$DB["TYPE"] = 'MYSQL';
$DB["SERVER"] = 'localhost';
$DB["PORT"] = '3306';
//$DB["PORT"] = '0';
$DB["DATABASE"] = 'zabbix';
$DB["USER"] = 'zabbix';
$DB["PASSWORD"] = '<ZabbixPwdHere>';
// SCHEMA is relevant only for IBM_DB2 database
$DB["SCHEMA"] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
Start MySQL client to set up the db there
Code: Select all
mysql -u'zabbix' -p'<ZabbixPwdHere>'
mysql> create database zabbix character set utf8;
mysql> quit;
Code: Select all
cd database/mysql
cat schema.sql | mysql -u'zabbix' -p'<ZabbixPwdHere>' zabbix
cat images.sql | mysql -u'zabbix' -p'<ZabbixPwdHere>' zabbix
cat data.sql | mysql -u'zabbix' -p'<ZabbixPwdHere>' zabbix
mysql -e"grant all privileges on zabbix.* to zabbix@localhost identified by '<ZabbixPwdHere>';"
mysql -u'zabbix' -p'<ZabbixPwdHere>'
FLUSH PRIVILEGES;
quit;
Edit services config file, add to the /etc/services file
Code: Select all
nano /etc/services
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
Binaries should now be in /usr/local/sbin, if not copy them there.
Also, copy Zabbix init.d scripts to proper location
Code: Select all
cp /root/code/zabbix-2.0.2/sbin/* /usr/local/sbin
cp /root/code/zabbix-2.0.2/misc/init.d/debian/* /etc/init.d
/etc/init.d/zabbix-server:
Code: Select all
#!/bin/sh
### BEGIN INIT INFO
# Provides: zabbix-server
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Zabbix Server
# Description: Zabbix server
### END INIT INFO
Code: Select all
#!/bin/sh
### BEGIN INIT INFO
# Provides: zabbix-agent
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Zabbix Server
# Description: Zabbix server
### END INIT INFO
Copy Zabbix server and agent config files to proper location (note: Zabbix 2.x use /usr/local/etc rather than /etc/zabbix, as described here)
Code: Select all
cp -r conf/* /usr/local/etc
Code: Select all
nano usr/local/etc/zabbix_server.conf
Create zabbix Linux user, add to admin group.
Code: Select all
adduser zabbix
enter in new password & confirm
adduser zabbix admin
Almost there. Start the daemons and check log files for errors
Code: Select all
/etc/init.d/zabbix-server start
/etc/init.d/zabbix-agent star
tail -n 25 /tmp/zabbix_server.log
Time to set up the web UI
Code: Select all
mkdir /home/zabbix/public_html
cp -R frontends/php/* /home/zabbix/public_html/
nano /etc/apache2/sites-enabled/000-default
(Enter into this file)
Alias /zabbix /home/zabbix/public_html/
<Directory /home/zabbix/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
Code: Select all
nano /etc/php5/apache2/php.ini
max_execution_time = 300 ; Maximum execution time of each script, in seconds
date.timezone = <YourTimezoneHere>
Code: Select all
sudo /etc/init.d/apache2 restart
The web based setup complained about max_input_time and post_max_size php options being too low. Increase them as needed, then restart apache again to make the changes take effect.
You should now be able to log in with username=Admin, pwd=zabbix
Assuming you got this far - this is where the fun begins. Zabbix is EXTREMELY customizable. There are plenty of online resources for doing this, with the forums and wiki at www.zabbix.com being useful starting points.
Finally, you might want to change so that the Zabbix daemon and agent starts automatically at boot.
The convenient little rcconf utility let you do that in a menu driven way.
Good luck!
There wasn't any perfect guide for all of the above online, the following ones were helpful though:
http://sigign.blogspot.se/2011/05/insta ... ueeze.html
http://www.zabbix.com/wiki/howto/instal ... ntuinstall
http://tipstricks.itmatrix.eu/?p=407