Opm Java Monitor

The Output Parser Monitor (Opm) bundled with boom allows you to create a monitor based on the output produced by system tools or other executables. Opm is a Java based Monitor that is able to parse and summarize result text lines containing numeric data.

Most of the standard system tools like "top", "df" or "ps" are delivering results with useful numeric values for multiple objects. These values can be used for the system or process monitoring.

Started from version 2.00 the Opm Monitor supports Java based actions that can generate output for parsing:

SshAction - can be used for monitoring remote systems over SSH.
JmxAction - can be used for monitoring remote JMX servers.
HttpAction - can be used for parsing remote HTTP pages.
StrAction - allows to split, filter and transform blocks in the output to a single lines.

Let's take an example of processing the 'df' output of a Unix system. We will use the 'df -Pkl' call to have a similar output from most of the Unix systems:

	File System          1024-blocks  Used  Available Capacity Mounted on
	/dev/vg00/lvol5         24456     8472    15984    35%   /home
	/dev/dsk/c0t0d0       3235348  3235348        0   100%   /iuxcdrom0
	/dev/vg00/lvol6       5235064  4167056  1068008    80%   /opt
	/dev/vg00/lvol4        715400     8632   706768     2%   /tmp
	/dev/vg00/u01         7693337   213287  7480050     3%   /u01
	/dev/vg00/lvol7       3289800  2853656   436144    87%   /usr
	/dev/vg00/lvol8       6118216  1811520  4306696    30%   /var
	/dev/vg00/lvol1        309928   130312   179616    43%   /stand
	/dev/vg00/lvol3        409016   327264    81752    81%   /
			      174116         0    174116    0% 	 /dev/shm
	  

Most of these lines are showing really important values for monitoring. But every line provides information for a different mounted partition. So, to be able to monitor mounted partitions, a monitor must submit a separate value for each object.

Let's assume we want to monitor the percentage of used space on each volume. We need to create a new Java Monitor with the MAXTHRESHOLD type based on the com.blixx.agent.monitors.Opm class.

In this example we are using the following pattern:

(/dev.*)\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9\.]+)%\s+(.*)


This pattern defines 6 capturing groups that provide us 6 variables for every matched line:

var1 - partition name
var2 - disk size in KB
var3 - used space
var4 - free space
var5 - used space in %
var6 - mount point

In the Opm Monitor all defined variables can be accessed as DOUBLE or STRING.
If you need to get value as DOUBLE - use varN.
If you need to get value as STRING - use svarN.

Every matched line in our example is a potential monitor value. To submit multiple monitor values we need the Object attribute. So the line:
   svar1 = var5
tells to the Opm Monitor how to submit the parsed values (submit double value of parsed var5 with the Object string captured by svar1).

An Opm Java Monitor expects the following lines of parameters:

LineByLine      TableSummary
L1:  com.blixx.agent.monitors.Opm (required)
L2:  <executable string>
L3:  LineByLine
L4:  <java pattern with capturing groups>
L5:  <objectName1> <summarization function> <calculation>
L6:  <java pattern with capturing groups>
L7:  <objectName2> <summarization function> <calculation>
...
  L1:  com.blixx.agent.monitors.Opm (required)
L2:  <executable string>
L3:  TableSummary
L4:  <Java pattern with capturing groups>
L5:  <objectName1> <summarization function> <calculation>
L6:  <objectName2> <summarization function> <calculation>
...

Line Description

L1: Java class name
L2: Any executable or script available on the managed host.

supported Java Actions (for L2):
SshAction   <host> <user> <pass> <command to execute on remote system>
JmxAction   [options] -u <url>

   with options:
  -l <login>
  -p <password>
  -o <objecName>		JMX canonical object name mask. Like "java.*:type=Memory"
  -a <attribute> -v <valueMask>	only masked attribute will be queried  
  -D <environment variables>
HttpAction   <URL>

L3: "LineByLine" or "TableSummary"
Two constants are defining the general behavior of the Opm Monitor: "LineByLine" tells the Monitor that every line must be processed separately. All filtered lines must be parsed, calculated and submitted as monitor values. "TableSummary" tells that all lines must be parsed and converted to a column where the column is declared by variables (capturing groups of a pattern).


L4: This pattern is responsible for matching and parsing strings in the output of the executable.

Please note: There is only one global pattern for the TableSummary type. LineByLine requires a separate pattern for every following object line!

L5: Object line.
All lines from this point can declare object names, summarization function and plain arithmetic calculation string. It is possible to specify multiple object lines. In case of using the LineByLine type - every processed string will submit multiple monitor values that are declared in the object lines.

Object Line Syntax

All elements must be separated by space. The first position is the object name. The object name can be defined as a constant string or if the LineByLine type is defined the svarN can be used. The svarN variables can also be combined with prefix or suffix. i.e. Err_svar1

Please note that svarN variables are not used by the TableSummary processing.

The second position - takes summarization function:

TypeSummarization Function allowed
LineByLineDELTA, '='
TableSummarySUM, MIN, MAX, AVG, COUNT*

* - The COUNT function requires one capture group in the pattern and returns number of matched lines in the output.

The DELTA function has to be used only for counters.

The rest of the line is the calculation string based on parsed double values. The calculation part can contain simple arithmetic operations, double constants and variables of double types (varN).

Syntax of Calculation

... X1 'operand1' X2 'operand2' X3 'operand3' X4 ...
Where Xn - double value or varN, operand - one of

'+', '-', '/' ,'*' (trivial arithmetical operations) and one special: '\'

Operand '\' - means a division of Xi/Xi-1. i.e. RES = var2 \ var3 => var3/var2

The example above will be calculated as: ((X1 'operand1' X2) 'operand2' X3) 'operand3' X4

For the following examples we assume that the filtered string is parsed into variables:

var1 - /dev/vg00/lvol5
var2 - 24456
var3 - 8472
var4 - 15984
var5 - 35
var6 - /home.
	
Examples of Object Lines (LineByLine)Description
FREEDISK = var4Monitor value = var4 = 15984.0
Object = FREEDISK
svar1 = var4Monitor value = var4 = 15984.0
Object = /dev/vg00/lvol5
svar6 = var4 / 1024Monitor value = (var4/1024) = 15.61
Object = /home
svar1 = 100 - var5Monitor value = (100 - var5) = 75.0
Object = /dev/vg00/lvol5
Examples of Object Lines (TableSummary)Description
FREEDISK_T SUM var4Sum of all free spaces
Object = FREEDISK_T
FREEDISK_A AVG var2 - var3 /1024Average of all free spaces in MB
calculated as (var2 - var3)/1024
Object = FREEDISK_A
FREEDISK_M MIN var4 /1024Minimum free space in MB
Object = FREEDISK_M