Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Invoke-IcingaCheckTimeSync when offset is negative - after upgrading from 1.4.0 to 1.5.1 #311

Closed
408573 opened this issue Jul 19, 2021 · 2 comments · Fixed by #312
Assignees
Labels
Bug There is an issue present
Milestone

Comments

@408573
Copy link

408573 commented Jul 19, 2021

Expected Behavior

Plugin should also be able to handle negative offsets.

Current Behavior

After upgrading the PowerShell Plugins from 1.4.0 to 1.5.1 the plugin returns the following message when the time offset is negative:

Output:

[UNKNOWN] Icinga Exception: Exception calling "WarnOutOfRange" with "1" argument(s): "Cannot convert value "-0.02s" to type "System.Decimal". Error: "Input string was not in a correct format.""

CheckCommand: Invoke-IcingaCheckTimeSync Arguments: -Server ntp.domain.net -Warning 1m -Critical 3m -Verbosity 2 StackTrace: at Invoke-IcingaCheckTimeSync, C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-plugins\plugins\Invoke-IcingaCheckTimeSync.psm1: line 77 at Exit-IcingaExecutePlugin, C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\lib\icinga\plugin\Exit-IcingaExecutePlugin.psm1: line 17 at , : line 1

We've imported the baskets with the modified variables etc. into Icinga Director during the migration from 1.4.0 to 1.5.1.

Possible Solution

Maybe there is a bug in the implementation of the following issue:

Fix: Time offset calculation for Invoke-IcingaCheckTimeSync should allow negative offset Icinga/icinga-powershell-plugins#182

Steps to Reproduce (for bugs)

Modify Date/Time on your Windows machine to the future with "Set-Date yyyy-mm-dd hh:mm:ss" and run the check.

Context

When the time offset is negative the plugin returns the state UNKNOWN.

Your Environment

  • PowerShell Version used ($PSVersionTable.PSVersion):
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      14393  4467
  • Operating System and version:
Windows Server 2016
@LordHepipud LordHepipud transferred this issue from Icinga/icinga-powershell-plugins Jul 27, 2021
@LordHepipud LordHepipud added this to the v1.6.0 milestone Jul 27, 2021
@LordHepipud LordHepipud added the Bug There is an issue present label Jul 27, 2021
@LordHepipud LordHepipud self-assigned this Jul 27, 2021
@LordHepipud
Copy link
Collaborator

Thank you for the issue - can you please test the linked PR and check, if this resolves the issue?

@408573
Copy link
Author

408573 commented Jul 27, 2021

Thanks for the quick reply / fix.
After modifying the file Convert-IcingaPluginThresholds.psm1 to the version in the referenced PR, negative time offsets are handled correctly (see below).

PS C:\WINDOWS\system32> Invoke-IcingaCheckTimeSync -Server ntp.domain.net -Warning -60s:60s -Critical -180s:180s -Verbosity 2
[CRITICAL] Time Package [CRITICAL] Time Offset (-5.19m)
\_ [OK] Sync Status: NoLeapWarning
\_ [CRITICAL] Time Offset: -5.19m is outside range -3m and 3m
\_ [OK] Time Service: Running
| 'time_offset'=-311.660004s;-60:60;-180:180 'time_service'=4;;4
2
PS C:\WINDOWS\system32> Invoke-IcingaCheckTimeSync -Server ntp.domain.net -Warning -60s:60s -Critical -180s:180s -Verbosity 2
[WARNING] Time Package [WARNING] Time Offset (-1.44m)
\_ [OK] Sync Status: NoLeapWarning
\_ [WARNING] Time Offset: -1.44m is outside range -1m and 1m
\_ [OK] Time Service: Running
| 'time_offset'=-86.150002s;-60:60;-180:180 'time_service'=4;;4
1

Important note to users: The thresholds need to be set as min./max. settings with negative and positive limits (see example above).

@408573 408573 closed this as completed Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug There is an issue present
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants