monitoring-plugins icon indicating copy to clipboard operation
monitoring-plugins copied to clipboard

Windows 'updates.exe' times out

Open withanhdammit opened this issue 1 year ago • 1 comments

This issue respects the following points:

  • [X] This is a bug, not a question or a setup/configuration issue.
  • [X] This issue is not already reported on Github (I've searched it).
  • [X] I use the latest release of the Monitoring Plugins (https://github.com/Linuxfabrik/monitoring-plugins/releases).
  • [X] I agree to follow Monitoring Plugins's Code of Conduct.

Which variant of the Monitoring Plugins do you use?

  • [ ] .rpm/.deb package from repo.linuxfabrik.ch
  • [ ] Compiled for Linux (.tar/.zip from download.linuxfabrik.ch)
  • [X] Compiled for Windows (from download.linuxfabrik.ch)
  • [ ] Source Code from GitHub

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

withanhdammit avatar May 08 '24 19:05 withanhdammit

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;
    }
    "

markuslf avatar May 11 '24 08:05 markuslf

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

withanhdammit avatar Jun 04 '24 01:06 withanhdammit

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

markuslf avatar Jun 04 '24 11:06 markuslf

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.

withanhdammit avatar Jun 04 '24 17:06 withanhdammit

Yeah, seems to be an Icinga issue.

markuslf avatar Jun 07 '24 14:06 markuslf