Plugin:cURL-XML/Config

From collectd Wiki
< Plugin:cURL-XML
Revision as of 23:06, 21 March 2013 by DanFandrich (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page contains some example configurations for the cURL-XML plugin. This page is meant as a cookbook, so if you have a configuration for an aspect not handled here or a daemon not present, please feel free to add anything that's useful for you.

Contents

Sun Java System Web Server 7.0

Sun Java System Web Server 7.0 is a web server which delivers a single, secure infrastructure for all web technologies and applications. The web server exposes the monitoring statistics via a URL which can be easily consumed by the cURL-XML plugin.

The example config collects the rate of incoming and outgoing traffic, rate of 3xx,4xx and 5xx errors and the rate of the web server requests for all the virtual servers. The config also collects the web server Java statistics like Java heap usage, current Java threads and total number of Java garbage collections for all the web server processes (if more than one).

<Plugin curl_xml>
  <URL "http://localhost:80/stats-xml">
      Instance "sunwebserver-inst1"
      <xpath "/stats/server/virtual-server">
          InstanceFrom "@id"
          ValuesFrom "request-bucket/@countBytesReceived"
                     "request-bucket/@countBytesTransmitted"
          Type "sjsws_bytes"
      </xpath>
      <xpath "/stats/server/virtual-server">
          InstanceFrom "@id"
          ValuesFrom "request-bucket/@count3xx" "request-bucket/@count4xx"
                     "request-bucket/@count5xx"
          Type "sjsws_errors"
      </xpath>
      <xpath "/stats/server/virtual-server">
          InstanceFrom "@id"
          ValuesFrom "request-bucket/@countRequests"
          Type "sjsws_requests"
      </xpath>       
      <xpath "/stats/server/process">
          InstanceFrom "@pid"
          ValuesFrom "jvm/@countTotalClassesLoaded" "jvm/@countTotalClassesUnloaded"
          Type "sjsws_jvm_classes"
      </xpath>
      <xpath "/stats/server/process">
          InstanceFrom "@pid"
          ValuesFrom "jvm/@countThreads" "jvm/@countTotalThreadsStarted"
          Type "sjsws_jvm_threads"
      </xpath>
      <xpath "/stats/server/process">
          InstanceFrom "@pid"
          ValuesFrom "jvm/@sizeHeap"
          Type "sjsws_jvm_heap"
      </xpath>
      <xpath "/stats/server/process">
          InstanceFrom "@pid"
          ValuesFrom "jvm/@countGarbageCollections"
          Type "sjsws_jvm_gc"
      </xpath>
  </URL>
</Plugin>

Twitter statistics

The following configuration uses the REST API for Twitter to read the number of status updates ("Tweets") and followers. The configuration uses the screen name "foobar" which you will have to replace by the screen name you're actually interested in.

This example demonstrates how data can be extracted from text nodes using the text() syntax.

<Plugin "curl_xml">
  <URL "http://api.twitter.com/1/users/show.xml?screen_name=foobar">
    Instance "twitter"
    
    <XPath "/user">
      Type "records"
      InstancePrefix "tweets"
      #InstanceFrom ""
      ValuesFrom "statuses_count/text()"
    </XPath>
    
    <XPath "/user">
      Type "users"
      InstancePrefix "followers"
      #InstanceFrom ""
      ValuesFrom "followers_count/text()"
    </XPath>
  </URL>
</Plugin>

Because Twitter does some rate-limiting on the use that this API, you should not use a 10 second interval when querying this data! Currently (July 2010) the limit is 150 requests per hour, so querying the information every 30 seconds should be fine. For more information, see http://dev.twitter.com/pages/rate-limiting.

Fritz!Box Internet Router

Some models of Fritz!Box routers (e.g. 3270) allow retrieving some status information with a SOAP call. The following example shows how to call a SOAP function and parse the XML response using namespaces in order to retrieve the number of bytes sent and received by the router.

<Plugin "curl_xml">
   <URL "http://192.168.0.1:49000/upnp/control/WANCommonIFC1">
   Instance "router_stats"
   Header "SoapAction: \"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetAd
donInfos\""
   Header "Content-Type: text/xml"
   Post "<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/
envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:G
etAddonInfos xmlns:u=\"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1\" /></s
:Body></s:Envelope>"
   
   Namespace "s" "http://schemas.xmlsoap.org/soap/envelope/"
   Namespace "u" "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
   
   <XPath "/s:Envelope/s:Body/u:GetAddonInfosResponse">
     Type "ipt_bytes"
     InstancePrefix "tx"
     ValuesFrom "NewTotalBytesSent"
   </XPath>
   <XPath "/s:Envelope/s:Body/u:GetAddonInfosResponse">
     Type "ipt_bytes"
     InstancePrefix "rx"
     ValuesFrom "NewTotalBytesReceived"
   </XPath>
 </URL>
</Plugin>


See also

Personal tools
Namespaces

Variants
Actions
Navigation
Tools