There are several ways to download the source of Zabbix. You can get the source code from a SVN repository, which will be discussed in Appendix B, however for this installation procedure it is suggested to download version 1.8.1 from the Zabbix homepage; http://www.zabbix.com/. While it should be possible to use latest stable version, using 1.8.1 will allow to follow instructions more closely. Go to the Download section and grab the compressed source package. Usually only the latest stable version is available on the downloads page, so you might have to browse the source archives, though do not take development or beta version, which might be available.
To ease further references, it is suggested that you choose a directory to work in, for example, ~/zabbix
(~
being your home directory). Download the archive into this directory.
Once the archive has finished downloading, open a terminal and extract it:
$ cd ~/zabbix; tar -zxvf zabbix-1.8.1.tar.gz
It is suggested that you install the requirements and compile Zabbix with external functionality right away so that you don't have to recompile as we progress.
For the purpose of this book, we will compile Zabbix with server, agent, MySQL, curl, SNMP, and IPMI support.
To continue, enter the following in the terminal:
$ cd zabbix-1.8.1
$ ./configure --enable-server --with-mysql --with-net-snmp --with-libcurl --with-openipmi --enable-agent
In the end, a summary of compiled components is printed. Verify that you have the following enabled:
Enable server: yes With database: MySQL WEB Monitoring via: cURL SNMP: net-snmp IPMI: openipmi Enable agent: yes
If configure completes successfully, it's all good. If it fails, check the error messages printed in the console and verify that all prerequisites are installed. A file named config.log
might provide more detail on the errors. If you can't find out what's wrong, check Appendix A, Troubleshooting, which lists some common compilation problems.
To actually compile Zabbix, issue the next command.
$ make
You can get a cup of tea, but don't expect to have much time - Zabbix compilation doesn't take too long, even an old 350 MHz Pentium II compiles it in approximately five minutes. After the make
process has finished, check the last lines for any error messages. If there are none, congratulations, you have successfully compiled Zabbix.
Now we should install it. Despite the output of configure
and many How Tos suggesting so, do not run make install
. It unnecessarily complicates package management and can lead to weird problems in future. Instead, you should create proper packages for your distribution. This process is package system specific, learning them all would be cumbersome, but there's a universal solution - software named CheckInstall (http://www.asic-linux.com.mx/~izto/checkinstall/). Packages should be available for most distributions, and it supports the creation of Slackware, RPM, and Debian packages.
To create a proper Zabbix package make sure that CheckInstall is installed and execute as root:
# checkinstall --nodoc --install=yes -y
This will create and install a package that you will later be able to remove using your system's package management tool. The created package's location depends on your distribution for Slackware, it's the directory you executed CheckInstall from, for RPM-based distributions it is usually /usr/src/packages/RPMS/<architecture>
.
After compilation, we have to configure some basic parameters for the server and agent. There are example configuration files provided with the Zabbix package, so let's use those. Again, as root execute:
# mkdir /etc/zabbix
Zabbix sourceinitial configuration# cp misc/conf/{zabbix_server.conf,zabbix_agentd.conf} /etc/zabbix
To configure the Zabbix agent, we don't have to do anything. The default configuration will do just fine for now. That was easy, right?
For the server we will need to make some changes. Open /etc/zabbix/zabbix_server.conf
in your favorite editor (you will need to run it as root) and find the following entries in the file:
DBName
DBUser
DBPassword
DBName
should be zabbix
by default, and we can leave it as is. DBUser
is set to root
, and we don't like that, so let's change it to zabbix
. For DBPassword
, choose any password. You won't have to remember it, so be creative.
After we insert a password into this configuration file, we should restrict the file's permissions so that the password is not that easy to obtain. This is done as shown below:
# chmod 400 /etc/zabbix/zabbix_server.conf
# chown zabbix /etc/zabbix/zabbix_server.conf
For the Zabbix server to store data, we have to create a database. Start a MySQL client.
$ mysql -u root -p
Enter the root user password for MySQL (you would have set this during the installation of MySQL, or the password could be something that is the default for your distribution). If you do not know the password, you can try omitting -p
. This switch will tell the client to attempt to connect with an empty password.
Now let's create the database. Add the user that Zabbix would connect to the database as, and grant necessary permissions to this user:
mysql> create database zabbix character set utf 8; Query OK, 1 row affected (0.01 sec) mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'mycreativepassword'; Query OK, 0 rows affected (0.12 sec)
Use the same password you set in zabbix_server.conf
file instead of mycreativepassword
.
Quit the MySQL client by entering the following command:
mysql> quit
Let's populate the newly-created database with Zabbix schema and initial data.
$ mysql -u zabbix -p zabbix < create/schema/mysql.sql
Zabbix sourcedatabase, populating$ mysql -u zabbix -p zabbix < create/data/data.sql
Next, let's insert the images to be used in network maps. While these images are not required for basic functionality, we'll want to create some nice looking network maps later.
$ mysql -u zabbix -p zabbix < create/data/images_mysql.sql
All three importing processes should complete without any messages. If there are any errors, review the messages, fix the issue, and retry the failed operation. Note, if the import is interrupted in the middle of the process, you might have to clear the database easiest way to do that is deleting the database by typing:
mysql> drop database zabbix;
Query OK, 0 rows affected (0.00 sec)
Be careful not to delete any database with important information! After deleting the Zabbix database recreate it and assign the correct user permissions, as indicated above.
By now we should have Zabbix server and agent installed, and ready to start.
You should never start the Zabbix server or agent as root, which is common sense for most daemon processes, so let's create user to run these processes. You can use tools provided by distribution, or the most widely available command - useradd
, which we need to execute as root:
# useradd -m -s /bin/bash zabbix
This will create user named zabbix
with a home directory in the default location (usually /home/zabbix
) and shell at /bin/bash
, which will be needed for advanced parameters later on.
For the first startup of both server and agent let's try the direct approach as root execute:
# /usr/local/sbin/zabbix_agentd
This will start the Zabbix agent daemon, which should start up silently and daemonize. If the above command produces errors, resolve those before proceeding. If it succeeds, continue by starting the Zabbix server.
# /usr/local/sbin/zabbix_server
Note
We are using zabbix_agentd
that runs as a daemon. While there's also the zabbix_agent
executable that provides an option to be run within inetd
, it does not support active items and in most cases will have worse performance than the agent daemon.
If you decided to install distribution packages of Zabbix above binaries will most likely be located in a different directory, but they should be in your path so try running the agent and server without specifying a directory name.
Note
The latest versions of Zabbix, including 1.8, automatically drop root privileges on startup and run as the zabbix
user.
While it's nice to have Zabbix running, that's hardly a process one expects to do manually upon each system boot, so the server and agent should be added to your system's startup sequence. This is fairly distribution specific, so all possible variations can't be discussed here. Instead, examples for SUSE Linux Enterprise Server and Slackware startup scripts will be provided.