Skip to content


 Zabbix
 Grafana
 Prometheus
 Threejs and TypeScript
 SocketIO and TypeScript
 Blender Topological Earth
 Sweet Home 3D
 Design Patterns Python
 Design Patterns TypeScript
   
 Course Coupon Codes
Three.js and TypeScript
Kindle Edition
$9.99 $14.99 Paperback 
$29.99 $34.99




Design Patterns in TypeScript
Kindle Edition
$9.99 $14.99 Paperback
$19.99 $24.99




Design Patterns in Python
Kindle Edition
$9.99 $14.99 Paperback
$19.99 $24.99




Zabbix Sender and Trapper

Video Lecture

Zabbix Sender Zabbix Sender and Trapper Zabbix Sender and Trapper

Description

zabbix_sender is a command line utility for sending data to Zabbix server.

You don't need to have Zabbix server, proxy or an agent running on the same OS to use the zabbix_sender utility, but you do need to make sure you have the correct version for your operating system.

Download the appropriate Zabbix version and repository for your operating system. I am using Zabbix 6 LTS on Ubuntu 20.04.

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
apt update

Now to install the zabbix_sender executable.

sudo apt install zabbix-sender

For help use

zabbix_sender -h

zabbix_sender is used to send data to your Zabbix server and can be called from either the command line or from a scripting language capable of running shell commands.

Example,

zabbix_sender -z 127.0.0.1 -s "Linux DB3" -k db.connections -o 43

On Zabbix, you need to create a host and add a Zabbix Trapper item to receive and process the zabbix_sender message.

Then you can use the zabbix_sender binary to send data to that trapper item any time you need.

Example Sender and Trapper script

This script will generate a new random number every second and send it to a host configured on Zabbix server.

1st create a new item on your host using the Zabbix UI.

Property Value
Name rnd
Type Zabbix Trapper
key rnd
Type of information Numeric (unsigned)

We can test the new Zabbix Trapper item,

zabbix_sender -z <Zabbix server/proxy IP or Domain name> -s "<host name as written in Zabbix>" -k rnd -o 123

Next create a new python script

sudo nano rnd.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import subprocess
import random
import time

while 1:
    rnd = random.randint(0, 100)

    cmd = 'zabbix_sender -z <Zabbix server/proxy IP or host name> -s "<Host name in Zabbix UI>" -k rnd -o ' + str(rnd)
    print(cmd)

    process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
    output, error = process.communicate()
    print(output)

    time.sleep(1)

Start it

python3 rnd.py