Statistics and monitoring with Zabbix

Kyryll Prytula


This tutorial brigs a example steps to be taken to display data on Zabbix.

Zabbix is the ultimate enterprise-level software designed for real-time monitoring of millions of metrics collected from tens of thousands of servers, virtual machines and network devices. Zabbix is Open Source and comes at no cost.

Zabbix sever side setup

To process and display statistics on zabbix server you need to make some preparations first.

Host group

Host group is a container for Hosts, helps to keep hosts organised.
To create a new Host group click on Create host group button at Configuration->Host groups page:

Create “Experimental” group as follows:

Now we need some hosts for our group.


Host defines real or fake network host which we want to monitor and aggregate statistics from.
It is a container and main identifier for all metrics we want to collect.
To create a new one click Create button at Configuration->Host page:

Fill the host creation form as follows (or use your preferred parameters):

Detailed description of these actions could be found here:
Zabbix manual -> New host


Now we need to add parameters to track on the host. They called Items.
Each item describes a key parameter which we are expecting to be received from our host.
To create a new monitoring item, find our previously created host from the Hosts list and
click on Items(0), then click Create Item button:

Fill the Create Item form as follows:

Detailed description could be found here:
Zabbix manual -> New Item

This is enough to start receiving data, but it would be good to add something what can display
our data on the server web interface.


A new Graph will help us to see dynamics of our TPS parameter in time.
To add a new graph, find our host in Hosts and click on Graphs(0), then click Create graph button:

Fill the Create graph form as follows:

Now we need to add our graph on a new monitoring screen for our host.


Screen aggregates visible information for the host on one panel.
To create a new screen, go to Configuration->Screens and then click Create screen button:

Set the screen name:

Add our graph on the screen:

I would recommend to add this screen on Dashboard for a quick access.


Dashboard gives us an overview of the situation on systems we monitor.
On the left panel there is a Favourite screens area, press drop-down menu button and
add our Dummy screen to the fast access menu:

Now we can access our screen from that menu on the dashboard:

Client side setup

Now we need some script to send data to Zabbix server.

Zabbix sender protocol bits


Here is a Python script which sends TPS statistics to the server:

!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import socket import struct import json import time import random iterations = 100 HOST = '' PORT = 10051 HEADER = '''ZBXD\1%s%s''' for idx in range(0, iterations):         DATA = '''{         "request":"sender data",         "data":[{         "host":"Dummy",         "key":"bus.tps",         "value":"'''+ str(10 * random.randint(1, 10)) +'''"          }]}'''         data_length = len(DATA)         data_header = struct.pack('i', data_length) + b'\0\0\0\0'         print('data_header:', data_header)         data_to_send = HEADER % (data_header.decode(), DATA)         print('data_to_send:', data_to_send)         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)         sock.connect((HOST, PORT))         print('data_to_send:', data_to_send)         print('data_to_send.encode:', data_to_send.encode())         sock.send(data_to_send.encode())         response_header = sock.recv(5)         print('response_header:', response_header)         if response_header != b'ZBXD\1':                 raise ValueError('Got invalid response')         response_data_header = sock.recv(8)         response_data_header = response_data_header[:4]         response_len = struct.unpack('i', response_data_header)[0]         response_raw = sock.recv(response_len)         print('response_raw:', response_raw)         sock.close()         response = json.loads(response_raw.decode())         print('response:', response)         time.sleep(10) 

This script will send random value from the range 10-100 for our TPS key to Zabbix server once in 10 seconds.


Graph after a while should look similar to this with fluctuation between 10 and 100.


Zabbix documentation
Zabbix agent description
Zabbix protocol