Create a Zabbix Item which Tracks the CKSUM of a File with a Slightly Varying Filename

configurationzabbix

Using Zabbix v2.4 on RHEL 6.4

Goal

I'd like to track the checksum of a file across multiple systems where the directory doesn't change, but the filename has very slight variations in it. In our case, the filename contains a build number for the software, and we have multiple sites at different versions. (Hence the difference in names.)

Question and Catches

Can I create a single template item which accounts for these varying file names using the built-in Regular Expressions support?

  • Can't modify the filenames to remove the build number.
  • Don't have a lot of control over the agent configurations, so adding UserParameters would be a considerable effort.

Example file names:

  • 1234_file.jar
  • 1254_file.jar

What I've Tried

Zabbix has built-in regular expression support, but I haven't been able to find a good example of its use in item keys. The Regular Expression page says

In those cases where that may lead to misinterpretation when
referencing (for example, a comma in the parameter of an item
key) the whole reference may be put in quotes like this

which implies that they can be used in keys, but, perhaps, not the way I'd like to use them.

I defined a custom RE as "FileName" with the proper logical expressions to match my filenames (tests checked out just fine), and my key is as follows:

vfs.file.cksum[/path/to/file/@FileName]

But when I review the Agent logs, it says "check 'vfs.file.cksum[/path/to/file/@FileName]' is not supported" with "no such file or directory," so it doesn't look like the key is expanding/matching which means I probably misunderstood how to use custom RE's in keys (or they only work in certain key types).

Best Answer

According to item documentation, vfs.file.cksum[] accepts a file name as the first parameter (unlike, for instance, logrt[] item), so a regular expression will not work there.

One possible approach would be to use a user macro here and define the item as follows:

vfs.file.cksum[/path/to/file/12{$VERSION}4_file.jar]

Then define the appropriate {$VERSION} macro for each host.

Alternatively, you can use low-level discovery to discover the files you want, but that would involve writing a UserParameter, which you would rather avoid. Meanwhile, there is a feature request for a built-in file discovery at ZBXNEXT-712 that you can vote on.