commit: b0f5f087c795c9e35a414698657c01b6372295b7
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 8 Oct 2024 13:30:37 +0200
init
Diffstat:
3 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) <year> <copyright holders>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/nft_bps b/nft_bps
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright © 2024 Haelwenn (lanodan) Monnier
+# SPDX-License-Identifier: MIT
+
+ #%# family=auto
+ #%# capabilities=autoconf
+
+set -e
+
+. "$MUNIN_LIBDIR/plugins/plugin.sh"
+
+case $1 in
+ autoconf)
+ if [ $(nft -j list counters | wc -l) != 0 ]; then
+ echo "No named nftable counters"
+ exit 0
+ fi
+ echo yes
+ exit 0
+ ;;
+ config)
+ echo "graph_title nftables bytes counters"
+ echo "graph_args --base 1000"
+ echo 'graph_vlabel bytes per ${graph_period}'
+ echo 'graph_category nftables'
+ for i in $(nft -j list counters | jq -r '.nftables.[] | select(.counter) | .counter.name'); do
+ echo "${i}.label ${i}"
+ echo "${i}.type DERIVE"
+ echo "${i}.min 0"
+ done
+ exit 0
+ ;;
+esac
+
+nft -j list counters | jq -r '.nftables.[] | select(.counter) | .counter | [.name, ".value ", .bytes] | join("")'
diff --git a/nft_packets b/nft_packets
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright © 2024 Haelwenn (lanodan) Monnier
+# SPDX-License-Identifier: MIT
+
+ #%# family=auto
+ #%# capabilities=autoconf
+
+set -e
+
+. "$MUNIN_LIBDIR/plugins/plugin.sh"
+
+case $1 in
+ autoconf)
+ if [ $(nft -j list counters | wc -l) != 0 ]; then
+ echo "No named nftable counters"
+ exit 0
+ fi
+ echo yes
+ exit 0
+ ;;
+ config)
+ echo "graph_title nftables packet counters"
+ echo "graph_args --base 1000"
+ echo 'graph_vlabel packets per ${graph_period}'
+ echo 'graph_category nftables'
+ for i in $(nft -j list counters | jq -r '.nftables.[] | select(.counter) | .counter.name'); do
+ echo "${i}.label ${i}"
+ echo "${i}.type DERIVE"
+ echo "${i}.min 0"
+ done
+ exit 0
+ ;;
+esac
+
+nft -j list counters | jq -r '.nftables.[] | select(.counter) | .counter | [.name, ".value ", .packets] | join("")'