exim.chart.py 1005 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. # Description: exim netdata python.d module
  3. # Author: Pawel Krupa (paulfantom)
  4. # SPDX-License-Identifier: GPL-3.0-or-later
  5. from bases.FrameworkServices.ExecutableService import ExecutableService
  6. EXIM_COMMAND = 'exim -bpc'
  7. ORDER = [
  8. 'qemails',
  9. ]
  10. CHARTS = {
  11. 'qemails': {
  12. 'options': [None, 'Exim Queue Emails', 'emails', 'queue', 'exim.qemails', 'line'],
  13. 'lines': [
  14. ['emails', None, 'absolute']
  15. ]
  16. }
  17. }
  18. class Service(ExecutableService):
  19. def __init__(self, configuration=None, name=None):
  20. ExecutableService.__init__(self, configuration=configuration, name=name)
  21. self.order = ORDER
  22. self.definitions = CHARTS
  23. self.command = EXIM_COMMAND
  24. def _get_data(self):
  25. """
  26. Format data received from shell command
  27. :return: dict
  28. """
  29. try:
  30. return {'emails': int(self._get_raw_data()[0])}
  31. except (ValueError, AttributeError):
  32. return None