Show reboot needed Linux

I have a script that I use to determine if a Linux server needs to be rebooted or not. Trying to figure out how to create a fixlet or analysis so this is in BigFix.

#!/bin/bash
if [ -f /var/run/reboot-required ]; then
age=$(( $(date +%s) - $(date -r /var/run/reboot-required +%s) ))
echo “1:$age:Restart Required”
else
echo “0:0:No restart required”
fi

I was looking to see if something like this already existed but didn’t see anything in BigFix. I would like to have Linux systems that show relevant to execute the fixlet so they get rebooted.

The relevance

pending restart

will return true if the client needs to be rebooted.

This ought to be documented at developer.bigfix.com, but curiously, I can’t find it on that page.

3 Likes

Q: pending restart
E: No inspector context.
T: 90

What does this mean?

It means you are running in QNA or the fixlet debugger.

See Common Relevance Error Messages

2 Likes

If you want to test it, create an Analyses and create a Property “Pending Restart” and put the Relevance “pending restart” into it. You can target All Computers with this Relevance.

3 Likes

The ‘pending restart’ inspector will return True if a BigFix action has flagged the system needs a restart (on Linux, we don’t check other places).
If your script is setting that file, you could make a Fixlet relevant by checking

exists file "/var/run/reboot-required"

You could have an Analysis return your results via something like

modification times of files "/var/run/reboot-required"

3 Likes

I tried but failed to create analysis for it. How can I create analysis using “/var/run/reboot-required” or modification times of files “/var/run/reboot-required” for the Linux.

Is it required any specific permission to read the file in Linux ?

Can you help for the same?