Zabbix is an enterprise open source monitoring solution for networks and applications.
The Zabbix monitoring system is divided in 3 sub-systems :
– Zabbix server : Collect and store data from the devices.
– Zabbix frontend : Render the data and manage the web UI.
– Zabbix agent : Run locally on the different devices to be monitored.
In this post, we’ll install everything on a FreeBSD 10.1 running on a Kimsufi KS-1 server.
Note : The Zabbix server is able to monitor devices and services such as routers, shared hosting, cloud services even if they are not running a Zabbix agent.
In this post, we assume that you already have a server with Ngnix, PHP and MySQL running. If not, you can follow this post.
1. Zabbix server
Install :
1 |
pkg install zabbix24-server-2.4.7 nmap |
Launch a MySQL shell :
1 |
mysql |
And create a MySQL user and database for our Zabbix server :
1 2 3 4 5 |
mysql -uroot -p mysql> create database zabbix character set utf8; mysql> CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'MyPassword'; mysql> GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'MyPassword'; mysql> quit |
Install the database :
1 2 3 4 |
cd /usr/local/share/zabbix24/server/database mysql -uzabbix -p zabbix < mysql/schema.sql mysql -uzabbix -p zabbix < mysql/images.sql mysql -uzabbix -p zabbix < mysql/data.sql |
Create and edit a new configuration based on the sample :
1 2 |
cp /usr/local/etc/zabbix24/zabbix_server.conf.sample /usr/local/etc/zabbix24/zabbix_server.conf vi /usr/local/etc/zabbix24/zabbix_server.conf |
Change the following parameters :
1 2 3 4 |
LogFile=/var/log/zabbix/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=MyPassword |
Create the log folder as defined earlier in the configuration file :
1 2 |
mkdir /var/log/zabbix/ chown zabbix:zabbix /var/log/zabbix/ |
Edit the rc.conf :
1 |
vi /etc/rc.conf |
And add the Zabbix server for automatic startup :
1 |
zabbix_server_enable="YES" |
Start the server :
1 |
service zabbix_server start |
And check in the logs if everything went well :
1 |
tail /var/log/zabbix/zabbix_server.log |
2. Zabbix Frontend
Install :
1 |
pkg install zabbix24-frontend-2.4.7 |
Configure a vhost of your choice. With this “alias” configuration, we’ll be able to access the zabbix frontend using mydomain.tld/zabbix.
1 2 3 4 5 6 |
location /zabbix{ alias /usr/local/www/zabbix24/; auth_basic "Restricted"; auth_basic_user_file /usr/local/www/mydomain.tld/www/zabbix/.htpasswd; autoindex on; } |
I choose to protect access by htpasswd, so I created an user/password :
1 |
echo "monitoring:`perl -le 'print crypt("MyMonitoringPassword","salt")'`" > /usr/local/www/mydomain.tld/www/zabbix/.htpasswd |
Then I just restarted my Nginx server:
1 |
service nginx restart |
Zabbix frontend UI should be reachable using mydomain.tld/zabbix for web based setup.
The installation requires to change some PHP parameters.
Open the php.ini configuration file :
1 |
vi /usr/local/etc/php.ini |
And change the following :
1 2 3 4 5 |
post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = "Europe/Paris" always_populate_raw_post_data = -1 |
And finally restart the PHP service :
1 |
service php-fpm restart |
You will need to give the permission to Nginx to write files :
1 |
chown -R www:www /usr/local/www/zabbix24/ |
3. Zabbix agent
Install :
1 |
pkg install zabbix24-agent-2.4.7 |
1 |
cd /usr/local/etc/zabbix24/ |
Create and edit a new configuration based on the sample :
1 2 |
cp /usr/local/etc/zabbix24/zabbix_agentd.conf.sample /usr/local/etc/zabbix24/zabbix_agentd.conf vi /usr/local/etc/zabbix24/zabbix_agentd.conf |
Change the following :
1 2 3 |
LogFile=/var/log/zabbix/zabbix_agentd.log Include=/usr/local/etc/zabbix24_agentd.conf.d/ Hostname=Kimsufi #Use the same hostname (case-sensitive) when declaring the host on the web UI |
Edit the rc.conf :
1 |
vi /etc/rc.conf |
And add the Zabbix agentd for automatic startup :
1 |
zabbix_agentd_enable="YES" |
Start the Zabbix agent service :
1 |
service zabbix_agentd start |
And check that everything went fine :
1 |
tail /var/log/zabbix/zabbix_agentd.log |
Then you can use the web UI to configure everything !
Thks, it’s a good job.
login and password zabbix ? i try user: admin pass : zabbix not sign in and user:salt pass:MyMonitoringPassword not sign in
login: Admin
pass: zabbix
Thanks !
Nice tutor, keep sharing for good things
thank you for sharing! i cant install zabbix, what should i do ?
can zabbix be operated by only one person?
Thanks so much, for this post. And the previous post on nginx, php-fpm.