Skip to content

Commit

Permalink
fix two pointer dereference issues
Browse files Browse the repository at this point in the history
  • Loading branch information
poblahblahblah committed Sep 14, 2017
1 parent 767fd53 commit 33fe1f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions plugins/inputs/nginx_plus/nginx_plus.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (s *Status) gatherProcessesMetrics(tags map[string]string, acc telegraf.Acc
acc.AddFields(
"nginx_plus_processes",
map[string]interface{}{
"respawned": s.Processes.Respawned,
"respawned": *s.Processes.Respawned,
},
tags,
)
Expand Down Expand Up @@ -411,7 +411,7 @@ func (s *Status) gatherUpstreamMetrics(tags map[string]string, acc telegraf.Accu
"healthchecks_unhealthy": peer.HealthChecks.Unhealthy,
"downtime": peer.Downtime,
"downstart": peer.Downstart,
"selected": peer.Selected,
"selected": *peer.Selected,
}
if peer.HealthChecks.LastPassed != nil {
peerFields["healthchecks_last_passed"] = *peer.HealthChecks.LastPassed
Expand Down
18 changes: 6 additions & 12 deletions plugins/inputs/nginx_plus/nginx_plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,7 @@ func TestNginxPlusGeneratesMetrics(t *testing.T) {
t,
"nginx_plus_processes",
map[string]interface{}{
"respawned": func() *int {
v := 9999
return &v
}(),
"respawned": int(9999),
},
map[string]string{
"server": host,
Expand Down Expand Up @@ -403,17 +400,14 @@ func TestNginxPlusGeneratesMetrics(t *testing.T) {
"healthchecks_unhealthy": int64(21),
"downtime": int64(5432),
"downstart": int64(4321),
"selected": func() *int64 {
var v int64 = 1451606400000
return &v
}(),
"selected": int64(1451606400000),
},
map[string]string{
"server": host,
"port": port,
"upstream": "first_upstream",
"server": host,
"port": port,
"upstream": "first_upstream",
"upstream_address": "1.2.3.123:80",
"id": "0",
"id": "0",
})

}

0 comments on commit 33fe1f0

Please sign in to comment.