> On Tue, Nov 09, 2004 at 01:52:32PM -0800, Michael Vogt wrote:
> > 
> > I am planning to monitor some application servers on a datacenter with
> > a custom monitor plugin.  I want to have another monitor running at a
> > remote location to monitor the main monitor at the datacenter (and
> > vice-versa).  It looks like I should use mon traps in heartbeat mode.
> > How do I create the heartbeats. 

Feel free to play around with my mon trap client, text is below.  I've
also attached it in case people's mail clients do naughty things with
the formatting.

        -- Ed

-------

#!/usr/bin/perl

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

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

#!/usr/bin/perl

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

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

_______________________________________________
mon mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/mon

Reply via email to