diff --git a/grafana/dashboards/net-test.json b/grafana/dashboards/net-test.json index e4ca782..4128196 100644 --- a/grafana/dashboards/net-test.json +++ b/grafana/dashboards/net-test.json @@ -94,6 +94,7 @@ "dashLength": 10, "dashes": false, "datasource": null, + "description": "Count of failed ICMP ping measurements.", "fieldConfig": { "defaults": {}, "overrides": [] @@ -135,9 +136,9 @@ "targets": [ { "exemplar": true, - "expr": "ping_failures_total", + "expr": "rate(ping_failures_total[1m])", "interval": "", - "legendFormat": "", + "legendFormat": "{{target_host}}", "refId": "A" } ], @@ -145,7 +146,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Failures", + "title": "Ping Failures", "tooltip": { "shared": true, "sort": 0, @@ -211,6 +212,8 @@ "alignAsTable": false, "avg": false, "current": false, + "hideEmpty": true, + "hideZero": true, "max": false, "min": false, "rightSide": false, @@ -227,7 +230,7 @@ "percentage": false, "pluginVersion": "7.5.3", "pointradius": 2, - "points": false, + "points": true, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, @@ -320,12 +323,12 @@ "list": [] }, "time": { - "from": "now-5m", + "from": "now-15m", "to": "now" }, "timepicker": {}, "timezone": "", "title": "Net Test", "uid": "WM-nr_lMk", - "version": 7 + "version": 9 } diff --git a/main.go b/main.go index c2ad5b5..891ea5c 100644 --- a/main.go +++ b/main.go @@ -13,8 +13,13 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" ) -const PING_COUNT int = 3 +// PING_COUNT is the number of ping packets sent to determine the average round trip time. +const PING_COUNT int = 1 +// PING_TIMEOUT_MS is the number of milliseconds before a ping attempt will timeout. 30 seconds. +const PING_TIMEOUT_MS int = 30000 + +// log is the application logger. var log golog.Logger = golog.NewLogger("net-test") // die will print an error then exit the process with code 1 @@ -133,8 +138,7 @@ func main() { Buckets: []float64{ 0, 20, 40, 60, 80, 100, 150, 200, 500, - 1000, 1500, 2000, 3000, 5000, - 10000, 30000, 60000, 120000, + 1000, 1500, 2000, 3000, }, }, []string{"target_host"}, @@ -156,10 +160,15 @@ func main() { pingers := []*ping.Pinger{} for _, host := range targetHosts.Get() { pinger, err := ping.NewPinger(host) - check(fmt.Sprintf("failed to create pinger for \"%s\"", host), err) + if err != nil { + log.Warnf("failed to create pinger for \"%s\": %s", host, err.Error()) + pingFailures.With(prom.Labels{ + "target_host": pinger.Addr(), + }).Inc() + } pinger.Count = PING_COUNT pinger.SetPrivileged(true) - pinger.Timeout = time.Duration(120) * time.Second // 2 minute timeout + pinger.Timeout = time.Duration(PING_TIMEOUT_MS) * time.Millisecond pingers = append(pingers, pinger) } diff --git a/screenshot.png b/screenshot.png index 15e3541..7e3834a 100644 Binary files a/screenshot.png and b/screenshot.png differ