Let’s say you’ve specified the rights and owner for a specific directory and want to ensure no one changes them. To do this, we’ll monitor it using Zabbix-agent.
Let’s add a parameter to the zabbix agent configuration:
UserParameter=dir.info[*],stat -c "%a %U:%G" $1 2>/dev/null
If you want, you can check (where ixnfo.com is your directory):
apt install zabbix-get
zabbix_get -s 127.0.0.1 -k "dir.info[/ixnfo.com]"
700 root:root
Now let’s create a data element in a template or network node:
Name: Directory info (/ixnfo.com)
Key: dir.info[/ixnfo.com]
Type: Zabbix agent
Type of information: Text
Example of a trigger on change:
change(/template/dir.info[/ixnfo.com])<>0
But it’s better to look at how the latest data for this data element is displayed, for example 700 root:root, and if it is not equal to this value, then the trigger will fire:
find(/template/dir.info[/ixnfo.com],,"like","700 root:root")=0
See also my articles:
Tracking file changes via Zabbix
File Integrity Check Script
File Integrity Check Script (size+mtime)