In EDI based communications you often have a dir where EDI files get saved and wait for processing. Every now and then these processes don’t work and the file count grows. Of course this is only one example, but it’s often handy to have a trigger fire, when a certain folder has more than X files in it.
First edit your Zabbix agent configuration file:
nano /etc/zabbix/zabbix_agentd.conf
And add the following line:
UserParameter=xenadmin.filecount[*],ls -A1 $1 | wc -l
Let me explain the different parts:
UserParameter= | Initiates the config optione in the zabbix_agentd.conf configuration file. |
xenadmin. | Custom prefix you may add, to make your item key unqiue (optional). |
filecount | Unique item key name. |
[*] | This key accepts parameters. |
ls -A1 $1 | wc -l | Command to be executed to evaluate value of the key. |
$1 | Up to $9 parameters can be used in the command. |
Save & close the file and restart your Zabbix agent.
Now switch to your Zabbix frontend and configure a new item. Most of the time you will want to use a new or existing template for this:
This screenshot is just an example, but you’ll get the idea.
With Zabbix 4.0 this feature won’t require a UserParameter anymore, since it will become a native function:
vfs.dir.count[]