powerdns.chart.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # -*- coding: utf-8 -*-
  2. # Description: powerdns netdata python.d module
  3. # Author: l2isbad
  4. from json import loads
  5. from bases.FrameworkServices.UrlService import UrlService
  6. priority = 60000
  7. retries = 60
  8. # update_every = 3
  9. ORDER = ['questions', 'cache_usage', 'cache_size', 'latency']
  10. CHARTS = {
  11. 'questions': {
  12. 'options': [None, 'PowerDNS Queries and Answers', 'count', 'questions', 'powerdns.questions', 'line'],
  13. 'lines': [
  14. ['udp-queries', None, 'incremental'],
  15. ['udp-answers', None, 'incremental'],
  16. ['tcp-queries', None, 'incremental'],
  17. ['tcp-answers', None, 'incremental']
  18. ]},
  19. 'cache_usage': {
  20. 'options': [None, 'PowerDNS Cache Usage', 'count', 'cache', 'powerdns.cache_usage', 'line'],
  21. 'lines': [
  22. ['query-cache-hit', None, 'incremental'],
  23. ['query-cache-miss', None, 'incremental'],
  24. ['packetcache-hit', 'packet-cache-hit', 'incremental'],
  25. ['packetcache-miss', 'packet-cache-miss', 'incremental']
  26. ]},
  27. 'cache_size': {
  28. 'options': [None, 'PowerDNS Cache Size', 'count', 'cache', 'powerdns.cache_size', 'line'],
  29. 'lines': [
  30. ['query-cache-size', None, 'absolute'],
  31. ['packetcache-size', 'packet-cache-size', 'absolute'],
  32. ['key-cache-size', None, 'absolute'],
  33. ['meta-cache-size', None, 'absolute']
  34. ]},
  35. 'latency': {
  36. 'options': [None, 'PowerDNS Latency', 'microseconds', 'latency', 'powerdns.latency', 'line'],
  37. 'lines': [
  38. ['latency', None, 'absolute']
  39. ]}
  40. }
  41. class Service(UrlService):
  42. def __init__(self, configuration=None, name=None):
  43. UrlService.__init__(self, configuration=configuration, name=name)
  44. self.order = ORDER
  45. self.definitions = CHARTS
  46. def _get_data(self):
  47. data = self._get_raw_data()
  48. if not data:
  49. return None
  50. return dict((d['name'], d['value']) for d in loads(data))