In a similar manner as in this Prometheus blog, you might want to monitor scripts which are short living or do not fit the pull-model (Server pulling from agent). Thus, it can use the push model (Agent pushing to server).

Zabbix Sender Installation

To achieve that, we will use zabbix_sender utility. If you already enabled Zabbix software repository, installation can be achieved with following command:

yum install zabbix-sender -y

Zabbix Trapper

Before being able to send data to Zabbix server, we must declare an item to store that data. It will be of type Zabbix trapper.

As usual, on the host or, even better, in a template, create a new item. Type will be Zabbix trapper, name and key are free to set as you want:

Push Data to Item

Now, we can push data into that item. Let’s imagine my backup script gather following information:

  • end time
  • records backuped
  • status of backup

In a JSON format like that:

{
   "endtime": "1688381695",
   "records": "12345",
   "status": "OK"
}

zabbix_sender command requires following parameters:

  • z: server hostname or IP
  • s: host to which item belongs to
  • k: item key
  • o: item value

Full command will look like that:

zabbix_sender -z 192.168.33.122 -s srv-linux-wls-ols-1 -k backup.script.stats -o '{"endtime": "1688381695","records": "12345","status": "OK"}'

And expected output:

Response from "192.168.33.122:10051": "processed: 1; failed: 0; total: 1; seconds spent: 0.000614"
sent: 1; skipped: 0; total: 1

And if we check in front-end, latest data section, we can see data are there:

Problem here is that we cannot plot or trigger anything easily, so the best is to define a dependent item that will extract values from this JSON.

New item will be of type Dependent item with its own name and key and which will use Backup Script item as Master item:

Of course, we are not done yet: We must add a pre-processing step which will extract backup status from JSON string:

Finally, to test whether works, we must send another JSON string to Zabbix server as there is no back-filling.

Next Steps

Defining a trigger on Backup Status would be the next step. For example, raising an alert if status is different from OK.

By the way, zabbix_sender could be integrated into your script at the very end of it.