#!/usr/bin/perl
#version 1.0

use strict;
use warnings;
use Getopt::Long;
use Data::Dumper qw(Dumper);

my $cmd ;

foreach my $p (@ARGV)
{
    $cmd .= " \"$p\" " ;
}

$cmd = "/usr/local/opmon/libexec/priax/nrpe/check_nrpe_comp $cmd";

my $out = `$cmd` ;
my $pp = $? >> 8 ;

if( $pp >= 3 ){
    print $out;
    exit(3);
}


if ( $out =~ m/(Service Check Timed Out|Socket timeout after|Connection refused or timed out|Connection refused by host|Could not complete SSL handshake|Could not get free space for|NRPE: Command|: not found )/)
{
    print $out;
    exit(3);
}else{
    print $out;
    exit($pp) ;
}
