update aggregation calculations
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1380,13 +1380,46 @@ SELECT
|
||||
agg.last_present AS "SnapshotTime",
|
||||
agg.samples_present AS "SamplesPresent",
|
||||
CASE WHEN totals.total_samples > 0
|
||||
THEN 1.0 * agg.sum_vcpu / totals.total_samples
|
||||
THEN (1.0 * agg.samples_present / totals.total_samples) * (
|
||||
SELECT s2."VcpuCount"
|
||||
FROM snapshots s2
|
||||
WHERE s2."Vcenter" = agg."Vcenter"
|
||||
AND (
|
||||
(s2."VmId" = agg."VmId" AND s2."VmId" IS NOT NULL AND agg."VmId" IS NOT NULL)
|
||||
OR (s2."VmUuid" = agg."VmUuid" AND s2."VmUuid" IS NOT NULL AND agg."VmUuid" IS NOT NULL)
|
||||
OR (LOWER(s2."Name") = LOWER(agg."Name") AND s2."Name" IS NOT NULL AND agg."Name" IS NOT NULL)
|
||||
)
|
||||
ORDER BY s2."SnapshotTime" DESC
|
||||
LIMIT 1
|
||||
)
|
||||
ELSE NULL END AS "AvgVcpuCount",
|
||||
CASE WHEN totals.total_samples > 0
|
||||
THEN 1.0 * agg.sum_ram / totals.total_samples
|
||||
THEN (1.0 * agg.samples_present / totals.total_samples) * (
|
||||
SELECT s2."RamGB"
|
||||
FROM snapshots s2
|
||||
WHERE s2."Vcenter" = agg."Vcenter"
|
||||
AND (
|
||||
(s2."VmId" = agg."VmId" AND s2."VmId" IS NOT NULL AND agg."VmId" IS NOT NULL)
|
||||
OR (s2."VmUuid" = agg."VmUuid" AND s2."VmUuid" IS NOT NULL AND agg."VmUuid" IS NOT NULL)
|
||||
OR (LOWER(s2."Name") = LOWER(agg."Name") AND s2."Name" IS NOT NULL AND agg."Name" IS NOT NULL)
|
||||
)
|
||||
ORDER BY s2."SnapshotTime" DESC
|
||||
LIMIT 1
|
||||
)
|
||||
ELSE NULL END AS "AvgRamGB",
|
||||
CASE WHEN agg.samples_present > 0
|
||||
THEN 1.0 * agg.sum_disk / agg.samples_present
|
||||
CASE WHEN totals.total_samples > 0
|
||||
THEN (1.0 * agg.samples_present / totals.total_samples) * (
|
||||
SELECT s2."ProvisionedDisk"
|
||||
FROM snapshots s2
|
||||
WHERE s2."Vcenter" = agg."Vcenter"
|
||||
AND (
|
||||
(s2."VmId" = agg."VmId" AND s2."VmId" IS NOT NULL AND agg."VmId" IS NOT NULL)
|
||||
OR (s2."VmUuid" = agg."VmUuid" AND s2."VmUuid" IS NOT NULL AND agg."VmUuid" IS NOT NULL)
|
||||
OR (LOWER(s2."Name") = LOWER(agg."Name") AND s2."Name" IS NOT NULL AND agg."Name" IS NOT NULL)
|
||||
)
|
||||
ORDER BY s2."SnapshotTime" DESC
|
||||
LIMIT 1
|
||||
)
|
||||
ELSE NULL END AS "AvgProvisionedDisk",
|
||||
CASE WHEN totals.total_samples > 0
|
||||
THEN 1.0 * agg.samples_present / totals.total_samples
|
||||
|
||||
@@ -759,10 +759,10 @@ INSERT INTO %s (
|
||||
if v.samples == 0 {
|
||||
continue
|
||||
}
|
||||
avgVcpu := float64(v.sumVcpu) / float64(v.samples)
|
||||
avgRam := float64(v.sumRam) / float64(v.samples)
|
||||
avgDisk := v.sumDisk / float64(v.samples)
|
||||
total := float64(totalSamples)
|
||||
avgVcpu := 0.0
|
||||
avgRam := 0.0
|
||||
avgDisk := 0.0
|
||||
avgPresent := 0.0
|
||||
tinPct := 0.0
|
||||
bronzePct := 0.0
|
||||
@@ -770,6 +770,9 @@ INSERT INTO %s (
|
||||
goldPct := 0.0
|
||||
if total > 0 {
|
||||
avgPresent = float64(v.samples) / total
|
||||
avgVcpu = avgPresent * float64(v.lastVcpu)
|
||||
avgRam = avgPresent * float64(v.lastRam)
|
||||
avgDisk = avgPresent * v.lastDisk
|
||||
}
|
||||
if v.samples > 0 {
|
||||
tinPct = float64(v.tinHits) * 100 / float64(v.samples)
|
||||
|
||||
Reference in New Issue
Block a user