summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/apache
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/python.d.plugin/apache')
-rw-r--r--collectors/python.d.plugin/apache/README.md4
-rw-r--r--collectors/python.d.plugin/apache/apache.chart.py114
-rw-r--r--collectors/python.d.plugin/apache/apache.conf10
3 files changed, 77 insertions, 51 deletions
diff --git a/collectors/python.d.plugin/apache/README.md b/collectors/python.d.plugin/apache/README.md
index c6d1d126a..090feb070 100644
--- a/collectors/python.d.plugin/apache/README.md
+++ b/collectors/python.d.plugin/apache/README.md
@@ -46,14 +46,14 @@ priority : 90100
local:
url : 'http://localhost/server-status?auto'
- retries : 20
remote:
url : 'http://www.apache.org/server-status?auto'
update_every : 5
- retries : 4
```
Without configuration, module attempts to connect to `http://localhost/server-status?auto`
---
+
+[![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%2Fapache%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/collectors/python.d.plugin/apache/apache.chart.py b/collectors/python.d.plugin/apache/apache.chart.py
index d136274d0..655616d07 100644
--- a/collectors/python.d.plugin/apache/apache.chart.py
+++ b/collectors/python.d.plugin/apache/apache.chart.py
@@ -5,64 +5,60 @@
from bases.FrameworkServices.UrlService import UrlService
-# default module values (can be overridden per job in `config`)
-# update_every = 2
-priority = 60000
-retries = 60
-
-# default job configuration (overridden by python.d.plugin)
-# config = {'local': {
-# 'update_every': update_every,
-# 'retries': retries,
-# 'priority': priority,
-# 'url': 'http://www.apache.org/server-status?auto'
-# }}
-
-# charts order (can be overridden if you want less charts, or different order)
-ORDER = ['requests', 'connections', 'conns_async', 'net', 'workers', 'reqpersec', 'bytespersec', 'bytesperreq']
+
+ORDER = [
+ 'requests',
+ 'connections',
+ 'conns_async',
+ 'net',
+ 'workers',
+ 'reqpersec',
+ 'bytespersec',
+ 'bytesperreq',
+]
CHARTS = {
'bytesperreq': {
- 'options': [None, 'apache Lifetime Avg. Response Size', 'bytes/request',
+ 'options': [None, 'Lifetime Avg. Request Size', 'KiB',
'statistics', 'apache.bytesperreq', 'area'],
'lines': [
- ['size_req']
+ ['size_req', 'size', 'absolute', 1, 1024 * 100000]
]},
'workers': {
- 'options': [None, 'apache Workers', 'workers', 'workers', 'apache.workers', 'stacked'],
+ 'options': [None, 'Workers', 'workers', 'workers', 'apache.workers', 'stacked'],
'lines': [
['idle'],
['busy'],
]},
'reqpersec': {
- 'options': [None, 'apache Lifetime Avg. Requests/s', 'requests/s', 'statistics',
+ 'options': [None, 'Lifetime Avg. Requests/s', 'requests/s', 'statistics',
'apache.reqpersec', 'area'],
'lines': [
- ['requests_sec']
+ ['requests_sec', 'requests', 'absolute', 1, 100000]
]},
'bytespersec': {
- 'options': [None, 'apache Lifetime Avg. Bandwidth/s', 'kilobits/s', 'statistics',
+ 'options': [None, 'Lifetime Avg. Bandwidth/s', 'kilobits/s', 'statistics',
'apache.bytesperreq', 'area'],
'lines': [
- ['size_sec', None, 'absolute', 8, 1000]
+ ['size_sec', None, 'absolute', 8, 1000 * 100000]
]},
'requests': {
- 'options': [None, 'apache Requests', 'requests/s', 'requests', 'apache.requests', 'line'],
+ 'options': [None, 'Requests', 'requests/s', 'requests', 'apache.requests', 'line'],
'lines': [
['requests', None, 'incremental']
]},
'net': {
- 'options': [None, 'apache Bandwidth', 'kilobits/s', 'bandwidth', 'apache.net', 'area'],
+ 'options': [None, 'Bandwidth', 'kilobits/s', 'bandwidth', 'apache.net', 'area'],
'lines': [
['sent', None, 'incremental', 8, 1]
]},
'connections': {
- 'options': [None, 'apache Connections', 'connections', 'connections', 'apache.connections', 'line'],
+ 'options': [None, 'Connections', 'connections', 'connections', 'apache.connections', 'line'],
'lines': [
['connections']
]},
'conns_async': {
- 'options': [None, 'apache Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'],
+ 'options': [None, 'Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'],
'lines': [
['keepalive'],
['closing'],
@@ -86,6 +82,14 @@ ASSIGNMENT = {
'ConnsAsyncWriting': 'writing'
}
+FLOAT_VALUES = [
+ 'BytesPerReq',
+ 'ReqPerSec',
+ 'BytesPerSec',
+]
+
+LIGHTTPD_MARKER = 'idle_servers'
+
class Service(UrlService):
def __init__(self, configuration=None, name=None):
@@ -96,20 +100,15 @@ class Service(UrlService):
def check(self):
self._manager = self._build_manager()
+
data = self._get_data()
+
if not data:
return None
- if 'idle_servers' in data:
- self.module_name = 'lighttpd'
- for chart in self.definitions:
- if chart == 'workers':
- lines = self.definitions[chart]['lines']
- lines[0] = ['idle_servers', 'idle']
- lines[1] = ['busy_servers', 'busy']
- opts = self.definitions[chart]['options']
- opts[1] = opts[1].replace('apache', 'lighttpd')
- opts[4] = opts[4].replace('apache', 'lighttpd')
+ if LIGHTTPD_MARKER in data:
+ self.turn_into_lighttpd()
+
return True
def _get_data(self):
@@ -118,15 +117,44 @@ class Service(UrlService):
:return: dict
"""
raw_data = self._get_raw_data()
+
if not raw_data:
return None
+
data = dict()
- for row in raw_data.split('\n'):
- tmp = row.split(':')
- if tmp[0] in ASSIGNMENT:
- try:
- data[ASSIGNMENT[tmp[0]]] = int(float(tmp[1]))
- except (IndexError, ValueError):
- continue
+ for line in raw_data.split('\n'):
+ try:
+ parse_line(line, data)
+ except ValueError:
+ continue
+
return data or None
+
+ def turn_into_lighttpd(self):
+ self.module_name = 'lighttpd'
+ for chart in self.definitions:
+ if chart == 'workers':
+ lines = self.definitions[chart]['lines']
+ lines[0] = ['idle_servers', 'idle']
+ lines[1] = ['busy_servers', 'busy']
+ opts = self.definitions[chart]['options']
+ opts[1] = opts[1].replace('apache', 'lighttpd')
+ opts[4] = opts[4].replace('apache', 'lighttpd')
+
+
+def parse_line(line, data):
+ parts = line.split(':')
+
+ if len(parts) != 2:
+ return
+
+ key, value = parts[0], parts[1]
+
+ if key not in ASSIGNMENT:
+ return
+
+ if key in FLOAT_VALUES:
+ data[ASSIGNMENT[key]] = int((float(value) * 100000))
+ else:
+ data[ASSIGNMENT[key]] = int(value)
diff --git a/collectors/python.d.plugin/apache/apache.conf b/collectors/python.d.plugin/apache/apache.conf
index 8b606f7e0..84e12a57c 100644
--- a/collectors/python.d.plugin/apache/apache.conf
+++ b/collectors/python.d.plugin/apache/apache.conf
@@ -27,11 +27,9 @@
# If unset, the default for python.d.plugin is used.
# priority: 60000
-# retries sets the number of retries to be made in case of failures.
-# If unset, the default for python.d.plugin is used.
-# Attempts to restore the service are made once every update_every
-# and only if the module has collected values in the past.
-# retries: 60
+# 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.
@@ -58,7 +56,7 @@
# # 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
-# retries: 60 # the JOB's number of restoration attempts
+# penalty: yes # the JOB's penalty
# autodetection_retry: 0 # the JOB's re-check interval in seconds
#
# Additionally to the above, apache also supports the following: