mirror of
https://github.com/openwrt/packages.git
synced 2025-12-16 07:31:20 +00:00
As muninlite doesn't appear to have had a release in a few years and activity on the git repo appears to have stalled, we add some patches on our end for now. Patches: - 001->004 are upstream fixes from master. - 100 is a submitted PR: https://github.com/munin-monitoring/muninlite/pull/19 to fix https://github.com/munin-monitoring/muninlite/issues/14. - 200->204 is a submitted PR to allow customizing the monitored network interfaces: https://github.com/munin-monitoring/muninlite/pull/18. Despite the large number of patches it is actually a trivial change. Signed-off-by: Rany Hany <rany_hany@riseup.net>
89 lines
2.8 KiB
Diff
89 lines
2.8 KiB
Diff
From cd0d4478916ff203db1d3e403b99a58d60d7c5ec Mon Sep 17 00:00:00 2001
|
|
From: Rany Hany <rany_hany@riseup.net>
|
|
Date: Thu, 2 Jan 2025 14:26:07 +0200
|
|
Subject: [PATCH 5/5] netstat: drop `netstat -s` dep by using `/proc/net/snmp`
|
|
data directly
|
|
|
|
This allows the plugin to work under OpenWRT as the busybox netstat
|
|
does not support `netstat -s`.
|
|
|
|
Fixes: https://github.com/munin-monitoring/muninlite/issues/14
|
|
Signed-off-by: Rany Hany <rany_hany@riseup.net>
|
|
---
|
|
muninlite.in | 2 +-
|
|
plugins/netstat | 54 +++++++++++++++++++++++++++++++++++++++++++------
|
|
2 files changed, 49 insertions(+), 7 deletions(-)
|
|
|
|
--- a/muninlite.in
|
|
+++ b/muninlite.in
|
|
@@ -87,7 +87,7 @@ for PLUG in $PLUGINS; do
|
|
done
|
|
;;
|
|
netstat)
|
|
- if netstat -s >/dev/null 2>&1; then
|
|
+ if [ -f /proc/net/snmp ]; then
|
|
RES="$RES netstat"
|
|
fi
|
|
;;
|
|
--- a/plugins/netstat
|
|
+++ b/plugins/netstat
|
|
@@ -31,10 +31,52 @@ config_netstat() {
|
|
echo "established.info The number of currently open connections."
|
|
}
|
|
fetch_netstat() {
|
|
- NINFO=$(netstat -s | sed 's/ \{1,\}/ /g')
|
|
- echo "active.value" "$(echo "$NINFO" | grep "active connection" | cut -d " " -f 2)"
|
|
- echo "passive.value" "$(echo "$NINFO" | grep "passive connection" | cut -d " " -f 2)"
|
|
- echo "failed.value" "$(echo "$NINFO" | grep "failed connection" | cut -d " " -f 2)"
|
|
- echo "resets.value" "$(echo "$NINFO" | grep "connection resets" | cut -d " " -f 2)"
|
|
- echo "established.value" "$(echo "$NINFO" | grep "connections established" | cut -d " " -f 2)"
|
|
+ awk '
|
|
+ BEGIN {
|
|
+ TcpNR = -1
|
|
+ ActiveOpens = -1
|
|
+ PassiveOpens = -1
|
|
+ AttemptFails = -1
|
|
+ EstabResets = -1
|
|
+ CurrEstab = -1
|
|
+ }
|
|
+
|
|
+ /^Tcp: / {
|
|
+ if (++TcpNR == 0) {
|
|
+ for (i = 1; i <= NF; i++) {
|
|
+ if ($i == "ActiveOpens") {
|
|
+ ActiveOpens = i
|
|
+ } else if ($i == "PassiveOpens") {
|
|
+ PassiveOpens = i
|
|
+ } else if ($i == "AttemptFails") {
|
|
+ AttemptFails = i
|
|
+ } else if ($i == "EstabResets") {
|
|
+ EstabResets = i
|
|
+ } else if ($i == "CurrEstab") {
|
|
+ CurrEstab = i
|
|
+ }
|
|
+ }
|
|
+ } else if (TcpNR == 1) {
|
|
+ if (ActiveOpens < 1 || PassiveOpens < 1 || AttemptFails < 1 || EstabResets < 1 || CurrEstab < 1) {
|
|
+ TcpNR = -1
|
|
+ } else {
|
|
+ print "active.value " $ActiveOpens
|
|
+ print "passive.value " $PassiveOpens
|
|
+ print "failed.value " $AttemptFails
|
|
+ print "resets.value " $EstabResets
|
|
+ print "established.value " $CurrEstab
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ END {
|
|
+ if (TcpNR < 1) {
|
|
+ print "active.value 0"
|
|
+ print "passive.value 0"
|
|
+ print "failed.value 0"
|
|
+ print "resets.value 0"
|
|
+ print "established.value 0"
|
|
+ }
|
|
+ }
|
|
+ ' /proc/net/snmp
|
|
}
|