--On Tuesday, March 22, 2005 11:37 AM -0500 Ed Ravin <[EMAIL PROTECTED]> wrote:

I've got a newer version with the fallback paging that I'll release One
of These Days Real Soon Now.  Maybe around the same time David releases
his two-way Skytel code :-) :-).

While the whole alert script isn't really designed for use outside of CMU, the relevant portion of the code is:


eval {
        local $SIG{ALRM} = sub {die "Timeout during connection" };
        alarm $timeout;
        my $snpp = Net::SNPP->new ($server,
                                   #Debug => 1,
                                  ) or die "Unable to connect";
        local $SIG{ALRM} = sub {die "Timeout during communication" };
        alarm $timeout*2;
        
        $snpp->_CALL('mon') || die "Failed in _CALL";
        $snpp->_HELP() || die "Failed in _HELP";
        my $help = $snpp->message;
        if (grep /RPLY/, $help) {
          if ($message =~ /ALERT/) {
            $snpp->_2WAY();
            $snpp->_RPLY('[EMAIL PROTECTED]');
            $snpp->_MCRE("ack Working on it");
            $snpp->_MCRE("ack On my way");
            $snpp->_MCRE("ack Will fix later");
            $snpp->_MCRE("ack Ignoring");
            $snpp->_MCRE("disable failing");
            $snpp->_MCRE("disable-service");
            $snpp->_MCRE("disable-group");
            $snpp->_MCRE("enable failing");
            $snpp->_MCRE("enable-service");
            $snpp->_MCRE("enable-group");
          }
        }
        
        $snpp->send ( Pager => $pager, Message => $message);
        my $status = $snpp->status;
        if ($status != CMD_OK &&
            $status != CMD_2WAYOK &&
            $status != CMD_2WAYQUEUED) {
          die "Failed to send to $pager: ".$snpp->message;;
        }
        $snpp->quit || die "Failed to quit";
        
        $success = $server;
        #print STDERR "$server: success!\n";
     };


And you need to add one line to Net::SNPP to add the non-standard RPLY command:
sub _RPLY { shift->command("RPLY", @_)->response() == CMD_OK }




-David

David Nolan                    <*>                    [EMAIL PROTECTED]
curses: May you be forced to grep the termcap of an unclean yacc while
     a herd of rogue emacs fsck your troff and vgrind your pathalias!

_______________________________________________
mon mailing list
mon@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/mon

Reply via email to