From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v4 6/6] zabbix_agentd: Add IPFire specific userparameters Date: Thu, 03 Mar 2022 22:02:54 +0100 Message-ID: <20220303210254.3116-7-robin.roevens@disroot.org> In-Reply-To: <20220303210254.3116-1-robin.roevens@disroot.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5109749521188236949==" List-Id: --===============5109749521188236949== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Provide IPFire specific items for the Zabbix server to monitor: - ipfire.net.gateway.pingtime: Internet Line Quality - ipfire.net.gateway.ping: Internet connection - ipfire.net.fw.hits.raw: JSON formatted list of Firewall hits/chain - ipfire.dhcpd.clients: Number of active DHCP leases - ipfire.captive.clients: Number of Captive Portal clients Signed-off-by: Robin Roevens --- config/rootfiles/packages/zabbix_agentd | 1 + config/zabbix_agentd/sudoers | 2 +- config/zabbix_agentd/userparameter_ipfire.conf | 12 ++++++++++++ lfs/zabbix_agentd | 5 ++++- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 config/zabbix_agentd/userparameter_ipfire.conf diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packa= ges/zabbix_agentd index 2ea98fc21..2ae4e24cb 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -19,4 +19,5 @@ var/ipfire/zabbix_agentd var/ipfire/zabbix_agentd/zabbix_agentd_ipfire_mandatory.conf var/ipfire/zabbix_agentd/userparameters var/ipfire/zabbix_agentd/userparameters/userparameter_pakfire.conf +var/ipfire/zabbix_agentd/userparameters/userparameter_ipfire.conf #var/log/zabbix diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index cb4263ff6..2d71ae78f 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -8,4 +8,4 @@ # To add more sudo rights to zabbix agent, you should modify the sudoers fil= e zabbix_agentd_user # Defaults:zabbix !requiretty -zabbix ALL=3D(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=3D(ALL) NOPASSWD: /opt/pakfire/pakfire status, /usr/sbin/fping, /= usr/local/bin/getipstat diff --git a/config/zabbix_agentd/userparameter_ipfire.conf b/config/zabbix_a= gentd/userparameter_ipfire.conf new file mode 100644 index 000000000..10c09c25d --- /dev/null +++ b/config/zabbix_agentd/userparameter_ipfire.conf @@ -0,0 +1,12 @@ +# Parameters for monitoring IPFire specific metrics +# +# Internet Gateway ping timings, can be used to measure "Internet Line Quali= ty" +UserParameter=3Dipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gatewa= y 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +# Internet Gateway availability, can be used to check Internet connection +UserParameter=3Dipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway= ; [ ! $? ]; echo $? +# Firewall Filter Forward chain drops in bytes/chain (JSON), can be used for= discovery of firewall chains and monitoring of firewall hits on each chain +UserParameter=3Dipfire.net.fw.hits.raw,sudo /usr/local/bin/getipstat -xf | g= rep "\/\* DROP_.* \*\/$" | awk 'BEGIN { ORS =3D ""; print "["} { printf "%s{\= "chain\": \"%s\", \"bytes\": \"%s\"}", separator, substr($11, 6), $2; separat= or =3D ", "; } END { print"]" }' +# Number of currently Active DHCP leases +UserParameter=3Dipfire.dhcpd.clients,grep -s -E 'lease|bind' /var/state/dhcp= /dhcpd.leases | sed ':a;/{$/{N;s/\n//;ba}' | grep "state active" | wc -l +# Number of Captive Portal clients +UserParameter=3Dipfire.captive.clients,awk -F ',' 'length($2) =3D=3D 17 {sum= +=3D 1} END {if (length(sum) =3D=3D 0) print 0; else print sum}' /var/ipfire= /captive/clients \ No newline at end of file diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 929d36628..226eb6253 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -35,7 +35,8 @@ DIR_APP =3D $(DIR_SRC)/$(THISAPP) TARGET =3D $(DIR_INFO)/$(THISAPP) PROG =3D zabbix_agentd PAK_VER =3D 5 -DEPS =3D + +DEPS =3D fping =20 SERVICES =3D zabbix_agentd =20 @@ -107,6 +108,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) /var/ipfire/zabbix_agentd/zabbix_agentd_ipfire_mandatory.conf install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/userparameter_pakfire.con= f \ /var/ipfire/zabbix_agentd/userparameters/userparameter_pakfire.conf + install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/userparameter_ipfire.conf= \ + /var/ipfire/zabbix_agentd/userparameters/userparameter_ipfire.conf =20 # Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix --=20 2.34.1 --=20 Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn. --===============5109749521188236949==--