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:
This script is run via this in Zabbix:
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
Item prototype is to check for a .placeholder file inside that mount to check if the mount is working. It's running this:
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:
I accomplish this by making mounts_dict just a list instead of a dictionary with the data key.
Running Zabbix 5.0.8 on CentOS 7. Remote systems are also CentOS 7. Does anyone have any insight?
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'}]
Running Zabbix 5.0.8 on CentOS 7. Remote systems are also CentOS 7. Does anyone have any insight?