Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl_json: Digest authentication support #328

Closed
fcorneli opened this issue May 21, 2013 · 3 comments
Closed

curl_json: Digest authentication support #328

fcorneli opened this issue May 21, 2013 · 3 comments

Comments

@fcorneli
Copy link
Contributor

When trying to monitor JBoss EAP 6.1, you need Digest authentication. The follow patch adds Digest authentication to the curl_json plugin.

--- src/curl_json.c.orig    2013-05-21 12:14:35.385729434 +0200
+++ src/curl_json.c 2013-05-21 12:39:48.852978605 +0200
@@ -64,6 +64,7 @@
   char *user;
   char *pass;
   char *credentials;
+  _Bool digest;
   _Bool verify_peer;
   _Bool verify_host;
   char *cacert;
@@ -562,6 +563,13 @@
     curl_easy_setopt (db->curl, CURLOPT_USERPWD, db->credentials);
   }
 
+  if (db->digest)
+  {
+    curl_easy_setopt (db->curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
+    curl_easy_setopt (db->curl, CURLOPT_USERNAME, db->user);
+    curl_easy_setopt (db->curl, CURLOPT_PASSWORD, db->pass);
+  }
+
   curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYPEER, (long) db->verify_peer);
   curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYHOST,
                     db->verify_host ? 2L : 0L);
@@ -626,6 +634,8 @@
       status = cf_util_get_string (child, &db->user);
     else if (strcasecmp ("Password", child->key) == 0)
       status = cf_util_get_string (child, &db->pass);
+    else if (strcasecmp ("Digest", child->key) == 0)
+      status = cf_util_get_boolean (child, &db->digest);
     else if (strcasecmp ("VerifyPeer", child->key) == 0)
       status = cf_util_get_boolean (child, &db->verify_peer);
     else if (strcasecmp ("VerifyHost", child->key) == 0)

Example config:

<Plugin curl_json>
        <URL "http://localhost:9990/management/core-service/platform-mbean/type/threading/">
                User "the_username"
                Password "the_password"
                Digest true
                Instance "jboss7"
                <Key "thread-count">
                        Type "gauge"
                        Instance "thread-count"
                </Key>
        </URL>
</Plugin>
@octo
Copy link
Member

octo commented May 25, 2013

Hi Frank,

thank you very much for your patch! I've pushed your change to the fc/curl-digest branch. It'd be great if you could expand your patch so the other cURL plugins (curl and curl_xml) provide the same functionality. Also, please add a description of this option to the collectd.conf(5) manual page (edit the file src/collectd.conf.pod).

Thanks and best regards,
—octo

@fcorneli
Copy link
Contributor Author

#482

@mfournier
Copy link

This got merged long ago, and will be part of collectd 5.5. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants