Windows Update Check

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Windows Update Check

Post by kwhogster »

Guys,

I posted this before but this is now a Nagios config issue

I got the check_ms_win_updates.ps1 working it was a bad line of code in the script. It now runs flawlessly from my Windows 10 Computer.

So now in Nagios I get this
TGKW001 WSUS Notifications for this service have been disabled UNKNOWN 03-04-2017 13:30:00 0d 0h 19m 44s 3/3 CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
In the nsclient log I see this

2017-03-04 13:25:38: error:c:\source\nscp\include\socket/connection.hpp:149: Failed to send data: The file handle supplied is not valid
2017-03-04 13:29:02: error:c:\source\nscp\include\socket/connection.hpp:149: Failed to send data: The file handle supplied is not valid
2017-03-04 13:31:00: error:c:\source\nscp\include\socket/connection.hpp:149: Failed to send data: The file handle supplied is not valid

In the NSCLIENT.INI

; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]
check_ms_win_updates=cmd /c echo scripts/powershell/check_ms_win_updates.ps1 $ARG1$; exit $LastExitCode | powershell.exe -command -


Thoughts
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Windows Update Check

Post by tmcdonald »

How long does it take for that check_ms_win_updates.ps1 script to run on your Windows machine if you run it manually? It almost looks like a timeout according to some other cases with that same error.
Former Nagios employee
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Windows Update Check

Post by kwhogster »

It runs in seconds the other day after I modified it.

Now again it is taken a very long time to execute. not sure why this is

Why would I not get a check nrpe timeout error if it is timing out?


How long can I put in the command line a timeout value -t 90 only 90 seconds how about 1 hour ?


Could it be that it is not running as administrator ????


Thanks
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Windows Update Check

Post by mcapra »

Which NSClient++ version and Windows version are in play? Can you also share a copy of the script you're using currently? I'm going to lab this up and see if I get similar results.

I wouldn't suggest making the timeout value for check_nrpe much larger than the check interval at which it is executed. If you're checking every 60 seconds and the timeout is set to 90 seconds, you can have duplicate checks running at the same time which is not good.
Former Nagios employee
https://www.mcapra.com/
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Windows Update Check

Post by kwhogster »

My NSclient is version 4.4.19

Attached the script

My service

Code: Select all

define service{
        use                     generic-service
        host_name               TGKW001
        service_description     WSUS
        check_command           check_ms_win_updates2
        servicegroups           Windows Updates
        }
My command

Code: Select all

define command{
        command_name    check_ms_win_updates2
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 90 -c check_ms_win_updates -a '-wd 45 -cd 90 -M PSWindowsUpdate'
}
My nsclient

Code: Select all

[/settings/external scripts/scripts]

check_ms_win_updates=cmd /c echo scripts/powershell/check_ms_win_updates.ps1 $ARG1$; exit $LastExitCode | powershell.exe -command -
My template

Code: Select all

define host{
        name                    windows-server  ; The name of this host template
        use                     generic-host    ; Inherit default values from the generic-host template
        check_period            24x7            ; By default, Windows servers are monitored round the clock
        check_interval          5               ; Actively check the server every 5 minutes
        retry_interval          1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts      10              ; Check each server 10 times (max)
        check_command           check-host-alive        ; Default command to check if servers are "alive"
        notification_period     24x7            ; Send notification out at any time - day or night
        notification_interval   30              ; Resend notifications every 30 minutes
        notification_options    d,r             ; Only send notifications for specific host states
        contact_groups          admins          ; Notifications get sent to the admins by default
        hostgroups              windows-servers ; Host groups that Windows servers should be a member of
        register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
        }

How can I make this check only once a week?

Thanks

Tom
Attachments
check_ms_win_updates.txt
Powershell script
(15.9 KiB) Downloaded 416 times
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Windows Update Check

Post by mcapra »

1 week is 10080 minutes, so you should be able to set your check_interval to that.

Haven't had a chance to lab this up yet, but i'll let you know if I find anything weird.
Former Nagios employee
https://www.mcapra.com/
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Windows Update Check

Post by kwhogster »

Thanks

I tried the 10080 but the notification level is less then its check level

What should the notification level be set at

I posted in my other issue this
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Windows Update Check

Post by mcapra »

I answered in the other thread. Did you have additional questions specific to the Windows update check?
Former Nagios employee
https://www.mcapra.com/
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Windows Update Check

Post by kwhogster »

yes

How do we get that to work
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Windows Update Check

Post by mcapra »

The notification interval? The check interval? The plugin itself?

We can't offer much assistance with the update check plugin since we didn't write it. The information provided in the previous thread regarding the 1-week check interval should still be valid here:
1 week is 10080 minutes, so you should be able to set your Nagios object's check_interval to that.
Former Nagios employee
https://www.mcapra.com/
Locked