Skip to content

Commit 97ad542

Browse files
committed
Fix flag parse issues
Install pidof in docker image Added -container flag to start the srvadmin-services.sh script
1 parent 5765e53 commit 97ad542

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ENV DSU_VERSION="DSU_17.07.00" \
1010

1111
# Do overall update and install missing packages needed for OpenManage
1212
RUN yum -y update && \
13-
yum -y install gcc wget perl passwd which tar libstdc++.so.6 compat-libstdc++-33.i686 glibc.i686 && \
13+
yum -y install sysvinit-tools wget perl passwd gcc which tar libstdc++.so.6 compat-libstdc++-33.i686 glibc.i686 && \
1414
echo "$USER:$PASS" | chpasswd && \
1515
wget -q -O - "http://linux.dell.com/repo/hardware/${DSU_VERSION}/bootstrap.cgi" | bash && \
1616
yum -y install srvadmin-base srvadmin-storageservices && \

cmd/dellhw_exporter/dellhw_exporter.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"net/http"
66
"os"
7+
"os/exec"
78
"sort"
89
"strings"
910
"sync"
@@ -56,6 +57,7 @@ var (
5657
type CmdLineOpts struct {
5758
version bool
5859
help bool
60+
container bool
5961
showCollectors bool
6062
debugMode bool
6163
metricsAddr string
@@ -79,6 +81,7 @@ type DellHWCollector struct {
7981
func init() {
8082
dellhwExporterFlags.BoolVar(&opts.help, "help", false, "Show help menu")
8183
dellhwExporterFlags.BoolVar(&opts.version, "version", false, "Show version information")
84+
dellhwExporterFlags.BoolVar(&opts.container, "container", false, "Start the Dell OpenManage service")
8285
dellhwExporterFlags.BoolVar(&opts.showCollectors, "collectors.print", false, "If true, print available collectors and exit.")
8386
dellhwExporterFlags.BoolVar(&opts.debugMode, "debug", false, "Enable debug output")
8487
dellhwExporterFlags.StringVar(&opts.metricsAddr, "web.listen-address", ":9137", "The address to listen on for HTTP requests")
@@ -162,7 +165,6 @@ func usage() {
162165
}
163166

164167
func main() {
165-
flag.Parse()
166168
flagutil.SetFlagsFromEnv(dellhwExporterFlags, "DELLHW_EXPORTER")
167169
if opts.version {
168170
fmt.Fprintln(os.Stdout, version.Print("srcds_exporter"))
@@ -188,6 +190,22 @@ func main() {
188190
log.Infoln("Starting srcds_exporter", version.Info())
189191
log.Infoln("Build context", version.BuildContext())
190192

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+
191209
omrOpts := &omreport.Options{
192210
OMReportExecutable: opts.omReportExecutable,
193211
}

0 commit comments

Comments
 (0)