/coffops-live-1-zabbix

Contains the Zabbix code I used in a live on the Coffops YouTube Channel

Primary LanguagePHP

#1 Live Coffops - Zabbix 6.4 + TimescaleDB

This repository contains the code I used in a live on the Coffops YouTube Channel:

We installed Zabbix with Docker Compose and used PostgreSQL with the TimescaleDB extension as the database.

Doc reference

Set DB secrets

  • cd zabbix-docker
  • Put DB user in file ./env_vars/.POSTGRES_USER
  • Put DB password in file ./env_vars/.POSTGRES_PASSWORD
  • Set files permissions:
    sudo chown 70:1995 env_vars/.POSTGRES_*
    sudo chmod 440 env_vars/.POSTGRES_*
    

Start containers

The --profile dev parameter include the postgres-server and mail-server services for dev/testing purposes.

docker compose --profile dev up -d
docker compose --profile dev ps -a

Useful command to reload Zabbix configurations:

docker compose exec zabbix-server zabbix_server -R config_cache_reload

Check postgres/timescaledb

docker compose logs postgres-server |less
docker compose exec postgres-server psql -U zabbix -d zabbix
\du #list roles
\l  #list databases
\dx #list installed extensions
\dt #list tables
select * from _timescaledb_catalog.hypertable; #show hypertables

Check zabbix services

docker compose logs zabbix-server |less
docker compose logs zabbix-web |less
docker compose logs zabbix-web-service |less

Access the Zabbix frontend:

Check timezone

docker compose exec mail-server date
docker compose exec postgres-server date
docker compose exec zabbix-server date
docker compose exec zabbix-web date
docker compose exec zabbix-web-service date
  • Proceed to the Administration -> General -> GUI frontend menu section
  • Check latest data datetime

Check housekeeping conf

  • Proceed to the Administration -> Housekeeping frontend menu section.

Finish zabbix-web-service configuration

A Frontend URL parameter should be set to enable communication between Zabbix frontend and Zabbix web service:

  • Proceed to the Administration -> General -> Other parameters frontend menu section
  • Specify the full URL of the Zabbix web interface in the Frontend URL parameter
    • http://zabbix-web:8080/ (use service name from docker compose)
    • docker compose --profile dev logs zabbix-web-service -f

Set Email media type and test

  • Proceed to the Alerts -> Media types frontend menu section and edit/enable Email (use the mail-server service, smtp port 1025)
  • Add the media type to the zabbix user
  • Reports -> Scheduled reports -> add and test
  • Show containers logs and zabbix processes graphs
  • To read the email sent by zabbix: http://localhost:1080/

Show rebranding

  • Enabled zabbix-web rebranding volume:
    • - ${REBRANDING_DIRECTORY}/:/usr/share/zabbix/local/conf/:ro
  • Apply changes: docker compose --profile dev up -d zabbix-web

Docker monitoring

Database monitoring

  • https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_odbc?at=refs%2Ftags%2F6.4.15
  • Add PostgreSQL by ODBC template to Zabbix host
  • Create DB user:
    CREATE USER zbx_monitor WITH PASSWORD 'zabbix' INHERIT;
    GRANT pg_monitor TO zbx_monitor;
    
  • Define host macros
  • Show ODBC error on a host item
  • Create custom zabbix-server docker image:
    build:
        context: ./Dockerfiles/zabbix-server
        args:
            ZABBIX_SERVER_IMAGE: ${ZABBIX_SERVER_IMAGE}
            ZABBIX_IMAGE_TAG: ${ZABBIX_IMAGE_TAG}
            ZABBIX_IMAGE_TAG_POSTFIX: ${ZABBIX_IMAGE_TAG_POSTFIX}
    
  • Rebuild container docker compose --profile dev up -d zabbix-server
  • Change Driver path to /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
  • Execute discovery rules
  • Show dashboard
  • In production, use a zabbix-proxy for ODBC monitoring!

Show trigger example

Show problem/dashboard and increase the ZBX_CACHESIZE value in the ./env_vars/.env_srv file.

To apply the new conf:

docker compose --profile dev up -d zabbix-server

Stop containers and clean volumes

docker compose --profile dev down -v
sudo rm -rf zbx_env/