diff --git a/collector/msmq.go b/collector/msmq.go index 2ad133f4..d6db15e0 100644 --- a/collector/msmq.go +++ b/collector/msmq.go @@ -26,23 +26,21 @@ type Win32_PerfRawData_MSMQ_MSMQQueueCollector struct { BytesinQueue *prometheus.Desc MessagesinJournalQueue *prometheus.Desc MessagesinQueue *prometheus.Desc - + queryWhereClause string } // NewWin32_PerfRawData_MSMQ_MSMQQueueCollector ... func NewMSMQCollector() (Collector, error) { const subsystem = "msmq" - + var wc bytes.Buffer if *msmqWhereClause != "" { wc.WriteString("WHERE ") wc.WriteString(*msmqWhereClause) log.Println("warning: No where-clause specified for msmq collector. This will generate a very large number of metrics!") } -// else { -// log.Println("warning: No where-clause specified for msmq collector. This will generate a very large number of metrics!") -// } + return &Win32_PerfRawData_MSMQ_MSMQQueueCollector{ BytesinJournalQueue: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "bytes_in_journal_queue"), @@ -97,7 +95,7 @@ func (c *Win32_PerfRawData_MSMQ_MSMQQueueCollector) collect(ch chan<- prometheus if err := wmi.Query(q, &dst); err != nil { return nil, err } - + for _, msmq := range dst { if msmq.Name == "Computer Queues" { @@ -128,6 +126,6 @@ func (c *Win32_PerfRawData_MSMQ_MSMQQueueCollector) collect(ch chan<- prometheus float64(msmq.MessagesinQueue), strings.ToLower(msmq.Name), ) -} + } return nil, nil } diff --git a/collector/os.go b/collector/os.go index db99db8d..06282907 100644 --- a/collector/os.go +++ b/collector/os.go @@ -6,7 +6,7 @@ package collector import ( "log" "time" - + "github.com/StackExchange/wmi" "github.com/prometheus/client_golang/prometheus" ) @@ -27,8 +27,8 @@ type OSCollector struct { PagingLimitBytes *prometheus.Desc VirtualMemoryBytes *prometheus.Desc VisibleMemoryBytes *prometheus.Desc - Time *prometheus.Desc - Timezone *prometheus.Desc + Time *prometheus.Desc + Timezone *prometheus.Desc } // NewOSCollector ... @@ -132,7 +132,7 @@ type Win32_OperatingSystem struct { SizeStoredInPagingFiles uint64 TotalVirtualMemorySize uint64 TotalVisibleMemorySize uint64 - LocalDateTime time.Time + LocalDateTime time.Time } func (c *OSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { @@ -148,7 +148,7 @@ func (c *OSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, er ) time := dst[0].LocalDateTime - + ch <- prometheus.MustNewConstMetric( c.Time, prometheus.GaugeValue, diff --git a/collector/textfile.go b/collector/textfile.go index 2a9fd673..a3219d9d 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -28,16 +28,16 @@ import ( dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" "github.com/prometheus/common/log" - kingpin "gopkg.in/alecthomas/kingpin.v2" + kingpin "gopkg.in/alecthomas/kingpin.v2" ) var ( - textFileDirectory = kingpin.Flag( - "collector.textfile.directory", - "Directory to read text files with metrics from.", - ).Default("C:\\Program Files\\wmi_exporter\\textfile_inputs").String() + textFileDirectory = kingpin.Flag( + "collector.textfile.directory", + "Directory to read text files with metrics from.", + ).Default("C:\\Program Files\\wmi_exporter\\textfile_inputs").String() - mtimeDesc = prometheus.NewDesc( + mtimeDesc = prometheus.NewDesc( "wmi_textfile_mtime_seconds", "Unixtime mtime of textfiles successfully read.", []string{"file"}, @@ -149,8 +149,8 @@ func convertMetricFamily(metricFamily *dto.MetricFamily, ch chan<- prometheus.Me buckets, values..., ) default: - log.Errorf("unknown metric type for file") - continue + log.Errorf("unknown metric type for file") + continue } if metricType == dto.MetricType_GAUGE || metricType == dto.MetricType_COUNTER || metricType == dto.MetricType_UNTYPED { ch <- prometheus.MustNewConstMetric( diff --git a/exporter.go b/exporter.go index 3a897820..5c4e4bb4 100644 --- a/exporter.go +++ b/exporter.go @@ -116,7 +116,7 @@ func expandEnabledCollectors(enabled string) []string { } } result := make([]string, 0, len(unique)) - for s, _ := range unique { + for s := range unique { result = append(result, s) } return result