Skip to content

Commit

Permalink
Fix wsl issue declarations should never be cuddled
Browse files Browse the repository at this point in the history
  • Loading branch information
mjtrangoni committed Nov 2, 2019
1 parent 147a9c0 commit 45e4d06
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
5 changes: 4 additions & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ func (n FlexlmCollector) Collect(ch chan<- prometheus.Metric) {
}

func execute(name string, c Collector, ch chan<- prometheus.Metric) {
var (
success float64
)

begin := time.Now()
err := c.Update(ch)
duration := time.Since(begin)
var success float64

if err != nil {
log.Errorf("ERROR: %s collector failed after %fs: %s", name, duration.Seconds(), err)
Expand Down
20 changes: 14 additions & 6 deletions collector/lmstat_feature_exp_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ import (
)

func parseLmstatLicenseFeatureExpDate(outStr [][]string) map[int]*featureExp {
var (
expires float64
index int
)

featuresExp := make(map[int]*featureExp)
var expires float64
var index int
// iterate over output lines
for _, line := range outStr {
lineJoined := strings.Join(line, "")
Expand Down Expand Up @@ -72,8 +75,10 @@ func parseLmstatLicenseFeatureExpDate(outStr [][]string) map[int]*featureExp {

// getLmstatFeatureExpDate returns lmstat active and inactive licenses expiration date
func (c *lmstatFeatureExpCollector) getLmstatFeatureExpDate(ch chan<- prometheus.Metric) error {
var outBytes []byte
var err error
var (
outBytes []byte
err error
)

for _, licenses := range LicenseConfig.Licenses {
// Call lmstat with -i (lmstat -i does not give information from the server,
Expand Down Expand Up @@ -101,8 +106,11 @@ func (c *lmstatFeatureExpCollector) getLmstatFeatureExpDate(ch chan<- prometheus
}

// features
var featuresToExclude = []string{}
var featuresToInclude = []string{}
var (
featuresToExclude = []string{}
featuresToInclude = []string{}
)

if licenses.FeaturesToExclude != "" && licenses.FeaturesToInclude != "" {
log.Fatalln("%v: can not define `features_to_include` and "+
"`features_to_exclude` at the same time", licenses.Name)
Expand Down
13 changes: 9 additions & 4 deletions collector/lmstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ func (c *lmstatCollector) getLmstatInfo(ch chan<- prometheus.Metric) error {

// getLmstatLicensesInfo returns lmstat active licenses information
func (c *lmstatCollector) getLmstatLicensesInfo(ch chan<- prometheus.Metric) error {
var outBytes []byte
var err error
var (
outBytes []byte
err error
)

for _, licenses := range LicenseConfig.Licenses {
// Call lmstat with -a (display everything)
Expand Down Expand Up @@ -304,8 +306,11 @@ func (c *lmstatCollector) getLmstatLicensesInfo(ch chan<- prometheus.Metric) err
}
}
// features
var featuresToExclude = []string{}
var featuresToInclude = []string{}
var (
featuresToExclude = []string{}
featuresToInclude = []string{}
)

if licenses.FeaturesToExclude != "" && licenses.FeaturesToInclude != "" {
log.Fatalln("%v: can not define `features_to_include` and "+
"`features_to_exclude` at the same time", licenses.Name)
Expand Down
8 changes: 5 additions & 3 deletions collector/lmstat_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ func TestParseLmstatLicenseInfoFeature(t *testing.T) {
t.Fatalf("Couldn't parse user \"cmfy211\" from feature31")
}

var found = false
var foundJohnDoe = false
var foundJaneDoe = false
var (
found = false
foundJohnDoe = false
foundJaneDoe = false
)

for username, licused := range licUsersByFeature["feature100"] {
if username == "user13" {
Expand Down

0 comments on commit 45e4d06

Please sign in to comment.