diff --git a/collector/hyperv.go b/collector/hyperv.go index d0bf01b1..5f476390 100644 --- a/collector/hyperv.go +++ b/collector/hyperv.go @@ -1001,8 +1001,17 @@ func (c *HyperVCollector) collectVmCpuUsage(ch chan<- prometheus.Metric) (*prome } // The name format is :Hv VP parts := strings.Split(obj.Name, ":") + if len(parts) != 2 { + log.Warnf("Unexpected format of Name in collectVmCpuUsage: %q, expected %q. Skipping.", obj.Name, ":Hv VP ") + continue + } + coreParts := strings.Split(parts[1], " ") + if len(coreParts) != 3 { + log.Warnf("Unexpected format of core identifier in collectVmCpuUsage: %q, expected %q. Skipping.", parts[1], "Hv VP ") + continue + } vmName := parts[0] - coreId := strings.Split(parts[1], " ")[2] + coreId := coreParts[2] ch <- prometheus.MustNewConstMetric( c.VMGuestRunTime,