From 506fd575abc33fc8c2a35166a6518fecc9807557 Mon Sep 17 00:00:00 2001 From: Joe Handzik Date: Thu, 25 May 2017 12:50:47 -0500 Subject: [PATCH] Cleanup errors caught by megacheck Signed-Off-By: Joe Handzik --- sources/procfs.go | 14 +++++++------- sources/procfs_test.go | 2 +- sources/source.go | 9 --------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/sources/procfs.go b/sources/procfs.go index 4f0ebe0b..1214aaf0 100644 --- a/sources/procfs.go +++ b/sources/procfs.go @@ -81,7 +81,6 @@ const ( type prometheusType func([]string, []string, string, string, uint64) prometheus.Metric type lustreProcMetric struct { - subsystem string filename string promName string source string //The parent data source (OST, MDS, MGS, etc) @@ -531,9 +530,7 @@ func parseStatsFile(helpText string, promName string, path string) (metricList [ return nil, err } if statsList != nil { - for _, item := range statsList { - metricList = append(metricList, item) - } + metricList = append(metricList, statsList...) } return metricList, nil @@ -620,9 +617,9 @@ func parseJobStatsText(jobStats string, promName string, helpText string) (metri if err != nil { return nil, err } - for _, item := range jobList { - metricList = append(metricList, item) - } + if jobList != nil { + metricList = append(metricList, jobList...) + } } return metricList, nil } @@ -712,6 +709,9 @@ func (s *lustreSource) parseBRWStats(nodeType string, metricType string, path st func (s *lustreSource) parseTextFile(nodeType string, metricType string, path string, directoryDepth int, helpText string, promName string, handler func(string, string, string, string, uint64)) (err error) { filename, nodeName, err := parseFileElements(path, directoryDepth) + if err != nil { + return err + } fileBytes, err := ioutil.ReadFile(path) if err != nil { return err diff --git a/sources/procfs_test.go b/sources/procfs_test.go index 52dc93f5..9ed023a8 100644 --- a/sources/procfs_test.go +++ b/sources/procfs_test.go @@ -204,7 +204,7 @@ func TestGetJobStats(t *testing.T) { testPromName = "job_write_bytes_total" testHelpText = writeTotalHelp - metricList, err = getJobStatsByOperation(testJobBlock, testJobID, testPromName, testHelpText) + _, err = getJobStatsByOperation(testJobBlock, testJobID, testPromName, testHelpText) if err != nil { t.Fatal(err) } diff --git a/sources/source.go b/sources/source.go index 287aaf82..88e4ae3b 100644 --- a/sources/source.go +++ b/sources/source.go @@ -27,12 +27,3 @@ var Factories = make(map[string]func() (LustreSource, error)) type LustreSource interface { Update(ch chan<- prometheus.Metric) (err error) } - -type typedDesc struct { - desc *prometheus.Desc - valueType prometheus.ValueType -} - -func (d *typedDesc) mustNewConstMetric(value float64, labels ...string) prometheus.Metric { - return prometheus.MustNewConstMetric(d.desc, d.valueType, value, labels...) -}