Using check_remote_monit for RHEL7
Posted: Wed Mar 07, 2018 2:03 pm
Hello,
I have a number of servers using RHEL 6 that I have been monitoring without issue using the following "check_remote_monit" plugin (As well as other remote checks) *in usr/lib64/nagios/plugins*:
Unfortunately, RHEL7 had to change the way you look things up. I am wondering if Nagios has some updated plugin to use with RHEL7 to check statuses of Hardware (CPU, Disk_Drive, Memory, etc.) and well as specific services that we are checking for our application running on RHEL6 (And now RHEL7)?
Chris
I have a number of servers using RHEL 6 that I have been monitoring without issue using the following "check_remote_monit" plugin (As well as other remote checks) *in usr/lib64/nagios/plugins*:
Code: Select all
#!/usr/bin/perl
#Libraries
use strict;
use warnings;
use lib qw(/usr/local/nagios/libexec);
use feature qw(switch say);
#Pull Host variable from command.cfg
use Getopt::Long;
my $host = '';
GetOptions ('Host=s' => \$host);
#set pattern to search for
my $good_pattern = "is running";
my $warning_pattern = "not running";
my $critical_pattern = "is stopped";
#Get status variable from ssh and chomp it to remove new lines
chomp(my $status = qx|/usr/bin/ssh ${host} '/sbin/service monit status'|);
#Search for good pattern if not exit with error
if ($status =~ m/$good_pattern/)
{
printf "OK: %s\n", $status;
exit(0);
}if ($status =~ m/$critical_pattern/){
printf "CRITICAL: %s\n", $status;
exit(2);
}if ($status =~ m/$warning_pattern/){
printf "WARNING: %s\n", $status;
exit(1);
}
printf "UNKNOWN: %s\n", $status;
exit(3);
Chris