Linuxfabrik / monitoring-plugins

200+ check plugins for Icinga and other Nagios-compatible monitoring applications. Each plugin is a standalone command line tool (written in Python) that provides a specific type of check.
https://linuxfabrik.ch
The Unlicense
207 stars 48 forks source link

Windows 'updates.exe' times out #761

Closed withanhdammit closed 1 month ago

withanhdammit commented 2 months ago

This issue respects the following points:

Which variant of the Monitoring Plugins do you use?

Bug description

Windows 'updates.exe' plugin always returns a timeout.

I initially had an issue with permissions, but following issue 695 resolved that, but now is returning timeouts.

This happens whether run via a check, from the command line, both standard as well as elevated. image

image

image

Steps to reproduce - Plugin call

'C:\ProgramData\icinga2\usr\lib64\nagios\plugins\updates.exe' '--critical' '50' '--timeout' '300' '--warning' '2'

Steps to reproduce - Data

Run the check whether from the Icinga2 portal or from the command line.

Environment

Windows Server 2022, domain joined, running either via the Icinga2 check, or manually through a standard command prompt or an elevated command prompt.

Plugin Version

updates: v2023112901 by Linuxfabrik GmbH, Zurich/Switzerland

Python version

No response

List of Python modules

Using Windows compiled version

Additional Information

No response

markuslf commented 1 month ago

How long does the following command take on your machine? What does it return?


powershell -Command "
    $WindowsUpdates = New-Object -ComObject 'Microsoft.Update.Session';
    $SearchIndex = $WindowsUpdates.CreateUpdateSearcher();
    $Pending = $SearchIndex.Search('IsInstalled=0');
    foreach ($update in $Pending.Updates) {
        [string]$name = [string]::Format('{0} [{1}]', $update.Title, $update.LastDeploymentChangeTime);
        Write-Output $name;
    }
    "
withanhdammit commented 1 month ago

Hi Mark,

I apologize for the late reply, apparently I did not have notifications enabled so I didn't see your reply until now.

This is from a non-elevated PowerShell prompt:

Get-Date

#powershell -Command "
    $WindowsUpdates = New-Object -ComObject 'Microsoft.Update.Session';
    $SearchIndex = $WindowsUpdates.CreateUpdateSearcher();
    $Pending = $SearchIndex.Search('IsInstalled=0');
    foreach ($update in $Pending.Updates) {
        [string]$name = [string]::Format('{0} [{1}]', $update.Title, $update.LastDeploymentChangeTime);
        Write-Output $name;
    }
#    "

Get-Date

Results:

Monday, June 3, 2024 6:53:49 PM
Monday, June 3, 2024 6:57:05 PM
markuslf commented 1 month ago

Try to increase the timeout by updates --timeout 600. Closing this issue.

withanhdammit commented 1 month ago

Interestingly, the plugin does not seem to be respecting the timeout.

Executed Command
'C:\ProgramData\icinga2\usr\lib64\nagios\plugins\updates.exe' '--critical' '50' '--timeout' '600' '--warning' '2'
Object Properties
__name  "test-srv22.mydomain.com!Updates"
acknowledgement 1
acknowledgement_expiry  0
acknowledgement_last_change 1711757304.907525
action_url  ""
active  true
check_attempt   1
check_command   cmd-check-updates-windows
check_interval  86400
check_period    ""
check_timeout   10
command_endpoint    "test-srv22.mydomain.com"
display_name    "Updates"
downtime_depth  0
enable_active_checks    true
enable_event_handler    false
enable_flapping false

Odd the 'check_timeout' is '10', when the command line shows '--timeout' is '600'.

Also, when run on the command line, setting the timeout to 600 worked, I got the expected result, however something seems to be amiss in that it's not actually applying the timeout when run through Icinga.

markuslf commented 1 month ago

Yeah, seems to be an Icinga issue.