@@ -109,7 +109,9 @@ func (p *PerformanceManager) buildAvailablePerfMetricsQueryResponse(ids []types.
109109 r .Returnval = append (r .Returnval , types.PerfMetricId {CounterId : id .CounterId , Instance : strconv .Itoa (i )})
110110 }
111111 case "$physDisk" :
112- r .Returnval = append (r .Returnval , types.PerfMetricId {CounterId : id .CounterId , Instance : datastoreURL })
112+ if datastoreURL != "" {
113+ r .Returnval = append (r .Returnval , types.PerfMetricId {CounterId : id .CounterId , Instance : datastoreURL })
114+ }
113115 case "$file" :
114116 r .Returnval = append (r .Returnval , types.PerfMetricId {CounterId : id .CounterId , Instance : "DISKFILE" })
115117 r .Returnval = append (r .Returnval , types.PerfMetricId {CounterId : id .CounterId , Instance : "DELTAFILE" })
@@ -128,7 +130,11 @@ func (p *PerformanceManager) queryAvailablePerfMetric(ctx *Context, entity types
128130 switch entity .Type {
129131 case "VirtualMachine" :
130132 vm := ctx .Map .Get (entity ).(* VirtualMachine )
131- return p .buildAvailablePerfMetricsQueryResponse (p .vmMetrics , int (vm .Summary .Config .NumCpu ), vm .Datastore [0 ].Value )
133+ ds := ""
134+ if len (vm .Datastore ) != 0 {
135+ ds = vm .Datastore [0 ].Value
136+ }
137+ return p .buildAvailablePerfMetricsQueryResponse (p .vmMetrics , int (vm .Summary .Config .NumCpu ), ds )
132138 case "HostSystem" :
133139 host := ctx .Map .Get (entity ).(* HostSystem )
134140 return p .buildAvailablePerfMetricsQueryResponse (p .hostMetrics , int (host .Hardware .CpuInfo .NumCpuThreads ), host .Datastore [0 ].Value )
0 commit comments