|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread com.palantir.opensource.sysmon.SysmonDaemon
public class SysmonDaemon
SysmonDaemon
can be used either as a component of a larger program or as standalone
process (by invoking main(String[])
).
In standalone mode, it is run as a normal Java class. It will look for a config file to override defaults by either consulting a the System property "sysmon.configPath" or from it's first non-VM command-line argument. Although it's called a daemon, it will not disassociate from the controlling terminal and run in the background - this capability is not provided by default by the Java VM. Pressing Ctrl-C will cause the process to exit.
To use the SysmonDaemon
as a component of another program, construct a new instance and
pass it a Properties
object with any custom configuration - null is fine to pick up
defaults. Construction will start a non-daemon background thread that can be shut down by
shutdown()
Nested Class Summary | |
---|---|
static class |
SysmonDaemon.ShutdownTask
Simple task for parallel shutdown of monitors. |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
static String |
SYSTEM_PROPERTY_CONFIG_FILE
System property used to specify the config file path. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
SysmonDaemon(Properties config)
Constructs a new SysmonDaemon object and determines its platform-specific
SystemMonitor but does not start any monitoring. |
Method Summary | |
---|---|
static void |
configureDefaultLogging()
Sets up log4j logging in the case where no external configuration has been specified. |
static SystemMonitor |
determinePlatformMonitor()
Since the number of platforms currently supported is small (one, to be exact), this is just a static method that must produce a SystemMonitor object to be run by
the daemon. |
static void |
main(String[] args)
Runs the SysmonDaemon as a process. |
void |
run()
Starts platform specific monitoring and then blocks in a non-daemon thread, waiting for a call to shutdown() to unblock it (by releasing a semaphore) and allowing
the thread to exit. |
void |
shutdown()
Shuts down this SysmonDaemon instance. |
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 |
---|
public static final String SYSTEM_PROPERTY_CONFIG_FILE
System.getProperties()
,
Constant Field ValuesConstructor Detail |
---|
public SysmonDaemon(Properties config) throws SysmonException
SysmonDaemon
object and determines its platform-specific
SystemMonitor
but does not start any monitoring.
SysmonException
- upon error figuring out which class will be used as the
SystemMonitor
, initializing an instance of that class, or that instance's
verification of the execution environment in this VM.Method Detail |
---|
public static final SystemMonitor determinePlatformMonitor() throws SysmonException
SystemMonitor
object to be run by
the daemon. A second and third platform could be trivially added to this method —
after that, perhaps some sort of classpath-scanning reflective mechanism should be
implemented to allow new platforms to be added to the system without changing this class.
SysmonException
public void run()
shutdown()
to unblock it (by releasing a semaphore) and allowing
the thread to exit. This will keep the VM alive even as the platform monitors themselves
are only running daemon threads.
run
in interface Runnable
run
in class Thread
Thread.setDaemon(boolean)
public void shutdown()
SysmonDaemon
instance. Shutdown depends on all platform monitors to
only start daemon threads.
Thread.setDaemon(boolean)
public static void configureDefaultLogging()
main(String[])
.
It sets up a single ConsoleAppender
, thresholded at Level.WARN
, and adds
it to the root logger.
public static void main(String[] args)
SYSTEM_PROPERTY_CONFIG_FILE
.
args
- takes single argument: the path to the config file.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |