Page 1 of 1

Using check_remote_monit for RHEL7

Posted: Wed Mar 07, 2018 2:03 pm
by CLee1972
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*:

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);
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

Re: Using check_remote_monit for RHEL7

Posted: Thu Mar 08, 2018 3:54 pm
by CLee1972
Also, to follow up on this, I have tried to use check_process_snmp with a number of "Processes" and it keeps coming back with unknown status in the Nagios Core webpage. I am thinking this is not set right for RHEL 7.4 either:

!/bin/perl
use strict;
use warnings;
use Net::SNMP;
use Net::SNMP::Util;
use lib qw(/usr/lib/nagios/libexec);
use feature qw(switch say);
use Getopt::Long;
my $host = '';
my $process = '';
GetOptions('Host=s' => \$host,
'Process=s' => \$process);
my $oid = '.1.3.6.1.2.1.25.4.2.1.4';
my ($session, $error) = Net::SNMP->session(
-hostname => shift || $host,
-community => shift || 'nagios',
);

if (!defined $session){
printf "ERROR: %s.\n", $error;
}

#my @result = $session->walk_request(-varbindlist => [ $oid ],);
my @result = '';
(@result, $error) = snmpwalk(
snmp => $session,
oids => [ $oid ],);
for my $i (0..$#result){
if ($process =~ m/$result[$i]/)
{
printf "OK: %s is running\n", $process;
exit 0;
}
$i++;
}
printf "ERROR %s is not running\n", $process;
exit 1;

Re: Using check_remote_monit for RHEL7

Posted: Thu Mar 08, 2018 5:05 pm
by tgriep
I found this plugin you can use to monitor services on Redhat / Centos 7 servers that use the systemctl command.
https://exchange.nagios.org/directory/P ... ce/details
Try it out and see if it works for you.

Re: Using check_remote_monit for RHEL7

Posted: Tue Mar 13, 2018 1:50 pm
by CLee1972
tgriep wrote:I found this plugin you can use to monitor services on Redhat / Centos 7 servers that use the systemctl command.
https://exchange.nagios.org/directory/P ... ce/details
Try it out and see if it works for you.
I believe this would work if I was running the service locally to the Nagios Core server but I am running it remotely. I have reached out to Taha to see if he has any ideas. Will keep you all updated.

Re: Using check_remote_monit for RHEL7

Posted: Tue Mar 13, 2018 3:01 pm
by tgriep
OK, let us know if you have any more questions on this.

Re: Using check_remote_monit for RHEL7

Posted: Thu Mar 15, 2018 4:38 pm
by CLee1972
I ended up going with NRPE. It just seemed like the next logical step on this, not to mention that it was able to do everything I needed from checking CPU, to verifying users logged in, Memory and watching all the processes and services that I had running on that machine. Thank you all for your help and input.

CLee1972

Re: Using check_remote_monit for RHEL7

Posted: Fri Mar 16, 2018 2:26 pm
by tgriep
Your welcome. I'll lock the post for you but feel free to open a new post in the future if you have any other questions.