Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit c63822740132da9d4dd8decbf70b547573eedcdf @dougm dougm committed Jan 14, 2009
Showing with 4,339 additions and 0 deletions.
  1. +339 −0 LICENSE
  2. +148 −0 README.markdown
  3. +126 −0 build.xml
  4. +36 −0 etc/javalang-jcollectd.xml
  5. +9 −0 etc/tomcat-jcollectd.xml
  6. +121 −0 src/main/java/org/collectd/mx/CollectdMBean.java
  7. +227 −0 src/main/java/org/collectd/mx/CollectdMBeanRegistry.java
  8. +26 −0 src/main/java/org/collectd/mx/CollectdMBeanRegistryMBean.java
  9. +92 −0 src/main/java/org/collectd/mx/CollectdSummaryMBean.java
  10. +117 −0 src/main/java/org/collectd/mx/MBeanAttribute.java
  11. +246 −0 src/main/java/org/collectd/mx/MBeanCollector.java
  12. +139 −0 src/main/java/org/collectd/mx/MBeanConfig.java
  13. +86 −0 src/main/java/org/collectd/mx/MBeanQuery.java
  14. +148 −0 src/main/java/org/collectd/mx/MBeanReceiver.java
  15. +252 −0 src/main/java/org/collectd/mx/MBeanSender.java
  16. +75 −0 src/main/java/org/collectd/mx/RemoteMBeanSender.java
  17. +97 −0 src/main/java/org/collectd/protocol/DataSource.java
  18. +29 −0 src/main/java/org/collectd/protocol/Dispatcher.java
  19. +100 −0 src/main/java/org/collectd/protocol/Network.java
  20. +70 −0 src/main/java/org/collectd/protocol/Notification.java
  21. +151 −0 src/main/java/org/collectd/protocol/PacketWriter.java
  22. +127 −0 src/main/java/org/collectd/protocol/PluginData.java
  23. +85 −0 src/main/java/org/collectd/protocol/Sender.java
  24. +57 −0 src/main/java/org/collectd/protocol/StdoutDispatcher.java
  25. +161 −0 src/main/java/org/collectd/protocol/TypesDB.java
  26. +286 −0 src/main/java/org/collectd/protocol/UdpReceiver.java
  27. +111 −0 src/main/java/org/collectd/protocol/UdpSender.java
  28. +105 −0 src/main/java/org/collectd/protocol/ValueList.java
  29. +108 −0 src/main/resources/META-INF/types.db
  30. +70 −0 src/test/java/org/collectd/mx/MBeanConfigTest.java
  31. +125 −0 src/test/java/org/collectd/mx/MBeanSenderTest.java
  32. +43 −0 src/test/java/org/collectd/protocol/MulticastReceiverTest.java
  33. +33 −0 src/test/java/org/collectd/protocol/MulticastSenderTest.java
  34. +95 −0 src/test/java/org/collectd/protocol/ReceiverTest.java
  35. +153 −0 src/test/java/org/collectd/protocol/SenderTest.java
  36. +51 −0 src/test/java/org/collectd/protocol/TypesDBTest.java
  37. +95 −0 src/test/java/org/collectd/protocol/ValueListTest.java
