diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
commit | a8220ab2d293bb7f4b014b79d16b2fb05090fa93 (patch) | |
tree | 77f0a30f016c0925cf7ee9292e644bba183c2774 /collectors/python.d.plugin/unbound | |
parent | Adding upstream version 1.19.0. (diff) | |
download | netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.tar.xz netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.zip |
Adding upstream version 1.29.0.upstream/1.29.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/python.d.plugin/unbound')
-rw-r--r-- | collectors/python.d.plugin/unbound/Makefile.inc | 13 | ||||
-rw-r--r-- | collectors/python.d.plugin/unbound/README.md | 114 | ||||
-rw-r--r-- | collectors/python.d.plugin/unbound/unbound.chart.py | 318 | ||||
-rw-r--r-- | collectors/python.d.plugin/unbound/unbound.conf | 85 |
4 files changed, 0 insertions, 530 deletions
diff --git a/collectors/python.d.plugin/unbound/Makefile.inc b/collectors/python.d.plugin/unbound/Makefile.inc deleted file mode 100644 index 59c306aed..000000000 --- a/collectors/python.d.plugin/unbound/Makefile.inc +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later - -# THIS IS NOT A COMPLETE Makefile -# IT IS INCLUDED BY ITS PARENT'S Makefile.am -# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT - -# install these files -dist_python_DATA += unbound/unbound.chart.py -dist_pythonconfig_DATA += unbound/unbound.conf - -# do not install these files, but include them in the distribution -dist_noinst_DATA += unbound/README.md unbound/Makefile.inc - diff --git a/collectors/python.d.plugin/unbound/README.md b/collectors/python.d.plugin/unbound/README.md deleted file mode 100644 index 4a3076100..000000000 --- a/collectors/python.d.plugin/unbound/README.md +++ /dev/null @@ -1,114 +0,0 @@ -# unbound - -## Deprecation Notes - -This module is deprecated. Please use [new version](https://github.com/netdata/go.d.plugin/tree/master/modules/unbound) instead. - -___ - -Monitoring uses the remote control interface to fetch statistics. - -Provides the following charts: - -1. **Queries Processed** - - - Ratelimited - - Cache Misses - - Cache Hits - - Expired - - Prefetched - - Recursive - -2. **Request List** - - - Average Size - - Max Size - - Overwritten Requests - - Overruns - - Current Size - - User Requests - -3. **Recursion Timings** - -- Average recursion processing time -- Median recursion processing time - -If extended stats are enabled, also provides: - -4. **Cache Sizes** - - - Message Cache - - RRset Cache - - Infra Cache - - DNSSEC Key Cache - - DNSCrypt Shared Secret Cache - - DNSCrypt Nonce Cache - -## Configuration - -Unbound must be manually configured to enable the remote-control protocol. -Check the Unbound documentation for info on how to do this. Additionally, -if you want to take advantage of the autodetection this plugin offers, -you will need to make sure your `unbound.conf` file only uses spaces for -indentation (the default config shipped by most distributions uses tabs -instead of spaces). - -Once you have the Unbound control protocol enabled, you need to make sure -that either the certificate and key are readable by Netdata (if you're -using the regular control interface), or that the socket is accessible -to Netdata (if you're using a UNIX socket for the contorl interface). - -By default, for the local system, everything can be auto-detected -assuming Unbound is configured correctly and has been told to listen -on the loopback interface or a UNIX socket. This is done by looking -up info in the Unbound config file specified by the `ubconf` key. - -To enable extended stats for a given job, add `extended: yes` to the -definition. - -You can also enable per-thread charts for a given job by adding -`per_thread: yes` to the definition. Note that the numbe rof threads -is only checked on startup. - -A basic local configuration with extended statistics and per-thread -charts looks like this: - -```yaml -local: - ubconf: /etc/unbound/unbound.conf - extended: yes - per_thread: yes -``` - -While it's a bit more complicated to set up correctly, it is recommended -that you use a UNIX socket as it provides far better performance. - -### Troubleshooting - -If you've configured the module and can't get it to work, make sure and -check all of the following: - -- If you're using autodetection, double check that your `unbound.conf` - file is actually using spaces instead of tabs, and that appropriate - indentation is present. Most Linux distributions ship a default config - for Unbound that uses tabs, and the plugin can't read such a config file - correctly. Also, make sure this file is actually readable by Netdata. -- Ensure that the control protocol is actually configured correctly. - You can check this quickly by running `unbound-control stats_noreset` - as root, which should print out a bunch of info about the internal - statistics of the server. If this returns an error, you don't have - the control protocol set up correctly. -- If using the regular control interface, make sure that the certificate - and key file you have configured in `unbound.conf` are readable by - Netdata. In general, it's preferred to use ACL's on the files to - provide the required permissions. -- If using a UNIX socket, make sure that the socket is both readable - _and_ writable by Netdata. Just like with the regular control - interface, it's preferred to use ACL's to provide these permissions. -- Make sure that SELinux, Apparmor, or any other mandatory access control - system isn't interfering with the access requirements mentioned above. - In some cases, you may have to add a local rule to allow this access. - ---- - -[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Funbound%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>) diff --git a/collectors/python.d.plugin/unbound/unbound.chart.py b/collectors/python.d.plugin/unbound/unbound.chart.py deleted file mode 100644 index 590de4c98..000000000 --- a/collectors/python.d.plugin/unbound/unbound.chart.py +++ /dev/null @@ -1,318 +0,0 @@ -# -*- coding: utf-8 -*- -# Description: unbound netdata python.d module -# Author: Austin S. Hemmelgarn (Ferroin) -# SPDX-License-Identifier: GPL-3.0-or-later - -import os -import sys - -from copy import deepcopy - -from bases.FrameworkServices.SocketService import SocketService -from bases.loaders import load_config - -PRECISION = 1000 - -ORDER = [ - 'queries', - 'recursion', - 'reqlist', -] - -CHARTS = { - 'queries': { - 'options': [None, 'Queries Processed', 'queries', 'Unbound', 'unbound.queries', 'line'], - 'lines': [ - ['ratelimit', 'ratelimited', 'absolute', 1, 1], - ['cachemiss', 'cache_miss', 'absolute', 1, 1], - ['cachehit', 'cache_hit', 'absolute', 1, 1], - ['expired', 'expired', 'absolute', 1, 1], - ['prefetch', 'prefetched', 'absolute', 1, 1], - ['recursive', 'recursive', 'absolute', 1, 1] - ] - }, - 'recursion': { - 'options': [None, 'Recursion Timings', 'milliseconds', 'Unbound', 'unbound.recursion', 'line'], - 'lines': [ - ['recursive_avg', 'average', 'absolute', 1, 1], - ['recursive_med', 'median', 'absolute', 1, 1] - ] - }, - 'reqlist': { - 'options': [None, 'Request List', 'items', 'Unbound', 'unbound.reqlist', 'line'], - 'lines': [ - ['reqlist_avg', 'average_size', 'absolute', 1, 1], - ['reqlist_max', 'maximum_size', 'absolute', 1, 1], - ['reqlist_overwritten', 'overwritten_requests', 'absolute', 1, 1], - ['reqlist_exceeded', 'overruns', 'absolute', 1, 1], - ['reqlist_current', 'current_size', 'absolute', 1, 1], - ['reqlist_user', 'user_requests', 'absolute', 1, 1] - ] - } -} - -# These get added too if we are told to use extended stats. -EXTENDED_ORDER = ['cache'] - -EXTENDED_CHARTS = { - 'cache': { - 'options': [None, 'Cache Sizes', 'items', 'Unbound', 'unbound.cache', 'stacked'], - 'lines': [ - ['cache_message', 'message_cache', 'absolute', 1, 1], - ['cache_rrset', 'rrset_cache', 'absolute', 1, 1], - ['cache_infra', 'infra_cache', 'absolute', 1, 1], - ['cache_key', 'dnssec_key_cache', 'absolute', 1, 1], - ['cache_dnscss', 'dnscrypt_Shared_Secret_cache', 'absolute', 1, 1], - ['cache_dnscn', 'dnscrypt_Nonce_cache', 'absolute', 1, 1] - ] - } -} - -# This is used as a templates for the per-thread charts. -PER_THREAD_CHARTS = { - '_queries': { - 'options': [None, '{longname} Queries Processed', 'queries', 'Queries Processed', - 'unbound.threads.queries', 'line'], - 'lines': [ - ['{shortname}_ratelimit', 'ratelimited', 'absolute', 1, 1], - ['{shortname}_cachemiss', 'cache_miss', 'absolute', 1, 1], - ['{shortname}_cachehit', 'cache_hit', 'absolute', 1, 1], - ['{shortname}_expired', 'expired', 'absolute', 1, 1], - ['{shortname}_prefetch', 'prefetched', 'absolute', 1, 1], - ['{shortname}_recursive', 'recursive', 'absolute', 1, 1] - ] - }, - '_recursion': { - 'options': [None, '{longname} Recursion Timings', 'milliseconds', 'Recursive Timings', - 'unbound.threads.recursion', 'line'], - 'lines': [ - ['{shortname}_recursive_avg', 'average', 'absolute', 1, 1], - ['{shortname}_recursive_med', 'median', 'absolute', 1, 1] - ] - }, - '_reqlist': { - 'options': [None, '{longname} Request List', 'items', 'Request List', 'unbound.threads.reqlist', 'line'], - 'lines': [ - ['{shortname}_reqlist_avg', 'average_size', 'absolute', 1, 1], - ['{shortname}_reqlist_max', 'maximum_size', 'absolute', 1, 1], - ['{shortname}_reqlist_overwritten', 'overwritten_requests', 'absolute', 1, 1], - ['{shortname}_reqlist_exceeded', 'overruns', 'absolute', 1, 1], - ['{shortname}_reqlist_current', 'current_size', 'absolute', 1, 1], - ['{shortname}_reqlist_user', 'user_requests', 'absolute', 1, 1] - ] - } -} - -# This maps the Unbound stat names to our names and precision requiremnets. -STAT_MAP = { - 'total.num.queries_ip_ratelimited': ('ratelimit', 1), - 'total.num.cachehits': ('cachehit', 1), - 'total.num.cachemiss': ('cachemiss', 1), - 'total.num.zero_ttl': ('expired', 1), - 'total.num.prefetch': ('prefetch', 1), - 'total.num.recursivereplies': ('recursive', 1), - 'total.requestlist.avg': ('reqlist_avg', 1), - 'total.requestlist.max': ('reqlist_max', 1), - 'total.requestlist.overwritten': ('reqlist_overwritten', 1), - 'total.requestlist.exceeded': ('reqlist_exceeded', 1), - 'total.requestlist.current.all': ('reqlist_current', 1), - 'total.requestlist.current.user': ('reqlist_user', 1), - # Unbound reports recursion timings as fractional seconds, but we want to show them as milliseconds. - 'total.recursion.time.avg': ('recursive_avg', PRECISION), - 'total.recursion.time.median': ('recursive_med', PRECISION), - 'msg.cache.count': ('cache_message', 1), - 'rrset.cache.count': ('cache_rrset', 1), - 'infra.cache.count': ('cache_infra', 1), - 'key.cache.count': ('cache_key', 1), - 'dnscrypt_shared_secret.cache.count': ('cache_dnscss', 1), - 'dnscrypt_nonce.cache.count': ('cache_dnscn', 1) -} - -# Same as above, but for per-thread stats. -PER_THREAD_STAT_MAP = { - '{shortname}.num.queries_ip_ratelimited': ('{shortname}_ratelimit', 1), - '{shortname}.num.cachehits': ('{shortname}_cachehit', 1), - '{shortname}.num.cachemiss': ('{shortname}_cachemiss', 1), - '{shortname}.num.zero_ttl': ('{shortname}_expired', 1), - '{shortname}.num.prefetch': ('{shortname}_prefetch', 1), - '{shortname}.num.recursivereplies': ('{shortname}_recursive', 1), - '{shortname}.requestlist.avg': ('{shortname}_reqlist_avg', 1), - '{shortname}.requestlist.max': ('{shortname}_reqlist_max', 1), - '{shortname}.requestlist.overwritten': ('{shortname}_reqlist_overwritten', 1), - '{shortname}.requestlist.exceeded': ('{shortname}_reqlist_exceeded', 1), - '{shortname}.requestlist.current.all': ('{shortname}_reqlist_current', 1), - '{shortname}.requestlist.current.user': ('{shortname}_reqlist_user', 1), - # Unbound reports recursion timings as fractional seconds, but we want to show them as milliseconds. - '{shortname}.recursion.time.avg': ('{shortname}_recursive_avg', PRECISION), - '{shortname}.recursion.time.median': ('{shortname}_recursive_med', PRECISION) -} - - -def is_readable(name): - return os.access(name, os.R_OK) - - -# Used to actually generate per-thread charts. -def _get_perthread_info(thread): - sname = 'thread{0}'.format(thread) - lname = 'Thread {0}'.format(thread) - charts = dict() - order = [] - statmap = dict() - - for item in PER_THREAD_CHARTS: - cname = '{0}{1}'.format(sname, item) - chart = deepcopy(PER_THREAD_CHARTS[item]) - chart['options'][1] = chart['options'][1].format(longname=lname) - - for index, line in enumerate(chart['lines']): - chart['lines'][index][0] = line[0].format(shortname=sname) - - order.append(cname) - charts[cname] = chart - - for key, value in PER_THREAD_STAT_MAP.items(): - statmap[key.format(shortname=sname)] = (value[0].format(shortname=sname), value[1]) - - return charts, order, statmap - - -class Service(SocketService): - def __init__(self, configuration=None, name=None): - # The unbound control protocol is always TLS encapsulated - # unless it's used over a UNIX socket, so enable TLS _before_ - # doing the normal SocketService initialization. - configuration['tls'] = True - self.port = 8935 - SocketService.__init__(self, configuration, name) - self.ext = self.configuration.get('extended', None) - self.ubconf = self.configuration.get('ubconf', None) - self.perthread = self.configuration.get('per_thread', False) - self.threads = None - self.order = deepcopy(ORDER) - self.definitions = deepcopy(CHARTS) - self.request = 'UBCT1 stats\n' - self.statmap = deepcopy(STAT_MAP) - self._parse_config() - self._auto_config() - self.debug('Extended stats: {0}'.format(self.ext)) - self.debug('Per-thread stats: {0}'.format(self.perthread)) - if self.ext: - self.order = self.order + EXTENDED_ORDER - self.definitions.update(EXTENDED_CHARTS) - if self.unix_socket: - self.debug('Using unix socket: {0}'.format(self.unix_socket)) - else: - self.debug('Connecting to: {0}:{1}'.format(self.host, self.port)) - self.debug('Using key: {0}'.format(self.key)) - self.debug('Using certificate: {0}'.format(self.cert)) - - def _auto_config(self): - self.load_unbound_config() - - if not self.key: - self.key = '/etc/unbound/unbound_control.key' - if not self.cert: - self.cert = '/etc/unbound/unbound_control.pem' - if not self.port: - self.port = 8953 - - def load_unbound_config(self): - if not (self.ubconf and is_readable(self.ubconf)): - self.debug('Unbound configuration not found.') - return - - self.debug('Loading Unbound config: {0}'.format(self.ubconf)) - - try: - conf = load_config(self.ubconf) - except Exception as error: - self.error("error on loading '{0}' : {1}".format(self.ubconf, error)) - return - - srv = conf.get('server') - if self.ext is None: - if srv and 'extended-statistics' in srv: - self.ext = srv['extended-statistics'] - - rc = conf.get('remote-control') - if not (rc and isinstance(rc, dict)): - return - - if rc.get('control-use-cert', False): - self.key = self.key or rc.get('control-key-file') - self.cert = self.cert or rc.get('control-cert-file') - self.port = self.port or rc.get('control-port') - else: - ci = rc.get('control-interface', str()) - is_socket = '/' in ci - if is_socket: - self.unix_socket = ci - - def _generate_perthread_charts(self): - tmporder = list() - for thread in range(0, self.threads): - charts, order, statmap = _get_perthread_info(thread) - tmporder.extend(order) - self.definitions.update(charts) - self.statmap.update(statmap) - self.order.extend(sorted(tmporder)) - - def check(self): - if not is_readable(self.key): - self.error("ssl key '{0}' is not readable".format(self.key)) - return False - - if not is_readable(self.cert): - self.error("ssl certificate '{0}' is not readable".format(self.certificate)) - return False - - # Check if authentication is working. - self._connect() - result = bool(self._sock) - self._disconnect() - # If auth works, and we need per-thread charts, query the server - # to see how many threads it's using. This somewhat abuses the - # SocketService API to get the data we need. - if result and self.perthread: - tmp = self.request - if sys.version_info[0] < 3: - self.request = 'UBCT1 status\n' - else: - self.request = b'UBCT1 status\n' - raw = self._get_raw_data() - if raw is None: - result = False - self.warning('Received no data from socket.') - else: - for line in raw.splitlines(): - if line.startswith('threads'): - self.threads = int(line.split()[1]) - self._generate_perthread_charts() - break - if self.threads is None: - self.info('Unable to auto-detect thread counts, disabling per-thread stats.') - self.perthread = False - self.request = tmp - return result - - def _get_data(self): - raw = self._get_raw_data() - data = dict() - tmp = dict() - if raw is not None: - for line in raw.splitlines(): - stat = line.split('=') - tmp[stat[0]] = stat[1] - for item in self.statmap: - if item in tmp: - data[self.statmap[item][0]] = float(tmp[item]) * self.statmap[item][1] - else: - self.warning('Received no data from socket.') - return data - - @staticmethod - def _check_raw_data(data): - # The server will close the connection when it's done sending - # data, so just keep looping until that happens. - return False diff --git a/collectors/python.d.plugin/unbound/unbound.conf b/collectors/python.d.plugin/unbound/unbound.conf deleted file mode 100644 index 68561366b..000000000 --- a/collectors/python.d.plugin/unbound/unbound.conf +++ /dev/null @@ -1,85 +0,0 @@ -# netdata python.d.plugin configuration for unbound -# -# This file is in YaML format. Generally the format is: -# -# name: value -# -# There are 2 sections: -# - global variables -# - one or more JOBS -# -# JOBS allow you to collect values from multiple sources. -# Each source will have its own set of charts. -# -# JOB parameters have to be indented (using spaces only, example below). - -# ---------------------------------------------------------------------- -# Global Variables -# These variables set the defaults for all JOBs, however each JOB -# may define its own, overriding the defaults. - -# update_every sets the default data collection frequency. -# If unset, the python.d.plugin default is used. -# update_every: 1 - -# priority controls the order of charts at the netdata dashboard. -# Lower numbers move the charts towards the top of the page. -# If unset, the default for python.d.plugin is used. -# priority: 60000 - -# penalty indicates whether to apply penalty to update_every in case of failures. -# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes. -# penalty: yes - -# autodetection_retry sets the job re-check interval in seconds. -# The job is not deleted if check fails. -# Attempts to start the job are made once every autodetection_retry. -# This feature is disabled by default. -# autodetection_retry: 0 - -# ---------------------------------------------------------------------- -# JOBS (data collection sources) -# -# The default JOBS share the same *name*. JOBS with the same name -# are mutually exclusive. Only one of them will be allowed running at -# any time. This allows autodetection to try several alternatives and -# pick the one that works. -# -# Any number of jobs is supported. -# -# All python.d.plugin JOBS (for all its modules) support a set of -# predefined parameters. These are: -# -# job_name: -# name: myname # the JOB's name as it will appear at the -# # dashboard (by default is the job_name) -# # JOBs sharing a name are mutually exclusive -# update_every: 1 # the JOB's data collection frequency -# priority: 60000 # the JOB's order on the dashboard -# penalty: yes # the JOB's penalty -# autodetection_retry: 0 # the JOB's re-check interval in seconds -# -# Additionally to the above, unbound also supports the following: -# -# host: localhost # The host to connect to. -# port: 8953 # WHat port to use (defaults to 8953) -# socket: /path/to/socket # A path to a UNIX socket to use instead -# # of a TCP connection -# tls_key_file: /path/to/key # The key file to use for authentication -# tls_cert_file: /path/to/key # The certificate to use for authentication -# extended: false # Whether to collect extended stats or not -# per_thread: false # Whether to show charts for per-thread stats -# -# In addition to the above, you can set the following to try and -# auto-detect most settings based on the unbound configuration: -# -# ubconf: /etc/unbound/unbound.conf -# -# Note that the SSL key and certificate need to be readable by the user -# unbound runs as if you're using the regular control interface. -# If you're using a UNIX socket, that has to be readable by the netdata user. - -# The following should work for most users if they have unbound configured -# correctly. -local: - ubconf: /etc/unbound/unbound.conf |