During my daily work I was tasked with two additional values, Zabbix should provide to our Administrators:
- Were Linux configuration files from a certain installed daemon modified? (/etc/postfix/)
- What is the timestamp of the oldest file in a certain directory? (EDI)
In both cases, the affected machines are Debian Linux virtual machines with Zabbix agent 3.4+ installed and configured. Zabbix offers no way to solve these challenges out of the box, but is easily customizable via User Parameter and custom Low Level Discovery to add this features.
I published my work on GitHub, where you can take a look at the Scripts, example Templates and User Parameter.
Example code:
#!/usr/bin/perl $base = $ARGV[0]; opendir(DIR, $base) || die "cannot open directory: $!"; @subdirs = grep { /^[^.]/ && -f "$base/$_" } readdir(DIR); closedir(DIR); $first = 1; print "{\n"; print "\t\"data\":[\n"; for (@subdirs) { print ",\n" if !$first; print "\t\t{\"{#FILENAME}\":\"$_\"}"; $first = 0; } print "\n\t]\n"; print "}\n";
# EXAMPLE UserParameter=vfs.file.age[*],/usr/local/bin/zabbix_vfs.file.old.sh $1 UserParameter=vfs.file.discovery[*],/etc/zabbix/zabbix_agentd.d/vfs-file-discovery.pl $1 UserParameter=vfs.dir.discovery[*],/etc/zabbix/zabbix_agentd.d/vfs-dir-discovery.pl $1
Source: https://github.com/xenadmin/zabbix-templates/tree/master/zabbix-vfs-linux