mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Merge pull request #459 from Crafter6432/master
Bug fix & Added possibility for http auth
This commit is contained in:
commit
7d50f759fc
1 changed files with 26 additions and 7 deletions
|
@ -24,12 +24,19 @@
|
||||||
# ln -s /usr/share/munin/plugins/cherokee__type_ cherokee_localhost_type_rate
|
# ln -s /usr/share/munin/plugins/cherokee__type_ cherokee_localhost_type_rate
|
||||||
|
|
||||||
|
|
||||||
import urllib
|
import urllib2
|
||||||
|
import base64
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
about_location = "/about/info/py"
|
#py returns invalid json
|
||||||
|
about_location = "/about/info/js"
|
||||||
|
|
||||||
|
#Leave empty if not required
|
||||||
|
http_user = "admin"
|
||||||
|
http_pass = "pass"
|
||||||
|
|
||||||
host = os.getenv('host');
|
host = os.getenv('host');
|
||||||
type = 'data';
|
type = 'data';
|
||||||
|
@ -66,14 +73,26 @@ def output_values(response):
|
||||||
|
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
raw_data = urllib.urlopen( "http://%s%s" % (host,about_location)).read()
|
global host
|
||||||
|
global about_location
|
||||||
|
global http_user
|
||||||
|
global http_pass
|
||||||
|
url = "http://%s%s" % ( host , about_location )
|
||||||
|
request = urllib2.Request(url)
|
||||||
|
base64string = base64.standard_b64encode('%s:%s' % (http_user, http_pass))
|
||||||
|
if len(http_user) > 0 and len(http_pass) > 0:
|
||||||
|
#print "DEBUG: AUTH: " + base64string
|
||||||
|
request.add_header("Authorization", "Basic %s" % base64string)
|
||||||
|
#print "DEBUG: GET: " + url
|
||||||
|
raw_data = urllib2.urlopen(request).read()
|
||||||
#print "DEBUG: " + raw_data
|
#print "DEBUG: " + raw_data
|
||||||
return eval(raw_data)
|
return json.loads(raw_data)
|
||||||
|
|
||||||
def munin_values(res):
|
def munin_values(res):
|
||||||
output_values(res)
|
output_values(res)
|
||||||
|
|
||||||
def munin_config(response):
|
def munin_config(response):
|
||||||
|
global type
|
||||||
print "graph_category cherokee"
|
print "graph_category cherokee"
|
||||||
if type == "rate":
|
if type == "rate":
|
||||||
print "graph_title Cherokee Data Transfer Rate"
|
print "graph_title Cherokee Data Transfer Rate"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue