9
9
10
10
LOGGER = logging .getLogger (__name__ )
11
11
12
- PATTERN = re .compile (r'^Active connections\:\s(?P<connections>\d+)\s+\n'
13
- r'server accepts handled requests\n\s+(?P<accepts>\d+)'
14
- r'\s+(?P<handled>\d+)\s+(?P<requests>\d+)\s+\nReading\:'
15
- r'\s+(?P<reading>\d+)\s+Writing\:\s+(?P<writing>\d+)'
16
- r'\s+Waiting\:\s+(?P<waiting>\d+)' )
12
+ PATTERN = re .compile (r'^Active connections: (?P<connections>\d+)\s+[\w ]+\n'
13
+ r'\s+(?P<accepts>\d+)'
14
+ r'\s+(?P<handled>\d+)'
15
+ r'\s+(?P<requests>\d+)'
16
+ r'(\s+(?P<time>\d+)|)'
17
+ r'\s+Reading:\s+(?P<reading>\d+)'
18
+ r'\s+Writing:\s+(?P<writing>\d+)'
19
+ r'\s+Waiting:\s+(?P<waiting>\d+)' )
17
20
18
21
19
22
class Nginx (base .HTTPStatsPlugin ):
@@ -26,17 +29,19 @@ class Nginx(base.HTTPStatsPlugin):
26
29
'accepts' : 'Requests/Accepted' ,
27
30
'handled' : 'Requests/Handled' ,
28
31
'requests' : 'Totals/Requests' ,
32
+ 'time' : 'Requests/Duration' ,
29
33
'reading' : 'Connections/Reading' ,
30
34
'writing' : 'Connections/Writing' ,
31
35
'waiting' : 'Connections/Waiting' }
32
36
33
37
TYPES = {'connections' : '' ,
34
- 'accepts' : '' ,
35
- 'handled' : '' ,
36
- 'requests' : '' ,
37
- 'reading' : '' ,
38
- 'writing' : '' ,
39
- 'waiting' : '' }
38
+ 'accepts' : '' ,
39
+ 'handled' : '' ,
40
+ 'requests' : '' ,
41
+ 'reading' : '' ,
42
+ 'time' : 'seconds' ,
43
+ 'writing' : '' ,
44
+ 'waiting' : '' }
40
45
41
46
def add_datapoints (self , stats ):
42
47
"""Add all of the data points for a node
@@ -50,10 +55,12 @@ def add_datapoints(self, stats):
50
55
if matches :
51
56
for key in self .KEYS .keys ():
52
57
try :
53
- value = int (matches .group (key ))
58
+ value = int (matches .group (key ) or 0 )
54
59
except (IndexError , ValueError ):
55
60
value = 0
56
61
if key in self .GAUGES :
57
62
self .add_gauge_value (self .KEYS [key ], '' , value )
58
63
else :
59
64
self .add_derive_value (self .KEYS [key ], '' , value )
65
+ else :
66
+ LOGGER .debug ('Stats output: %r' , stats )
0 commit comments