com.palantir.opensource.sysmon.linux
Class LinuxDiskspaceJMXWrapper

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

public class LinuxDiskspaceJMXWrapper
extends Thread
implements Monitor

Monitors disk space on a Linux system. Requires the df utility (part of the coreutils package on Redhat based systems.

Reads the output from 'df -P -B M' that looks like this:

  Filesystem         1048576-blocks      Used Available Capacity Mounted on
  /dev/md0                19689M     5275M    13414M      29% /
  none                     4021M        0M     4021M       0% /dev/shm
  /dev/md1                51376M    48506M      262M     100% /u1
 
It then looks up the filesystem type by reading /proc/self/mounts (for maximum portability).

JMX Data Path

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

Configuration parameters

Note that any value not set in the config file will use the default value.
Config KeyDescriptionDefault ValueConstant
sysmon.linux.df.df.path path to df binary df CONFIG_KEY_DF_PATH
sysmon.linux.df.df.block.opts options passed to df when checking free space -P -B M CONFIG_KEY_DF_OPTIONS
sysmon.linux.df.df.inode.opts options passed to df when checking inodes -P -i CONFIG_KEY_DF_INODE_OPTIONS
sysmon.linux.df.df.period Period between checks, in seconds 10 CONFIG_KEY_DF_PERIOD
sysmon.linux.df.df.deviceNameFilter Comma-separated list of device names (full path) to ignore when making free space calculations. CONFIG_KEY_DF_DEVICE_NAME_FILTER
sysmon.linux.df.df.fsTypeFilter Comma-separated list of filesystem types to ignore when making free space calculations. iso9660,proc,sysfs,tmpfs CONFIG_KEY_DF_FS_TYPE_FILTER
sysmon.linux.df.mtab.path path to mtab file /etc/mtab CONFIG_KEY_MTAB_PATH

See Also:
Lifecycle documentation

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String CONFIG_KEY_DF_DEVICE_NAME_FILTER
          Comma-separated list of device names (full path) to ignore when making free space calculations.
static String CONFIG_KEY_DF_FS_TYPE_FILTER
          Comma-separated list of file system types to ignore when making free space calculations.
static String CONFIG_KEY_DF_INODE_OPTIONS
          Options passed to df when calculating free inodes.
static String CONFIG_KEY_DF_OPTIONS
          Options passed to df.
static String CONFIG_KEY_DF_PATH
          Path to the df executable.
static String CONFIG_KEY_DF_PERIOD
          How often to run space calculations, in seconds.
static String CONFIG_KEY_MTAB_PATH
          Path to the mtab file.
static String DEFAULT_DF_DEVICE_NAME_FILTER
          Default device filter.
static String DEFAULT_DF_FS_TYPE_FILTER
          Default filesystem type filter.
static String DEFAULT_DF_INODE_OPTIONS
          Default options passed to df when making inode calculations.
static String DEFAULT_DF_OPTIONS
          Default options passed to df when making disk space calculations.
static String DEFAULT_DF_PATH
          Default's to using a bare path to allow use of $PATH to find the df executable.
static int DEFAULT_DF_PERIOD
          Default period, in seconds.
static String DEFAULT_MTAB_PATH
          Default path to mtab file Default value: "/etc/mtab"
static String OBJECT_NAME_PREFIX
          For each device name and the passed JMX bean path, the a bean will be mounted with the name '":type=filesystem,devicename="<devicename>'
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LinuxDiskspaceJMXWrapper(Properties config)
           
 
Method Summary
 void kill()
           
 void run()
           
 void startMonitoring()
          Starts background thread that will actually be performing monitoring runs.
 void stopMonitoring()
          Signals shutdown to background thread and then waits for thread to die.
 
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_DF_PATH

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

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

CONFIG_KEY_DF_OPTIONS

public static final String CONFIG_KEY_DF_OPTIONS
Options passed to df. Set this key in config file to override defaults options. Config key: "sysmon.linux.df.df.block.opts"

See Also:
DEFAULT_DF_OPTIONS, df(1) on your local linux box, Constant Field Values

CONFIG_KEY_DF_INODE_OPTIONS

public static final String CONFIG_KEY_DF_INODE_OPTIONS
Options passed to df when calculating free inodes. Set this key in config file to override defaults options. Config key: "sysmon.linux.df.df.inode.opts"

See Also:
DEFAULT_DF_INODE_OPTIONS, df(1) on your local linux box, Constant Field Values

CONFIG_KEY_DF_PERIOD

public static final String CONFIG_KEY_DF_PERIOD
How often to run space calculations, in seconds. Set this key in config file to override defaults options. Config key: "sysmon.linux.df.df.period"

See Also:
DEFAULT_DF_PERIOD, df(1) on your local linux box, Constant Field Values

CONFIG_KEY_DF_DEVICE_NAME_FILTER

public static final String CONFIG_KEY_DF_DEVICE_NAME_FILTER
Comma-separated list of device names (full path) to ignore when making free space calculations. Set this key in config file to override defaults options. Config key: "sysmon.linux.df.df.deviceNameFilter"

See Also:
DEFAULT_DF_DEVICE_NAME_FILTER, df(1) on your local linux box, Constant Field Values

CONFIG_KEY_DF_FS_TYPE_FILTER

public static final String CONFIG_KEY_DF_FS_TYPE_FILTER
Comma-separated list of file system types to ignore when making free space calculations. Set this key in config file to override defaults options. Config key: "sysmon.linux.df.df.fsTypeFilter"

See Also:
DEFAULT_DF_FS_TYPE_FILTER, df(1) on your local linux box, Constant Field Values

CONFIG_KEY_MTAB_PATH

public static final String CONFIG_KEY_MTAB_PATH
Path to the mtab file. Set this key in config file to override defaults options. Config key: "sysmon.linux.df.mtab.path"

See Also:
DEFAULT_MTAB_PATH, mount(8) on your local linux box, Constant Field Values

OBJECT_NAME_PREFIX

public static final String OBJECT_NAME_PREFIX
For each device name and the passed JMX bean path, the a bean will be mounted with the name '":type=filesystem,devicename="<devicename>'

See Also:
Constant Field Values

DEFAULT_DF_PATH

public static final String DEFAULT_DF_PATH
Default's to using a bare path to allow use of $PATH to find the df executable. Default value: "df"

See Also:
for information on overriding the default value., Constant Field Values

DEFAULT_DF_OPTIONS

public static final String DEFAULT_DF_OPTIONS
Default options passed to df when making disk space calculations. Default value: "-P -B M"

See Also:
for information on overriding the default value., Constant Field Values

DEFAULT_DF_INODE_OPTIONS

public static final String DEFAULT_DF_INODE_OPTIONS
Default options passed to df when making inode calculations. Default value: "-P -i"

See Also:
for information on overriding the default value., Constant Field Values

DEFAULT_DF_PERIOD

public static final int DEFAULT_DF_PERIOD
Default period, in seconds. Default value: 10

See Also:
for information on overriding the default value., Constant Field Values

DEFAULT_DF_DEVICE_NAME_FILTER

public static final String DEFAULT_DF_DEVICE_NAME_FILTER
Default device filter. Default value: ""

See Also:
for information on overriding the default value., Constant Field Values

DEFAULT_DF_FS_TYPE_FILTER

public static final String DEFAULT_DF_FS_TYPE_FILTER
Default filesystem type filter. Default value: "iso9660,proc,sysfs,tmpfs"

See Also:
for information on overriding the default value., Constant Field Values

DEFAULT_MTAB_PATH

public static final String DEFAULT_MTAB_PATH
Default path to mtab file Default value: "/etc/mtab"

See Also:
for information on overriding the default value., Constant Field Values
Constructor Detail

LinuxDiskspaceJMXWrapper

public LinuxDiskspaceJMXWrapper(Properties config)
                         throws LinuxMonitoringException
Throws:
LinuxMonitoringException
Method Detail

startMonitoring

public void startMonitoring()
Starts background thread that will actually be performing monitoring runs.

Specified by:
startMonitoring in interface Monitor

stopMonitoring

public void stopMonitoring()
                    throws InterruptedException
Signals shutdown to background thread and then waits for thread to die.

Specified by:
stopMonitoring in interface Monitor
Throws:
InterruptedException - if interrupted while waiting for thread to die.

run

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

kill

public void kill()


Copyright © 2012 Palantir Technologies. All Rights Reserved.