Skip to content

Commit

Permalink
Add missing rcode and zonestat to bind input (influxdata#6123)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored Jul 17, 2019
1 parent 35d6894 commit a07f29c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
38 changes: 38 additions & 0 deletions plugins/inputs/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,36 @@ func TestBindJsonStats(t *testing.T) {
{"STATUS", 0},
},
},
{
"rcode",
[]fieldSet{
{"NOERROR", 1732},
{"FORMERR", 0},
{"SERVFAIL", 6},
{"NXDOMAIN", 200},
{"NOTIMP", 0},
{"REFUSED", 6},
{"REFUSED", 0},
{"YXDOMAIN", 0},
{"YXRRSET", 0},
{"NXRRSET", 0},
{"NOTAUTH", 0},
{"NOTZONE", 0},
{"RESERVED11", 0},
{"RESERVED12", 0},
{"RESERVED13", 0},
{"RESERVED14", 0},
{"RESERVED15", 0},
{"BADVERS", 0},
{"17", 0},
{"18", 0},
{"19", 0},
{"20", 0},
{"21", 0},
{"22", 0},
{"BADCOOKIE", 0},
},
},
{
"qtype",
[]fieldSet{
Expand Down Expand Up @@ -96,6 +126,14 @@ func TestBindJsonStats(t *testing.T) {
{"TCP6Open", 2},
},
},
{
"zonestat",
[]fieldSet{
{"NotifyOutv4", 8},
{"NotifyInv4", 5},
{"SOAOutv4", 5},
},
},
}

for _, tc := range testCases {
Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/bind/json_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
type jsonStats struct {
OpCodes map[string]int
QTypes map[string]int
RCodes map[string]int
ZoneStats map[string]int
NSStats map[string]int
SockStats map[string]int
Views map[string]jsonView
Expand Down Expand Up @@ -78,6 +80,10 @@ func (b *Bind) addStatsJSON(stats jsonStats, acc telegraf.Accumulator, urlTag st
tags["type"] = "opcode"
addJSONCounter(acc, tags, stats.OpCodes)

// RCodes stats
tags["type"] = "rcode"
addJSONCounter(acc, tags, stats.RCodes)

// Query RDATA types
tags["type"] = "qtype"
addJSONCounter(acc, tags, stats.QTypes)
Expand All @@ -90,6 +96,10 @@ func (b *Bind) addStatsJSON(stats jsonStats, acc telegraf.Accumulator, urlTag st
tags["type"] = "sockstat"
addJSONCounter(acc, tags, stats.SockStats)

// Zonestats
tags["type"] = "zonestat"
addJSONCounter(acc, tags, stats.ZoneStats)

// Memory stats
fields := map[string]interface{}{
"total_use": stats.Memory.TotalUse,
Expand Down
33 changes: 32 additions & 1 deletion plugins/inputs/bind/testdata/json/v1/server
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@
"RESERVED14":0,
"RESERVED15":0
},
"rcodes":{
"NOERROR":1732,
"FORMERR":0,
"SERVFAIL":6,
"NXDOMAIN":200,
"NOTIMP":0,
"REFUSED":0,
"YXDOMAIN":0,
"YXRRSET":0,
"NXRRSET":0,
"NOTAUTH":0,
"NOTZONE":0,
"RESERVED11":0,
"RESERVED12":0,
"RESERVED13":0,
"RESERVED14":0,
"RESERVED15":0,
"BADVERS":0,
"17":0,
"18":0,
"19":0,
"20":0,
"21":0,
"22":0,
"BADCOOKIE":0
},
"qtypes":{
"A":2,
"PTR":7,
Expand All @@ -40,6 +66,11 @@
"QryDuplicate":1,
"QryUDP":13
},
"zonestats":{
"NotifyOutv4":8,
"NotifyInv4":5,
"SOAOutv4":5
},
"views":{
"_default":{
"resolver":{
Expand Down Expand Up @@ -138,4 +169,4 @@
}
}
}
}
}

0 comments on commit a07f29c

Please sign in to comment.