mirror of
https://github.com/Oxalide/vsphere-influxdb-go.git
synced 2023-10-10 13:36:51 +02:00
defined ResourcePool as metric
This commit is contained in:
parent
b656d6be88
commit
3442d30e1a
@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"Metrics": [
|
"Metrics": [
|
||||||
{
|
{
|
||||||
"ObjectType": [ "VirtualMachine", "HostSystem" ],
|
"ObjectType": [ "VirtualMachine", "HostSystem", "ResourcePool" ],
|
||||||
"Definition": [
|
"Definition": [
|
||||||
{ "Metric": "cpu.usage.average", "Instances": "*" },
|
{ "Metric": "cpu.usage.average", "Instances": "*" },
|
||||||
{ "Metric": "cpu.usage.maximum", "Instances": "*" },
|
{ "Metric": "cpu.usage.maximum", "Instances": "*" },
|
||||||
@ -64,6 +64,13 @@
|
|||||||
{ "Metric": "disk.numberWriteAveraged.average", "Instances": "*" },
|
{ "Metric": "disk.numberWriteAveraged.average", "Instances": "*" },
|
||||||
{ "Metric": "net.throughput.contention.summation", "Instances": "*" }
|
{ "Metric": "net.throughput.contention.summation", "Instances": "*" }
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
{ "ObjectType": [ "ResourcePool" ],
|
||||||
|
"Definition": [
|
||||||
|
{ "Metric": "cpu.usagemhz.average", "Instances": "*" },
|
||||||
|
{ "Metric": "mem.consumed.average", "Instances": "*" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,7 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
|
|||||||
vm_refs := []types.ManagedObjectReference{}
|
vm_refs := []types.ManagedObjectReference{}
|
||||||
host_refs := []types.ManagedObjectReference{}
|
host_refs := []types.ManagedObjectReference{}
|
||||||
cluster_refs := []types.ManagedObjectReference{}
|
cluster_refs := []types.ManagedObjectReference{}
|
||||||
|
resp_refs := []types.ManagedObjectReference{}
|
||||||
|
|
||||||
new_mors := []types.ManagedObjectReference{}
|
new_mors := []types.ManagedObjectReference{}
|
||||||
|
|
||||||
@ -258,9 +259,15 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
|
|||||||
} else if mor.Type == "HostSystem" {
|
} else if mor.Type == "HostSystem" {
|
||||||
host_refs = append(host_refs, mor)
|
host_refs = append(host_refs, mor)
|
||||||
new_mors = append(new_mors, mor)
|
new_mors = append(new_mors, mor)
|
||||||
} else if mor.Type == "ClusterComputeResource" {
|
}
|
||||||
|
else if mor.Type == "ResourcePool" {
|
||||||
|
resp_refs = append(resp_refs, mor)
|
||||||
|
new_mors = append(new_mors, mor)
|
||||||
|
}
|
||||||
|
else if mor.Type == "ClusterComputeResource" {
|
||||||
cluster_refs = append(cluster_refs, mor)
|
cluster_refs = append(cluster_refs, mor)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Copy the mors without the clusters
|
// Copy the mors without the clusters
|
||||||
mors = new_mors
|
mors = new_mors
|
||||||
@ -282,6 +289,13 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Retrieve properties for all resourcepools
|
||||||
|
var respmo []mo.ResourcePool
|
||||||
|
err = pc.Retrieve(ctx, resp_refs, []string{"summary"}, &respmo)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the map that will hold the VM MOR to cluster reference
|
// Initialize the map that will hold the VM MOR to cluster reference
|
||||||
vmToCluster := make(map[types.ManagedObjectReference]string)
|
vmToCluster := make(map[types.ManagedObjectReference]string)
|
||||||
@ -490,8 +504,7 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
|
|||||||
if special_fields[measurementName] == nil {
|
if special_fields[measurementName] == nil {
|
||||||
special_fields[measurementName] = make(map[string]map[string]map[string]interface{})
|
special_fields[measurementName] = make(map[string]map[string]map[string]interface{})
|
||||||
special_tags[measurementName] = make(map[string]map[string]map[string]string)
|
special_tags[measurementName] = make(map[string]map[string]map[string]string)
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if special_fields[measurementName][tags["name"]] == nil {
|
if special_fields[measurementName][tags["name"]] == nil {
|
||||||
special_fields[measurementName][tags["name"]] = make(map[string]map[string]interface{})
|
special_fields[measurementName][tags["name"]] = make(map[string]map[string]interface{})
|
||||||
@ -651,3 +664,5 @@ func main() {
|
|||||||
queryVCenter(*vcenter, config, InfluxDBClient)
|
queryVCenter(*vcenter, config, InfluxDBClient)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user