Add missing rcode and zonestat to bind input (#6123)

This commit is contained in:
Daniel Nelson 2019-07-17 14:31:57 -07:00 committed by GitHub
parent 35d689401d
commit a07f29c02f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 1 deletions

View File

@ -47,6 +47,36 @@ func TestBindJsonStats(t *testing.T) {
{"STATUS", 0}, {"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", "qtype",
[]fieldSet{ []fieldSet{
@ -96,6 +126,14 @@ func TestBindJsonStats(t *testing.T) {
{"TCP6Open", 2}, {"TCP6Open", 2},
}, },
}, },
{
"zonestat",
[]fieldSet{
{"NotifyOutv4", 8},
{"NotifyInv4", 5},
{"SOAOutv4", 5},
},
},
} }
for _, tc := range testCases { for _, tc := range testCases {

View File

@ -16,6 +16,8 @@ import (
type jsonStats struct { type jsonStats struct {
OpCodes map[string]int OpCodes map[string]int
QTypes map[string]int QTypes map[string]int
RCodes map[string]int
ZoneStats map[string]int
NSStats map[string]int NSStats map[string]int
SockStats map[string]int SockStats map[string]int
Views map[string]jsonView Views map[string]jsonView
@ -78,6 +80,10 @@ func (b *Bind) addStatsJSON(stats jsonStats, acc telegraf.Accumulator, urlTag st
tags["type"] = "opcode" tags["type"] = "opcode"
addJSONCounter(acc, tags, stats.OpCodes) addJSONCounter(acc, tags, stats.OpCodes)
// RCodes stats
tags["type"] = "rcode"
addJSONCounter(acc, tags, stats.RCodes)
// Query RDATA types // Query RDATA types
tags["type"] = "qtype" tags["type"] = "qtype"
addJSONCounter(acc, tags, stats.QTypes) addJSONCounter(acc, tags, stats.QTypes)
@ -90,6 +96,10 @@ func (b *Bind) addStatsJSON(stats jsonStats, acc telegraf.Accumulator, urlTag st
tags["type"] = "sockstat" tags["type"] = "sockstat"
addJSONCounter(acc, tags, stats.SockStats) addJSONCounter(acc, tags, stats.SockStats)
// Zonestats
tags["type"] = "zonestat"
addJSONCounter(acc, tags, stats.ZoneStats)
// Memory stats // Memory stats
fields := map[string]interface{}{ fields := map[string]interface{}{
"total_use": stats.Memory.TotalUse, "total_use": stats.Memory.TotalUse,

View File

@ -21,6 +21,32 @@
"RESERVED14":0, "RESERVED14":0,
"RESERVED15":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":{ "qtypes":{
"A":2, "A":2,
"PTR":7, "PTR":7,
@ -40,6 +66,11 @@
"QryDuplicate":1, "QryDuplicate":1,
"QryUDP":13 "QryUDP":13
}, },
"zonestats":{
"NotifyOutv4":8,
"NotifyInv4":5,
"SOAOutv4":5
},
"views":{ "views":{
"_default":{ "_default":{
"resolver":{ "resolver":{