NCPA on Windows to monitor windows updates

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lucasari
Posts: 15
Joined: Tue Aug 13, 2019 4:26 am

NCPA on Windows to monitor windows updates

Post by lucasari »

Hi,

I have tried many windows updates script and found the following that suits our needs:
https://exchange.nagios.org/directory/P ... ll/details

when on Windows 2016 I run the script it perfectly runs, but when ran as plugin from NCPA, the test-path on the HKLM...\RebootRequired will always fail so it won't notify on pending reboots.
it seems like I am able to browse the HKLM via NCPA only up to HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ but it is unable to find the WindowsUpdate key even tho it exists.
these the various steps I tried:

- I tried to run the service "NCPA Listener" as a local admin on the server, I can confirm the Powershell script runs with that user too, but still unable to access the key
- I tried to change the ExecutionPolicy to Unrestricted and confirmed it was by getting the result of Get-ExecutionPolicy from the plugin but still unable to access the key
- I tried on a couple of different other server with 2016, and never able to access the key.
- I changed the script a little, instead of using Test-Path I tried the Get-ChildItem in order to get an error message, and this is the error message:

Code: Select all

Warning
Unrestricted
Get-ChildItem : Cannot find path 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows
\\CurrentVersion\\WindowsUpdate\\Auto Update\\RebootRequired' because it does not
exist.
At C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_updates.ps1:97
char:1
+ Get-ChildItem -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKEY_LOCAL_MACH...\\RebootRequir
ed:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh
ildItemCommand

Updates: 0 critical, 1 optional
on all these check, if I run the script manually from the same location I get:

Code: Select all

updates installed, reboot required
I am wondering if anybody else had similar problem of accessing registry via NCPA.
lucasari
Posts: 15
Joined: Tue Aug 13, 2019 4:26 am

Re: NCPA on Windows to monitor windows updates

Post by lucasari »

I found the possible reason:
NCPA for windows runs in 32bit, while the key is present only in the 64 bit version of the registry.
is there any plan to build NCPA in 64 bit for windows?

UPDATE:
I found a way to run a 64bit powershell from NCPA.
I edited the ncpa.cfg file for the execution of .ps1 files like this:

Code: Select all

# Windows
.ps1 = C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File $plugin_name $plugin_args
the C:\Windows\SysNative\ shortcut allows you to exit the 32bit sandbox that masquerades the sysmte32 and SysWOW64 folders.
I am able to run the script successfully now.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: NCPA on Windows to monitor windows updates

Post by mbellerue »

Excellent! I'm glad you were able to get this working!

To answer your question, yes, we do plan to have a 64bit version of NCPA available. It's in the works, and we'll have it out as soon as we can.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked