From nobody Wed Nov 29 23:56:02 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SgbnH0FZCz52Rrl; Wed, 29 Nov 2023 23:56:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SgbnG68C9z3HnF; Wed, 29 Nov 2023 23:56:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701302162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=O/fDl11tC/EV45UqNewT8gGDy+SEewJeOhZpM6BuxRQ=; b=uxDV8vMAANZsFrfK7TlwE8nlu8OdJixaM0PFn16c4iqbV4R8F91CVHq8ZUTmVBs9QJFZ8Q STIXqcAeBX6FBICX8idKp0YlfKKKs1g9EGnfLri/PX9kx82JVX5+bRrH7KkbfufezamH9c ULSJQcZPVE58tLmTpJspcMtd1A6gkZ+w+SyahvC6U6Yi4HMVhYo1hAACY5ItdEynlJ6pGv vbBVllgTka0G3sLNS2XYj4DGqYIjDpNP2+H/d+ponS4GTUj3+H3asXfmOXGSP3dV7TXDFP LOVFEngrrDdhZU6SQU+a4EP54gqJzG/s34CQyWhmfx1A1G/LSduntEuY5EB7Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701302162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=O/fDl11tC/EV45UqNewT8gGDy+SEewJeOhZpM6BuxRQ=; b=cir2YOSUBG/hqtytPOpzVCmZeJ+TW3bxPedhXzZ4kKWX4UzyFRJK+jR1//4sMs4TMGtAJi hwj7NB+I/cXMcDCGbRzy+hacfsxjLFVvjHzppSPpwY7mgM0trS8e/qNCvZVYdFxPEsRllh p5UMHkU0Dmd5uyj49G79GoVDSH4xWrqy3DSUiLrh7yWbVBlqgBeDk/QSTHXQzUcZh19fHU G5/J9+LVtew8tAplcURucZBW1/zXbAF1Mm2mIIdBaOMTEkR7D+3jwhvy6ZgOsB8ITZxfT7 jroq4qn0qzrcGv+z0xmDIyAsaf0I5AB7CQfoklxu5rwTM2M069o47VGYHHJPcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701302162; a=rsa-sha256; cv=none; b=S/j483cw5uvU0H1BiO+PhS/Ttkx+a3Zq9cZGFxr03D3eG1V/PsHFwQFv5g4YPVFZtx/ypG a3nA2yYlo7E8EjZf07xIlVeksECOKgthz9jnDXywndB+9XqtaYMJRCc3TMIYZ43kub8o2K 66T7/2wOX/2a95q84sVKFUcTUfCRKQQ7UHU4f/Rr3KU7I8DLnMEkyo9gqSSxr138baK10u aA/FtB4jc4KUGNP/NNfMAFMNKCbP73Zo+rBH/0D1TZ82RnVuLxuQIooe4tGTCqLLVZCi82 b+qaA+kkLMPgUww52bG2Cfcj5IigBlusRq5LI1JRmHe9f5XokgVQOmpuDhsFCA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SgbnG5CCtzCDx; Wed, 29 Nov 2023 23:56:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3ATNu2cc083893; Wed, 29 Nov 2023 23:56:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ATNu2lg083890; Wed, 29 Nov 2023 23:56:02 GMT (envelope-from git) Date: Wed, 29 Nov 2023 23:56:02 GMT Message-Id: <202311292356.3ATNu2lg083890@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Brad Davis Subject: git: 5b63443a6ea8 - main - net-mgmt/collectd5: Use libpfctl List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brd X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5b63443a6ea8490165d887f00c250f506f41e0d4 Auto-Submitted: auto-generated The branch main has been updated by brd: URL: https://cgit.FreeBSD.org/ports/commit/?id=5b63443a6ea8490165d887f00c250f506f41e0d4 commit 5b63443a6ea8490165d887f00c250f506f41e0d4 Author: Brad Davis AuthorDate: 2023-11-29 23:52:11 +0000 Commit: Brad Davis CommitDate: 2023-11-29 23:55:47 +0000 net-mgmt/collectd5: Use libpfctl PR: 275013 Reviewed by: kp Approved by: Krzysztof (maintainer) Sponsored by: Rubicon Communications, LLC ("Netgate") --- net-mgmt/collectd5/Makefile | 9 ++-- net-mgmt/collectd5/files/patch-src__pf.c | 84 ++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/net-mgmt/collectd5/Makefile b/net-mgmt/collectd5/Makefile index 049f6fdebb9a..4cb4de66ccfc 100644 --- a/net-mgmt/collectd5/Makefile +++ b/net-mgmt/collectd5/Makefile @@ -1,6 +1,6 @@ PORTNAME= collectd PORTVERSION= 5.12.0 -PORTREVISION= 9 +PORTREVISION= 10 CATEGORIES= net-mgmt MASTER_SITES= https://storage.googleapis.com/collectd-tarballs/ PKGNAMESUFFIX= 5 @@ -12,7 +12,10 @@ WWW= https://www.collectd.org/ LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/COPYING -USES= autoreconf cpe gmake libtool pkgconfig shebangfix tar:bzip2 +LIB_DEPENDS= libpfctl.so:net/libpfctl +LDFLAGS+= -lpfctl + +USES= autoreconf cpe gmake libtool localbase:ldflags pkgconfig shebangfix tar:bzip2 GNU_CONFIGURE= yes @@ -47,7 +50,7 @@ MQTT_DESC= Enable MQTT broker metrics MYSQL_DESC= Enable mysql-based plugins NOTIFYDESKTOP_DESC= Enable desktop notifications NOTIFYEMAIL_DESC= Enable notifications via email -NUTUPS_DESC= Enable nut (ups) plugin +NUTUPS_DESC= Enable nut (ups) plugin (sysutils/nut must be configured with DEV option) OLSRD_DESC= Enable olsrd plugin ONEWIRE_DESC= Eanble onewire plugin (via owfs) OPENLDAP_DESC= Enable OpenLDAP plugin diff --git a/net-mgmt/collectd5/files/patch-src__pf.c b/net-mgmt/collectd5/files/patch-src__pf.c new file mode 100644 index 000000000000..79ffa899938b --- /dev/null +++ b/net-mgmt/collectd5/files/patch-src__pf.c @@ -0,0 +1,84 @@ +commit 57a1b64ff3ade058a5d8ddd60b3d54f5a2c73c33 +Author: Brad Davis +Date: Tue Nov 7 03:35:47 2023 -0700 + + FreeBSD's PF has a new interface so leverage libpfctl to access it so the right interface is used depending on the version + +diff --git a/src/pf.c b/src/pf.c +index 9681d366..eef9540d 100644 +--- a/src/pf.c ++++ b/src/pf.c +@@ -35,6 +35,9 @@ + #endif + + #include ++#ifdef __FreeBSD__ ++#include ++#endif + + #ifndef FCNT_NAMES + #if FCNT_MAX != 3 +@@ -76,6 +79,56 @@ static void pf_submit(char const *type, char const *type_instance, uint64_t val, + plugin_dispatch_values(&vl); + } /* void pf_submit */ + ++#ifdef __FreeBSD__ ++static int pf_read(void) { ++ struct pfctl_status *state; ++ int fd; ++ ++ fd = open(pf_device, O_RDONLY); ++ if (fd < 0) { ++ ERROR("pf plugin: Unable to open %s: %s", pf_device, STRERRNO); ++ return -1; ++ } ++ ++ if ((state = pfctl_get_status(fd)) == NULL) { ++ ERROR("pf plugin: ioctl(DIOCGETSTATUS) failed: %s", STRERRNO); ++ close(fd); ++ return -1; ++ } ++ ++ close(fd); ++ ++ if (!state->running) { ++ pfctl_free_status(state); ++ WARNING("pf plugin: PF is not running."); ++ return -1; ++ } ++ ++ for (int i = 0; i < PFRES_MAX; i++) { ++ pf_submit("pf_counters", pf_reasons[i], pfctl_status_counter(state, i), ++ /* is gauge = */ false); ++ } ++ for (int i = 0; i < LCNT_MAX; i++) { ++ pf_submit("pf_limits", pf_lcounters[i], pfctl_status_lcounter(state, i), ++ /* is gauge = */ false); ++ } ++ for (int i = 0; i < FCNT_MAX; i++) { ++ pf_submit("pf_state", pf_fcounters[i], pfctl_status_fcounter(state, i), ++ /* is gauge = */ false); ++ } ++ for (int i = 0; i < SCNT_MAX; i++) { ++ pf_submit("pf_source", pf_scounters[i], pfctl_status_scounter(state, i), ++ /* is gauge = */ false); ++ } ++ ++ pf_submit("pf_states", "current", (uint32_t)state->states, ++ /* is gauge = */ true); ++ ++ pfctl_free_status(state); ++ ++ return 0; ++} /* int pf_read */ ++#else + static int pf_read(void) { + struct pf_status state; + int fd; +@@ -119,5 +172,6 @@ static int pf_read(void) { + + return 0; + } /* int pf_read */ ++#endif + + void module_register(void) { plugin_register_read("pf", pf_read); }