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