I'm trying to make discovery rule to add file size monitor. But when I add my Template to Host, zabbix says me:
Value should be a JSON object
- Zabbix Agent (daemon) v2.2.10 (revision 54806) (10 August 2015)
- Zabbix server v2.2.9 (revision 52686) (12 March 2015)
I've written the python-script:
import os
import sys
import json
logdir = sys.argv[1]
data = []
for (logdir, _, files) in os.walk(logdir):
for f in files:
if f.endswith(".log"):
path = os.path.join(logdir, f)
data.append({'#LOGFILEPATH':path})
jsondata = json.dumps(data)
print jsondata
It works fine and gets follows:
[{"#LOGFILEPATH": "/opt/logs/projects/cms/cms.log"}, {"#LOGFILEPATH": "/opt/logs/projects/books/nginx.log"}]
I've checked it by jsonlint.com - valid JSON.
UserParameter in conf.d:
UserParameter = discovery.logfile.path, python /opt/scripts/zabbix/find.logfile.path.and.size.py /opt/logs/
There are attachments show my discovery configuration:
User zabbix has permission to directory with script and logs.