@@ -3,7 +3,7 @@ package collector
33import (
44 "bufio"
55 "encoding/json"
6- "errors "
6+ "fmt "
77 "log"
88 "os"
99 "strconv"
@@ -20,7 +20,7 @@ import (
2020// Signals.
2121const (
2222 SIGRTMIN = syscall .Signal (32 )
23- SIGJSON = syscall . Signal ( SIGRTMIN + 4 )
23+ SIGJSON = SIGRTMIN + 4
2424)
2525
2626// States.
@@ -210,14 +210,14 @@ func (k *KACollector) Collect(ch chan<- prometheus.Metric) {
210210 svcs , err := k .handle .GetServices ()
211211 if err != nil {
212212 ch <- prometheus .MustNewConstMetric (k .metrics ["keepalived_up" ], prometheus .GaugeValue , 0 )
213- log .Printf ("keepalived_exporter: %v" , err )
213+ log .Printf ("keepalived_exporter: services: %v" , err )
214214 return
215215 }
216216
217217 for _ , s := range svcs {
218218 dsts , err := k .handle .GetDestinations (s )
219219 if err != nil {
220- log .Printf ("keepalived_exporter: %v" , err )
220+ log .Printf ("keepalived_exporter: destinations: %v" , err )
221221 continue
222222 }
223223
@@ -273,17 +273,17 @@ func (k *KACollector) signal(sig syscall.Signal) error {
273273 }
274274
275275 if pid == 0 {
276- return errors . New ("cannot find pid" )
276+ return fmt . Errorf ("cannot find pid" )
277277 }
278278
279279 proc , err := os .FindProcess (int (pid ))
280280 if err != nil {
281- return err
281+ return fmt . Errorf ( "process %v: %v" , pid , err )
282282 }
283283
284284 err = proc .Signal (sig )
285285 if err != nil {
286- return err
286+ return fmt . Errorf ( "signal %v: %v" , sig , err )
287287 }
288288
289289 time .Sleep (100 * time .Millisecond )
0 commit comments