Problems with vfs.file.exists on Zabbix 2.0

G Mawr asked:

I’m having problems with vfs.file.exists on Zabbix 2.0.6 on a 64-bit Fedora 19 box. 2.0.6 is the latest version available from the Fedora yum repository, at the time of writing.

I want to check for the existence of the file /tmp/test:

[root@localhost ~]# ls -l /tmp/test
-rw-r--r-- 1 root root 14 Sep 16 10:30 /tmp/test

If I run I check directly with zabbix_agentd, it correctly determines that the file exists:

[root@localhost ~]# zabbix_agentd -t "vfs.file.exists[/tmp/test]"
vfs.file.exists[/tmp/test][/tmp/test]         [u|1]

However, if I use zabbix_get, it always returns 0, whether the file exists, or not:

[root@localhost log]# zabbix_get -s -k "vfs.file.exists[/tmp/test]"

It’s strange, because the same test works perfectly when connecting from the same server to a remote machine (also Fedora) running an older version of the Zabbix agent (1.8.13):

[root@localhost log]# zabbix_get -s -k "vfs.file.exists[/tmp/test]"

Some things will work:

[root@localhost ~]# zabbix_get -s -k "system.uname"
Linux 3.9.5-301.fc19.x86_64 #1 SMP Tue Jun 11 19:39:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# zabbix_get -s -k "system.uptime"
[root@localhost ~]# zabbix_get -s -k "[whoami]"

AFAICT, though, all the vfs.file.* keys do not work:

[root@localhost ~]# zabbix_get -s -k "vfs.file.cksum[/tmp/test]"
[root@localhost ~]# zabbix_get -s -k "vfs.file.contents[/tmp/test]"
[root@localhost ~]# zabbix_get -s -k "vfs.file.md5sum[/tmp/test]"
[root@localhost ~]# zabbix_get -s -k "vfs.file.size[/tmp/test]"
[root@localhost ~]# zabbix_get -s -k "vfs.file.time[/tmp/test]"

I have checked that the zabbix user can access that file, so its not a permissions issue:

[root@localhost ~]# sudo su -s /bin/bash zabbix
bash-4.2$ whoami
bash-4.2$ ls -l /tmp/test
-rw-r--r-- 1 root root 14 Sep 16 10:30 /tmp/test

SELinux is also disabled.

Am I doing something wrong, or is this a bug in that particular version/distribution of Zabbix?

My answer:

On current versions of Fedora, the Zabbix agent, like many other system services, has a private namespaced /tmp and cannot see files in /tmp which are created by other processes. Since you’re testing, try checking for the existence of a file in another directory.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.