nft_packets (810B)
- #!/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("")'