diff --git a/plugins/inputs/bind/bind_test.go b/plugins/inputs/bind/bind_test.go index 40c32aee3..f2bfbbf66 100644 --- a/plugins/inputs/bind/bind_test.go +++ b/plugins/inputs/bind/bind_test.go @@ -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{ @@ -96,6 +126,14 @@ func TestBindJsonStats(t *testing.T) { {"TCP6Open", 2}, }, }, + { + "zonestat", + []fieldSet{ + {"NotifyOutv4", 8}, + {"NotifyInv4", 5}, + {"SOAOutv4", 5}, + }, + }, } for _, tc := range testCases { diff --git a/plugins/inputs/bind/json_stats.go b/plugins/inputs/bind/json_stats.go index cf595c1a3..87b6065e2 100644 --- a/plugins/inputs/bind/json_stats.go +++ b/plugins/inputs/bind/json_stats.go @@ -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 @@ -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) @@ -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, diff --git a/plugins/inputs/bind/testdata/json/v1/server b/plugins/inputs/bind/testdata/json/v1/server index 53acd9067..060fab6b1 100644 --- a/plugins/inputs/bind/testdata/json/v1/server +++ b/plugins/inputs/bind/testdata/json/v1/server @@ -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, @@ -40,6 +66,11 @@ "QryDuplicate":1, "QryUDP":13 }, + "zonestats":{ + "NotifyOutv4":8, + "NotifyInv4":5, + "SOAOutv4":5 + }, "views":{ "_default":{ "resolver":{ @@ -138,4 +169,4 @@ } } } -} \ No newline at end of file +}