Skip to content

Commit 9000137

Browse files
committed
Add error descriptions
1 parent 031d164 commit 9000137

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

collector/collector.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package collector
33
import (
44
"bufio"
55
"encoding/json"
6-
"errors"
6+
"fmt"
77
"log"
88
"os"
99
"strconv"
@@ -20,7 +20,7 @@ import (
2020
// Signals.
2121
const (
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)

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func main() {
3939

4040
http.Handle(*metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
4141
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
42-
w.Write([]byte(`<html>
42+
_, _ = w.Write([]byte(`<html>
4343
<head><title>Keepalived Exporter</title></head>
4444
<body>
4545
<h1>Keepalived Exporter</h1>

0 commit comments

Comments
 (0)