diff --git a/plugins/system/deborphan b/plugins/system/deborphan index e063de53..0fe38591 100755 --- a/plugins/system/deborphan +++ b/plugins/system/deborphan @@ -30,6 +30,9 @@ GPLv2 =cut +# shellcheck disable=SC1090 +. "$MUNIN_LIBDIR/plugins/plugin.sh" + # Auto enable if we have deborphan only if [ "$1" = "autoconf" ] ; then if which deborphan >/dev/null; then @@ -46,12 +49,9 @@ if ! which deborphan >/dev/null; then exit 1 fi -OUT=$(mktemp -t munin-deborphan.XXXXXX) -TMPFILES=$OUT -trap 'rm -f $TMPFILES' EXIT -deborphan --show-section --guess-all | sed 's/\//_/' | sort > "${OUT}" +OUT=$(deborphan --show-section --guess-all | sort) -CATEGORIES="$(awk '{print $1}' "${OUT}" | uniq)" +CATEGORIES="$(echo "${OUT}" | awk '{print $1}' | uniq)" if [ "$1" = "config" ]; then cat < "${TMP}" - echo "${cat}.value $(wc -l < "${TMP}")" - # shellcheck disable=SC2005 disable=SC2046 - # echo is not useless here: we want everything on one line - echo "${cat}.extinfo $(echo $(cat "${TMP}"))" + for CAT in ${CATEGORIES}; do + CATFIELD=$(clean_fieldname "${CAT}") + CATDATA=$(echo "${OUT}" | sed -n "s#${CAT} \+##p") + echo "${CATFIELD}.value $(echo "${CATDATA}" | wc -l)" + echo "${CATFIELD}.extinfo $(echo "${CATDATA}" | tr '\n' ' ')" done fi