diff --git a/collectors/cpufreqCpuinfoMetric.go b/collectors/cpufreqCpuinfoMetric.go index 44a3b0c..6c3de7a 100644 --- a/collectors/cpufreqCpuinfoMetric.go +++ b/collectors/cpufreqCpuinfoMetric.go @@ -57,7 +57,7 @@ func (m *CPUFreqCpuInfoCollector) Init(config json.RawMessage) error { const cpuInfoFile = "/proc/cpuinfo" file, err := os.Open(cpuInfoFile) if err != nil { - return fmt.Errorf("Failed to open file '%s': %v", cpuInfoFile, err) + return fmt.Errorf("failed to open file '%s': %v", cpuInfoFile, err) } defer file.Close() @@ -106,14 +106,14 @@ func (m *CPUFreqCpuInfoCollector) Init(config json.RawMessage) error { topology.coreID = coreID topology.coreID_int, err = strconv.ParseInt(coreID, 10, 64) if err != nil { - return fmt.Errorf("Unable to convert coreID '%s' to int64: %v", coreID, err) + return fmt.Errorf("unable to convert coreID '%s' to int64: %v", coreID, err) } // Physical package ID topology.physicalPackageID = physicalPackageID topology.physicalPackageID_int, err = strconv.ParseInt(physicalPackageID, 10, 64) if err != nil { - return fmt.Errorf("Unable to convert physicalPackageID '%s' to int64: %v", physicalPackageID, err) + return fmt.Errorf("unable to convert physicalPackageID '%s' to int64: %v", physicalPackageID, err) } // increase maximun socket / package ID, when required diff --git a/collectors/cpufreqMetric.go b/collectors/cpufreqMetric.go index 5146baa..0bf6d4c 100644 --- a/collectors/cpufreqMetric.go +++ b/collectors/cpufreqMetric.go @@ -70,10 +70,10 @@ func (m *CPUFreqCollector) Init(config json.RawMessage) error { globPattern := filepath.Join(baseDir, "cpu[0-9]*") cpuDirs, err := filepath.Glob(globPattern) if err != nil { - return fmt.Errorf("Unable to glob files with pattern '%s': %v", globPattern, err) + return fmt.Errorf("unable to glob files with pattern '%s': %v", globPattern, err) } if cpuDirs == nil { - return fmt.Errorf("Unable to find any files with pattern '%s'", globPattern) + return fmt.Errorf("unable to find any files with pattern '%s'", globPattern) } // Initialize CPU topology @@ -82,38 +82,38 @@ func (m *CPUFreqCollector) Init(config json.RawMessage) error { processor := strings.TrimPrefix(cpuDir, "/sys/devices/system/cpu/cpu") processor_int, err := strconv.ParseInt(processor, 10, 64) if err != nil { - return fmt.Errorf("Unable to convert cpuID '%s' to int64: %v", processor, err) + return fmt.Errorf("unable to convert cpuID '%s' to int64: %v", processor, err) } // Read package ID physicalPackageIDFile := filepath.Join(cpuDir, "topology", "physical_package_id") line, err := ioutil.ReadFile(physicalPackageIDFile) if err != nil { - return fmt.Errorf("Unable to read physical package ID from file '%s': %v", physicalPackageIDFile, err) + return fmt.Errorf("unable to read physical package ID from file '%s': %v", physicalPackageIDFile, err) } physicalPackageID := strings.TrimSpace(string(line)) physicalPackageID_int, err := strconv.ParseInt(physicalPackageID, 10, 64) if err != nil { - return fmt.Errorf("Unable to convert packageID '%s' to int64: %v", physicalPackageID, err) + return fmt.Errorf("unable to convert packageID '%s' to int64: %v", physicalPackageID, err) } // Read core ID coreIDFile := filepath.Join(cpuDir, "topology", "core_id") line, err = ioutil.ReadFile(coreIDFile) if err != nil { - return fmt.Errorf("Unable to read core ID from file '%s': %v", coreIDFile, err) + return fmt.Errorf("unable to read core ID from file '%s': %v", coreIDFile, err) } coreID := strings.TrimSpace(string(line)) coreID_int, err := strconv.ParseInt(coreID, 10, 64) if err != nil { - return fmt.Errorf("Unable to convert coreID '%s' to int64: %v", coreID, err) + return fmt.Errorf("unable to convert coreID '%s' to int64: %v", coreID, err) } // Check access to current frequency file scalingCurFreqFile := filepath.Join(cpuDir, "cpufreq", "scaling_cur_freq") err = unix.Access(scalingCurFreqFile, unix.R_OK) if err != nil { - return fmt.Errorf("Unable to access file '%s': %v", scalingCurFreqFile, err) + return fmt.Errorf("unable to access file '%s': %v", scalingCurFreqFile, err) } t := &m.topology[processor_int] diff --git a/collectors/cpustatMetric.go b/collectors/cpustatMetric.go index 28ae002..556aad4 100644 --- a/collectors/cpustatMetric.go +++ b/collectors/cpustatMetric.go @@ -21,11 +21,10 @@ type CpustatCollectorConfig struct { type CpustatCollector struct { metricCollector - config CpustatCollectorConfig - matches map[string]int - cputags map[string]map[string]string - nodetags map[string]string - num_cpus_metric lp.CCMetric + config CpustatCollectorConfig + matches map[string]int + cputags map[string]map[string]string + nodetags map[string]string } func (m *CpustatCollector) Init(config json.RawMessage) error { diff --git a/collectors/customCmdMetric.go b/collectors/customCmdMetric.go index e978c49..ec2109b 100644 --- a/collectors/customCmdMetric.go +++ b/collectors/customCmdMetric.go @@ -61,7 +61,7 @@ func (m *CustomCmdCollector) Init(config json.RawMessage) error { } } if len(m.files) == 0 && len(m.commands) == 0 { - return errors.New("No metrics to collect") + return errors.New("no metrics to collect") } m.handler = influx.NewMetricHandler() m.parser = influx.NewParser(m.handler) diff --git a/collectors/ipmiMetric.go b/collectors/ipmiMetric.go index e59f407..16b08ef 100644 --- a/collectors/ipmiMetric.go +++ b/collectors/ipmiMetric.go @@ -54,7 +54,7 @@ func (m *IpmiCollector) Init(config json.RawMessage) error { m.ipmisensors = p } if len(m.ipmitool) == 0 && len(m.ipmisensors) == 0 { - return errors.New("No IPMI reader found") + return errors.New("no IPMI reader found") } m.init = true return nil diff --git a/collectors/metricCollector.go b/collectors/metricCollector.go index 747772f..7c04e90 100644 --- a/collectors/metricCollector.go +++ b/collectors/metricCollector.go @@ -125,5 +125,5 @@ func RemoveFromStringList(s []string, r string) ([]string, error) { return append(s[:i], s[i+1:]...), nil } } - return s, fmt.Errorf("No such string in list") + return s, fmt.Errorf("no such string in list") } diff --git a/collectors/tempMetric.go b/collectors/tempMetric.go index bbc5100..7ba8eb1 100644 --- a/collectors/tempMetric.go +++ b/collectors/tempMetric.go @@ -70,10 +70,10 @@ func (m *TempCollector) Init(config json.RawMessage) error { globPattern := filepath.Join("/sys/class/hwmon", "*", "temp*_input") inputFiles, err := filepath.Glob(globPattern) if err != nil { - return fmt.Errorf("Unable to glob files with pattern '%s': %v", globPattern, err) + return fmt.Errorf("unable to glob files with pattern '%s': %v", globPattern, err) } if inputFiles == nil { - return fmt.Errorf("Unable to find any files with pattern '%s'", globPattern) + return fmt.Errorf("unable to find any files with pattern '%s'", globPattern) } // Get sensor name for each temperature sensor file @@ -158,7 +158,7 @@ func (m *TempCollector) Init(config json.RawMessage) error { // Empty sensors map if len(m.sensors) == 0 { - return fmt.Errorf("No temperature sensors found") + return fmt.Errorf("no temperature sensors found") } // Finished initialization diff --git a/collectors/topprocsMetric.go b/collectors/topprocsMetric.go index dd6bff3..408c3cc 100644 --- a/collectors/topprocsMetric.go +++ b/collectors/topprocsMetric.go @@ -39,14 +39,14 @@ func (m *TopProcsCollector) Init(config json.RawMessage) error { m.config.Num_procs = int(DEFAULT_NUM_PROCS) } if m.config.Num_procs <= 0 || m.config.Num_procs > MAX_NUM_PROCS { - return errors.New(fmt.Sprintf("num_procs option must be set in 'topprocs' config (range: 1-%d)", MAX_NUM_PROCS)) + return fmt.Errorf("num_procs option must be set in 'topprocs' config (range: 1-%d)", MAX_NUM_PROCS) } m.setup() command := exec.Command("ps", "-Ao", "comm", "--sort=-pcpu") command.Wait() _, err = command.Output() if err != nil { - return errors.New("Failed to execute command") + return errors.New("failed to execute command") } m.init = true return nil