Just when you thought things couldn't get any better, you notice that Zabbix has support for external checks. This means that Zabbix will run a script or a binary from a specific location, without the need of any agent running on the host that we want to monitor.
For this setup, we need our Zabbix server with a host that can be reached by the Zabbix server. There is no need to install a Zabbix agent on the host as we will make use of our own scripts to run some checks.
zabbix_server.conf
file. Here we see the option ExternalScripts
where we can specify the location or use the standard one:ExternalScripts=/usr/lib/zabbix/externalscripts
cores.sh
with the following content:#!/bin/bash nproc
chmod +x
zabbix
and group zabbix
so we need to change the user and the group.chown zabbix:zabbix cores.sh
Number of CPU Cores
.External check
.cores.sh[]
.This example was pretty easy, but it should give you an idea of the possibilities of external checks. It's important that our scripts are placed in the correct directory as defined in our zabbix_server.conf
file and that the script has the correct rights, so that Zabbix can read and execute the script.
Next step is to create an item in Zabbix and select the Type, External check
and add a key with the exact same name as our script.
It is important to remember that external checks cannot take too much time to run. If a script takes more than 5 seconds, Zabbix will then mark the item as unsupported.
If your scripts needs input such as a variable then you can pass this variable in your item key between the []
. For example, myscript.sh["var1","var2",...]
.
It is also possible to make use of macros. For example, running a script that sends the IP address with some variable could be done easily like this:
myscript.sh["{HOST.IP}","var1"]