mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
[#6]: Optimise message building for hello message
This commit is contained in:
parent
05633f331f
commit
d515b22255
1 changed files with 15 additions and 15 deletions
|
|
@ -13,26 +13,26 @@ $ClientJobs | Add-Member -membertype ScriptMethod -name 'AddTicks' -value {
|
||||||
$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);
|
||||||
|
|
||||||
[hashtable]$hello = @{
|
|
||||||
'os' = $os;
|
|
||||||
'fqdn' = $fqdn;
|
|
||||||
'version' = $version;
|
|
||||||
'port' = $Icinga2.Config.'tcp.socket.port';
|
|
||||||
};
|
|
||||||
|
|
||||||
[string]$token = $this.getAuthToken();
|
|
||||||
if ([string]::isNullOrEmpty($token) -eq $FALSE) {
|
|
||||||
$hello.Add(
|
|
||||||
'modules',
|
|
||||||
(New-Icinga-Monitoring -ListModules)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this.hello_counter -ge 30) {
|
if ($this.hello_counter -ge 30) {
|
||||||
$this.hello_counter = 0;
|
$this.hello_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this.hello_counter -eq 0 -Or $force -eq $TRUE) {
|
if ($this.hello_counter -eq 0 -Or $force -eq $TRUE) {
|
||||||
|
[hashtable]$hello = @{
|
||||||
|
'os' = $os;
|
||||||
|
'fqdn' = $fqdn;
|
||||||
|
'version' = $version;
|
||||||
|
'port' = $Icinga2.Config.'tcp.socket.port';
|
||||||
|
};
|
||||||
|
|
||||||
|
[string]$token = $this.getAuthToken();
|
||||||
|
if ([string]::isNullOrEmpty($token) -eq $FALSE) {
|
||||||
|
$hello.Add(
|
||||||
|
'modules',
|
||||||
|
(New-Icinga-Monitoring -ListModules)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
$response = $Icinga2.ClientProtocol.NewRequest(
|
$response = $Icinga2.ClientProtocol.NewRequest(
|
||||||
@('X-Windows-Hello: 1'),
|
@('X-Windows-Hello: 1'),
|
||||||
($hello | ConvertTo-Json -Depth 2 -Compress),
|
($hello | ConvertTo-Json -Depth 2 -Compress),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue