1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 10:39:53 +00:00

Plugin pacman_pending_updates: handle absence of available updates properly

"checkupdates" returns the exit code 2, if no updates are pending.
Previously the plugin did not output anything in this case.

Closes: #1233
This commit is contained in:
Lars Kruse 2021-08-08 15:50:54 +02:00
parent 13b9078f76
commit c2aa56531c

View file

@ -58,14 +58,21 @@ EOM
;; ;;
*) *)
if updates="$(checkupdates)"; then updates="$(checkupdates)"
exitcode=$?
if [ "$exitcode" = 0 ]; then
if [ -n "$updates" ]; then if [ -n "$updates" ]; then
echo "updates.value $(echo "$updates" | wc -l)" echo "updates.value $(echo "$updates" | wc -l)"
echo "updates.extinfo $(echo "$updates" | paste -s -d,)" echo "updates.extinfo $(echo "$updates" | paste -s -d,)"
else else
echo updates.value 0 echo "updates.value 0"
fi fi
echo "updates.value U" && exit 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 fi
;; ;;
esac esac