339 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,148 @@
+## jcollectd - Java integration for collectd
+
+### collectd
+
+[collectd](http://collectd.org) is a lightweight, extensible system statistics gathering
+daemon written in C for performance and portability. In-process
+plugins can be written in C or Perl. Out-of-process plugins are
+executed on each collection interval or can put values via the
+unixsock plugin.
+
+### jcollectd
+
+The jcollectd package implements the collectd protocol in Java, making
+it possible for Java applications to push data into collectd over the
+wire. A Java app can configure JMX MBean attributes to be collected,
+or use the Java client API directly.
+
+The listener side of the protocol is also supported, including an
+implementation that registers JMX MBeans making it possible to view
+collectd data using a graphical tool such as jconsole.
+
+There is no installation process for jcollectd, as all required files
+are self-contained in *collectd.jar* with no dependecies other than
+Java version 5 or higher. The command-line and java configuration
+options required to use the package are described below.
+
+### MBeanReceiver
+
+The **MBeanReceiver** class listens for collectd packets and publishes the
+data as JMX MBeans. A summary MBean is created to aggregate metrics, where
+the attributes values are the average across all instances.
+The MBeans can be viewed using a tool such as the standard jconsole.
+The MBeanReceiver can be started using the following command:
+
+ java -jar collectd.jar
+
+#### Examples
+
+* Listen on the default IPv4 multicast group **239.192.74.66:25826**:
+
+ java -jar collectd.jar -jconsole
+
+* Listen on the IPv4 unicast address **127.0.0.1:25827** and start
+ jconsole attached locally to the collectd.jar process:
+
+ java -Djcd.laddr=udp://127.0.0.1:25827 -jar collectd.jar -jconsole
+
+* Listen on the default IPv4 multicast group and allow remote JMX
+ connections to RMI/TCP port *25826*:
+
+ java -Dcom.sun.management.jmxremote.port=25826 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar collectd.jar
+
+* Connect to the MBeanServer example above from another machine:
+
+ jconsole the-remote-hostname:25826
+
+#### Configuration
+
+* jcd.laddr - UDP listen address, the default is **239.192.74.66:25826**.
+ Example:
+
+ jcd.laddr=udp://localhost:25826
+
+* jcd.ifaddr - The multicast network interface, default is any.
+ Example:
+
+ jcd.ifaddr=eth2
+
+* jcd.mx.summary - Enable summary MBean aggregator, the default is true.
+ Example:
+
+ jcd.mx.summary=false
+
+* jcd.mx.hosts - Filter displayed hosts using a regex, the default is .*.
+ Example:
+
+ jcd.mx.hosts=dev|qa
+
+### MBeanSender
+
+Any Java application can be configured to publish MBean data without
+any code changes. The following example will push java.lang:* MBeans
+to the default collectd multicast group:
+
+ java -Djcd.tmpl=javalang -javaagent:collectd.jar YourMainClass
+
+Tomcat example:
+
+ export CATALINA_OPTS="-Djcd.instance=hudson -Djcd.dest=udp://10.1.0.102 -Djcd.tmpl=javalang,tomcat -javaagent:collectd.jar"
+ ./bin/catalina.sh start
+
+#### Configuration
+
+The jcd.* properties can be defined as System properties or in the
+jcd.properties file:
+
+* jcd.dest - UDP destination(s), the default is
+ **239.192.74.66:25826**. Example:
+
+ jcd.dest=udp://localhost:25826
+
+* jcd.tmpl - jcollectd.xml MBean filter templates (see etc/). Example:
+
+ jcd.tmpl=javalang,tomcat
+
+* jcd.host - The collectd host (Hostname in collectd.conf) defaults to InetAddress.getLocalHost().getHostName(). Example:
+
+ jcd.host=myhost
+
+* jcd.instance - The collectd Plugin Instance, defaults to
+ *java.lang:type=Runtime:Name*. Example:
+
+ jcd.instance=tomcat01
+
+* jcd.beans - ObjectName(s) which are not defined in a filter
+ template. The ObjectName can be a pattern or fully qualified.
+ Multiple ObjectNames are delimited using `#`. All attributes
+ for the matching MBeans will be collected where the attribute value
+ is a *Number*. Example:
+
+ jcd.beans=mydomain:*#foo:type=Stats#bar:type=App,*
+
+* jcd.properties - Path to the jcd.properties file which can be used
+ to define all of the above properties. Example:
+
+ jcd.properties=/path/to/my-jcd.properties
+
+#### XML MBean filters
+
+The MBean filters provide a way to define exactly which MBean
+attributes should be collected, how they should be named in collectd
+and what type the metric is. See the etc/ directory for examples.
+The format is currently subject to change pending feedback and
+documentation will follow.
+
+### See Also
+
+* [collectd](http://collectd.org) - the system statistics collection daemon
+
+* [collectd jmx plugin](http://marc.info/?l=collectd&w=2&r=1&s=jmx&q=b) - Embeds a JVM in collectd
+
+* [jmxetric](http://code.google.com/p/jmxetric/) - JMX injector for Ganglia
+
+### About
+
+Copyright (c) 2009 [Hyperic, Inc.](http://www.hyperic.com/) - See LICENSE
+
+For feedback and discussion, please use collectd's mailinglist: collectd at verplant.org
126 build.xml
@@ -0,0 +1,126 @@
+<project name="jcollectd" default="test" basedir=".">
+ <description>Java collectd</description>
+ <property name="src.main" location="src/main/java" />
+ <property name="src.test" location="src/test/java" />
+ <property name="target" location="target" />
+ <property name="version" value="0.1.0"/>
+ <property name="dist.name" value="jcollectd-${version}"/>
+ <property name="dist" value="${target}/${dist.name}"/>
+
+ <property name="debug" value="true" />
+ <available property="junit" classname="junit.framework.Test"/>
+
+ <path id="alljars">
+ <fileset dir="${target}" includes="lib/collectd.jar"/>
+ </path>
+
+ <target name="init">
+ <mkdir dir="${target}/classes"/>
+ <mkdir dir="${target}/lib"/>
+ </target>
+
+ <target name="compile-tests" depends="init,compile" if="junit">
+ <javac destdir="${target}/classes"
+ debug="${debug}"
+ source="1.5" target="1.5"
+ classpath="${target}/classes">
+ <src path="${src.test}"/>
+ </javac>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac destdir="${target}/classes"
+ debug="${debug}"
+ source="1.5" target="1.5">
+ <src path="${src.main}"/>
+ </javac>
+ </target>
+
+ <target name="jar" depends="compile">
+ <jar jarfile="${target}/lib/collectd.jar">
+ <fileset dir="${target}/classes"
+ excludes="**/*Test.class" />
+ <fileset dir="src/main/resources"/>
+ <fileset dir="." includes="etc/*.xml"/>
+ <manifest>
+ <attribute name="Main-Class"
+ value="org.collectd.mx.MBeanReceiver"/>
+ <attribute name="Premain-Class"
+ value="org.collectd.mx.RemoteMBeanSender"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="test" depends="compile-tests,jar" if="junit">
+ <property name="testresults"
+ location="${target}/testresults"/>
+
+ <mkdir dir="${testresults}"/>
+
+ <junit printsummary="yes" fork="yes"
+ haltonfailure="yes" showoutput="true">
+
+ <classpath>
+ <path refid="alljars"/>
+ <path location="${target}/classes"/>
+ </classpath>
+
+ <formatter type="xml"/>
+
+ <batchtest fork="yes" todir="${testresults}">
+ <fileset dir="${src.test}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="clean">
+ <delete dir="${target}" />
+ </target>
+
+ <target name="javadoc">
+ <mkdir dir="${target}/javadoc"/>
+ <javadoc packagenames="org.collectd.*"
+ useexternalfile="yes"
+ sourcepath="src/main/java"
+ destdir="${target}/javadoc"
+ author="false"
+ version="false"
+ windowtitle="Java collectd API"
+ doctitle="Jcollectd">
+ <group title="Jcollectd" packages="org.collectd" />
+ <bottom>Copyright &#169; 2009 <![CDATA[<a target="_top" href="http://www.hyperic.com/">Hyperic, Inc.</a>]]>. All Rights Reserved.</bottom>
+ </javadoc>
+ </target>
+
+ <target name="dist" depends="jar,javadoc">
+ <mkdir dir="${dist}"/>
+
+ <copy toDir="${dist}" filtering="on">
+ <fileset dir=".">
+ <include name="build.xml"/>
+ <include name="LICENSE"/>
+ <include name="README*"/>
+ <include name="etc/*.xml"/>
+ <include name="src/**/*.*"/>
+ </fileset>
+ <fileset dir="${target}">
+ <include name="javadoc/**"/>
+ <include name="lib/**"/>
+ </fileset>
+ </copy>
+
+ <tar destfile="${target}/${dist.name}.tar.gz"
+ basedir="${target}"
+ includes="${dist.name}/**"
+ longfile="gnu"
+ compression="gzip"/>
+ </target>
+
+ <target name="markdown">
+ <exec executable="markdown" dir="." output="${target}/README.html">
+ <arg value="README.markdown"/>
+ </exec>
+ </target>
+</project>
@@ -0,0 +1,36 @@
+<jcollectd-config>
+ <mbeans name="java.lang">
+ <mbean name="java.lang:type=Memory" alias="Memory">
+ <attribute name="HeapMemoryUsage.init" alias="Heap_init" units="bytes"/>
+ <attribute name="HeapMemoryUsage.committed" alias="Heap_committed" units="bytes"/>
+ <attribute name="HeapMemoryUsage.used" alias="Heap_used" units="bytes"/>
+ <attribute name="HeapMemoryUsage.max" alias="Heap_max" units="bytes"/>
+ <attribute name="NonHeapMemoryUsage.init" alias="NonHeap_init" units="bytes"/>
+ <attribute name="NonHeapMemoryUsage.committed" alias="NonHeap_committed" units="bytes"/>
+ <attribute name="NonHeapMemoryUsage.used" alias="NonHeap_used" units="bytes"/>
+ <attribute name="NonHeapMemoryUsage.max" alias="NonHeap_max" units="bytes"/>
+ </mbean>
+
+ <mbean name="java.lang:type=Threading" alias="Threading">
+ <attribute name="ThreadCount" alias="Threads"/>
+ <attribute name="DaemonThreadCount" alias="DaemonThreads"/>
+ </mbean>
+
+ <mbean name="java.lang:type=ClassLoading" alias="ClassLoading">
+ <attribute name="LoadedClassCount" alias="LoadedClasses"/>
+ <attribute name="TotalLoadedClassCount" alias="TotLoadedClasses"/>
+ <attribute name="UnloadedClassCount" alias="UnloadedClasses"/>
+ </mbean>
+
+ <!-- ms
+ <mbean name="java.lang:type=Compilation" alias="Compilation">
+ <attribute name="TotalCompilationTime" alias="TotalTime"/>
+ </mbean>
+ -->
+
+ <mbean name="java.lang:type=GarbageCollector,*" alias="GC">
+ <attribute name="CollectionCount" type="counter"/>
+ <attribute name="CollectionTime" type="counter"/>
+ </mbean>
+ </mbeans>
+</jcollectd-config>
@@ -0,0 +1,9 @@
+<jcollectd-config>
+ <mbeans name="tomcat">
+ <mbean name="Catalina:type=GlobalRequestProcessor,*" alias="GRP">
+ <attribute name="bytesReceived" alias="received" units="bytes" type="counter"/>
+ <attribute name="bytesSent" alias="sent" units="bytes" type="counter"/>
+ <attribute name="errorCount" alias="errors" type="counter"/>
+ </mbean>
+ </mbeans>
+</jcollectd-config>
Oops, something went wrong.

0 comments on commit c638227

Please sign in to comment.