Using check_remote_monit for RHEL7

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Using check_remote_monit for RHEL7

Postby CLee1972 » 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*:

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
Last edited by scottwilkerson on Wed Mar 07, 2018 2:22 pm, edited 1 time in total.
Reason: code wrap
CLee1972
 
Posts: 18
Joined: Wed Mar 07, 2018 1:53 pm

Re: Using check_remote_monit for RHEL7

Postby CLee1972 » Thu Mar 08, 2018 3:54 pm

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;
CLee1972
 
Posts: 18
Joined: Wed Mar 07, 2018 1:53 pm

Re: Using check_remote_monit for RHEL7

Postby tgriep » Thu Mar 08, 2018 5:05 pm

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/Plugins/Operating-Systems/Linux/check_rhel7_service/details
Try it out and see if it works for you.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6937
Joined: Thu Oct 30, 2014 9:02 am

Re: Using check_remote_monit for RHEL7

Postby CLee1972 » Tue Mar 13, 2018 1:50 pm

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/Plugins/Operating-Systems/Linux/check_rhel7_service/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.
CLee1972
 
Posts: 18
Joined: Wed Mar 07, 2018 1:53 pm

Re: Using check_remote_monit for RHEL7

Postby tgriep » Tue Mar 13, 2018 3:01 pm

OK, let us know if you have any more questions on this.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6937
Joined: Thu Oct 30, 2014 9:02 am

Re: Using check_remote_monit for RHEL7

Postby CLee1972 » Thu Mar 15, 2018 4:38 pm

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
CLee1972
 
Posts: 18
Joined: Wed Mar 07, 2018 1:53 pm

Re: Using check_remote_monit for RHEL7

Postby tgriep » Fri Mar 16, 2018 2:26 pm

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6937
Joined: Thu Oct 30, 2014 9:02 am


Return to Nagios Core

Who is online

Users browsing this forum: Phill123, scottwilkerson and 31 guests