diff --git a/checks.d/apache.py b/checks.d/apache.py index 4879f9919c..211a6d29c0 100644 --- a/checks.d/apache.py +++ b/checks.d/apache.py @@ -1,4 +1,5 @@ import urllib2 +import base64 from util import headers from checks import AgentCheck @@ -35,6 +36,10 @@ def check(self, instance): tags = instance.get('tags', []) req = urllib2.Request(url, None, headers(self.agentConfig)) + if 'apache_user' in instance and 'apache_password' in instance: + auth_str = '%s:%s' % (instance['apache_user'], instance['apache_password']) + encoded_auth_str = base64.encodestring(auth_str) + req.add_header("Authorization", "Basic %s" % encoded_auth_str) request = urllib2.urlopen(req) response = request.read() diff --git a/conf.d/apache.yaml.example b/conf.d/apache.yaml.example index 6966a708d5..b645d3b1c5 100644 --- a/conf.d/apache.yaml.example +++ b/conf.d/apache.yaml.example @@ -2,5 +2,7 @@ init_config: instances: - apache_status_url: http://example.com/server-status?auto + apache_user: example_user + apache_password: example_password tags: - - instance:foo \ No newline at end of file + - instance: foo