Page 1 of 1
Check Windows Safe Mode
Posted: Fri Jul 27, 2018 6:20 am
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.
Re: Check Windows Safe Mode
Posted: Fri Jul 27, 2018 8:57 am
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.
Re: Check Windows Safe Mode
Posted: Fri Jul 27, 2018 9:31 am
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.
Re: Check Windows Safe Mode
Posted: Fri Jul 27, 2018 9:55 am
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.
Re: Check Windows Safe Mode
Posted: Fri Jul 27, 2018 10:20 am
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
Re: Check Windows Safe Mode
Posted: Fri Jul 27, 2018 10:39 am
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.
Re: Check Windows Safe Mode
Posted: Fri Jul 27, 2018 10:41 am
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!