9
9
"net"
10
10
"net/http"
11
11
"os"
12
+ "strings"
12
13
"time"
13
14
14
15
"github.com/prometheus/client_golang/prometheus"
@@ -86,7 +87,9 @@ func queryTelemetry(conn net.Conn, command string, response interface{}) {
86
87
log .Fatalf ("Failed to read response from %s: %v" , socketPath , err )
87
88
}
88
89
responseBuffer .Write (respBytes [:n ])
89
- if bytes .Contains (respBytes , []byte (command [:len (command )- 2 ])) {
90
+ parts := strings .SplitN (command , "," , 2 )
91
+ command = parts [0 ]
92
+ if bytes .Contains (respBytes , []byte (command )) {
90
93
break
91
94
}
92
95
}
@@ -125,7 +128,6 @@ func updateMetrics(conn net.Conn, hostname string) {
125
128
for graphNodeName , callCount := range dpserviceCallCount .GraphCallCnt .Node_0_to_255 {
126
129
promMetricsCallCount .With (prometheus.Labels {"node_name" : hostname , "graph_node" : graphNodeName }).Set (callCount )
127
130
}
128
-
129
131
}
130
132
131
133
func main () {
@@ -143,6 +145,7 @@ func main() {
143
145
144
146
var host string
145
147
hostnameFlag := flag .String ("hostname" , "" , "Hostname to use" )
148
+ pollIntervalFlag := flag .Int ("poll-interval" , 20 , "Polling interval in seconds" )
146
149
flag .Parse ()
147
150
148
151
if * hostnameFlag == "" {
@@ -166,7 +169,7 @@ func main() {
166
169
go func () {
167
170
for {
168
171
updateMetrics (conn , host )
169
- time .Sleep (5 * time .Second )
172
+ time .Sleep (time . Duration ( * pollIntervalFlag ) * time .Second )
170
173
}
171
174
}()
172
175
0 commit comments