Zabbix

argos_zabbix.png
  1. Official Zabbix JSON-RPC API
  2. Zabbix Python API from gescheit@github for automation of web-frontend tasks
  3. First version of 'zabbix_sender' written in Python
  4. Python module for sending metrics to Zabbix server (also on github: https://github.com/pistolero/zbxsend) The documentation is sufficient although only beeing two lines of code in the README.

Zabbix 2.0 Installation On CentOS 6

The packages are required:

# Install packages
yum install zabbix20-server-pgsql.x86_64 zabbix20-web-pgsql.noarch
yum install postgresql-server.x86_64
yum install postgresql.x86_64

# setup PostgreSQL
sudo service postgresql initdb

# Active services at startup
sudo chkconfig postgresql on
sudo chkconfig httpd on
sudo chkconfig zabbix-server on

# Start services for first usage
sudo service postgresql restart
sudo service httpd restart
sudo service zabbix-server restart

Log file locations for trouble-shooting:
  1. zabbix : /var/log/zabbix/zabbix_server.log
  2. PostgreSQL: /var/lib/pgsql/data/pg_log/
Server TCP listening ports:
  1. Http: TCP port 80
  2. PostgreSQL: TCP port 5432
  3. Zabbix-server TCP port 10051

Configure PostgreSQL

/var/lib/pgsql/data/pg_hba.conf

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
local   zabbix      zabbix                            md5
host    zabbix      zabbix      127.0.0.1/32          md5
host    zabbix      zabbix      ::1/128               md5
sudo service postgresql restart
$ sudo -u postgres psql
psql (8.4.13)
Geben Sie \xBBhelp\xAB f\xFCr Hilfe ein.

postgres=# CREATE USER zabbix with PASSWORD 'top_secret';
CREATE ROLE
postgres=# CREATE DATABASE zabbix OWNER zabbix;
CREATE DATABASE
postgres=# \q

Initialize Zabbix DB

$ pwd
/usr/share/zabbix-postgresql
$ ls
data.sql  images.sql  schema.sql  upgrades
$ psql -U zabbix                                
Passwort f\xFCr Benutzer zabbix: 
psql (8.4.13)
Geben Sie \xBBhelp\xAB f\xFCr Hilfe ein.

zabbix=> \i schema.sql
zabbix=> \i images.sql
zabbix=> \i data.sql
zabbix=> \q

Note: Import images.sql before data.sql

$ pwd
/etc/zabbix
$ sudo vim zabbix_server.conf 

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=top_secret

#Comment out DB socket or provide the correct one!
#DBSocket=/var/lib/mysql/mysql.sock

# Enable trapper!
ListenPort=10051

sudo service zabbix-server restart

Setup Zabbix Web Appliation

  1. Setting up zabbix web frontend at http://127.0.0.1/zabbix/.
  2. CentOS 6 contains the PHP settings in /etc/php.ini.
If, for some reason, you fail to login with the default admin password, the following steps might help:

# 1) Stop zabbix-server and httpd
sudo service zabbix-server stop
sudo service httpd stop

# 2) Delete the zabbix DB
$ sudo -u postgres psql 
psql (8.4.13)
Type "help" for help.

postgres= DROP DATABASE zabbix;

# 3) Create database zabbix and initialize it!

# 4) Remove existing zabbix front end configuration
# pwd
/etc/zabbix/web
# mv zabbix.conf.php zabbix.conf.php.orig

# 5) Start zabbix-server and httpd
sudo service zabbix-server start
sudo service httpd start

# 6) Try again the Zabbix web frontend!

Customize Zabbix Web Frontend

Decrease Minimum Graph Period

According to the Zabbix 2.0 web interface documentation, it is possible to set the minimum graph period 'ZBX_MIN_PERIOD'. In practice, this feature is broken.

Updated method
  1. Check the version of zabbix. At the time of writing is 2.0.15
  2. Check https://support.zabbix.com/browse/ZBX-2517 for new available patches
  3. Download patch and copy in /usr/share
  4. Patch using brain and example below
[argos@dx-lgsw share]$ sudo patch -p0 --dry-run < zabbix-2.0.7-zoom.patch
patching file zabbix/include/defines.inc.php
patching file zabbix/js/functions.js
Hunk #1 succeeded at 884 (offset -3 lines).
Hunk #2 succeeded at 899 (offset -3 lines).
Hunk #3 succeeded at 913 (offset -3 lines).
patching file zabbix/js/gtlc.js
Hunk #1 succeeded at 312 (offset 3 lines).
Hunk #2 succeeded at 1127 (offset 3 lines).
Hunk #3 succeeded at 1170 (offset 3 lines).
Hunk #4 succeeded at 1697 (offset 4 lines).
[argos@dx-lgsw share]$ sudo patch -p0  < zabbix-2.0.7-zoom.patch
Old method

In order to have a 10 minute minimum period, it is necessary to patch /usr/share/zabbix/js/gtlc.js

--- gtlc.js   2013-03-01 13:32:01.751526666 +0100
+++ gtlc.js.orig   2013-03-01 12:17:25.473526124 +0100
@@ -71,7 +71,7 @@
                now = parseInt(nowDate.getTime() / 1000);
 
             if (!isset('period', obj.time)) {
-               obj.time.period = 600;
+               obj.time.period = 3600;
             }
             if (!isset('endtime', obj.time)) {
                obj.time.endtime = now;
@@ -272,7 +272,7 @@
 
    objectReset: function() {
       var usertime = 1600000000,
-         period = 600,
+         period = 3600,
          stime = 201911051255;
 
       this.timeline.period(period);
@@ -309,7 +309,7 @@
    _period:   null,   // selected period
    _now:      false,   // state if time is set to NOW
    _isNow:      false,   // state if time is set to NOW (for outside usage)
-   minperiod:   600,   // minimal allowed period
+   minperiod:   3600,   // minimal allowed period
    maxperiod:   null,   // max period in seconds
 
    initialize: function($super, period, starttime, usertime, endtime, maximumPeriod, isNow) {
@@ -1121,7 +1121,7 @@
    appendZoomLinks: function() {
       var timeline = timeControl.timeline.endtime() - timeControl.timeline.starttime();
       var caption = '';
-      var zooms = [600, 3600, 7200, 10800, 21600, 43200, 86400, 604800, 1209600, 2592000, 7776000, 15552000, 31536000];
+      var zooms = [3600, 7200, 10800, 21600, 43200, 86400, 604800, 1209600, 2592000, 7776000, 15552000, 31536000];
       var links = 0;
 
       for (var key in zooms) {
@@ -1164,7 +1164,7 @@
    appendNavLinks: function() {
       var timeline = timeControl.timeline.endtime() - timeControl.timeline.starttime();
       var caption = '';
-      var moves = [600, 3600, 43200, 86400, 604800, 2592000, 15552000, 31536000];
+      var moves = [3600, 43200, 86400, 604800, 2592000, 15552000, 31536000];
       var links = 0;
 
       var tmp_laquo = document.createElement('span');

This patches requires the setting of 'ZBX_MIN_PERIOD' to 300.

The task is using the following logo as the Zabbix logo: argos_zabbix.png
# 1) Copy custom logo to zabbix folder!
$ pwd
/usr/share/zabbix/images/general
sudo cp -v /path/to/argos_zabbix.png .
# 2) Patch zabbix style!
$ pwd
/usr/share/zabbix/styles
$ diff -du icon.css icon.css.orig 
--- icon.css    2013-03-01 15:03:41.272526740 +0100
+++ icon.css.orig       2013-03-01 15:03:16.216526740 +0100
@@ -20,8 +20,8 @@
 /********* DIV IMG *********/
 .zabbix_logo{
        height: 31px;
-       width: 236px;
-       background: #FFFFFF url('../images/general/argos_zabbix.png') no-repeat;
+       width: 118px;
+       background: #FFFFFF url('../images/general/zabbix.png') no-repeat;
        cursor: pointer;
 }
 

Backup of Zabbix Configuration

Zabbix supports exporting and importing of its configuration, e.g. the host configuration. The attachment section of this wiki page contains backups of zabbix configurations.

Custom scripts are necessary for telemetry data back-up.

Zabbix Database Size

The following curse provides the used database and table size:

$ psql -U zabbix zabbix
Passwort f\xFCr Benutzer zabbix: 
psql (8.4.13)
Geben Sie \xBBhelp\xAB f\xFCr Hilfe ein.

zabbix=> SELECT pg_size_pretty(pg_database_size('zabbix')) As fulldbsize;
 fulldbsize 
------------
 90 MB
(1 Zeile)

zabbix=> SELECT pg_size_pretty(pg_total_relation_size('history')) As fulltblsize, pg_size_pretty(pg_relation_size('history')) As justthetblsize;
 fulltblsize | justthetblsize 
-------------+----------------
 78 MB       | 40 MB
(1 Zeile)

Topic revision: r2 - 01 Aug 2018, AndrewColson
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback