Zabbix how to

installation

Download and install postgresql in database server

Configure postgresql

psql -U postgres

CREATE USER zabbix WITH PASSWORD 'zabbix';
CREATE DATABASE zabbix OWNER zabbix;

cd /usr/share/zabbix/database/postgresql

psql -U zabbix -d zabbix -f schema.sql
psql -U zabbix -d zabbix -f images.sql
psql -U zabbix -d zabbix -f data.sql

local   zabbix      zabbix                            md5

emerge package

cat >> /etc/portage/package.use <<"EOF"
net-analyzer/zabbix server snmp ssh -mysql -oracle postgres frontend agent openipmi libxml2
EOF
emerge -av zabbix

Configure fpm-php

vi /etc/php/fpm-php5.5/php.ini

max_execution_time = 300
max_input_time = 300
post_max_size = 16M

Configure zabbix_server

# sed '/^#/d;/^$/d' /etc/zabbix/zabbix_server.conf
 LogFile=/var/log/zabbix/zabbix_server.log
 LogFileSize=128
 PidFile=/run/zabbix/zabbix_server.pid
 DBHost=
 DBName=zabbix
 DBUser=zabbix
 DBPassword=zabbix
  SNMPTrapperFile=/tmp/zabbix_traps.tmp
   StartSNMPTrapper=1
   AlertScriptsPath=/var/lib/zabbix/alertscripts
   ExternalScripts=/var/lib/zabbix/externalscripts
   CacheSize=128M
   HistoryCacheSize=128M
   TrendCacheSize=64M
   HistoryTextCacheSize=128M
   Timeout=30

Run on Nginx

/opt/nginx/conf/zabbix.conf

server {
        listen 8080;
        server_name localhost;
        index index.html index.htm index.php;
        root /usr/share/webapps/zabbix/2.2.5/htdocs;
        access_log off;
        error_log /tmp/xxxx.log;
location ~ \.php {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME /usr/share/webapps/zabbix/2.2.5/htdocs$fastcgi_script_name;
        fastcgi_param QUERY_STRING $query_string;
        include fastcgi_params;
        } 
}

Start Servers

/etc/init.d/php-fpm start
/etc/init.d/zabbix-server start
/etc/init.d/nginx reload

http://127.0.0.1:8080

Graph report

download zabbix-dynamic-pdf-report module

git clone https://github.com/spy86/Zabbix_
mkdir /usr/share/webapps/zabbix/2.2.5/htdocs/report
cp -r /tmp/Zabbix_/zabbix-dynamic-pdf-report/* /usr/share/webapps/zabbix/2.2.5/htdocs/report/

vi /usr/share/webapps/zabbix/2.2.5/htdocs/report/config.inc.php

   1 <?php
   2 //CONFIGURABLE
   3 # zabbix server info(user must have API access)
   4 $z_server       = 'http://127.0.0.1:8080/';
   5 $z_user         = 'Admin';
   6 $z_pass         = 'zabbix';
   7 # Temporary directory for storing pdf data and graphs - must exist
   8 $z_tmp_path     = '/tmp';
   9 # Directory for storing PDF reports
  10 $pdf_report_dir = './reports';
  11 # Root URL to reports
  12 $pdf_report_url = $z_server ."/report/reports";
  13 # paper settings
  14 $paper_format   = 'A4'; // formats supported: 4A0, 2A0, A0 -> A10, B0 -> B10,
  15 C0 -> C10, RA0 -> RA4, SRA0 -> SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO
  16 $paper_orientation = 'portrait'; // formats supported: portrait / landscape
  17 # time zone - see http://php.net/manual/en/timezones.php
  18 $timezone       = 'Asia/Shanghai';
  19 # Logo used in PDF - may be empty
  20 # TODO: Specify image size!
  21 $pdf_logo       = './images/zabbix.png';
  22 $company_name   = 'Zabbix';
  23 
  24 //DO NOT CHANGE BELOW THIS LINE
  25 $z_tmp_cookies  = "/tmp/";
  26 $z_url_index    = $z_server ."index.php";
  27 $z_url_graph    = $z_server ."chart2.php";
  28 $z_url_api      = $z_server ."api_jsonrpc.php";
  29 $z_login_data   = "name=" .$z_user ."&password=" .$z_pass
  30 ."&autologin=1&enter=Sign+in";
  31 ?>

http://127.0.0.1:8080/report/

TroubleShooting

Fix Chinese language support

copy an chinese font to $ZABBIX_ROOT

cd /usr/share/webapps/zabbix/2.2.5/htdocs
cp -v /usr/share/fonts/TTF/uming.ttf fonts/
sed -i 's/DejaVuSans/uming/g' include/defines.inc.php 

http://www.linuxworms.in/2013/06/installing-zabbix-with-postgresql-in.html

http://wikibaseofknowledge.blogspot.com/2014/09/module-to-generate-pdf-reports-in-zabbix.html

https://www.zabbix.com/forum/showthread.php?t=24998&page=16