When using PAL 2.7.5 the __Overall Counter Instance Statistics__ sometimes displays incorrect values for Min, Avg and some of the other values, but not for the Max value. This happens the the performance counter data contains values which are 0.
This seems to be caused by the following lines in the FillNullsWithDashesAndIsAllNull function:
```
If (($Values[$i] -eq ' ') -or ($Values[$i] -eq $null))
{
$Values[$i] = '-'
}
```
If the value in ($Values[$i] is 0 PowerShell apparently considers it equal to ' ' which causes those values to become replaced by '-'.
To overcome this I added the following function:
```
Function IsAllMinus
{
param($values)
For ($i=0;$i -le $values.GetUpperBound(0);$i++)
{
If ($values[$i] -ne '-')
{
return $False
}
}
return $True
}
```
and removed the FillNullsWithDashesAndIsAllNull function.
I also replaced the following lines in the LoadCounterDataIntoXml function:
```
$ic = $XmlCounterInstance.COUNTERDATAINDEX
$oCounterInstance.aValues = GetCounterDataFromPerfmonLog -iCounterIndexInCsv $ic
$global:IsValuesAllNull = $True
$oCounterInstance.aValues = FillNullsWithDashesAndIsAllNull -Values $oCounterInstance.aValues
$oCounterInstance.IsAllNull = $global:IsValuesAllNull
If ($global:IsValuesAllNull -eq $True)
{
$XmlCounterInstance.SetAttribute("ISALLNULL", "True")
}
```
with the following lines:
```
$ic = $XmlCounterInstance.COUNTERDATAINDEX
$oCounterInstance.aValues = GetCounterDataFromPerfmonLog -iCounterIndexInCsv $ic
$oCounterInstance.IsAllNull = IsAllMinus -Values $oCounterInstance.aValues
If ($oCounterInstance.IsAllNull -eq $True)
{
$XmlCounterInstance.SetAttribute("ISALLNULL", "True")
}
```
Then it generated correct values.
I hope the code above will be put into the next version of PAL. Let me know if you want me to send you my modified version of PAL.ps1 if that makes it easier for you to incorporate the changes.
Thanks for a great tool!
Comments: ** Comment from web user: Mogensen **
This seems to be caused by the following lines in the FillNullsWithDashesAndIsAllNull function:
```
If (($Values[$i] -eq ' ') -or ($Values[$i] -eq $null))
{
$Values[$i] = '-'
}
```
If the value in ($Values[$i] is 0 PowerShell apparently considers it equal to ' ' which causes those values to become replaced by '-'.
To overcome this I added the following function:
```
Function IsAllMinus
{
param($values)
For ($i=0;$i -le $values.GetUpperBound(0);$i++)
{
If ($values[$i] -ne '-')
{
return $False
}
}
return $True
}
```
and removed the FillNullsWithDashesAndIsAllNull function.
I also replaced the following lines in the LoadCounterDataIntoXml function:
```
$ic = $XmlCounterInstance.COUNTERDATAINDEX
$oCounterInstance.aValues = GetCounterDataFromPerfmonLog -iCounterIndexInCsv $ic
$global:IsValuesAllNull = $True
$oCounterInstance.aValues = FillNullsWithDashesAndIsAllNull -Values $oCounterInstance.aValues
$oCounterInstance.IsAllNull = $global:IsValuesAllNull
If ($global:IsValuesAllNull -eq $True)
{
$XmlCounterInstance.SetAttribute("ISALLNULL", "True")
}
```
with the following lines:
```
$ic = $XmlCounterInstance.COUNTERDATAINDEX
$oCounterInstance.aValues = GetCounterDataFromPerfmonLog -iCounterIndexInCsv $ic
$oCounterInstance.IsAllNull = IsAllMinus -Values $oCounterInstance.aValues
If ($oCounterInstance.IsAllNull -eq $True)
{
$XmlCounterInstance.SetAttribute("ISALLNULL", "True")
}
```
Then it generated correct values.
I hope the code above will be put into the next version of PAL. Let me know if you want me to send you my modified version of PAL.ps1 if that makes it easier for you to incorporate the changes.
Thanks for a great tool!
Comments: ** Comment from web user: Mogensen **
Great!
Here is the modified pal.ps1.
/Erik Mogensen