add proxy-auth and proxy-acc charts; make all charts except auth optional and disabled by default; conf file was updated
lgz committed
Dec 20, 2016 at 23:31 UTC
5e7fb194e644ea46c6a4af6533de175118fcc2dc
2 files changed
+38
-11
conf.d/python.d/freeradius.conf
+9
-3
@@ -56,9 +56,12 @@
56
#
57
# Additionally to the above, freeradius also supports the following:
58
#
59
-# host: 'host' # ip address or hostname
60
-# port: 'port' # port on which freeradius server listen (type = status)
61
-# secret: 'secret'
59
+# host: 'host' # Default: 'localhost'. Server ip address or hostname.
60
+# port: 'port' # Default: '18121'. Port on which freeradius server listen (type = status).
61
+# secret: 'secret' # Default: 'adminsecret'.
62
+# acct: True/False # Defalt: False. Freeradius accounting statistics.
63
+# proxy_auth: True/False # Default: False. Freeradius proxy authentication statistics.
64
+# proxy_acct: True/False # Default: False. Freeradius proxy accounting statistics.
65
#
66
# ------------------------------------------------------------------------------------------------------------------
67
# Freeradius server configuration:
@@ -78,3 +81,6 @@ local:
81
host: 'localhost'
82
port: '18121'
83
secret: 'adminsecret'
84
+#acct: False
85
+#proxy_auth: False
86
+#proxy_acct: False
python.d/freeradius.chart.py
+29
-8
@@ -10,11 +10,11 @@ from subprocess import Popen, PIPE
10
# default module values (can be overridden per job in `config`)
11
priority = 60000
12
retries = 60
13
-update_every = 10
14
-directories = ['/bin/', '/usr/bin/', '/sbin/', '/usr/sbin/']
13
+update_every = 15
14
+directories = ['/bin/', '/usr/bin/', '/sbin', '/usr/sbin/']
15
16
# charts order (can be overridden if you want less charts, or different order)
17
-ORDER = ['authentication', 'accounting']
17
+ORDER = ['authentication', 'accounting', 'proxy-auth', 'proxy-acct']
18
19
CHARTS = {
20
'authentication': {
@@ -32,21 +32,39 @@ CHARTS = {
32
['acct-dropped-requests', None, 'incremental'], ['acct-duplicate-requests', None, 'incremental'],
33
['acct-invalid-requests', None, 'incremental'], ['acct-malformed-requests', None, 'incremental'],
34
['acct-unknown-types', None, 'incremental']
35
+ ]},
36
+ 'proxy-auth': {
37
+ 'options': [None, "Proxy Authentication", "packets/s", 'Authentication', 'freerad.proxy.auth', 'line'],
38
+ 'lines': [
39
+ ['proxy-access-accepts', None, 'incremental'], ['proxy-access-rejects', None, 'incremental'],
40
+ ['proxy-auth-dropped-requests', None, 'incremental'], ['proxy-auth-duplicate-requests', None, 'incremental'],
41
+ ['proxy-auth-invalid-requests', None, 'incremental'], ['proxy-auth-malformed-requests', None, 'incremental'],
42
+ ['proxy-auth-unknown-types', None, 'incremental']
43
+ ]},
44
+ 'proxy-acct': {
45
+ 'options': [None, "Proxy Accounting", "packets/s", 'Accounting', 'freerad.proxy.acct', 'line'],
46
+ 'lines': [
47
+ ['proxy-accounting-requests', None, 'incremental'], ['proxy-accounting-responses', None, 'incremental'],
48
+ ['proxy-acct-dropped-requests', None, 'incremental'], ['proxy-acct-duplicate-requests', None, 'incremental'],
49
+ ['proxy-acct-invalid-requests', None, 'incremental'], ['proxy-acct-malformed-requests', None, 'incremental'],
50
+ ['proxy-acct-unknown-types', None, 'incremental']
51
]}
52
+
53
}
54
55
56
class Service(SimpleService):
57
def __init__(self, configuration=None, name=None):
58
SimpleService.__init__(self, configuration=configuration, name=name)
42
- self.order = ORDER
43
- self.definitions = CHARTS
59
self.host = self.configuration.get('host', 'localhost')
60
self.port = self.configuration.get('port', '18121')
61
self.secret = self.configuration.get('secret', 'adminsecret')
62
+ self.acct = self.configuration.get('acct', False)
63
+ self.proxy_auth = self.configuration.get('proxy_auth', False)
64
+ self.proxy_acct = self.configuration.get('proxy_acct', False)
65
self.echo = [''.join([directory, 'echo']) for directory in directories if isfile(''.join([directory, 'echo']))][0]
66
self.radclient = [''.join([directory, 'radclient']) for directory in directories if isfile(''.join([directory, 'radclient']))][0]
49
- self.sub_echo = [self.echo, 'Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 3, Response-Packet-Type = Access-Accept']
67
+ self.sub_echo = [self.echo, 'Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 15, Response-Packet-Type = Access-Accept']
68
self.sub_radclient = [self.radclient, '-r', '1', '-t', '1', ':'.join([self.host, self.port]), 'status', self.secret]
69
70
def check(self):
@@ -54,7 +72,10 @@ class Service(SimpleService):
72
self.error('Command radclient not found')
73
return False
74
if self._get_raw_data():
57
- self.info('plugin was started succesfully')
75
+ chart_choice = [True, bool(self.acct), bool(self.proxy_auth), bool(self.proxy_acct)]
76
+ self.order = [chart for chart, choice in zip(ORDER, chart_choice) if choice]
77
+ self.definitions = {k:v for k, v in CHARTS.items() if k in self.order}
78
+ self.info('Plugin was started succesfully')
79
return True
80
else:
81
self.error('Request returned no data. Is server alive? Used options: host {}, port {}, secret {}'.format(self.host, self.port, self.secret))
@@ -72,7 +93,7 @@ class Service(SimpleService):
93
def _get_raw_data(self):
94
"""
95
The following code is equivalent to
75
- 'echo "Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 3, Response-Packet-Type = Access-Accept" | radclient -t 1 -r 1 host:port status secret'
96
+ 'echo "Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 15, Response-Packet-Type = Access-Accept" | radclient -t 1 -r 1 host:port status secret'
97
:return: str
98
"""
99
try: