Personal Programming Notes

To err is human; to debug, divine.

Automated Performance Logging and Plotting for Cassandra

In this mini-project, I created a Python script ( to record JMX values from a running Cassandra instance, using JMXTerm (, and do the following:

  • Put the records into a Cassandra table.
  • Plot the results.

The project is based on a Cassandra interview question found on Glassdoor.

Currently, the first version only works with Windows version of Cassandra (using DataStax Community installer). Developed and tested in Python 2.7.



When running the script from command line, the following arguments must be provided:

  • installDir INSTALLDIR: Path to installation directory.
  • host HOST: URL string for Cassandra instance. Only localhost tested.
  • jmxTerm JMXTERM: Path to jmxterm jar file.
  • osString OSSTRING: String that represents the current OS. Windows: win. Mac: mac. Unix/Linux: linux.


> python -installDir C:\datastax -host localhost -jmxTerm lib\jmxterm.jar -osString win


  • CSV file with each field for each JMX metric. Example:
CSV output
  • Records in a Cassandra table
  • Performance plot as PNG file (automatically generated from CSV output file). Example:

alt text

Python modules

  1. Main module to run the automated tasks. Please use “python PerformanceLog -h” for the required arguments. Example call for Windows is in the doc string.
  2. Logging support module
  3. Support module to record metrics into a Cassandra table.
  4. Support module to plot metrics into plots and save into PNG file.

Automated tasks by the modules

  1. Check if Cassandra is Running
  2. Record certain JMX Metrics
  3. Runs the external tool Cassandra Stress
  4. Once the stress session has completed, stop recording JMX Metrics
  5. Record the metrics back into a Cassandra Table
  6. Graph the results (create these graphs at the end of the run).

External Python libraries required


This module requires Datastax’s Python driver:


This Python module used Matplotlib library. Please install the following Python libraries: matplotlib, numpy, dateutil, pytz, pyparsing, six (optionally: pillow, pycairo, tornado, wxpython, pyside, pyqt, ghostscript, miktex, ffmpeg, mencoder, avconv, or imagemagick).

Installation of these Python libraries are straight-forward on Linux and Win32. On Win64, please find their installers here:

Other files

The following output files are produced. For consistency check, they are left behind. In the final version of the script, they may be cleaned up accordingly.

  • tempout: Output from JmxTerm session
  • jmxMetrics.csv: The cvs file that records the interested JMX metrics.
  • CassandraTest.log: The log file for the script.