[#2] Added module run ticks to main cycle

This commit is contained in:
LordHepipud 2018-11-22 11:31:07 +01:00
parent 1b086adf23
commit 05633f331f
2 changed files with 13 additions and 6 deletions

View file

@ -44,6 +44,7 @@ $Checker | Add-Member -membertype ScriptMethod -name 'Start' -value {
# they will become executed right on time # they will become executed right on time
$StopWatchHandler.Stop(); $StopWatchHandler.Stop();
$this.time_offset = [math]::Round($StopWatchHandler.Elapsed.TotalSeconds, 0); $this.time_offset = [math]::Round($StopWatchHandler.Elapsed.TotalSeconds, 0);
$Icinga2.ClientJobs.AddTicks($this.time_offset);
Start-Sleep -Seconds 1; Start-Sleep -Seconds 1;
} }

View file

@ -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_scheduler' -value @( );
$ClientJobs | Add-Member -membertype NoteProperty -name 'module_output' -value $null; $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 { $ClientJobs | Add-Member -membertype ScriptMethod -name 'WindowsHello' -value {
param([string]$os, [string]$fqdn, [string]$version, [bool]$force); 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) { if ($this.hello_counter -eq 0 -Or $force -eq $TRUE) {
$response = $Icinga2.ClientProtocol.NewRequest( $response = $Icinga2.ClientProtocol.NewRequest(
@('X-Windows-Hello: 1'), @('X-Windows-Hello: 1'),
@ -51,13 +61,9 @@ $ClientJobs | Add-Member -membertype ScriptMethod -name 'WindowsHello' -value {
$Icinga2.Cache.Checker.Authenticated = $FALSE; $Icinga2.Cache.Checker.Authenticated = $FALSE;
return $response; return $response;
} else { }
if ($this.hello_counter -ge 30) {
$this.hello_counter = 0;
} else {
$this.hello_counter += 1; $this.hello_counter += 1;
}
}
return $null; return $null;
} }