forked from outlyerapp/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapache.py
More file actions
executable file
·38 lines (29 loc) · 962 Bytes
/
apache.py
File metadata and controls
executable file
·38 lines (29 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
"""
This plugin expects the apache status page to be available on /server-status?auto
To enable simply add this block to your httpd.conf:
<Location /server-status>
SetHandler server-status
</Location>
For more info including how to make that more secure visit http://httpd.apache.org/docs/2.2/mod/mod_status.html
"""
import sys
import requests
HOST = 'localhost'
PORT = 80
URL = "http://%s:%s/server-status?auto" % (HOST, PORT)
excludes = ['scoreboard', 'uptime']
try:
resp = requests.get(URL, timeout=60).content.split('\n')
except:
print "Plugin Failed! Unable to connect to %s" % URL
sys.exit(2)
result = "OK | "
for metric in resp:
if len(metric) > 0:
key = metric.split(':')[0].replace(' ', '.').lower().strip()
if not any(x in key for x in excludes):
value = float(metric.split(':')[1].strip())
result += key + "=" + str(value) + ";;;; "
print result
sys.exit(0)