-
Notifications
You must be signed in to change notification settings - Fork 33
DNS Check API example
DNS Check is a web service for monitoring DNS records. It allows you to easily monitor sets of DNS records, including MX, CNAME and NS records without having to configure each individual DNS record within Nagios.
The DNS Check API returns JSON formatted data, so in the examples below, we're using the check_http_json Nagios plugin to make an API call, parse the data, and return the result to Nagios.
The following can be used to check the status of DNS record groups:
define command {
command_name check_dns_record_group
command_line $USER1$/check_http_json.rb -u 'https://www.dnscheck.co/api/v1/groups/$ARG1$?api_key=YOUR_API_KEY' -e 'group.status' -r 'pass' -W 'unknown' -C 'fail'
}
Replace YOUR_API_KEY
in the above command with your DNS Check API key.
A DNS record group is a logical collection of DNS records. DNS record groups can have a 1:1 correlation with zone files, but this isn't a requirement. For example, if you'd rather group your DNS records by application, like "Mail servers", then you can do that.
Here's an example service definition for monitoring a DNS record group:
define service {
name mail-server-dns-records
service_description Mail Server DNS Records
use generic-service
host_name mx.example.com
check_command check_dns_record_group!YOUR_DNS_RECORD_GROUP
}
Replace YOUR_DNS_RECORD_GROUP
with the UUID of the DNS record group that you wish to monitor. This is the 36-character string that follows /tests/
in the DNS record group URL. For example, this DNS record group's UUID is ea883d67-d9f6-45e3-b3a1-844dd1857824
.
A more detailed set of instructions, including information on how to monitor individual DNS records can be found in the Nagios / DNS Check Integration Guide.