Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 42 lines (32 sloc) 1.084 kB
9db496e new plugins
Scott Smith authored
1 import requests
2
3 from porkchop.plugin import PorkchopPlugin
4
2d110cc @dcramer large refactor which handles previous state better, changes postgresq…
dcramer authored
5
9db496e new plugins
Scott Smith authored
6 class ApachePlugin(PorkchopPlugin):
2d110cc @dcramer large refactor which handles previous state better, changes postgresq…
dcramer authored
7 def parse_scoreboard(self, scoreboard):
8 sb = {}
9 scoreboard_keys = {
10 '_': 'waiting',
11 'S': 'starting',
12 'R': 'reading',
13 'W': 'sending',
14 'K': 'keepalive',
15 'D': 'dnslookup',
16 'C': 'closing',
17 'L': 'logging',
18 'G': 'finishing',
19 'I': 'idle_cleanup',
20 '.': 'open'
21 }
22
23 for chr in list(scoreboard):
24 sb.setdefault(scoreboard_keys[chr], 0)
25 sb[scoreboard_keys[chr]] += 1
26
27 return sb
28
29 def get_data(self):
30 data = {}
31
32 r = requests.get('http://localhost/server-status?auto')
33 for line in r.content.strip('\n').splitlines():
34 (key, val) = line.split(':', 1)
35
36 if key == 'Scoreboard':
37 data['scoreboard'] = self.parse_scoreboard(val.strip())
38 else:
39 data[key.replace(' ', '_').lower()] = val.strip()
40
41 return data
Something went wrong with that request. Please try again.