jmonitor, jtool monitor
A platform agent tool used to send monitor data values from within OS processes.
This tool cannot be used outside job-context; the -j
or -job-context
parameter is implied.
The Java server creates monitor nodes, checks and values automatically if needed.
Since a monitor value can only be set on a MonitorValue, and a MonitorValue needs to have a MonitorCheck as its parent node, and a MonitorCheck node must have a MonitorNode as its parent, the path that is passed needs to contain at least three levels, for example /RootNode[/ChildNode...]/Check/Value
.
note
Although you are free to use any path, it is highly recommended to store the values under /System/ProcessServer/${process_server}/Custom/
; you can create child nodes there to group specific values.
Syntax
jmonitor [-h|-?|-help] [-l <loglevel>] [-f <logfile>] -j|-job-context <path>=<value> ...
Argument | Description |
---|---|
-h,-?,-help | Show this help and exit. |
-l <loglevel> | Set the logging level. |
-f <logfile> | Log to file instead of stdout/stderr. |
-j, -job-context | Run the command in job-context |
<path> | A monitor path. |
<value> | The new value for the monitor node. |
Example
Ping Statistics
The following is a basic KSH script that is designed to run Linux and report ping statistics for the server defined in parameter P_SERVER
, the update interval is defined in P_TIME
; it sets the value to 9999
when the ping command times out or returns invalid data.
prc=`jtool getpar ProcessServer -l info || echo "Could not determine process server name.";exit 2`
while (true)
do
ms= `ping -c1 $P_SERVER | head -n 2 | tail -n 1 | sed 's/.*=//;s/\.//;s/ .*//'`
[ $input -ge 0 ] || ms= 9999
jmonitor /System/ProcessServer/$prc/Custom/PingStat=$ms
sleep $P_TIME
done
UNIX/Windows Perl Script for Disk Space Statistics
The following example shows the script source of a Perl script that runs on Microsoft Windows and UNIX systems with a GNU-like df
binary. It finds out how much free space exists on the fixed disk drives / partitions and stores that data in the monitor tree.
use strict;
my $processServer = `jtool getpar ProcessServer -l info` or die "Cannot determine process server name";
$processServer =~ s/\s+$//;
my $cmd = "jtool monitor -l debug";
my $MonitorPath = " /System/ProcessServer/".$processServer."/Custom/Diskspace";
if ($^O eq "MSWin32")
{
require Win32::OLE;
my $server = Win32::NodeName();
my $FIXED_DRIVE = 3;
my $NETWORK_DRIVE = 4;
my $locatorObj = Win32::OLE->new('WbemScripting.SWbemLocator') || die "Error creating locator object: ".Win32::OLE->LastError()."\n";
$locatorObj->{Security_}->{impersonationlevel} = 3;
my $serverObj = $locatorObj->ConnectServer($server,'root\cimv2',"","") || die "Error connecting to $server: ".Win32::OLE->LastError()."\n";
printf "Free diskspace on $server:\n\n";
printf "%-14s %-14s %-14s %-4s\n","Drive","Size","Free", "Perc";
printf "%-14s %-14s %-14s %-4s\n","-" x 5,"-" x 14,"-" x 14, "-" x 4;
foreach my $drive (Win32::OLE::Enum->All($serverObj->InstancesOf("Win32_LogicalDisk")))
{
next if ($drive->{DriveType} != $FIXED_DRIVE);
my $dr = $drive->{DeviceID};
my $fs = $drive->{FileSystem};
my $sz = $drive->{Size};
my $fb = $drive->{FreeSpace};
my $perc = $fb / $sz * 100.0;
printf "%-14s %-14.0f %-14.0f %-2.1f%%\n",$dr,$sz,$fb, $perc;
$cmd .= $MonitorPath . "/" . $dr . "/Size=" . $sz;
$cmd .= $MonitorPath . "/" . $dr . "/Free=" . $fb;
$cmd .= $MonitorPath . "/" . $dr . "/PctFree=" . $perc;
}
}
else
{
# Assume UNIX with Gnu DF, for now
open DF, "df -l -B1 |" or die "Cannot execute 'df': $!";
printf "Free diskspace on `hostname`:\n\n";
printf "%-14s %-14s %-14s %-4s\n","Drive","Size","Free", "Perc";
printf "%-14s %-14s %-14s %-4s\n","-" x 14,"-" x 14,"-" x 14, "-" x 4;
while (<DF>)
{
my ($fs, $sz, $us, $fb, $perc, $mount) = split /\s+/, $_;
if ($mount =~ m/^\// && $sz > 1024 && $sz != $fb)
{
my $perc = $fb / $sz * 100.0;
$mount =~ s/\//./g;
$mount =~ s/\//./g;
$mount =~ s/^\.//;
$mount =~ s/^$/root/;
printf "%-8s %-14.0f %-14.0f %-2.1f%%\n",$mount,$sz,$fb, $perc;
$cmd .= $MonitorPath . "/" . $mount . "/Size=" . $sz;
$cmd .= $MonitorPath . "/" . $mount . "/Free=" . $fb;
$cmd .= $MonitorPath . "/" . $mount . "/PctFree=" . $perc;
}
}
close DF;
}
print `$cmd`;