Skip to content
This repository has been archived by the owner on Jan 11, 2020. It is now read-only.

Developers

Nick Miyake edited this page Dec 6, 2016 · 3 revisions

Working on the project in Eclipse

See [these instructions](Working on the project using Eclipse) to get Sysmon up and running in Eclipse

Features/Design

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.

Object Model

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.

Monitor Lifecycle

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()

Linux Implementation

The Linux monitoring implementation, (com.palantir.opensource.sysmon.linux.LinuxMonitor), currently implements the following types of monitoring:

Extending for other platforms

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.