Plugin - No output

victor victor at ambra.ro
Mon Oct 11 10:17:14 CEST 2004


[1097482044] HOST ALERT: 1;DOWN;SOFT;1;(No output!)

I made a very simple plugin called check_mping.
The problem is that it gives me "No output".
The plugin owner is nagios, and the rights are 777.

Tha checkcommand is like this:
define command{
        command_name    check-host-alive
        command_line    $USER1$/check_mping -H $HOSTADDRESS$ -s 1400 -p 
1      
        }


The plugin is made in perl(check_mping):
#! /usr/bin/perl -wT

use strict;
use utils qw(%ERRORS &print_revision &support &usage);
my @addresses;
my $pachete;
my $size;

for(0..$#ARGV) {
    if($ARGV[$_] eq '-H') {
        @addresses = split(/,/, $ARGV[$_+1]);
        foreach(@addresses){
            print "Unknown Argument incorect: $_" 
if($_!~m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
        }
    } elsif($ARGV[$_] eq '-p') {
        print "Unknown Argument incorect: $ARGV[$_+1]" 
if($ARGV[$_+1]!~m/^\d{1,}$/);
       
    } elsif($ARGV[$_] eq '-s') {
        print "Unknown Argument incorect: $ARGV[$_+1]" 
if($ARGV[$_+1]!~m/^\d{1,}$/);
    }
}

if(!$addresses[0])      { print "Adrese insuficiente";  }
if(!$pachete)           { $pachete = 5;                 }
if(!$size)              { $size = 1000;                 }

my $time = time;
$time = localtime($time);
my $ret = 'CRITICAL';
foreach(@addresses) {
    if($_!~m/^127/) {
        my $raspuns = `/bin/ping $_ -s $size -c $pachete -i 0.2 -w 2`;
        $raspuns=~m/(\d{1,})\% packet loss/;
        if($1==0) {
            $ret='OK';
            open(LOG, ">>/var/log/mping.log");
            print LOG "$time    $ret, @ARGV ".$ERRORS{'OK'}."\n";
            close(LOG);
            print "OK\n";
            exit $ERRORS{'OK'};
        }
    }
}
open(LOG, ">>/var/log/mping.log");
print LOG "$time        $ret, @ARGV ".$ERRORS{'CRITICAL'}."\n";
close(LOG);
print "CRITICAL";
exit $ERRORS{'CRITICAL'};

Thank you.


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list