Skip to main content

Hi,

 

I’m asking a question : There is a simple method to monitor reboot pending of a Linux Server ?

 

Because there are a few methods that’s I read, but don’t know if it’s the right method to do it :

  • Script “check file exist”
  • NRPE4 ?? (I think there is a service to do that)
  • Create a Systemd service and monitor the service (the worse method)

 

For monitor if the Linux server need a reboot there is a way that I learn ; if the server is waiting for a reboot to applied updates, an empty file will be created at :

/var/run/reboot-required

So we just need to verify if the file exist or not, no ? 
So that’s why I’m asking, it is the right way to do that or not ?

 

Sorry for my bad english, i’m french.

Hello :)

It seems that the current Linux connector doesn't allow you to check ‘pending reboot’ unlike its Windows counterpart. Indeed it is possible to check linux pending reboot in several ways, for example via a custom script that can be run as a plugin. Something like this: 

#!/bin/bash
if / -f /var/run/reboot-required ] || needs-restarting -r &>/dev/null; then
echo "Reboot pending on $(hostname)"
else
echo "No reboot needed"
fi

On most Linux distributions, certain files indicate that a reboot is required in “/var/run/reboot-required” so if this file exists, a reboot is pending. And if you use RHEL or CentOS, you can use needs-restarting (from the yum-utils package). If a reboot is required, the command will indicate this.

Hope this may help, kind regards.

 


Hi,

 

Thanks for the help, I understand what you mean but how I can use this script ? 

I add it in a “command check” ? Where I can put this script and how to use it as a service ?

 

I’m waiting your answer.

Kind regards


Hello :)

This script is very rudimentary and will not meet Centreon standards as such. Also as it is, it can only be run if the script is in the directory of Linux Server you want to monitor and with the right rigths to execute it.
However, this is the way to create a command you will be able to link to a service: 

  • Use the same Linux user as the supervision engine: su - centreon-engine
  • Go to the following directory: /usr/lib/centreon/plugins/
  • Create a pending_reboot_linux.sh file
  • Check that the command runs in the console : /usr/lib/centreon/plugins/pending_reboot_linux

 

  • Then go to your Centreon Web and go to the Configuration > Commands > Checks menu and use the Add button.
  • Name the command for example check_pending_reboot_linux, in the Command name field.
  • In the command line field add this: $CENTREONPLUGINS$pending_reboot_linux
  • Save the command and then create a service using this command and link it to your linux host

Kind regards.

 


Reply