From 39330e4d31d37a006c225f518c3c8699c873d441 Mon Sep 17 00:00:00 2001 From: MicKBfr Date: Fri, 6 Apr 2018 09:40:32 +0200 Subject: [PATCH 1/3] Remove domain from esx name Domain in esx name can be a problem with influxgraph and grafana. --- vsphere-influxdb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsphere-influxdb.go b/vsphere-influxdb.go index db42bad..b1cb6e6 100644 --- a/vsphere-influxdb.go +++ b/vsphere-influxdb.go @@ -443,7 +443,7 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient. // Extra tags per host hostSummary[host.Self] = make(map[string]string) - hostSummary[host.Self]["name"] = host.Summary.Config.Name + hostSummary[host.Self]["name"] = strings.Replace(host.Summary.Config.Name, config.Domain, "", -1) hostSummary[host.Self]["cluster"] = hostToCluster[host.Self] // Extra metrics per host From 3eb0f579a982ac1cac311aa9ae8841ae94a2ab2b Mon Sep 17 00:00:00 2001 From: MicKBfr Date: Thu, 12 Apr 2018 17:36:51 +0200 Subject: [PATCH 2/3] Update vsphere-influxdb.go --- vsphere-influxdb.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vsphere-influxdb.go b/vsphere-influxdb.go index b1cb6e6..c56b256 100644 --- a/vsphere-influxdb.go +++ b/vsphere-influxdb.go @@ -99,7 +99,7 @@ type EntityQuery struct { Metrics []int32 } -var getversion, debug, test bool +var getversion, debug, test, RemoveHostDomainName bool var stdlog, errlog *log.Logger var version = "master" @@ -443,7 +443,11 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient. // Extra tags per host hostSummary[host.Self] = make(map[string]string) - hostSummary[host.Self]["name"] = strings.Replace(host.Summary.Config.Name, config.Domain, "", -1) + hostSummary[host.Self]["name"] = hostSummary[host.Self]["name"] = host.Summary.Config.Name + // Remove Domain Name from Host + if RemoveHostDomainName { + hostSummary[host.Self]["name"] = strings.Replace(host.Summary.Config.Name, config.Domain, "", -1) + } hostSummary[host.Self]["cluster"] = hostToCluster[host.Self] // Extra metrics per host From 3ddb5a30da1b6b9674788701116905517c82da9d Mon Sep 17 00:00:00 2001 From: MicKBfr Date: Thu, 12 Apr 2018 17:45:57 +0200 Subject: [PATCH 3/3] patch to made RemoveHostDomainName optional --- vsphere-influxdb.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vsphere-influxdb.go b/vsphere-influxdb.go index c56b256..aaebcc4 100644 --- a/vsphere-influxdb.go +++ b/vsphere-influxdb.go @@ -51,6 +51,7 @@ type Configuration struct { Metrics []Metric Interval int Domain string + RemoveHostDomainName bool InfluxDB InfluxDB } @@ -99,7 +100,7 @@ type EntityQuery struct { Metrics []int32 } -var getversion, debug, test, RemoveHostDomainName bool +var getversion, debug, test bool var stdlog, errlog *log.Logger var version = "master" @@ -445,7 +446,7 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient. hostSummary[host.Self] = make(map[string]string) hostSummary[host.Self]["name"] = hostSummary[host.Self]["name"] = host.Summary.Config.Name // Remove Domain Name from Host - if RemoveHostDomainName { + if config.RemoveHostDomainName { hostSummary[host.Self]["name"] = strings.Replace(host.Summary.Config.Name, config.Domain, "", -1) } hostSummary[host.Self]["cluster"] = hostToCluster[host.Self]