+-------------+ +-------------+ +-------------+
| DB Server | | ZBServer | | ZBWeb |
|172.16.200.50| |172.16.200.60| |172.16.200.70|
+-------------+ +-------------+ +-------------+
↑ ↑ ↑ ↑ ↑ ↑
| | | | | |
| +------------------+ +-------------------+ |
+-----------------------------------------------+
Instalação PostgreSQL:Instalação no CentOS
# vim /var/lib/pgsql/data/pg_hba.conf [...] # Zabbix host zabbix zabbix 172.16.200.0/24 md5 [...]
postgres=# CREATE DATABASE zabbix; CREATE DATABASE postgres=# CREATE ROLE zabbix LOGIN; CREATE ROLE postgres=# \password zabbix Digite nova senha: Digite-a novamente: postgres=# \q
Testando a conexão
# systemctl restart postgresql.service # psql -U zabbix zabbix Senha para usuário zabbix: psql (9.2.10) Digite "help" para ajuda. zabbix=> \q
Adicionando o repositório Epel
# yum install epel-release
Instação do pacotes
# yum install zabbix22-server-pgsql zabbix22-server zabbix22 zabbix22-dbfiles-pgsql zabbix22-agent
Configuração do firewallD
# firewall-cmd --add-rich-rule 'rule family="ipv4" source address="172.16.200.0/24" port port="10051" protocol="tcp" accept' --permanent accept' --permanent # firewall-cmd --add-rich-rule 'rule family="ipv4" source address="172.16.200.0/24" port port="10051" protocol="udp" accept' --permanent success
# firewall-cmd --reload
success
Configuração da comunicação com o DataBase
# vim /etc/zabbix_server.conf [...] DBHost=pgsql.rascunhos.wiki.br [...] DBName=zabbix [...] DBUser=zabbix [...] DBPassword=senha [...] #DBSocket=/var/lib/mysql/mysql.sock # Comenta [...] DBPort=5432 [...]
Importando os bancos modelo
# cd /usr/share/zabbix-postgresql/ # scp data.sql images.sql schema.sql pgsql.rascunhos.wiki.br:/tmp The authenticity of host 'pgsql.rascunhos.wiki.br (172.16.200.50)' can't be established. ECDSA key fingerprint is d8:d7:78:aa:ab:3f:83:22:9c:a0:e4:8f:e5:59:f4:f3. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'pgsql.rascunhos.wiki.br,172.16.200.50' (ECDSA) to the list of known hosts. root@pgsql.rascunhos.wiki.br's password: data.sql 100% 853KB 852.8KB/s 00:01 images.sql 100% 1933KB 1.9MB/s 00:00 schema.sql 100% 101KB 100.5KB/s 00:00
Agora vamos passar para o DataBase Server
# cd /tmp/ # cat schema.sql | psql -U zabbix zabbix Senha para usuário zabbix: # cat images.sql | psql -U zabbix zabbix Senha para usuário zabbix: # cat data.sql | psql -U zabbix zabbix Senha para usuário zabbix:
Voltando ao Zabbix server vamos checar a importação e já testando a conexão remota com o usuário zabbix
# psql -h pgsql.rascunhos.wiki.br -U zabbix zabbix Senha para usuário zabbix: psql (9.2.10) Digite "help" para ajuda. zabbix=> \dt Lista de relações Esquema | Nome | Tipo | Dono ---------+-----------------------+--------+-------- public | acknowledges | tabela | zabbix public | actions | tabela | zabbix public | alerts | tabela | zabbix public | application_template | tabela | zabbix public | applications | tabela | zabbix public | auditlog | tabela | zabbix public | auditlog_details | tabela | zabbix public | autoreg_host | tabela | zabbix public | conditions | tabela | zabbix public | config | tabela | zabbix public | dbversion | tabela | zabbix public | dchecks | tabela | zabbix public | dhosts | tabela | zabbix public | drules | tabela | zabbix public | dservices | tabela | zabbix public | escalations | tabela | zabbix public | events | tabela | zabbix public | expressions | tabela | zabbix public | functions | tabela | zabbix public | globalmacro | tabela | zabbix public | globalvars | tabela | zabbix public | graph_discovery | tabela | zabbix public | graph_theme | tabela | zabbix public | graphs | tabela | zabbix public | graphs_items | tabela | zabbix public | group_discovery | tabela | zabbix public | group_prototype | tabela | zabbix public | groups | tabela | zabbix public | history | tabela | zabbix public | history_log | tabela | zabbix public | history_str | tabela | zabbix public | history_str_sync | tabela | zabbix public | history_sync | tabela | zabbix public | history_text | tabela | zabbix public | history_uint | tabela | zabbix public | history_uint_sync | tabela | zabbix public | host_discovery | tabela | zabbix public | host_inventory | tabela | zabbix public | hostmacro | tabela | zabbix public | hosts | tabela | zabbix public | hosts_groups | tabela | zabbix public | hosts_templates | tabela | zabbix public | housekeeper | tabela | zabbix public | httpstep | tabela | zabbix public | httpstepitem | tabela | zabbix public | httptest | tabela | zabbix public | httptestitem | tabela | zabbix public | icon_map | tabela | zabbix public | icon_mapping | tabela | zabbix public | ids | tabela | zabbix public | images | tabela | zabbix public | interface | tabela | zabbix public | interface_discovery | tabela | zabbix public | item_discovery | tabela | zabbix public | items | tabela | zabbix public | items_applications | tabela | zabbix public | maintenances | tabela | zabbix public | maintenances_groups | tabela | zabbix public | maintenances_hosts | tabela | zabbix public | maintenances_windows | tabela | zabbix public | mappings | tabela | zabbix public | media | tabela | zabbix public | media_type | tabela | zabbix public | node_cksum | tabela | zabbix public | nodes | tabela | zabbix public | opcommand | tabela | zabbix public | opcommand_grp | tabela | zabbix public | opcommand_hst | tabela | zabbix public | opconditions | tabela | zabbix public | operations | tabela | zabbix public | opgroup | tabela | zabbix public | opmessage | tabela | zabbix public | opmessage_grp | tabela | zabbix public | opmessage_usr | tabela | zabbix public | optemplate | tabela | zabbix public | profiles | tabela | zabbix public | proxy_autoreg_host | tabela | zabbix public | proxy_dhistory | tabela | zabbix public | proxy_history | tabela | zabbix public | regexps | tabela | zabbix public | rights | tabela | zabbix public | screens | tabela | zabbix public | screens_items | tabela | zabbix public | scripts | tabela | zabbix public | service_alarms | tabela | zabbix public | services | tabela | zabbix public | services_links | tabela | zabbix public | services_times | tabela | zabbix public | sessions | tabela | zabbix public | slides | tabela | zabbix public | slideshows | tabela | zabbix public | sysmap_element_url | tabela | zabbix public | sysmap_url | tabela | zabbix public | sysmaps | tabela | zabbix public | sysmaps_elements | tabela | zabbix public | sysmaps_link_triggers | tabela | zabbix public | sysmaps_links | tabela | zabbix public | timeperiods | tabela | zabbix public | trends | tabela | zabbix public | trends_uint | tabela | zabbix public | trigger_depends | tabela | zabbix public | trigger_discovery | tabela | zabbix public | triggers | tabela | zabbix public | user_history | tabela | zabbix public | users | tabela | zabbix public | users_groups | tabela | zabbix public | usrgrp | tabela | zabbix public | valuemaps | tabela | zabbix (108 registros) zabbix=> \q
Iniciando e habilitando o Zabbix Server e agent
# systemctl list-unit-files --type service | grep zabbix
zabbix-agent.service disabled
zabbix-server-pgsql.service disabled
zabbix-server.service disabled
# systemctl start zabbix-server-pgsql.service # systemctl start zabbix-agent.service
# systemctl enable zabbix-server-pgsql.service ln -s '/usr/lib/systemd/system/zabbix-server-pgsql.service' '/etc/systemd/system/multi-user.target.wants/zabbix-server-pgsql.service' # systemctl enable zabbix-agent.service ln -s '/usr/lib/systemd/system/zabbix-agent.service' '/etc/systemd/system/multi-user.target.wants/zabbix-agent.service'
Checando os serviços
# systemctl status zabbix-server-pgsql.service zabbix-server-pgsql.service - Zabbix Server with PostgreSQL DB Loaded: loaded (/usr/lib/systemd/system/zabbix-server-pgsql.service; enabled) Active: active (running) since Ter 2015-04-28 12:56:45 BRT; 4min 29s ago Main PID: 2784 (zabbix_server) CGroup: /system.slice/zabbix-server-pgsql.service ├─2784 /usr/sbin/zabbix_server ├─2785 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.009214 sec, idle 60 sec] ├─2786 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.007735 sec, idle 60 sec] ├─2787 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000001 sec, idle 5 sec] ├─2788 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000003 sec, idle 5 sec] ├─2789 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000002 sec, idle 5 sec] ├─2790 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000001 sec, idle 5 sec] ├─2791 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000003 sec, idle 5 sec] ├─2792 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000001 sec, idle 5 sec] ├─2793 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection] ├─2794 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection] ├─2795 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection] ├─2796 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection] ├─2797 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.002727 sec, waiting for connection] ├─2798 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000005 sec, idle 5 sec] ├─2799 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.000796 sec, idle 30 sec] ├─2800 /usr/sbin/zabbix_server: housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.044173 sec, idle 1 hour(s)... ├─2801 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000009 sec, 0 maintenances in 0.001806 sec, idle 30 sec] ├─2802 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000910 sec, idle 5 sec] ├─2803 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000768 sec, idle 60 sec] ├─2804 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000000 sec, idle 5 sec] ├─2805 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000000 sec, idle 5 sec] ├─2806 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 5 sec] ├─2807 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000001 sec, idle 5 sec] ├─2808 /usr/sbin/zabbix_server: escalator [processed 0 escalations in 0.000804 sec, idle 3 sec] ├─2809 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000002 sec, idle 5 sec] └─2810 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000004 sec, idle 1 sec] Abr 28 12:56:44 zabbixserver.rascunhos.wiki.br systemd[1]: Starting Zabbix Server with PostgreSQL DB... Abr 28 12:56:45 zabbixserver.rascunhos.wiki.br systemd[1]: PID file /run/zabbixsrv/zabbix_server.pid not readable (yet?) after start. Abr 28 12:56:45 zabbixserver.rascunhos.wiki.br systemd[1]: Started Zabbix Server with PostgreSQL DB.
# systemctl status zabbix-agent.service zabbix-agent.service - Zabbix Monitor Agent Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled) Active: active (running) since Ter 2015-04-28 12:58:41 BRT; 3min 8s ago Main PID: 2832 (zabbix_agentd) CGroup: /system.slice/zabbix-agent.service ├─2832 /usr/sbin/zabbix_agentd ├─2833 /usr/sbin/zabbix_agentd: collector [idle 1 sec] ├─2834 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] ├─2835 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] ├─2836 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] └─2837 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec] Abr 28 12:58:41 zabbixserver.rascunhos.wiki.br systemd[1]: Starting Zabbix Monitor Agent... Abr 28 12:58:41 zabbixserver.rascunhos.wiki.br systemd[1]: PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) after start. Abr 28 12:58:41 zabbixserver.rascunhos.wiki.br systemd[1]: Started Zabbix Monitor Agent.
# yum install zabbix22-web-pgsql zabbix22-web zabbix22-agent
Configurando o FirewallD
# firewall-cmd --add-rich-rule 'rule family="ipv4" source address="172.16.200.0/24" service name="http" accept' --permanent # firewall-cmd --add-rich-rule 'rule family="ipv4" source address="172.16.200.0/24" port port="10050" protocol="tcp" accept' --permanent # firewall-cmd --add-rich-rule 'rule family="ipv4" source address="172.16.200.0/24" port port="10050" protocol="udp" accept' --permanent
# firewall-cmd --reload
success
Configurando os parâmetros do PHP
# vim /etc/php.ini [...] post_max_size = 16M [...] max_execution_time = 300 [...] max_input_time = 300 [...] date.timezone = America/Belem [...]
Configurando o VirtualHost
# cat /etc/httpd/conf.d/zabbix.conf # # Zabbix monitoring system php web frontend # NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin gean@rascunhos.wiki.br ServerName zabbixweb.rascunhos.wiki.br ServerAlias www.zabbixweb.rascunhos.wiki.br DocumentRoot "/usr/share/zabbix" ServerPath / Alias /zabbix /usr/share/zabbix <Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None <IfModule mod_authz_core.c> # Apache 2.4 Require all granted </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order allow,deny Allow from all </IfModule> </Directory> <Directory ~ "^/usr/share/zabbix/(conf|api|include)/"> <IfModule mod_authz_core.c> # Apache 2.4 Require all denied </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order deny,allow Deny from all </IfModule> <files *.php> <IfModule mod_authz_core.c> # Apache 2.4 Require all denied </IfModule> <IfModule !mod_authz_core.c> Order deny,allow Deny from all </IfModule> </files> </Directory> ErrorLog logs/zabbixweb_error.log CustomLog logs/zabbixweb_access.log combined </VirtualHost>
Iniciando e habilitando o apache
# systemctl start httpd.service # systemctl enable httpd.service ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
Configurando o SELinux da conexão com o banco do apache
# getsebool httpd_can_network_connect_db httpd_can_network_connect_db --> off
# setsebool -P httpd_can_network_connect_db 1 # getsebool httpd_can_network_connect_db httpd_can_network_connect_db --> on
Agora vamos terminar a configuração no browser firefox: http://zabbixweb.rascunhos.wiki.br
Clique em Next »
Novamente clique em Next »
Nesta tela será configurado a conexão com o DataBase, coloque os dados e faça um teste de conexão clicando em Test connection.
Se tiver sucesso podemos continuar clicando em Next »
Aqui configuramos a conexão com o ZabbixServer. Preencha os campos com as imformações do ZabbixServer e clique em next »
Aqui é mostrado um sumário da instalação. Clique em Next »
Fim da instalação.
Agora podemos acessar o sistema com o usário: Admin (“A” Maiúsculo) e senha: zabbix