hello,
My original question was resolved. Please see the below script, if you are interested in using it in your testing environment. I do have another question though.
Our nodes are showing on-line and available. The actual application worked, but it seems an update was done by the server admins (OS update to the Linux systems). Since then, I am seeing those upgraded to Redhat 7.4, with a state of unknown for two of my application monitors. One of being the script I used below, which does test out successfully. I had an engineer reboot a lab system, where we are currently doing our testing and configuration changes before we push live. The same result were occurring. Any insight into this issue? Or has anyone seen this before?
#!/usr/bin/perl
use warnings;
use strict;
# Perl trim function to remove whitespace from the start and end of the string stolen from https://www.somacon.com/p114.php
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
#process to check for
my $processName = 'jsvc.exe';
#number of $processName that should be running when app is 'healthy';
my $healthyProcessCount = 4;
#setup the command to use, this will return number of processes containing $processName
my $psCommand = "ps -ef | grep $processName | grep -v grep | wc -l";
#Run the command
my $psCommandOutput = `$psCommand`;
chomp($psCommandOutput);
trim($psCommandOutput);
#print the output as a statistic
print "Statistic.Count1: $psCommandOutput\n";
#check if number of processes
if ( $psCommandOutput == $healthyProcessCount )
{
#exit status code of 0 means up to solarwinds
print "Message.Status1: Returning 0, count of processes was good.\n";
exit 0;
}
else
{
#exit status code of 1 means down to solarwinds
print "Message.Status1: Returning 1, count for $processName was $psCommandOutput and not $healthyProcessCount\n";
exit 1;
}
}
Thank you
Dé