com.palantir.opensource.sysmon.linux
Class LinuxIOStatJMXWrapper

java.lang.Object
  extended by java.lang.Thread
      extended by com.palantir.opensource.sysmon.linux.LinuxIOStatJMXWrapper
All Implemented Interfaces:
Monitor, Runnable

public class LinuxIOStatJMXWrapper
extends Thread
implements Monitor

Monitors I/O statistics as reported by iostat

This class that fires up iostat in a background process, reads its output, and publishes it via JMX MBeans.

JMX Data Path

Each device will be placed at: sysmon.linux.beanpath:type=io-device,devicename=<devicename>

Configuration parameters

Note that any value not set in the config file will use the default value.
Config KeyDescriptionDefault ValueConstant
sysmon.linux.iostat.path path to iostat binary iostat CONFIG_KEY_IOSTAT_PATH
sysmon.linux.iostat.opts options passed to iostat -d -x -k CONFIG_KEY_IOSTAT_OPTIONS
sysmon.linux.iostat.period period, in seconds, between iostat reports 60 CONFIG_KEY_IOSTAT_PERIOD

See Also:
Lifecycle documentation, iostat(1) for more information on iostat.

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String CONFIG_KEY_IOSTAT_OPTIONS
           Options passed to iostat (other than period argument).
static String CONFIG_KEY_IOSTAT_PATH
          Path to iostat executable.
static String CONFIG_KEY_IOSTAT_PERIOD
          Period for iostat.
static String DEFAULT_IOSTAT_OPTIONS
          Default options passed to iostat executable.
static String DEFAULT_IOSTAT_PATH
          Default path to iostat executable.
static Integer DEFAULT_IOSTAT_PERIOD
          Default period between iostat output (in seconds).
static Pattern FIRST_LINE_PREFIX
           
static String OBJECT_NAME_PREFIX
          Relative JMX data path where this monitor publishes its data.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LinuxIOStatJMXWrapper(Properties config)
          Constructs a new iostat JMX wrapper.
 
Method Summary
 void run()
           
 void startMonitoring()
          Start iostat as a background process and makes sure header output parses correctly.
 void stopMonitoring()
          Shuts down and cleans up both background iostat process and data reading thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONFIG_KEY_IOSTAT_PATH

public static final String CONFIG_KEY_IOSTAT_PATH
Path to iostat executable. Defaults to "iostat" (uses $PATH to find executable). Set this config value in the to override where to find iostat. Config key: "sysmon.linux.iostat.path"

See Also:
default value for this config parameter, iostat(1) on your local linux box, Constant Field Values

CONFIG_KEY_IOSTAT_OPTIONS

public static final String CONFIG_KEY_IOSTAT_OPTIONS

Options passed to iostat (other than period argument).

Note that passing config values that change the format of the output from iostat may break this monitor. Proceed with caution.

Set this key in the config file to override default values.

Config key: "sysmon.linux.iostat.opts"

See Also:
default value for this config parameter, iostat(1) on your local linux box, Constant Field Values

CONFIG_KEY_IOSTAT_PERIOD

public static final String CONFIG_KEY_IOSTAT_PERIOD
Period for iostat. Set this config value to override how often iostat is outputting values. Config key: "sysmon.linux.iostat.period"

See Also:
default value for this config parameter, iostat(1) on your local linux box, Constant Field Values

DEFAULT_IOSTAT_PATH

public static final String DEFAULT_IOSTAT_PATH
Default path to iostat executable. Defaults to "iostat" (uses $PATH to find executable). Config key: "iostat"

See Also:
instructions on overriding this value., iostat(1) on your local linux box, Constant Field Values

DEFAULT_IOSTAT_OPTIONS

public static final String DEFAULT_IOSTAT_OPTIONS
Default options passed to iostat executable. Config key: "-d -x -k"

See Also:
instructions on overriding this value., iostat(1) on your local linux box, Constant Field Values

DEFAULT_IOSTAT_PERIOD

public static final Integer DEFAULT_IOSTAT_PERIOD
Default period between iostat output (in seconds). Config key:

See Also:
Instructions on overriding this value., iostat(1) on your local linux box

OBJECT_NAME_PREFIX

public static final String OBJECT_NAME_PREFIX
Relative JMX data path where this monitor publishes its data. This will have the individual device name appended to the end in the JMX tree. Path: ":type=io-device,devicename="

See Also:
Constant Field Values

FIRST_LINE_PREFIX

public static final Pattern FIRST_LINE_PREFIX
Constructor Detail

LinuxIOStatJMXWrapper

public LinuxIOStatJMXWrapper(Properties config)
                      throws LinuxMonitoringException
Constructs a new iostat JMX wrapper. Does not start monitoring. Call startMonitoring() to start monitoring and publishing JMX data.

Parameters:
config - configuration for this service
Throws:
LinuxMonitoringException - upon error in setting up this service.
See Also:
CONFIG_KEY_IOSTAT_OPTIONS, CONFIG_KEY_IOSTAT_PATH, CONFIG_KEY_IOSTAT_PERIOD
Method Detail

startMonitoring

public void startMonitoring()
                     throws LinuxMonitoringException
Start iostat as a background process and makes sure header output parses correctly. If no errors are encountered, starts this instance's Thread to read the data from the iotstat process in the background.

Specified by:
startMonitoring in interface Monitor
Throws:
LinuxMonitoringException - upon error with iostat startup.

stopMonitoring

public void stopMonitoring()
                    throws InterruptedException
Shuts down and cleans up both background iostat process and data reading thread.

Specified by:
stopMonitoring in interface Monitor
Throws:
InterruptedException

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread


Copyright © 2012 Palantir Technologies. All Rights Reserved.