Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support of CNAMEs. Handle only A records. #12

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions ZenPacks/zenoss/DnsMonitor/datasources/DnsMonitorDataSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import logging
log = logging.getLogger('zen.DnsMonitor')

RECORD_A = 1

class DnsException(Exception):
"""
Expand Down Expand Up @@ -114,26 +114,34 @@ def onSuccess(self, results, config):
expectedIpAddress = ds0.params['expectedIpAddress']

answers, authority, additional = results[0]
x = answers[0]
hostname = x.name.name
receivedIp = x.payload.dottedQuad()
if expectedIpAddress and expectedIpAddress != receivedIp:
receivedIps = []
hostname = ''
for x in answers:
if x.type != RECORD_A: # Further code is expecting a dottedQuad anyway
continue
hostname = x.name.name # TODO: should be a list ?
Hemie143 marked this conversation as resolved.
Show resolved Hide resolved
receivedIps.append(x.payload.dottedQuad())

if expectedIpAddress and expectedIpAddress not in receivedIps:
message = ("DNS CRITICAL - "
"expected '{}' but got '{}'".format(
expectedIpAddress, receivedIp))
expectedIpAddress, receivedIps))
raise DnsException(message)

if not hostname:
hostname = config.id
Hemie143 marked this conversation as resolved.
Show resolved Hide resolved

message = ("DNS OK: "
"{:.3f} seconds response time. "
"{} returns {}".format(respTime, hostname, receivedIp))
"{} returns {}".format(respTime, hostname, receivedIps))

log.debug('{} {}'.format(config.id, message))

for dp in ds0.points:
if dp.id in perfData:
data['values'][None][dp.id] = perfData[dp.id]

eventKey = ds0.eventKey or 'DnsMonitor'
eventKey = ds0.eventKey or 'DnsMonitor'

data['events'].append({
'eventKey': eventKey,
Expand Down