@@ -22,22 +22,10 @@ import (
22
22
)
23
23
24
24
const (
25
- defaultCollectors = "chassis,fans,memory,processors,ps,ps_amps_sysboard_pwr,storage_battery,storage_enclosure, storage_controller,storage_pdisk,storage_vdisk,system,temps,volts"
25
+ defaultCollectors = "chassis,chassis_batteries, fans,memory,nics, processors,ps,ps_amps_sysboard_pwr,storage_battery,storage_controller,storage_enclosure ,storage_pdisk,storage_vdisk,system,temps,volts"
26
26
)
27
27
28
28
var (
29
- connectionDurationDesc = prometheus .NewDesc (
30
- prometheus .BuildFQName (collector .Namespace , "scrape" , "connection_duration_seconds" ),
31
- "srcds_exporter: Duration of the server connection." ,
32
- []string {"connection" },
33
- nil ,
34
- )
35
- connectionSucessDesc = prometheus .NewDesc (
36
- prometheus .BuildFQName (collector .Namespace , "scrape" , "connection_success" ),
37
- "srcds_exporter: Whether the server connection succeeded." ,
38
- []string {"connection" },
39
- nil ,
40
- )
41
29
scrapeDurationDesc = prometheus .NewDesc (
42
30
prometheus .BuildFQName (collector .Namespace , "scrape" , "collector_duration_seconds" ),
43
31
"srcds_exporter: Duration of a collector scrape." ,
@@ -91,7 +79,9 @@ func init() {
91
79
// Define the usage function
92
80
dellhwExporterFlags .Usage = usage
93
81
94
- dellhwExporterFlags .Parse (os .Args [1 :])
82
+ if err := dellhwExporterFlags .Parse (os .Args [1 :]); err != nil {
83
+ log .Fatal (err )
84
+ }
95
85
}
96
86
97
87
// Describe implements the prometheus.Collector interface.
@@ -113,28 +103,17 @@ func (n DellHWCollector) Collect(ch chan<- prometheus.Metric) {
113
103
wg .Wait ()
114
104
}
115
105
116
- func filterAvailableCollectors (collectors string ) string {
117
- var availableCollectors []string
118
- for _ , c := range strings .Split (collectors , "," ) {
119
- _ , ok := collector .Factories [c ]
120
- if ok {
121
- availableCollectors = append (availableCollectors , c )
122
- }
123
- }
124
- return strings .Join (availableCollectors , "," )
125
- }
126
-
127
106
func execute (name string , c collector.Collector , ch chan <- prometheus.Metric ) {
128
107
begin := time .Now ()
129
108
err := c .Update (ch )
130
109
duration := time .Since (begin )
131
110
var success float64
132
111
133
112
if err != nil {
134
- log .Errorf ("ERROR: %s collector failed after %fs: %s" , name , duration .Seconds (), err )
113
+ log .Errorf ("%s collector failed after %fs: %s" , name , duration .Seconds (), err )
135
114
success = 0
136
115
} else {
137
- log .Debugf ("OK: %s collector succeeded after %fs." , name , duration .Seconds ())
116
+ log .Debugf ("%s collector succeeded after %fs." , name , duration .Seconds ())
138
117
success = 1
139
118
}
140
119
ch <- prometheus .MustNewConstMetric (scrapeDurationDesc , prometheus .GaugeValue , duration .Seconds (), name )
@@ -164,7 +143,12 @@ func usage() {
164
143
}
165
144
166
145
func main () {
167
- flagutil .SetFlagsFromEnv (dellhwExporterFlags , "DELLHW_EXPORTER" )
146
+ if err := flagutil .SetFlagsFromEnv (dellhwExporterFlags , "DELLHW_EXPORTER" ); err != nil {
147
+ log .Fatal (err )
148
+ }
149
+ if opts .help {
150
+ usage ()
151
+ }
168
152
if opts .version {
169
153
fmt .Fprintln (os .Stdout , version .Print ("srcds_exporter" ))
170
154
os .Exit (0 )
0 commit comments