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

Invoke-IcingaCheckHyperVSnapshot - Exception calling "WarnOutOfRange" with "1" argument(s): "Cannot convert value "B" to type "System.Decimal". Error: "Input string was not in a correct format."" #67

Closed K0nne closed 1 year ago

K0nne commented 1 year ago

Hello!

On some of our HyperV hosts the check Invoke-IcingaCheckHyperVSnapshot has problems while parsing the results. Those machines seems to behave different than the majority. It happens in our qs and prod stage.

Output:

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

CheckCommand: Invoke-IcingaCheckHyperVSnapshot Arguments: System.Collections.Hashtable StackTrace: at Invoke- 
 IcingaCheckHyperVSnapshot, C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-hyperv\compiled\icinga-powershell- 
 hyperv.ifw_compilation.psm1: line 623 at Exit-IcingaExecutePlugin, C:\Program Files\WindowsPowerShell\Modules\icinga-powershell- 
 framework\cache\framework_cache.psm1: line 26525 at , : line 1

Line 623: image

K0nne commented 1 year ago

This is the plugin execution:

icinga {Invoke-IcingaCheckHyperVSnapshot -CreationTimeCritical 1209600s -TotalSnapshotSizeWarning 30% -TotalSnapshotSizeCritical 40% -Verbosity 2 -AvoidEmptyCheck}

Important finding: The error appears only if the arguments -TotalSnapshotSizeWarning or -TotalSnapshotSizeCritical are used. Otherwise everything works fine.

with TotalSnapshotSizeWarning/Critical:

PS C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework> icinga {Invoke-IcingaCheckHyperVSnapshot -TotalSnapshotSizeWarning 30% -TotalSnapshotSizeCritical 40%}
Exception calling "WarnOutOfRange" with "1" argument(s): "Cannot convert value "B" to type "System.Decimal". Error: "Input string was not in a correct format.""
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-hyperv\compiled\icinga-powershell-hyperv.ifw_compilation.psm1:623 char:13
+             $SnapshotMainCheck.AddCheck(
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ScriptMethodRuntimeException

[OK] VM Snapshots: 5 Ok

without on the same machine:

PS C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework> icinga {Invoke-IcingaCheckHyperVSnapshot}
[OK] VM Snapshots: 5 Ok
LordHepipud commented 1 year ago

Could you please test the linked PR? This should resolve the problem.

K0nne commented 1 year ago

With the PR the error message differs slightly, but its still the same. Do I have to change something within the framework?

Exception calling "WarnOutOfRange" with "1" argument(s): "Cannot convert value "B" to type "System.Decimal". Error: "Input string was not in a correct format.""
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-hyperv\compiled\icinga-powershell-hyperv.ifw_compilation.psm1:624 char:17
+                 $SnapshotMainCheck.AddCheck(
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ScriptMethodRuntimeException

[OK] VM Snapshots: 5 Ok

//edit: Framework 1.11.0 changed nothing.

LordHepipud commented 1 year ago

Did you run the command within an Icinga shell and the arguments -DeveloperMode and -RebuildCache?

icinga { Invoke-IcingaCheckHyperVSnapshot -TotalSnapshotSizeWarning 30% -TotalSnapshotSizeCritical 40% } -DeveloperMode -RebuildCache
K0nne commented 1 year ago

Unfortunately I did everything right.

sniplet from overview:

framework    1.11.0
hyperv       1.3.0

check execution:

PS C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework> icinga {Invoke-IcingaCheckHyperVSnapshot -TotalSnapshotSizeWarning 30% -TotalSnapshotSizeCritical 40%} -DeveloperMode -RebuildCache
Exception calling "WarnOutOfRange" with "1" argument(s): "Cannot convert value "B" to type "System.Decimal". Error: "Input string was not in a correct format.""
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-hyperv\compiled\icinga-powershell-hyperv.ifw_compilation.psm1:624 char:17
+                 $SnapshotMainCheck.AddCheck(
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ScriptMethodRuntimeException

[OK] VM Snapshots: 5 Ok
K0nne commented 1 year ago

The affected snapshot is from a vm without scsi controller and disk:

image

K0nne commented 1 year ago

The updated PR fixes the problem 👍