logo

munin-plugins

Collection of my custom munin pluginsgit clone https://hacktivis.me/git/munin-plugins.git

nft_bps (805B)


  1. #!/bin/sh
  2. # Copyright © 2024 Haelwenn (lanodan) Monnier
  3. # SPDX-License-Identifier: MIT
  4. #%# family=auto
  5. #%# capabilities=autoconf
  6. set -e
  7. . "$MUNIN_LIBDIR/plugins/plugin.sh"
  8. case $1 in
  9. autoconf)
  10. if [ $(nft -j list counters | wc -l) = 0 ]; then
  11. echo "No named nftable counters"
  12. exit 0
  13. fi
  14. echo yes
  15. exit 0
  16. ;;
  17. config)
  18. echo "graph_title nftables bytes counters"
  19. echo "graph_args --base 1000"
  20. echo 'graph_vlabel bytes per ${graph_period}'
  21. echo 'graph_category nftables'
  22. for i in $(nft -j list counters | jq -r '.nftables.[] | select(.counter) | .counter.name'); do
  23. echo "${i}.label ${i}"
  24. echo "${i}.type DERIVE"
  25. echo "${i}.min 0"
  26. done
  27. exit 0
  28. ;;
  29. esac
  30. nft -j list counters | jq -r '.nftables.[] | select(.counter) | .counter | [.name, ".value ", .bytes] | join("")'