Differences between revisions 2 and 25 (spanning 23 versions)
Revision 2 as of 2008-01-18 15:09:17
Size: 405
Comment: Zabbix page filled in
Revision 25 as of 2022-01-16 11:05:47
Size: 10019
Comment: more Zabbix proxy instructions
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Zabbix is a host and network monitoring system. http://www.zabbix.com

Its most relevant features are:

 * Web-based monitoring and administration
 * Performance, security and service availability checks
 * Distributed monitoring, up to thousands of nodes
 * Autodiscovery
 * Charting, trending, SLA reporting
 * Sending alerts via email, SMS and Jabber
 * Data stored in a relational database
#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~
----
= Zabbix and Debian =

<<TableOfContents>>

== Overview ==
Zabbix is a server/client [[SystemMonitoring|monitoring system]] and it's also packaged in Debian. Its most relevant features are:

 * web-based monitoring and administration
 * agentless monitoring
 * performance, security and service availability checks
 * distributed monitoring, up to thousands of nodes
 * auto-discovery
 * charting, trending, SLA reporting
 * sending alerts via e-mail, SMS and Jabber
 * data stored in a relational database

== Documentation and informations ==

 * {{{/usr/share/doc/zabbix*}}} (most notably {{{README.Debian}}} and {{{NEWS.Debian}}} files as every Debian package)
 * [[https://www.zabbix.com/documentation/current/manual|Zabbix official documentation]]

== Debian packages ==
Debian splits Zabbix functionalities in these packages:

 * Zabbix client
  * [[DebianPkg:zabbix-agent]]
  * [[DebianPkg:zabbix-cli]]
  * [[DebianPkg:zabbix-frontend-php]]
 * Zabbix server
  * [[DebianPkg:zabbix-server-mysql]] for MySQL/MariaDB
  * [[DebianPkg:zabbix-server-pgsql]] for PostgreSQL
 * Proxy and gateways
  * [[DebianPkg:zabbix-proxy-mysql]]
  * [[DebianPkg:zabbix-proxy-pgsql]]
  * [[DebianPkg:zabbix-proxy-sqlite3]]
  * [[DebianPkg:zabbix-java-gateway]]

Look at the related descriptions in order to understand which of these packages fit your needs.

Most of these Zabbix packages are available in Debian jessie, jessie-backports, stretch, stretch-backports, bullseye and above.

== Installation ==
The following instructions will try to be as generic as possible and should work in Debian jessie, jessie-backports, stretch, bullseye and above.

=== Installing Zabbix server using MySQL/MariaDB ===
You should already have a MySQL/MariaDB server. If you have not, first install the [[DebianPkg:default-mysql-server]] package.

All the below commands should be run as root.

Install the [[DebianPkg:zabbix-server-mysql]] package.

Now open a MySQL shell as administrator:

{{{
mysql
}}}

If it does not work try:

{{{
mysql --defaults-extra-file=/etc/mysql/debian.cnf
}}}

Create a new database (e.g. "zabbix"), create a related MySQL/MariaDB username (e.g. "zabbix") with a strong password, and grant permissions to that username:

{{{
mysql
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'here-an-example-password-but-please-change-me';
GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
quit
}}}

Do not forget the password you just entered for your Zabbix username because you have to write it down also in the configuration:

{{{
nano /etc/zabbix/zabbix_server.conf
}}}

{{{
DBName=zabbix
DBUser=zabbix
DBPassword=here-an-example-password-but-please-change-me
}}}

Now it's the time to populate your Zabbix database.

Decompress the SQL files provided in {{{/usr/share}}} and import them:

{{{
cd /usr/share/zabbix-server-mysql
zcat schema.sql.gz images.sql.gz data.sql.gz | mysql zabbix
}}}

NOTE: If you see "ERROR 1071 (42000) at line 348: Specified key was too long; max key length is 3072 bytes" it means you have not followed the guide. Drop the database and create it again following the above instructions.

NOTE: If you are in Debian buster, the table creation script will fail with a "row size error". As a workaround, temporarily disable INNODB strict mode, appending `SET global innodb_strict_mode='OFF'` in the top of the SQL file.

NOTE: It may need a couple of minutes to create and populate all the ~113 MySQL tables in your {{{zabbix}}} database. In the meanwhile, you can play a Debian [[Game|game]].

NOTE: For Buster, fix the table columns and re-enable INNODB strict mode:

{{{
ALTER TABLE `host_inventory` MODIFY `name` varchar(128) default '' not null, modify `alias` varchar(128) default '' not null, modify `os` varchar(128) default '' not null, modify `os_short` varchar(128) default '' not null;
}}}

Now be sure to have the service enabled at startup, and restart it:

{{{
systemctl enable zabbix-server
systemctl restart zabbix-server
}}}

== Installing Zabbix PHP frontend ==

After installing the server, you can install the [[DebianPkg:zabbix-frontend-php]] package that provides an user interface to administer your Zabbix instance. You can see some [[https://screenshots.debian.net/package/zabbix-frontend-php|Zabbix frontend screenshots]].

If you use the [[Apache]] HTTP server and you just want to use the default Zabbix configuration, just remember to specify a PHP {{{date.timezone}}} in {{{/etc/apache2/conf-available/zabbix-frontend-php.conf}}}. If you want some additional PHP restrictions, you may want to set the {{{open_basedir}}} restriction to {{{/usr/share/zabbix/:/var/lib/zabbix:/etc/zabbix:/usr/share/javascript}}}.

Then you can enable that Apache configuration and you can reload the webserver:

{{{
a2enconf zabbix-frontend-php
service apache2 reload
}}}

At this point you can follow the installation instructions for your {{{http://your-host/zabbix}}}. It may asks you of populating manually the {{{/etc/zabbix/zabbix.conf.php}}} configuration file. After that you should see something as «Congratulations! You have successfully installed Zabbix frontend. Configuration file "/etc/zabbix/zabbix.conf.php" created.» and you can do the login into your Zabbix frontend.

Anyway you can just create the file {{{/etc/zabbix/zabbix.conf.php}}} manually with the following minimal content:

{{{
<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'here-an-example-password-but-please-change-me';

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'My Server Name';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
}}}

Now try visiting again your {{{http://your-host/zabbix}}} page, and you should see a login page instead of the installation process.

The default username/password credentials for you Zabbix frontend will be:

 * {{{Admin}}}
 * {{{zabbix}}}

''Note: '''never expose your Zabbix frontend to the world before changing these default credentials!''' You should quickly change your password visiting the {{{/profile.php}}} page of your Zabbix frontend.''

Have fun with your Zabbix frontend! Now you should know what you have to do with Zabbix. In any case you can explore the [[https://www.zabbix.com/documentation/|official documentation]].

== Securing Zabbix PHP frontend ==
You may want to restrict the directories allowed to be read by your Zabbix PHP frontend, setting a [[https://secure.php.net/manual/en/ini.core.php#ini.open-basedir|PHP open_basedir directive]].

As example, put this in your {{{/etc/apache2/conf-available/zabbix-frontend-php.conf}}}, near the other {{{php_value}}}s:

{{{
php_admin_value open_basedir /usr/share/zabbix/:/var/lib/zabbix:/etc/zabbix:/usr/share/javascript:/usr/share/fonts
}}}

== Installing a Zabbix proxy ==

A Zabbix proxy is useful for example when you have a LAN with some hosts to be monitored, but your Zabbix server is not in the same network.

Create a new UTF8 binary database with a dedicated username (choose a good password):

{{{
mysql
CREATE DATABASE zabbix_proxy CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'zabbix_proxy'@'localhost' IDENTIFIED BY 'here-an-example-password-but-please-change-me';
GRANT ALL PRIVILEGES ON `zabbix_proxy`.* TO 'zabbix_proxy'@'localhost';
FLUSH PRIVILEGES;
quit
}}}

Do not forget the password you just entered for your Zabbix username because you have to write it down also in the configuration:

{{{
nano /etc/zabbix/zabbix_proxy.conf
}}}

{{{
DBName=zabbix_proxy
DBUser=zabbix_proxy
DBPassword=here-an-example-password-but-please-change-me
}}}

Now decompress the SQL files provided in {{{/usr/share}}} and import them:

{{{
zcat /usr/share/zabbix-proxy-mysql/schema.sql.gz | mysql zabbix_proxy
}}}

NOTE: If you see "ERROR 1071 (42000) at line 348: Specified key was too long; max key length is 3072 bytes" or similar, it means you have not followed the guide. Drop the database and create it again following the above instructions.

NOTE: It may need a couple of minutes to create and populate all the ~166 MySQL tables in your {{{zabbix}}} database. In the meanwhile, you can play a Debian [[Game|game]].

Now go in your Zabbix web interface and add your Zabbix proxy:

https://example.com/zabbix.php?action=proxy.edit

Now be sure to have the service enabled at startup, and restart it:

{{{
systemctl enable zabbix-proxy
systemctl restart zabbix-proxy
}}}

More documentation here:

* https://www.zabbix.com/documentation/current/en/manual/installation/install_from_packages/debian_ubuntu

== Installing a Zabbix agent ==

To monitor a Debian host, you can install the [[DebianPkg:zabbix-agent]] package on them.

In the default passive mode, the Zabbix server (or a Zabbix proxy) connects to the agent to collect metrics.

Edit {{{/etc/zabbix/zabbix_agentd.conf}}} to allow access to the Zabbix server (or proxy) by specifying it's IP address or domain name in the `Server` option:

{{{
Server=YOUR_ZABBIX_SERVER_IP_HERE
}}}

The Zabbix agent listens for requests from the Zabbix server on TCP port 10050. Add required rules to the agent host firewall. For example:

{{{
$IPT -A INPUT -i eth0 -p tcp --dport 10050 -j ACCEPT
}}}

Restart the agent:

{{{
service zabbix-agent restart
}}}


(These instructions are released under the CC BY-SA 4.0 / GNU GFL / GNU GPL v3+ at your opinion by Valerio Bozzolan - 2018 and [[https://wiki.debian.org/Zabbix?action=info|contributors]])

Translation(s): none


Zabbix and Debian

Overview

Zabbix is a server/client monitoring system and it's also packaged in Debian. Its most relevant features are:

  • web-based monitoring and administration
  • agentless monitoring
  • performance, security and service availability checks
  • distributed monitoring, up to thousands of nodes
  • auto-discovery
  • charting, trending, SLA reporting
  • sending alerts via e-mail, SMS and Jabber
  • data stored in a relational database

Documentation and informations

Debian packages

Debian splits Zabbix functionalities in these packages:

Look at the related descriptions in order to understand which of these packages fit your needs.

Most of these Zabbix packages are available in Debian jessie, jessie-backports, stretch, stretch-backports, bullseye and above.

Installation

The following instructions will try to be as generic as possible and should work in Debian jessie, jessie-backports, stretch, bullseye and above.

Installing Zabbix server using MySQL/MariaDB

You should already have a MySQL/MariaDB server. If you have not, first install the default-mysql-server package.

All the below commands should be run as root.

Install the zabbix-server-mysql package.

Now open a MySQL shell as administrator:

mysql

If it does not work try:

mysql --defaults-extra-file=/etc/mysql/debian.cnf

Create a new database (e.g. "zabbix"), create a related MySQL/MariaDB username (e.g. "zabbix") with a strong password, and grant permissions to that username:

mysql
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'here-an-example-password-but-please-change-me';
GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
quit

Do not forget the password you just entered for your Zabbix username because you have to write it down also in the configuration:

nano /etc/zabbix/zabbix_server.conf

DBName=zabbix
DBUser=zabbix
DBPassword=here-an-example-password-but-please-change-me

Now it's the time to populate your Zabbix database.

Decompress the SQL files provided in /usr/share and import them:

cd /usr/share/zabbix-server-mysql
zcat schema.sql.gz images.sql.gz data.sql.gz | mysql zabbix

NOTE: If you see "ERROR 1071 (42000) at line 348: Specified key was too long; max key length is 3072 bytes" it means you have not followed the guide. Drop the database and create it again following the above instructions.

NOTE: If you are in Debian buster, the table creation script will fail with a "row size error". As a workaround, temporarily disable INNODB strict mode, appending SET global innodb_strict_mode='OFF' in the top of the SQL file.

NOTE: It may need a couple of minutes to create and populate all the ~113 MySQL tables in your zabbix database. In the meanwhile, you can play a Debian game.

NOTE: For Buster, fix the table columns and re-enable INNODB strict mode:

ALTER TABLE `host_inventory` MODIFY `name` varchar(128) default '' not null, modify `alias` varchar(128) default '' not null, modify `os` varchar(128) default '' not null, modify `os_short` varchar(128) default '' not null;

Now be sure to have the service enabled at startup, and restart it:

systemctl enable  zabbix-server
systemctl restart zabbix-server

Installing Zabbix PHP frontend

After installing the server, you can install the zabbix-frontend-php package that provides an user interface to administer your Zabbix instance. You can see some Zabbix frontend screenshots.

If you use the Apache HTTP server and you just want to use the default Zabbix configuration, just remember to specify a PHP date.timezone in /etc/apache2/conf-available/zabbix-frontend-php.conf. If you want some additional PHP restrictions, you may want to set the open_basedir restriction to /usr/share/zabbix/:/var/lib/zabbix:/etc/zabbix:/usr/share/javascript.

Then you can enable that Apache configuration and you can reload the webserver:

a2enconf zabbix-frontend-php
service apache2 reload

At this point you can follow the installation instructions for your http://your-host/zabbix. It may asks you of populating manually the /etc/zabbix/zabbix.conf.php configuration file. After that you should see something as «Congratulations! You have successfully installed Zabbix frontend. Configuration file "/etc/zabbix/zabbix.conf.php" created.» and you can do the login into your Zabbix frontend.

Anyway you can just create the file /etc/zabbix/zabbix.conf.php manually with the following minimal content:

<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE']     = 'MYSQL';
$DB['SERVER']   = 'localhost';
$DB['PORT']     = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER']     = 'zabbix';
$DB['PASSWORD'] = 'here-an-example-password-but-please-change-me';

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'My Server Name';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;

Now try visiting again your http://your-host/zabbix page, and you should see a login page instead of the installation process.

The default username/password credentials for you Zabbix frontend will be:

  • Admin

  • zabbix

Note: never expose your Zabbix frontend to the world before changing these default credentials! You should quickly change your password visiting the /profile.php page of your Zabbix frontend.

Have fun with your Zabbix frontend! Now you should know what you have to do with Zabbix. In any case you can explore the official documentation.

Securing Zabbix PHP frontend

You may want to restrict the directories allowed to be read by your Zabbix PHP frontend, setting a PHP open_basedir directive.

As example, put this in your /etc/apache2/conf-available/zabbix-frontend-php.conf, near the other php_values:

php_admin_value open_basedir /usr/share/zabbix/:/var/lib/zabbix:/etc/zabbix:/usr/share/javascript:/usr/share/fonts

Installing a Zabbix proxy

A Zabbix proxy is useful for example when you have a LAN with some hosts to be monitored, but your Zabbix server is not in the same network.

Create a new UTF8 binary database with a dedicated username (choose a good password):

mysql
CREATE DATABASE zabbix_proxy CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'zabbix_proxy'@'localhost' IDENTIFIED BY 'here-an-example-password-but-please-change-me';
GRANT ALL PRIVILEGES ON `zabbix_proxy`.* TO 'zabbix_proxy'@'localhost';
FLUSH PRIVILEGES;
quit

Do not forget the password you just entered for your Zabbix username because you have to write it down also in the configuration:

nano /etc/zabbix/zabbix_proxy.conf

DBName=zabbix_proxy
DBUser=zabbix_proxy
DBPassword=here-an-example-password-but-please-change-me

Now decompress the SQL files provided in /usr/share and import them:

zcat /usr/share/zabbix-proxy-mysql/schema.sql.gz | mysql zabbix_proxy

NOTE: If you see "ERROR 1071 (42000) at line 348: Specified key was too long; max key length is 3072 bytes" or similar, it means you have not followed the guide. Drop the database and create it again following the above instructions.

NOTE: It may need a couple of minutes to create and populate all the ~166 MySQL tables in your zabbix database. In the meanwhile, you can play a Debian game.

Now go in your Zabbix web interface and add your Zabbix proxy:

https://example.com/zabbix.php?action=proxy.edit

Now be sure to have the service enabled at startup, and restart it:

systemctl enable  zabbix-proxy
systemctl restart zabbix-proxy

More documentation here:

* https://www.zabbix.com/documentation/current/en/manual/installation/install_from_packages/debian_ubuntu

Installing a Zabbix agent

To monitor a Debian host, you can install the zabbix-agent package on them.

In the default passive mode, the Zabbix server (or a Zabbix proxy) connects to the agent to collect metrics.

Edit /etc/zabbix/zabbix_agentd.conf to allow access to the Zabbix server (or proxy) by specifying it's IP address or domain name in the Server option:

Server=YOUR_ZABBIX_SERVER_IP_HERE

The Zabbix agent listens for requests from the Zabbix server on TCP port 10050. Add required rules to the agent host firewall. For example:

$IPT -A INPUT -i eth0 -p tcp --dport 10050 -j ACCEPT

Restart the agent:

service zabbix-agent restart

(These instructions are released under the CC BY-SA 4.0 / GNU GFL / GNU GPL v3+ at your opinion by Valerio Bozzolan - 2018 and contributors)