Repository
Munin (contrib)
Last change
2021-08-08
Graph Categories
Family
auto
Capabilities
Keywords
Language
Shell
License
GPL-2.0-only
Authors

pacman_pending_updates

Name

pacman_pending_updates - Plugin to monitor pending updates

Applicable Systems

All systems with pacman as their package manager.

Configuration

The plugin needs no additional configuration and works out of the box.

Interpretation

This plugin will draw one line: the number of updates pending.

Magic Markers

#%# family=auto
#%# capabilities=autoconf

Version

1.1.1

Author

Bert Peters bert@bertptrs.nl

License

GPLv2

#!/bin/sh

: <<=cut

=head1 NAME

pacman_pending_updates - Plugin to monitor pending updates

=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 line: the number of updates pending.

=head1 MAGIC MARKERS

  #%# family=auto
  #%# capabilities=autoconf

=head1 VERSION

  1.1.1

=head1 AUTHOR

Bert Peters <bert@bertptrs.nl>

=head1 LICENSE

GPLv2

=cut

case $1 in
	config)
		cat <<'EOM'
graph_args --base 1000 -l 0
graph_title Pending updates
graph_vlabel updates
graph_category security
updates.label updates
updates.info Current number of pending updates
EOM
		;;

	autoconf)
		if hash checkupdates >/dev/null 2>&1; then
			echo yes
		else
			echo "no (checkupdates not found)"
		fi
		;;

	*)
		updates="$(checkupdates)"
		exitcode=$?
		if [ "$exitcode" = 0 ]; then
			if [ -n "$updates" ]; then
				echo "updates.value $(echo "$updates" | wc -l)"
				echo "updates.extinfo $(echo "$updates" | paste -s -d,)"
			else
				echo "updates.value 0"
			fi
		elif [ "$exitcode" = 2 ]; then
			# Surprisingly "checkupdates" returns the exitcode 2, if all packages are
			# up to date.
			echo "updates.value 0"
		else
			echo "updates.value U"
		fi
		;;
esac

exit 0