Icinga / icinga-powershell-hyperv

A collection of Hyper-V plugins for the Icinga Powershell Framework
GNU General Public License v2.0
6 stars 0 forks source link

Check execution is in some cases very slow #22

Closed K0nne closed 3 years ago

K0nne commented 3 years ago

Hello,

I was looking at the Hyper-V checks and was surprised, that some of them had a very long executiontime. The checks are killed by icinga after 60 seconds.

It takes over a minute to execute them. right now I'm not sure whats the reason for this. Every few seconds I get a glimpse of a progressbar showing "collecting data"

I'm not sure if this is a normal system behaviour or not. Just wanted to let you known.

Invoke-IcingaCheckHyperVSnapshot --> very slow

PS C:\WINDOWS\system32> measure-command {Use-Icinga; return Invoke-IcingaCheckHyperVSnapshot}
You cannot call a method on a null-valued expression.
At C:\Program
Files\WindowsPowerShell\Modules\icinga-powershell-hyperv\plugins\Invoke-IcingaCheckHyperVSnapshot.psm1:294 char:9
+     if ($HypervServer.Summary.ContainsKey('SnapshotLocated')) {
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

[OK] Check package "VM Snapshots"
| 'guest807_latest_snapshot_creation_delta'=37093086s;; 'guest807_c_total_snapshot_size'=69666B;; 'guest807_c_snapsho
t_count_prediction'=534631c;; 'guest807_c_count'=1c;;

Days              : 0
Hours             : 0
Minutes           : 1
Seconds           : 15
Milliseconds      : 444
Ticks             : 754447559
TotalDays         : 0,000873203193287037
TotalHours        : 0,0209568766388889
TotalMinutes      : 1,25741259833333
TotalSeconds      : 75,4447559
TotalMilliseconds : 75444,7559

Invoke-IcingaCheckHyperVOverCommitment --> very slow

PS C:\WINDOWS\system32> measure-command {Use-Icinga; return Invoke-IcingaCheckHyperVOverCommitment}
[OK] Check package "Hyper-V Overcommitment"
| 'hostname1100001_used_percent'=60%;;;0;100 'hostname1100001_used_cores'=64c;;;0;40 'hostname1100001_used_percent'=0%;;
;0;100 'hostname1100001_used_bytes'=212992B;;;0;1099138600960 'c_used_percent'=0%;;;0;100 'c_used_bytes'=4711579123712B;
;;0;8795955593216

Days              : 0
Hours             : 0
Minutes           : 1
Seconds           : 15
Milliseconds      : 164
Ticks             : 751641510
TotalDays         : 0,000869955451388889
TotalHours        : 0,0208789308333333
TotalMinutes      : 1,25273585
TotalSeconds      : 75,164151
TotalMilliseconds : 75164,151

Invoke-IcingaCheckHyperVVmHealth --> very slow

PS C:\WINDOWS\system32> measure-command {Use-Icinga; return Invoke-IcingaCheckHyperVVMHealth}

Days              : 0
Hours             : 0
Minutes           : 1
Seconds           : 15
Milliseconds      : 363
Ticks             : 753634078
TotalDays         : 0,000872261664351852
TotalHours        : 0,0209342799444444
TotalMinutes      : 1,25605679666667
TotalSeconds      : 75,3634078
TotalMilliseconds : 75363,4078

Invoke-IcingaCheckHyperVHealth --> fast

PS C:\WINDOWS\system32> measure-command {Use-Icinga; return Invoke-IcingaCheckHyperVHealth}
[OK] Check package "Hyper-V Health Package"
| 'vmms_status'=4;; 'vmicshutdown_status'=1;; 'vmicguestinterface_status'=1;; 'vmcompute_status'=4;; 'vmicrdv_status'=1;
; 'vmictimesync_status'=1;; 'vmickvpexchange_status'=1;; 'vmicheartbeat_status'=1;; 'vmicvmsession_status'=1;; 'vmicvss_
status'=1;;

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 309
Ticks             : 13093136
TotalDays         : 1,51540925925926E-05
TotalHours        : 0,000363698222222222
TotalMinutes      : 0,0218218933333333
TotalSeconds      : 1,3093136
TotalMilliseconds : 1309,3136

Invoke-IcingaCheckHyperVVirtualSwitches --> fast

PS C:\WINDOWS\system32> measure-command {Use-Icinga; return Invoke-IcingaCheckHyperVVirtualSwitches}
[OK] Check package "Virtual Switches"
| 'networkname_healthstate'=5;;5

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 175
Ticks             : 11750592
TotalDays         : 1,36002222222222E-05
TotalHours        : 0,000326405333333333
TotalMinutes      : 0,01958432
TotalSeconds      : 1,1750592
TotalMilliseconds : 1175,0592
yhabteab commented 3 years ago

Hello @K0nne, Thank you for the report. The plugins are not too slow but the command Use-Icinga. If you always run the plugins with Use-Icinga in front of them, they will of course be slower because this command has to load the whole Icinga powershell framework before the plugins are executed. In comparison to your test results, my test results look like this. It can also be a bit slower with you, because you surely have more VMs and snapshots lying around than I do, but they are not that slow.


icinga> measure-command { return Invoke-IcingaCheckHyperVOverCommitment}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 96
Ticks             : 20967194
TotalDays         : 2,42675856481481E-05
TotalHours        : 0,000582422055555556
TotalMinutes      : 0,0349453233333333
TotalSeconds      : 2,0967194
TotalMilliseconds : 2096,7194
icinga> measure-command { return Invoke-IcingaCheckHyperVVMHealth}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 3
Milliseconds      : 506
Ticks             : 35066777
TotalDays         : 4,05865474537037E-05
TotalHours        : 0,000974077138888889
TotalMinutes      : 0,0584446283333333
TotalSeconds      : 3,5066777
TotalMilliseconds : 3506,6777
icinga> measure-command { return Invoke-IcingaCheckHyperVHealth}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 754
Ticks             : 7540682
TotalDays         : 8,7276412037037E-06
TotalHours        : 0,000209463388888889
TotalMinutes      : 0,0125678033333333
TotalSeconds      : 0,7540682
TotalMilliseconds : 754,0682
icinga> measure-command { return Invoke-IcingaCheckHyperVVirtualSwitches}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 665
Ticks             : 6652038
TotalDays         : 7,69911805555556E-06
TotalHours        : 0,000184778833333333
TotalMinutes      : 0,01108673
TotalSeconds      : 0,6652038
TotalMilliseconds : 665,2038
icinga> measure-command {return Invoke-IcingaCheckHyperVSnapshot}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 6
Milliseconds      : 155
Ticks             : 61551822
TotalDays         : 7,12405347222222E-05
TotalHours        : 0,00170977283333333
TotalMinutes      : 0,10258637
TotalSeconds      : 6,1551822
TotalMilliseconds : 6155,1822
K0nne commented 3 years ago

Hi @Yonas-net I tested my commands from above without the use-icinga. In every case the execution time was reduced between 0 and 1sec.