rbicelli / pfsense-zabbix-template

Zabbix Template for pfSense
Apache License 2.0
244 stars 107 forks source link

Discovery: Value should be a JSON object. #67

Closed JSuenram closed 6 months ago

JSuenram commented 3 years ago

Well, monitoring 6 pfSense with this template. 2 of them having Problems with discovery. Value should be a JSON object. Validator gives VALID (RFC 8259) for returned JSON. Maybe a Zabbix issue with 4.0.29. Unsure for now. Difference between working and non working are installed FRR-Services which have forward slash in description. Maybe that's an issue?

Sample-JSON for Services with is returned when issue happens: { "data":[ { "{#SERVICE}":"zabbix_agentd", "{#DESCRIPTION}":"Zabbix Agent Host Monitor Daemon" }, { "{#SERVICE}":"FRRzebra", "{#DESCRIPTION}":"FRR core/abstraction daemon" }, { "{#SERVICE}":"FRRstaticd", "{#DESCRIPTION}":"FRR static route daemon" }, { "{#SERVICE}":"FRRbfdd", "{#DESCRIPTION}":"FRR BFD daemon" }, { "{#SERVICE}":"FRRbgpd", "{#DESCRIPTION}":"FRR BGP routing daemon" }, { "{#SERVICE}":"FRRospfd", "{#DESCRIPTION}":"FRR OSPF routing daemon" }, { "{#SERVICE}":"FRRospf6d", "{#DESCRIPTION}":"FRR OSPF6 routing daemon" }, { "{#SERVICE}":"unbound", "{#DESCRIPTION}":"DNS Resolver" }, { "{#SERVICE}":"ntpd", "{#DESCRIPTION}":"NTP clock sync" }, { "{#SERVICE}":"syslogd", "{#DESCRIPTION}":"System Logger Daemon" }, { "{#SERVICE}":"dpinger", "{#DESCRIPTION}":"Gateway Monitoring Daemon" }, { "{#SERVICE}":"bsnmpd", "{#DESCRIPTION}":"SNMP Service" }, { "{#SERVICE}":"sshd", "{#DESCRIPTION}":"Secure Shell Daemon" } ] }

rbicelli commented 3 years ago

It could be the forward slash, if you are familiare with php, edit the pfsense_zbx.php

Line 323: Change

$json_string .= ',"{#DESCRIPTION}":"' . $service['description'] . '"';

to

$json_string .= ',"{#DESCRIPTION}":"' . str_replace("/","",$service['description']) . '"';

And see if it helps. If your problems solves i will addd asanitization function for the json.

JSuenram commented 3 years ago

It could be the forward slash, if you are familiare with php, edit the pfsense_zbx.php

Line 323: Change

$json_string .= ',"{#DESCRIPTION}":"' . $service['description'] . '"';

to

$json_string .= ',"{#DESCRIPTION}":"' . str_replace("/","",$service['description']) . '"';

And see if it helps. If your problems solves i will addd asanitization function for the json.

Hi,

I did the change on both pfSense nodes. Unfortunately it did not help. I digged a bit deeper and it seems that most Discovery-Rules fail with "Value should be a JSON object"

image

Also values which are discovered/hardcoded show not suitable value.

image
rbicelli commented 3 years ago

Did you configured Zabbix Agent in pfsense for active checks? Which version of pfsense are you running?

JSuenram commented 3 years ago

Yes, sure Zabbix Agent active checks are enabled and configured. Some of the active checks are working. pfsense Version is current pfsense+ 21.02-RELEASE-p1 (amd64). However we have also 2 other pas with same version, which are running perfectly with your template. Zabbix Server is 4.029, agent is 4.027 on pfsense.

rbicelli commented 3 years ago

Please check if the script is running fine, try from pfsense console php root/scripts/pfsense_zbx.php

JSuenram commented 3 years ago

Script is running fine, result attached... result.zip