From 05633f331f3d16ed394bd959dc4ceaff28c80f8e Mon Sep 17 00:00:00 2001 From: LordHepipud Date: Thu, 22 Nov 2018 11:31:07 +0100 Subject: [PATCH] [#2] Added module run ticks to main cycle --- core/include/Checker.ps1 | 1 + core/include/ClientJobs.ps1 | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/include/Checker.ps1 b/core/include/Checker.ps1 index a13c6b1..b408c84 100644 --- a/core/include/Checker.ps1 +++ b/core/include/Checker.ps1 @@ -44,6 +44,7 @@ $Checker | Add-Member -membertype ScriptMethod -name 'Start' -value { # they will become executed right on time $StopWatchHandler.Stop(); $this.time_offset = [math]::Round($StopWatchHandler.Elapsed.TotalSeconds, 0); + $Icinga2.ClientJobs.AddTicks($this.time_offset); Start-Sleep -Seconds 1; } diff --git a/core/include/ClientJobs.ps1 b/core/include/ClientJobs.ps1 index cfeabb7..bcd8d19 100644 --- a/core/include/ClientJobs.ps1 +++ b/core/include/ClientJobs.ps1 @@ -4,6 +4,12 @@ $ClientJobs | Add-Member -membertype NoteProperty -name 'hello_counter' -valu $ClientJobs | Add-Member -membertype NoteProperty -name 'module_scheduler' -value @( ); $ClientJobs | Add-Member -membertype NoteProperty -name 'module_output' -value $null; +$ClientJobs | Add-Member -membertype ScriptMethod -name 'AddTicks' -value { + param([int]$ticks); + + $this.hello_counter += $ticks; +} + $ClientJobs | Add-Member -membertype ScriptMethod -name 'WindowsHello' -value { param([string]$os, [string]$fqdn, [string]$version, [bool]$force); @@ -22,6 +28,10 @@ $ClientJobs | Add-Member -membertype ScriptMethod -name 'WindowsHello' -value { ) } + if ($this.hello_counter -ge 30) { + $this.hello_counter = 0; + } + if ($this.hello_counter -eq 0 -Or $force -eq $TRUE) { $response = $Icinga2.ClientProtocol.NewRequest( @('X-Windows-Hello: 1'), @@ -51,14 +61,10 @@ $ClientJobs | Add-Member -membertype ScriptMethod -name 'WindowsHello' -value { $Icinga2.Cache.Checker.Authenticated = $FALSE; return $response; - } else { - if ($this.hello_counter -ge 30) { - $this.hello_counter = 0; - } else { - $this.hello_counter += 1; - } } + $this.hello_counter += 1; + return $null; }