Skip to content

Commit 92e3171

Browse files
author
Philipp D
authored
Merge pull request #19 from Icinga/fix/wrong_output_calculation
Fix data type of output
2 parents c4c1788 + 2e26f2e commit 92e3171

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

provider/mssql/Get-IcingaMSSQLBackupOverallStatus.psm1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@
126126
$TotalBackupSize = (Get-IcingaHashtableItem -Hashtable $LastBackup -Key 'TotalBackupSize' -NullValue 0) + $Entry.backup_size;
127127

128128
[hashtable]$CurrentBackup = @{
129-
'TotalBackupSize' = $TotalBackupSize;
130-
'AvgBackupSize' = ($TotalBackupSize / ([Math]::Max($BackupHistory.Count, 1)));
129+
'TotalBackupSize' = ([long]$TotalBackupSize);
130+
'AvgBackupSize' = ([math]::round([decimal](([long]$TotalBackupSize) / ([Math]::Max($BackupHistory.Count, 1))), 4));
131131
'UUID' = $Entry.backup_set_uuid;
132132
'StartDate' = $Entry.backup_start_date;
133133
'FinishDate' = $Entry.backup_finish_date;
134134
'IsDamaged' = $Entry.is_damaged;
135135
'Type' = $Entry.type;
136-
'LastBackupLogAge' = $LastBackupLogAge;
137-
'LastBackupAge' = ($Entry.last_backup_hours * 60 * 60);
138-
'ExecutionTime' = ($Entry.last_backup_duration_min * 60);
136+
'LastBackupLogAge' = [long]$LastBackupLogAge;
137+
'LastBackupAge' = (([long]$Entry.last_backup_hours) * 60 * 60);
138+
'ExecutionTime' = (([long]$Entry.last_backup_duration_min) * 60);
139139
'Location' = $Entry.physical_device_name;
140140
'Drive' = $BackupDrive;
141141
'Status' = $Entry.state;

provider/mssql/Get-IcingaMSSQLPerformanceCounter.psm1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,21 @@ function Get-IcingaMSSQLPerformanceCounter
133133
Close-IcingaMSSQLConnection -SqlConnection $SqlConnection;
134134
}
135135

136-
return $Data;
136+
[array]$CounterResult = @();
137+
138+
foreach ($counter in $Data) {
139+
[decimal]$CounterValue = 0;
140+
if ((Test-Numeric $counter.cntr_value)) {
141+
$CounterValue = ([math]::round([decimal]$counter.cntr_value, 6));
142+
}
143+
144+
$CounterResult += @{
145+
'instance_name' = $counter.instance_name;
146+
'object_name' = $counter.object_name;
147+
'counter_name' = $counter.counter_name;
148+
'cntr_value' = $CounterValue;
149+
}
150+
}
151+
152+
return $CounterResult;
137153
}

0 commit comments

Comments
 (0)