Skip to content

Commit

Permalink
Making golint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Liebsch committed Apr 27, 2017
1 parent 88bc206 commit 6558137
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions vsphere-influxdb.go
Expand Up @@ -47,7 +47,7 @@ const (
description = "send vsphere stats to influxdb"
)

// Configuration
// Configuration is used to store config data
type Configuration struct {
VCenters []*VCenter
Metrics []Metric
Expand All @@ -56,46 +56,46 @@ type Configuration struct {
InfluxDB InfluxDB
}

// InfluxDB description
// InfluxDB is used for InfluxDB connections
type InfluxDB struct {
Hostname string
Username string
Password string
Database string
}

// VCenter description
// VCenter for VMware vCenter connections
type VCenter struct {
Hostname string
Username string
Password string
MetricGroups []*MetricGroup
}

// Metric Definition
// MetricDef metric definition
type MetricDef struct {
Metric string
Instances string
Key int32
}

// Metrics description in config
var vmRefs []types.ManagedObjectReference
var debug bool

// Metric is used for metrics retrieval
type Metric struct {
ObjectType []string
Definition []MetricDef
}

// Metric Grouping for retrieval
// MetricGroup is used for grouping metrics retrieval
type MetricGroup struct {
ObjectType string
Metrics []MetricDef
Mor []types.ManagedObjectReference
}

// Informations to query about an entity
// EntityQuery are informations to query about an entity
type EntityQuery struct {
Name string
Entity types.ManagedObjectReference
Expand All @@ -107,6 +107,7 @@ var dependencies = []string{}

var stdlog, errlog *log.Logger

// Connect to the actual vCenter connection used to query data
func (vcenter *VCenter) Connect() (*govmomi.Client, error) {
// Prepare vCenter Connections
ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -127,7 +128,7 @@ func (vcenter *VCenter) Connect() (*govmomi.Client, error) {
return client, nil
}

// Initialise vcenter
// Init the VCenter connection
func (vcenter *VCenter) Init(config Configuration) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -393,9 +394,9 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
queries := []types.PerfQuerySpec{}

// Common parameters
intervalIdint := 20
var intervalId int32
intervalId = int32(intervalIdint)
intervalIDint := 20
var intervalID int32
intervalID = int32(intervalIDint)

endTime := time.Now().Add(time.Duration(-1) * time.Second)
startTime := endTime.Add(time.Duration(-config.Interval) * time.Second)
Expand All @@ -410,7 +411,7 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
}
}
}
queries = append(queries, types.PerfQuerySpec{Entity: mor, StartTime: &startTime, EndTime: &endTime, MetricId: metricIds, IntervalId: intervalId})
queries = append(queries, types.PerfQuerySpec{Entity: mor, StartTime: &startTime, EndTime: &endTime, MetricId: metricIds, intervalID: intervalID})
}

// Query the performances
Expand Down Expand Up @@ -624,14 +625,14 @@ func main() {
// read the configuration
file, err := os.Open(*cfgFile)
if err != nil {
errlog.Println("Could not open configuration file" + *cfgFile)
errlog.Println("Could not open configuration file " + *cfgFile)
errlog.Println(err)
}
jsondec := json.NewDecoder(file)
config := Configuration{}
err = jsondec.Decode(&config)
if err != nil {
errlog.Println("Could not decode configuration file")
errlog.Println("Could not decode configuration file " + *cfgFile)
errlog.Println(err)

}
Expand All @@ -647,7 +648,7 @@ func main() {
errlog.Println("Could not connect to InfluxDB")
errlog.Println(err)
} else {
stdlog.Println("Successfully connected to Influx\n")
stdlog.Println("Successfully connected to Influx")
}
for _, vcenter := range config.VCenters {
queryVCenter(*vcenter, config, InfluxDBClient)
Expand Down

0 comments on commit 6558137

Please sign in to comment.