Skip to content

Commit 34dd42e

Browse files
authored
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 <[email protected]>
1 parent 5781348 commit 34dd42e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: yum.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Description: Expose metrics from yum updates.
44
#
55
# Author: Slawomir Gonet <[email protected]>
6-
#
6+
#
77
# Based on apt.sh by Ben Kochie <[email protected]>
88

99
set -u -o pipefail
@@ -37,3 +37,14 @@ if [[ -n "${upgrades}" ]] ; then
3737
else
3838
echo 'yum_upgrades_pending{origin=""} 0'
3939
fi
40+
41+
# If yum-utils/dnf-utils is not installed then we skip rendering this metric
42+
if [[ -x /bin/needs-restarting ]] ; then
43+
echo '# HELP node_reboot_required Node reboot is required for software updates.'
44+
echo '# TYPE node_reboot_required gauge'
45+
if /bin/needs-restarting -r > /dev/null 2>&1 ; then
46+
echo 'node_reboot_required 0'
47+
else
48+
echo 'node_reboot_required 1'
49+
fi
50+
fi

0 commit comments

Comments
 (0)