From patchwork Thu Jun 30 10:15:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5713 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4LYZ4Z5xJvz40V5 for ; Thu, 30 Jun 2022 10:16:46 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4LYZ4W40txz1gk; Thu, 30 Jun 2022 10:16:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LYZ4W12jRz302M; Thu, 30 Jun 2022 10:16:43 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4LYZ4V33Qnz2yNm for ; Thu, 30 Jun 2022 10:16:42 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4LYZ4T3xtCz1Fh for ; Thu, 30 Jun 2022 10:16:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id D9D7A45A8E for ; Thu, 30 Jun 2022 12:16:40 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GG3JQWQWWh5x for ; Thu, 30 Jun 2022 12:16:39 +0200 (CEST) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id 7F32B4B9F4; Thu, 30 Jun 2022 12:16:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1656584195; bh=pRQ/sHWwx0WGtAzSDNxzRzzBBkNs+evcesBZqRCDaNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f4zwMeCvI5sPp28MbLh/oncL4yCJ7dcYLe9kxQvOJUTDpCuvRUiJa4lAgRh9dBHjO eZOVQ7sWIENPE3gZL9cKUezlAFO3ofqP87juHB/pnIRVlZ3Nxds2R+BPxBAZKONuCz Ko4sKOHQ/YI6ke0a1FeABcSjo3da/SEvbRf8mCjdP+87uxZAtrwlNrJgjqxmFnhvXx eqL1HMFvXONBIL+piz3RLMuNc3SDTgWX81a+q+DzzYdWaDrd0ctpl6XnPS3ZPv1fP8 z8SVHGNV47kHRHKdom4hXgnnA1KNoXH7Al+1hMF1n3zbaXfK1JN45S4mrB5kiBM9Pb GkGpxVovwREjw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v5 6/6] zabbix_agentd: Add IPFire specific userparameters Date: Thu, 30 Jun 2022 12:15:55 +0200 Message-Id: <20220630101555.13438-7-robin.roevens@disroot.org> In-Reply-To: <20220630101555.13438-1-robin.roevens@disroot.org> References: <20220630101555.13438-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 7F32B4B9F4.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1657188971.79462@2eZhofpGwkVYsz02HqOZ2A ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1656584201; a=rsa-sha256; cv=none; b=j5f2F0f7yNrjGWRZwC07ki2r6g35m0HkMkRC39RiYspWvBCeoNtrwIwAxtlmGJ0Wbquf/b LQipzVh3I8f1ApJwcJg8dzxtk8gXx70VSEYITzikfb+XOJF2ppnUpBAz5yCv7kDtGwd48H khfekIG8SYUzYovpQHFf7SmpRlewENVJExH8KIe7Eg2r+s/xukr3Yfmf4V7Krul/uFjSwS jBvP2bFfuiUfJ/MUArId/GPa7cerk5g/SZajf6hnsIwqv+fc07Lq8jFOvw0HKN8A1uT0Xc azL2lW5sWhklsBPJinXRQHGdFt1v6k2feC0HJXn+hZCIPjJLdY878PnNEUPHFQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=f4zwMeCv; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1656584201; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=koA8f2mC77wHX1tnoAyNfLZzbjciG3E3gguXSw5yNNk=; b=pup8bd8OD4dovz8tYWcrq4tiDYcgrVig4rAzumpD20CWc6QSYdl/IGsAx72pUnOTpI1tmR BT9PprZB/Cw6FgmQDPKjcYxpe7cDjn7SOZ5w25uRA40epFMr0MEMatxkwsUoWTtomeT8lv JF/o3Kd6Rvdq4hSu9Z7Q43HG5WSjs+geSf7D1IGSFZAU6r93yCoBfYB99uFA+b1L5AlQcC 7kEFf+VePLVhb3XfJea9EuvpTTNgq629RLCjeKjKc2gHEa993EqkWVp/1VqNlxhzYWKoJG Ds1d3rfpC06ey5U94BGQ2qHaOU9Pwx6JjOpW7LxTOrS4byEwQkqRlE1O0cKZyg== X-Spamd-Result: default: False [-7.80 / 11.00]; REPLY(-4.00)[]; BAYES_HAM(-2.99)[99.97%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; SPF_REPUTATION_HAM(-0.78)[-0.78380183397146]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_SPF_ALLOW(-0.20)[+a:c]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; IP_REPUTATION_HAM(-0.01)[asn: 50673(0.00), country: NL(-0.01), ip: 178.21.23.139(0.00)]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; RCVD_COUNT_THREE(0.00)[4]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=f4zwMeCv; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org X-Rspamd-Queue-Id: 4LYZ4T3xtCz1Fh X-Rspamd-Server: mail01.haj.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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/packages/zabbix_agentd index b5325c636..6f2c831d7 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -20,4 +20,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 file zabbix_agentd_user # Defaults:zabbix !requiretty -zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=(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_agentd/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 Quality" +UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +# Internet Gateway availability, can be used to check Internet connection +UserParameter=ipfire.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=ipfire.net.fw.hits.raw,sudo /usr/local/bin/getipstat -xf | grep "\/\* DROP_.* \*\/$" | awk 'BEGIN { ORS = ""; print "["} { printf "%s{\"chain\": \"%s\", \"bytes\": \"%s\"}", separator, substr($11, 6), $2; separator = ", "; } END { print"]" }' +# Number of currently Active DHCP leases +UserParameter=ipfire.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=ipfire.captive.clients,awk -F ',' 'length($2) == 17 {sum += 1} END {if (length(sum) == 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 f8fbdae5e..73c5dc0b6 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -35,7 +35,8 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd PAK_VER = 5 -DEPS = + +DEPS = fping SERVICES = zabbix_agentd @@ -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.conf \ /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 # Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix