-
Notifications
You must be signed in to change notification settings - Fork 28
Developers
See [these instructions](Working on the project using Eclipse) to get Sysmon up and running in Eclipse
Sysmon takes a lightweight approach to systems monitoring. In practice, this means that no native code is used. While it may cause certain interesting implementation details, it's a huge win in terms of portability and safety. Using native code to make system calls would require compiling native code for every conceivable combination of architecture and OS version. Additionally, native code introduces instability to the VM - incorrectly written native code can easily crash the VM, taking down the entire application.
In order to avoid those pitfalls, the included Linux implementation of Sysmon employs a combination of reading data out of the /proc filesystem and forking off the existing platform monitoring tools (e.g. iostat) while reading their output.
SysmonDaemon - top level class and holder of the main()
. This class figures out which platform the VM is running on, instantiates the platform specific monitor and starts it up. Can be run as a standalone program or used as component embedded in a larger program.
SystemMonitor - Implement this interface to build a platform monitor. This class is responsible for verifying the execution environment and starting up all the of the individual Monitors for the current platform.
Monitor - Instances of this interface are the actual monitors of the platform metrics. Usually, they include a background thread that polls the host platform. Monitors
can also be run standalone to just measure a particular set of values rather than running all available Monitors
for current host platform via SystemMonitor
or SysmonDaemon
.
Construction of a Monitor object must not start any background processes. startMonitoring()
must be called to start up the background routines.
A call to stopMonitoring()
will shut down and clean up any background processes and data processing threads.
Monitor objects should not be restarted. While it might be possible build restartable Monitor
objects, the safe practice is to discard them after calling stopMonitoring()
The Linux monitoring implementation, (com.palantir.opensource.sysmon.linux.LinuxMonitor), currently implements the following types of monitoring:
- Diskspace - how full the different block devices in the system are.
- Entropy Pool - how much entropy is available in the entropy pool
- IO Statistics - measures of reads, writes, and disk utilization, as provided by iostat.
- Load Average - the one, ten, and fifteen minuted load averages
- Network statistics - measures of network traffic.
- Linux VM statistics - performance measurements of the Linux virtual machine (not the Java VM), as provided by vmstat
Extending this framework for other platforms should be a fairly straightforward process. Each type of platform monitor is implemented in its own class that implements the Monitor interface.
All the Monitor
classes for a given platform are managed by a class that implements SystemMonitor - that class is responsible for instantiating the individual Monitors
at runtime.
Each SystemMonitor
is integrated into the SysmonDaemon by adding an appropriate platform detection section to SysmonDaemon#determinePlatformMonitor()
. That method does the runtime selection of which SystemMonitor
to invoke.
See LinuxMonitor as an example of a SystemMonitor
implementation. LinuxEntropyLevelJMXWrapper is a simple example (reads from a file) of a Monitor
; LinuxVMStatJMXWrapper is more complex example - it runs vmstat in a background thread and reads its output.