Hi,

In the week-end I spent a lot of time to
elucidate the mon's mistery. This is the result:

The mon.cf file:

 alertdir   = /usr/lib/mon/alert.d
 mondir     = /usr/lib/mon/mon.d
 histlength = 100

 hostgroup bc localhost

#watch bc # service fping
 #        interval 2m
 #        monitor fping.monitor -r 3 -t 5000
 #        description It tests if the bc works or not
 #        period wd {Mon-Sun}
 #            alert bc.alert

 watch bc
     service bcwork
         description It tests if the bc works or not
         traptimeout 2m
         period wd {Mon-Sun}
             alert bc.alert
             upalert bc.alert

I left intentionally the first 'watch bc' commented because it works
but is not what I need. The heartbeat generator Perl script is attached.

The bc.alert content is this and the file is executable:

 #!/usr/bin/perl
 my $now = `date`;
 open (FILE,">>/var/log/bc.log");
 print FILE "bc.alert at $now\n";
 close FILE;
 exit 0

After restarting mon with my mon.cf and the heartbeat generator client
within x.sh in background, in /var/log/bc.log do not appear the new lines.

Why? What is wrong?
Please help me.


Thank you,

--
Graf László

#!/usr/bin/perl

use strict;
use Getopt::Std;
use Mon::Client;

my $now = `date`;
print "---$now";

my @opstrings= (
        "fail", "ok", "coldstart", "warmstart", "linkdown",
        "unknown", "timeout", "untested",
        );

my $usage= "montrap [-p port] [-r retval] -o opstatus -s summary [-d detail] 
host group:service\n";

use vars qw($opt_p $opt_r $opt_o $opt_s $opt_d);
getopts("p:r:o:s:d:");


die $usage unless @ARGV == 2 and $ARGV[1] =~ /[^:]+:[^:]+/;

my $host= $ARGV[0];
my ($group, $service)= $ARGV[1] =~ /^([^:]+):([^:]+)/;

my $port= $opt_p || 2583;
my $retval= $opt_r || 255;
my $opstatus= $opt_o || die "montrap: '-o opstatus' required\n";

die "montrap: unrecognized opstatus: $opstatus\n" unless
        grep $opstatus, @opstrings;


my $summary= $opt_s  || die "montrap: '-s summary' required\n";
my $detail= $opt_d || "";

my $mon;

        if (!defined ($mon = Mon::Client->new)) {
                die "$0: could not create client object: $@";
        }
        $mon->host($host);

        $mon->send_trap(
                group=> $group,
                service=> $service,
                retval=> $retval,
                opstatus=> $opstatus,
                summary=> $summary,
                detail => $detail,
                );

$now = `date`;
print "---$now";
#!/bin/sh

while true
do
        perl x.pl -o fail -s sumar sarge b:bc_van
        sleep 20
done
_______________________________________________
mon mailing list
mon@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/mon

Reply via email to