dist_pythonconfig_DATA = \
python.d/apache.conf \
python.d/apache_cache.conf \
+ python.d/cpufreq.conf \
python.d/example.conf \
+ python.d/exim.conf \
python.d/hddtemp.conf \
python.d/mysql.conf \
python.d/nginx.conf \
python.d/phpfpm.conf \
+ python.d/postfix.conf \
python.d/squid.conf \
python.d/tomcat.conf \
$(NULL)
--- /dev/null
+# Example configuration of cpufreq.chart.py
+# YAML format
+
+update_every : 2
--- /dev/null
+# Example configuration of exim.chart.py
+# YAML format
+
+update_every : 2
--- /dev/null
+# Example configuration of postfix.chart.py
+# YAML format
+
+update_every : 2
SUFFIXES = .in
dist_python_SCRIPTS = \
- example.chart.py \
- mysql.chart.py \
- phpfpm.chart.py \
apache.chart.py \
- nginx.chart.py \
apache_cache.chart.py \
+ cpufreq.chart.py \
+ example.chart.py \
+ exim.chart.py \
hddtemp.chart.py \
+ mysql.chart.py \
+ nginx.chart.py \
+ phpfpm.chart.py \
+ postfix.chart.py \
squid.chart.py \
tomcat.chart.py \
python-modules-installer.sh \
# -*- coding: utf-8 -*-
-# Description: apache netdata python.d plugin
+# Description: apache netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import UrlService
# -*- coding: utf-8 -*-
-# Description: apache cache netdata python.d plugin
+# Description: apache cache netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import LogService
--- /dev/null
+# -*- coding: utf-8 -*-
+# Description: cpufreq netdata python.d module
+# Author: Pawel Krupa (paulfantom)
+
+import os
+from base import SimpleService
+
+# default module values (can be overridden per job in `config`)
+# update_every = 2
+
+ORDER = ['cpufreq']
+
+CHARTS = {
+ 'cpufreq': {
+ 'options': [None, 'CPU Clock', 'MHz', 'cpufreq', None, 'line'],
+ 'lines': [
+ # lines are created dynamically in `check()` method
+ ]}
+}
+
+
+class Service(SimpleService):
+ def __init__(self, configuration=None, name=None):
+ self.sys_dir = "/sys/devices"
+ self.filename = "scaling_cur_freq"
+ SimpleService.__init__(self, configuration=configuration, name=name)
+ self.order = ORDER
+ self.definitions = CHARTS
+ self._orig_name = ""
+ self.assignment = {}
+ self.paths = []
+
+ def _get_data(self):
+ raw = {}
+ for path in self.paths:
+ with open(path, 'r') as f:
+ raw[path] = f.read()
+ data = {}
+ for path in self.paths:
+ data[self.assignment[path]] = raw[path]
+ return data
+
+ def check(self):
+ self._orig_name = self.chart_name
+
+ for dirpath, _, filenames in os.walk(self.sys_dir):
+ if self.filename in filenames:
+ self.paths.append(dirpath + "/" + self.filename)
+
+ if len(self.paths) == 0:
+ return False
+
+ self.paths.sort()
+ i = 0
+ for path in self.paths:
+ self.assignment[path] = "cpu" + str(i)
+ i += 1
+
+ for name in self.assignment:
+ dim = self.assignment[name]
+ self.definitions[ORDER[0]]['lines'].append([dim, dim, 'absolute', 1, 1000])
+
+ return True
+
+ def create(self):
+ self.chart_name = "cpu"
+ status = SimpleService.create(self)
+ self.chart_name = self._orig_name
+ return status
+
+ def update(self, interval):
+ self.chart_name = "cpu"
+ status = SimpleService.update(self, interval=interval)
+ self.chart_name = self._orig_name
+ return status
# -*- coding: utf-8 -*-
-# Description: example netdata python.d plugin
+# Description: example netdata python.d module
# Author: Pawel Krupa (paulfantom)
import os
--- /dev/null
+# -*- coding: utf-8 -*-
+# Description: exim netdata python.d module
+# Author: Pawel Krupa (paulfantom)
+
+from base import ExecutableService
+
+# default module values (can be overridden per job in `config`)
+# update_every = 2
+priority = 60000
+retries = 5
+
+# charts order (can be overridden if you want less charts, or different order)
+ORDER = ['qemails']
+
+CHARTS = {
+ 'qemails': {
+ 'options': [None, "Exim Queue Emails", "emails", 'queue', 'exim.queued.emails', 'line'],
+ 'lines': [
+ ['emails', None, 'absolute']
+ ]}
+}
+
+
+class Service(ExecutableService):
+ def __init__(self, configuration=None, name=None):
+ ExecutableService.__init__(self, configuration=configuration, name=name)
+ self.command = "exim -bpc"
+ self.order = ORDER
+ self.definitions = CHARTS
+
+ def _get_data(self):
+ """
+ Format data received from shell command
+ :return: dict
+ """
+ try:
+ raw = self._get_raw_data()[-1].split(' ')
+ return {'emails': raw[4],
+ 'size': raw[1]}
+ except (ValueError, AttributeError):
+ return None
# -*- coding: utf-8 -*-
-# Description: hddtemp netdata python.d plugin
+# Description: hddtemp netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import NetSocketService
# -*- coding: utf-8 -*-
-# Description: MySQL netdata python.d plugin
+# Description: MySQL netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import SimpleService
# -*- coding: utf-8 -*-
-# Description: nginx netdata python.d plugin
+# Description: nginx netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import UrlService
# -*- coding: utf-8 -*-
-# Description: PHP-FPM netdata python.d plugin
+# Description: PHP-FPM netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import UrlService
--- /dev/null
+# -*- coding: utf-8 -*-
+# Description: postfix netdata python.d module
+# Author: Pawel Krupa (paulfantom)
+
+from base import ExecutableService
+
+# default module values (can be overridden per job in `config`)
+# update_every = 2
+priority = 60000
+retries = 5
+
+# charts order (can be overridden if you want less charts, or different order)
+ORDER = ['qemails', 'qsize']
+
+CHARTS = {
+ 'qemails': {
+ 'options': [None, "Postfix Queue Emails", "emails", 'queue', 'postfix.queued.emails', 'line'],
+ 'lines': [
+ ['emails', None, 'absolute']
+ ]},
+ 'qsize': {
+ 'options': [None, "Postfix Queue Emails Size", "emails size in KB", 'queue', 'postfix.queued.size', 'area'],
+ 'lines': [
+ ["size", None, 'absolute']
+ ]}
+}
+
+
+class Service(ExecutableService):
+ def __init__(self, configuration=None, name=None):
+ ExecutableService.__init__(self, configuration=configuration, name=name)
+ self.command = "postqueue -p"
+ self.order = ORDER
+ self.definitions = CHARTS
+
+ def _get_data(self):
+ """
+ Format data received from shell command
+ :return: dict
+ """
+ try:
+ raw = self._get_raw_data()[-1].split(' ')
+ return {'emails': raw[4],
+ 'size': raw[1]}
+ except (ValueError, AttributeError):
+ return None
class ExecutableService(SimpleService):
- command_whitelist = ['exim']
+ command_whitelist = ['exim', 'postqueue']
def __init__(self, configuration=None, name=None):
self.command = ""
else:
self.error("Wrong command. Probably not on whitelist.")
return False
+ # test command and search for it in /usr/sbin or /sbin when failed
+ base = self.command[0]
+ if self._get_raw_data() is None:
+ for prefix in ['/sbin/', '/usr/sbin/']:
+ self.command[0] = prefix + base
+ if self._get_raw_data() is not None:
+ break
+
if self._get_data() is None or len(self._get_data()) == 0:
return False
return True
# -*- coding: utf-8 -*-
-# Description: squid netdata python.d plugin
+# Description: squid netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import NetSocketService
# -*- coding: utf-8 -*-
-# Description: tomcat netdata python.d plugin
+# Description: tomcat netdata python.d module
# Author: Pawel Krupa (paulfantom)
from base import UrlService