4
4
"fmt"
5
5
"net/http"
6
6
"os"
7
+ "os/exec"
7
8
"sort"
8
9
"strings"
9
10
"sync"
56
57
type CmdLineOpts struct {
57
58
version bool
58
59
help bool
60
+ container bool
59
61
showCollectors bool
60
62
debugMode bool
61
63
metricsAddr string
@@ -79,6 +81,7 @@ type DellHWCollector struct {
79
81
func init () {
80
82
dellhwExporterFlags .BoolVar (& opts .help , "help" , false , "Show help menu" )
81
83
dellhwExporterFlags .BoolVar (& opts .version , "version" , false , "Show version information" )
84
+ dellhwExporterFlags .BoolVar (& opts .container , "container" , false , "Start the Dell OpenManage service" )
82
85
dellhwExporterFlags .BoolVar (& opts .showCollectors , "collectors.print" , false , "If true, print available collectors and exit." )
83
86
dellhwExporterFlags .BoolVar (& opts .debugMode , "debug" , false , "Enable debug output" )
84
87
dellhwExporterFlags .StringVar (& opts .metricsAddr , "web.listen-address" , ":9137" , "The address to listen on for HTTP requests" )
@@ -162,7 +165,6 @@ func usage() {
162
165
}
163
166
164
167
func main () {
165
- flag .Parse ()
166
168
flagutil .SetFlagsFromEnv (dellhwExporterFlags , "DELLHW_EXPORTER" )
167
169
if opts .version {
168
170
fmt .Fprintln (os .Stdout , version .Print ("srcds_exporter" ))
@@ -188,6 +190,22 @@ func main() {
188
190
log .Infoln ("Starting srcds_exporter" , version .Info ())
189
191
log .Infoln ("Build context" , version .BuildContext ())
190
192
193
+ if opts .container {
194
+ log .Infoln ("Starting srvadmin-services" )
195
+ cmd := exec .Command ("/opt/dell/srvadmin/sbin/srvadmin-services.sh" , "start" )
196
+ if err := cmd .Start (); err != nil {
197
+ log .Fatal (err )
198
+ }
199
+ timer := time .AfterFunc (30 * time .Second , func () {
200
+ cmd .Process .Kill ()
201
+ })
202
+ err := cmd .Wait ()
203
+ if err != nil {
204
+ log .Fatal (err )
205
+ }
206
+ timer .Stop ()
207
+ }
208
+
191
209
omrOpts := & omreport.Options {
192
210
OMReportExecutable : opts .omReportExecutable ,
193
211
}
0 commit comments