jmonitor, jtool monitor
jmonitor
lets you send monitor data values from within OS processes.
Note: This tool cannot be used outside of 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
.
Tip: Although you can use any path, Redwood recommends storing the values under /System/ProcessServer/${process_server}/Custom/
. You can create child nodes there to group specific values.
Note: For installation instructions, see jtool
.
Syntax
jmonitor [-h|-?|-help] [-l <loglevel>] [-f <logfile>] -j|-job-context <path>=<value> ...
Argument | Description |
---|---|
-h,-?,-help | Shows the help. |
-l <loglevel> |
Sets the log level. |
-f <logfile> |
Logs to a file instead of stdout and stderr . |
-j, -job-context | Gets the environment from the job context. |
<path>
|
A monitor path. |
<value>
|
The new value for the monitor node. |
Examples
Pinging Statistics
The following is a basic KSH script that runs Linux and reports ping statistics for the server defined in parameter P_SERVER
. The update interval is defined in P_TIME
. It sets the value to 9999
if 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 Perl script runs on Windows and UNIX systems with a GNU-like df
binary. The script finds out how much free space exists on the fixed disk drives and 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`;