From 19e5bb6abdfbc69e9f2039485842eb3c0cf87d08 Mon Sep 17 00:00:00 2001 From: Slawomir Gonet Date: Thu, 28 Feb 2019 00:12:47 +0100 Subject: [PATCH] yum.sh: yum update monitor (#1273) Signed-off-by: Slawomir Gonet --- text_collector_examples/yum.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 text_collector_examples/yum.sh diff --git a/text_collector_examples/yum.sh b/text_collector_examples/yum.sh new file mode 100755 index 00000000..d0034ee8 --- /dev/null +++ b/text_collector_examples/yum.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Description: Expose metrics from yum updates. +# +# Author: Slawomir Gonet +# +# Based on apt.sh by Ben Kochie + +upgrades=$(/usr/bin/yum -q check-updates | awk 'BEGIN { mute=1 } /Obsoleting Packages/ { mute=0 } mute { print }' | egrep '^\w+\.\w+' | awk '{print $3}' | sort | uniq -c | awk '{print "yum_upgrades_pending{origin=\""$2"\"} "$1}') + +echo '# HELP yum_upgrades_pending Yum package pending updates by origin.' +echo '# TYPE yum_upgrades_pending gauge' +if [[ -n "${upgrades}" ]] ; then + echo "${upgrades}" +else + echo 'yum_upgrades_pending{origin=""} 0' +fi +