1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 10:39:53 +00:00
Munin-Contrib/plugins/other/pacman_unrequired_packages
Olivier Mehani 45b02b302e
pacman_unrequired_packages: new plugin
Heavily based on pacman_pending_updates
2025-01-17 22:52:47 +11:00

81 lines
1.5 KiB
Bash
Executable file

#!/bin/sh
: <<=cut
=head1 NAME
pacman_unrequired_packages - Plugin to monitor packages no longer required.
=head1 APPLICABLE SYSTEMS
All systems with pacman as their package manager.
=head1 CONFIGURATION
The plugin needs no additional configuration and works out of the box.
=head1 INTERPRETATION
This plugin will draw one block: the number of packages no longer required.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
1.0.0
=head1 AUTHOR
Olivier Mehani <shtrom+munin@ssji.net>
Bert Peters <bert@bertptrs.nl> (pacman_pending_updates)
=head1 LICENSE
GPLv2
=cut
case $1 in
config)
cat <<'EOM'
graph_args --base 1000 -l 0
graph_title Unrequired packages
graph_vlabel packages
graph_category security
unrequired.label unrequired
unrequired.info Current number of unrequired packages. They can be removed with `pacman -Rsn $(pacman -Qdtq).`
unrequired.draw AREA
EOM
;;
autoconf)
if hash pacman >/dev/null 2>&1; then
echo yes
else
echo "no (pacman not found)"
fi
;;
*)
unrequired="$(pacman -Qdtq)"
exitcode=$?
if [ "$exitcode" = 0 ]; then
if [ -n "$unrequired" ]; then
echo "unrequired.value $(echo "$unrequired" | wc -l)"
echo "unrequired.extinfo $(echo "$unrequired" | paste -s -d,)"
else
echo "unrequired.value 0"
fi
elif [ "$exitcode" = 1 ]; then
# "pacman" returns the exitcode 1 if no matching package is found
echo "unrequired.value 0"
else
echo "unrequired.value U"
fi
;;
esac
exit 0