Flings
Apps and tools built by our engineers that are intended to be played with and explored.

StatsFeeder

StatsFeeder

Summary

Statsfeeder is a tool that enables performance metrics to be retrieved from vCenter and sent to multiple destinations, including 3rd party systems.

The goal of StatsFeeder is to make it easier to collect statistics in a scalable manner. The user specifies the statistics to be collected in an XML file, and StatsFeeder will collect and persist these stats. The default persistence mechanism is comma-separated values, but the user can extend it to persist the data in a variety of formats, including a standard relational database or Key-value store. StatsFeeder is written leveraging significant experience with the performance APIs, allow the metrics to be retrieved in the most efficient manner possible.

For more information on Statsfeeder it’s purpose and operation, please see the “VMware Technical Journal: Vol. 1″ where it is extensively described.

System Requirements

Pre-requisites:

JRE 1.6 or higher

Instructions

Overview:

StatsFeeder provides a set of Java classes for retrieving stats in a scalable manner for a given vSphere installation.
The statistics to be collected are specified in an .xml configuration file, along with the source vSphere entities and the destination. Instructions on how to edit the sample configuration file are provided within the file itself. To get you started we have included a sample configuration file called sampleConfig.xml, which has the following properties:

  • Output all statistics to a CSV file called output.csv
  • Provide statistics output every 10 minutes, and roll the output files every hour
  • Metrics are retrieve for real-time data over the vCenter inventory for both hosts and VMs. A basic set of metrics are specified

The package includes the .jar file, a sample .xml configuration file, a shell script for running StatsFeeder on Linux, and a .bat file for running StatsFeeder on Windows..
The .jar file includes classes for retrieving data and storing them to a .csv file.

To use StatsFeeder, you can simply use the shell script or .bat file directly (directions below in "How to run").

How to Run:

  1. Unzip the attached .zip file.
  2. Linux (or Cygwin on Windows): Execute command "StatsFeeder.sh -h [vcenterserver] -u [username] -p [password] -c [configfile]"
  3. Windows: Execute command "StatsFeeder.bat -h [vcenterserver] -u [username] -p [password] -c [configfile]"

Sample Invocations:

  1. StatsFeeder.sh -h 10.28.140.70 -u Administrator -p password -c sfconfig.xml
  2. StatsFeeder.bat -h my-vcenter-ip.vmware.com -u root -p "" -c pconfig.xml
  3. StatsFeeder.sh -h 10.28.140.47 -u guest -p guest -c /home/user/workspace/sfconfig.xml
  4. StatsFeeder.sh -h 10.28.140.147 -u Administrator -p password - csampleConfig.xml

Video

Change Log

Engineers


Ravi Soundararajan

Performance

Jon Cook

EcoSystem
Add Comment

