registry.MustRegister(probeDNSAuthorityRRSGauge)
registry.MustRegister(probeDNSAdditionalRRSGauge)
+ qt := dns.TypeANY
+ if module.DNS.QueryType != "" {
+ var ok bool
+ qt, ok = dns.StringToType[module.DNS.QueryType]
+ if !ok {
+ level.Error(logger).Log("msg", "Invalid query type", "Type seen", module.DNS.QueryType, "Existing types", dns.TypeToString)
+ return false
+ }
+ }
+ var probeDNSSOAGauge prometheus.Gauge
+
var ip *net.IPAddr
if module.DNS.TransportProtocol == "" {
module.DNS.TransportProtocol = "udp"
}
}
- qt := dns.TypeANY
- if module.DNS.QueryType != "" {
- var ok bool
- qt, ok = dns.StringToType[module.DNS.QueryType]
- if !ok {
- level.Error(logger).Log("msg", "Invalid query type", "Type seen", module.DNS.QueryType, "Existing types", dns.TypeToString)
- return false
- }
- }
msg := new(dns.Msg)
msg.SetQuestion(dns.Fqdn(module.DNS.QueryName), qt)
probeDNSAuthorityRRSGauge.Set(float64(len(response.Ns)))
probeDNSAdditionalRRSGauge.Set(float64(len(response.Extra)))
+ if qt == dns.TypeSOA {
+ probeDNSSOAGauge = prometheus.NewGauge(prometheus.GaugeOpts{
+ Name: "probe_dns_serial",
+ Help: "Returns the serial number of the zone",
+ })
+ registry.MustRegister(probeDNSSOAGauge)
+
+ for _, a := range response.Answer {
+ if soa, ok := a.(*dns.SOA); ok {
+ probeDNSSOAGauge.Set(float64(soa.Serial))
+ }
+ }
+ }
+
if !validRcode(response.Rcode, module.DNS.ValidRcodes, logger) {
return false
}
m := new(dns.Msg)
m.SetReply(r)
- a, err := dns.NewRR("example.com. 3600 IN A 127.0.0.1")
- if err != nil {
- panic(err)
+ if r.Question[0].Qtype == dns.TypeSOA {
+ a, err := dns.NewRR("example.com. 3600 IN SOA ns.example.com. noc.example.com. 1000 7200 3600 1209600 3600")
+ if err != nil {
+ panic(err)
+ }
+ m.Answer = append(m.Answer, a)
+
+ } else {
+ a, err := dns.NewRR("example.com. 3600 IN A 127.0.0.1")
+ if err != nil {
+ panic(err)
+ }
+ m.Answer = append(m.Answer, a)
}
- m.Answer = append(m.Answer, a)
authority := []string{
"example.com. 7200 IN NS ns1.isp.net.",
}, true,
},
{
+ config.DNSProbe{
+ PreferredIPProtocol: "ipv4",
+ QueryName: "example.com",
+ QueryType: "SOA",
+ }, true,
+ }, {
config.DNSProbe{
PreferredIPProtocol: "ipv4",
QueryName: "example.com",
"probe_dns_authority_rrs": 2,
"probe_dns_additional_rrs": 3,
}
+ if test.Probe.QueryType == "SOA" {
+ expectedResults["probe_dns_serial"] = 1000
+ }
+
checkRegistryResults(expectedResults, mfs, t)
}
}