Hello! I'm trying to get automatic monitoring of remote mounts going, but I'm getting this error: I have this script that is run by the discovery rule:
Code:
#!/usr/bin/env python3
import re
# Empty dictionary for later
mounts_dict = {"data": []}
# read /etc/fstab to get any permanent mounts
f = open("/etc/fstab", "r")
fstab = f.read()
# search through /etc/fstab to find IP addresses
list_of_ips = re.findall(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", fstab)
# Search through all the lines in /etc/fstab
for line in fstab.split('\n'):
# search each line to see if it's a remote mount
for entry in list_of_ips:
# append the local path to the mount dictionary if it's valid
if line.find(entry) != -1:
mount_name = line.split()[1]
formatted_entry = ({"{#MOUNTPOINT}":"%s" % (mount_name)})
if formatted_entry not in mounts_dict["data"]:
mounts_dict["data"].append(formatted_entry)
# Print it out and hope Zabbix understands
print(mounts_dict)
template->Discovery Rules->This item, which does
system.run[/path/to/script/zabbix_enumerate_mounts.py]
When I run this on the command line, I get this output:
root@system $ /path/to/script/zabbix_enumerate_mounts.py
Code:
{'data': [{'{#MOUNTPOINT}': '/mount/orders'}, {'{#MOUNTPOINT}': '/mount/downloads'}]}
vfs.file.exists[{#MOUNTPOINT}/.placeholder]
When I try to run the discovery rule in Zabbix by checking the box and clicking "Execute Now", I get this error: Cannot find the "data" array in the received JSON object.
I tried to follow this format:https://www.zabbix.com/documentation...stom_lld_rules
I've also tried it where I get this output, with the same error message:
Code:
[{'{#MOUNTPOINT}': '/mount/orders'}, {'{#MOUNTPOINT}': '/mount/downloads'}]
I've tried copying/pasting the sample output from the above link and just writing a script that spits that out, and I still get the same error, so I don't know if the format is the issue. I've also tried the lowercase macro names and the JSONpath thingy too.
Running Zabbix 5.0.8 on CentOS 7. Remote systems are also CentOS 7. Does anyone have any insight?
Comment