Zabbix: Simple file count for Linux

Watch the files count of a dir on Linux with Zabbix.

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:

Author: Marco

Gelernter Fachinformatiker für Systemintegration (2010) CCA für XenServer 5.0 (2009) CCA für XenApp 5.0 (2011) CCA für XenApp 6.5 (2013) CCAA für XenApp 6.5 (2013) CCA für XenDesktop 5 (2013) Dell Wyse ThinOS Select Techniker (2011) Igel Authorized Partner (2009-2014) Intensivkurs “Group Policy Administration” Windows 7, 8.x sowie Windows Server 2008-R2 / 2012-R2 bei NT Systems, Dipl.-Ing. T. Pham (2014) Zu Gast auf der E2EVC Virtualization Conference in Berlin (2015) Zu Gast auf der Citrix Technology Exchange in Berlin (2016) Citrix Certified Associate – Networking (CCA – N) (2016) Citrix Certified Professional – Networking (CCP – N) (2017)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.