From 34dd42ee2cf5bf1ffcfdea5a3599130f146b88fc Mon Sep 17 00:00:00 2001 From: Arnaud V Date: Thu, 29 Jun 2023 16:38:49 +0200 Subject: [PATCH] Add the node_reboot_required metric to yum.sh (#165) Added the node_reboot_required metric to yum.sh, based on PR #70, with the requested changes incorporated in the code Signed-off-by: Arnaud Vazard --- yum.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/yum.sh b/yum.sh index 23bbaff..f30143f 100755 --- a/yum.sh +++ b/yum.sh @@ -3,7 +3,7 @@ # Description: Expose metrics from yum updates. # # Author: Slawomir Gonet -# +# # Based on apt.sh by Ben Kochie set -u -o pipefail @@ -37,3 +37,14 @@ if [[ -n "${upgrades}" ]] ; then else echo 'yum_upgrades_pending{origin=""} 0' fi + +# If yum-utils/dnf-utils is not installed then we skip rendering this metric +if [[ -x /bin/needs-restarting ]] ; then + echo '# HELP node_reboot_required Node reboot is required for software updates.' + echo '# TYPE node_reboot_required gauge' + if /bin/needs-restarting -r > /dev/null 2>&1 ; then + echo 'node_reboot_required 0' + else + echo 'node_reboot_required 1' + fi +fi