Skip to content

Commit

Permalink
[feature] added host fields for number of vms and datastores
Browse files Browse the repository at this point in the history
  • Loading branch information
tbelda-ems committed May 19, 2023
1 parent 84edcd8 commit f6f5684
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
- memory_size (int) in bytes
- num_cpus (int)
- cpu_freq (int) in MHz
- num_datastores (int)
- num_vms (int)
- vcstat_host_esxcli
- tags:
- esxhostname
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Metric timestamp precision will be set according to the polling interval, so it
vcstat_vcenter,vcenter=vcenter.local name="VMware vCenter Server",num_datacenters=1i,ostype="linux-x64",version="6.5.0" 1653060681000000000
vcstat_datacenter,dcname=MyDC,moid=datacenter-2,vcenter=vcenter.local num_datastores=51i,num_hosts=8i,num_networks=32i,num_clusters=1i 1653060681000000000
vcstat_cluster,clustername=MyCluster-01,dcname=MyDC,moid=domain-c121,vcenter=vcenter.local num_cpu_cores=152i,total_cpu=342248i,total_memory=1648683421696i,effective_cpu=299032i,status="green",status_code=0i,num_vms=26i,num_hosts=8i,num_effective_hosts=8i,num_cpu_threads=304i,effective_memory=1502236i 1653060681000000000
vcstat_host,dcname=MyDC,clustername=MyCluster-01,esxhostname=myesxi01.local,moid=host-706,vcenter=vcenter.local connection_state_code=0i,memory_size=206110695424i,num_cpus=16i,cpu_freq=2199i,status="green",status_code=0i,reboot_required=false,in_maintenance_mode=false,connection_state="connected" 1653060681000000000
vcstat_host,dcname=MyDC,clustername=MyCluster-01,esxhostname=myesxi01.local,moid=host-706,vcenter=vcenter.local connection_state_code=0i,memory_size=206110695424i,num_cpus=16i,num_datasotres=2i,cpu_freq=2199i,status="green",status_code=0i,reboot_required=false,in_maintenance_mode=false,connection_state="connected",num_vms=2i 1653060681000000000
vcstat_host_graphics,address=0000:3b:00.0,clustername=MyCluster-01,dcname=MyDC,device=NVIDIA\ A40,esxhostname=myesxi01.local,vcenter=vcenter.local memory="9",temperature="29",cpu="3",driver="510.84.01" 1653060681000000000
vcstat_host_graphics,address=0000:a1:00.0,clustername=MyCluster-01,dcname=MyDC,device=NVIDIA\ A40,esxhostname=myesxi01.local,vcenter=vcenter.local driver="510.84.01",memory="11",temperature="28",cpu="5" 1653060681000000000
vcstat_host_firewall,dcname=MyDC,clustername=MyCluster-01,esxhostname=myesxi01.local,vcenter=vcenter.local defaultaction="DROP",enabled=true,loaded=true 1653060681000000000
Expand Down
4 changes: 3 additions & 1 deletion internal/vccollector/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *VcCollector) CollectHostInfo(
chunks := chunckMoRefSlice(arefs, c.queryBulkSize)

for _, refs := range chunks {
err = c.coll.Retrieve(ctx, refs, []string{"name", "summary"}, &hsMos)
err = c.coll.Retrieve(ctx, refs, []string{"name", "summary", "vm", "datastore"}, &hsMos)
if err != nil {
if err, exit := govplus.IsHardQueryError(err); exit {
return err
Expand Down Expand Up @@ -108,6 +108,8 @@ func (c *VcCollector) CollectHostInfo(
hsfields["memory_size"] = h.MemorySize
hsfields["num_cpus"] = h.NumCpuCores
hsfields["cpu_freq"] = h.CpuMhz
hsfields["num_vms"] = len(hsMo.Vm)
hsfields["num_datasotres"] = len(hsMo.Datastore)

acc.AddFields("vcstat_host", hsfields, hstags, t)
}
Expand Down

0 comments on commit f6f5684

Please sign in to comment.