1 of 1 people found this helpful
A component monitor is keying off of the out formatted as:
MESSAGE: <SOME TEXT>
STATISTIC: <SOME VALUE>
If you want more outputs you can use:
In a perl script output you might see something like:
# some perl code that executes your NAMonitor.sh and captures $message and $alarm
# It looks easy enough to split the result output result:2:NNA commands issued in the past 5 minutes 25
# Open the file /app/scripts/log/NAMonitor.log
my $filename = '/app/scripts/log/NAMonitor.log;
open(my $fh, '<:encoding(UTF-8)', $filename);
my $str = readline $fh;
my @words = split /:/, $str;
$message = $words;
$alarm = $words;
printf("Message: The NNA Commands issued: %d . \n", $message);
printf("Statistic: %d\n", $alarm);
This output would be collected by a SAM template Component and you can then set up an alert based on the alarm statistic.
Close I am missing something though. The numeric value 0|1|2 is what I am trying to fetch for the statistic, everything else even the $count variable is just information for the SA.
I just did a rudimentary script outline there. I don't know the contents of your log file. The script above works if the shell script overwrites the log file each time and the only thing in it is the result you shared. It reads the line, splits it into an array of items - @words - delimited on the colon ";", then uses elements 1 and 2 of the array. Assuming the line begins with the word RESULT - which would be element 0. Thus the component monitor would use the 0, 1, or 2 found in array element 1 of @words as the statistic. It would use the last element "NNA commands issued in the past 5 minutes 25" as the message contents. At least that is what I am proposing the script should do.