26 thoughts on “StatsFeeder

  1. angus

    Hi,

    When configuring statsfeeder w/ kairosdb (using a cassandra backend), I get these errors:
    ERROR com.vmware.ee.statsfeeder.kairosdb.KairosdbStatsReceiver – Error processing entity stats

    using the kairosdb UI, i can see that my config.xml metrics (using the kairosdb receiver).

    Any idea?

    Reply
  2. Sajib

    Hi,

    I am facing problems while running the new version of the StatsFeeder (4.1.697). When I’m continuously running the statsfeeder for days, it’s stopping after a day or two by throwing similar connection error. Here is a snapshot of the error messages.

    25465543 [ContainerMonitor-Thread] ERROR com.vmware.ee.statsfeeder.ContainerMonitor – Unexpected Exception
    javax.xml.ws.WebServiceException: java.net.ConnectException: Connection refused: connect
    at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
    at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
    at com.sun.proxy.$Proxy35.waitForUpdatesEx(Unknown Source)
    at com.vmware.ee.statsfeeder.ContainerMonitor$RepeatingCheckContainersTask.run(ContainerMonitor.java:212)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
    at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
    … 17 more
    25466916 [ContainerMonitor-Thread] ERROR com.vmware.ee.statsfeeder.ContainerMonitor – Unexpected Exception
    com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection ref
    used: connect
    at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
    at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
    at com.sun.proxy.$Proxy35.waitForUpdatesEx(Unknown Source)
    at com.vmware.ee.statsfeeder.ContainerMonitor$RepeatingCheckContainersTask.run(ContainerMonitor.java:212)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
    at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
    … 16 more

    I did run the previous version for longer duration, but it didn’t crash. Can you please look into this issue and suggest something.

    Thanks a lot,
    Sajib

    Reply
  3. Omer

    Trying to collect data via using Statsfeeder into Kairosdb (Kairosdb is storing in HBase on top of hadoop HDFS):

    I got following error when trying to retrieve stats of a single host.:
    [Thread-2] ERROR com.vmware.ee.statsfeeder.kairosdb.kairsdbStatsReceiver – Error processing entity stats
    java.lang.ArrayIndexOutOfBoundsException: 2

    Any idea appreciated??

    Thanks
    Omer.

    Reply
  4. Ralf

    Hi Jon,

    Is there a way I can get my hands on the source code of the openTSDB or kairosdb receiver files?
    I’m in no way a Java developer but I do got some programming experience, so I guess I should be able to figure out how to write a custom receiver from these source files.

    Thank you.

    Reply
    1. Jon Cook

      Ralf,

      There should be an example in the package download, look in the sample directory. Giving out source could be problematic, although, I would like to consider open sourcing at some point but have to go through the VMware process.

      Let me know if you have specific questions.

      Jon

      Reply
  5. Ralf

    Hi,

    According to the README included with the .zip file, you need to set these value’s for OpenTSDB and KariosDB.

    com.vmware.ee.statsfeeder.TsdbStatsReceiver for OpenTSDB.
    com.vmware.ee.statsfeeder.KairosdbStatsReceiver for KariosDB.

    Both of them produce error’s used this way.
    Guess it should be like below?

    com.vmware.ee.statsfeeder.opentsdb.TsdbStatsReceiver for OpenTSDB.
    com.vmware.ee.statsfeeder.kariosdb.KairosdbStatsReceiver for KariosDB.

    Reply
  6. Jon Cook

    All,

    I have posted a new version of Statsfeeder that fixes the following issues reported in the comments:

    1) CSV output files are ignored when using multiple receiver definitions
    2) Container MoRef list is truncated due to pagination issue

    Please let me know if you encounter any further issues.

    Regards,
    Jon

    Reply
  7. Sajib

    Hi,

    I’m having an issue when I am trying to use multiple receivers on the same config file. For example, I want to redirect all VM level data and all Host level data to separate CSV files. I defined two receivers, one for VMs and another for hosts. And inside the entities, I am changing the receivers values to pass it to different files. But, it is simply replicating the data, both the files contain values for VM level as well as host level. Am I doing something wrong here? Thanking you in advance for your help.

    Here is the relevant portion of the config xml:

    HostOutput
    com.vmware.ee.statsfeeder.CSVFileStatsReceiver

    file
    hostoutput.csv

    VMOutput
    com.vmware.ee.statsfeeder.CSVFileStatsReceiver

    file
    vmoutput.csv

    HostOutput

    vCenter
    Folder

    HostSystem

    VMOutput

    vCenter
    Folder

    VirtualMachine

    Reply
  8. cortex

    Hi,

    I have a strange issue when running StatsFeeder on a Folder container. The folder actually contains 479 VirtualMachine but StatsFeeder only retrieve stats for 79 of them. It seems many of them gets filtered but I can’t figure out why.
    Some relevant debug traces :
    5 [main] INFO com.vmware.ee.statsfeeder.MOREFRetriever – entityNameSet size: 0
    195 [main] DEBUG com.vmware.ee.statsfeeder.MOREFRetriever – MOR Type: Datacenter
    196 [main] DEBUG com.vmware.ee.statsfeeder.MOREFRetriever – Entity Name: TEST
    196 [main] DEBUG com.vmware.ee.statsfeeder.MOREFRetriever – MOR Type: Datacenter
    854 [main] INFO com.vmware.ee.statsfeeder.MOREFRetriever – Number of MOREFs in the container: 79
    1173 [ContainerMonitor-Thread] DEBUG com.vmware.ee.statsfeeder.ContainerMonitor – Size—- : 479
    2049 [ContainerMonitor-Thread] DEBUG com.vmware.ee.statsfeeder.ContainerMonitor – ************ names size: 79

    Reply
    1. cortex

      I finally found why.
      You have a bug in MOREFRetriever.getNameMOREFMap where the retVal Map is new’ed in the do while. So if retrievePropertiesEx as more than one “page” to retrieve, previous collected results are gone. Only the entityNameDetailsMap is full. That’s why the number are different for those two Lists.
      Could you provide an update to fix that ?

      Reply
  9. Jon Cook

    We have pushed a new version of StatsFeeder to Labs. Included in this release are the following items:

    1) Support for additional receivers, Perfmon, OpenTSDB, and KairosDB.
    2) Sample Receiver project to allow creation of custom receivers.

    Documentation is provided within the package README.

    Any feedback appreciated.

    Reply
    1. Jon Cook

      Richard,

      I am about to release a new version where I will document the extension API available. Also, it will have support for perfomon, opentsdb and kairosdb. Just waiting for final approvals to push.

      Jon

      Reply
  10. NiTRo

    Hi Guys, could you tell how use the mysql receiver ?
    Do you plan to plan to add the moref in case some items have the same name ?
    Thanks

    Reply
  11. Jon Cook

    Erich,

    Thanks for the questions. I have a number of requests to allow the output format of StatsFeeder to be customized, either for different CSV formats or even to push data elsewhere. This is very possible. Certainly the ability to add headers to the CSV is a change I can make in short order, I am also looking to create a generic mechanism to change the format of the CSV. However, I also plan to expose an API here shortly , probably before I make the code changes for CSV, so you can write your own output adapter to anything you want. Seems potentially simpler than having me write different variants.

    Stay tuned.
    Jon

    Reply
    1. Erich Popp

      Hi Jon,

      thanks for this “pre-insight” to actual work.

      Where do i find informations about different output formats?

      I didn’t find anything about this topics in available documentation.

      Do i need to look into source code?

      regards
      Erich

      Reply
  12. Erich Popp

    Hi,

    first of all: working and a good way to select metrics (you should now which metrics) before collecting

    What i like to know or to recommend:
    how to analyze with tools like powershell?
    is it possible to output available metrics?
    is it possible to create column headers with statsfeeder? (it’s more convenient for import-csv cmdlet)

    Erich

    Reply
  13. Jon Cook

    All entries in the CSV contain an entity type. The default configuration file is set to collect both VirtualMachine and HostSystem metrics. However, these are not sorted by type, so scan the entire output file for the entity type “HostSystem”, there should an entry for each host within the inventory.

    Jon

    Reply
  14. zoli

    Hi,

    I tried it with the attached sampleConfig.xml config file. It works, but in the result I cannot find any host related statistics. What is teh reason of this behavior?

    Reply
    1. Jon Cook

      All entries in the CSV contain an entity type. The default configuration file is set to collect both VirtualMachine and HostSystem metrics. However, these are not sorted by type, so scan the entire output file for the entity type “HostSystem”, there should an entry for each host within the inventory.

      Jon

      Reply
      1. zoli

        Unfortunately, no. But if I delete the virtualmachine childtype from the config file, then the script will collect the stats of the hosts correctly.

        Zoli

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>