Check Windows Safe Mode

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Check Windows Safe Mode

Post by lpereira »

hello All:
We are facing regular issues in our remote location servers, after a power outage servers ramdonly start in "Safe Mode", and we do not know until we manually log in on them.

I'm wondering if there's a way to monitor if a server is in normal or safe mode and send the alert accordingly.

thanks in advance.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check Windows Safe Mode

Post by mcapra »

You can do this via WMI assuming you have networking on the machine:
https://docs.microsoft.com/en-us/window ... utersystem
https://serverfault.com/questions/43376 ... -safe-mode

Code: Select all

PS H:\> gwmi -Query "SELECT BootupState FROM Win32_ComputerSystem"


__GENUS          : 2
__CLASS          : Win32_ComputerSystem
__SUPERCLASS     :
__DYNASTY        :
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
BootupState      : Normal boot
The check_wmi_plus plugin that ships with Nagios XI allows you to write custom WMI queries and load them as "plugins" under check_wmi_plus. It's a bit complicated though.

Or you could wrap the above execution in some Powershell and parse the BootupState property translating it to an appropriate status code for Nagios.
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check Windows Safe Mode

Post by scottwilkerson »

Thanks @mcapra This is even new one on me..

I wasn't sure that you could call WMI if server is in safe mode, usually machine has limited services operating.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check Windows Safe Mode

Post by mcapra »

Yeah, regarding remote WMI requests I think it would depend on what "flavor" of safe mode you're running in. If the request failed, at least you'd have that.

Locally executed Powershell should work regardless I would think? Never tried it myself.
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check Windows Safe Mode

Post by scottwilkerson »

mcapra wrote:Yeah, regarding remote WMI requests I think it would depend on what "flavor" of safe mode you're running in. If the request failed, at least you'd have that.

Locally executed Powershell should work regardless I would think? Never tried it myself.
Correct, for sure nothing would work if it was a "Network down" safe mode
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Check Windows Safe Mode

Post by lpereira »

Thanks Everyone for the responses.

I think the fastest and "easiest" way is to create a custom Powershell script, as mcapra suggested.

Once i have it created and tested will update the results.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check Windows Safe Mode

Post by scottwilkerson »

lpereira wrote:Thanks Everyone for the responses.

I think the fastest and "easiest" way is to create a custom Powershell script, as mcapra suggested.

Once i have it created and tested will update the results.
Thanks, let us know how it comes out!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked