Attached is ito.alert. It uses the "ITO" component of HPOV. I think that 
"ITO" has been re-named "OVO".

ito.alert needs some work. If multiple hosts are down, it sends an 
individual ITO alert for each host. That may, or may not, be a desirable 
feature.

I also attached an snmp based version by Scott Prater. This is probably a 
lot easier, and cheaper, to implement.

Jon

On Wed, 18 Aug 2004, Byron Emerson [mon] wrote:

> Hello,
> 
> Does anyone have a working example of an hpov.alert
> 
> Thanks,
> byron
> 
> _______________________________________________
> mon mailing list
> [EMAIL PROTECTED]
> http://linux.kernel.org/mailman/listinfo/mon
> 
#!/usr/local/bin/perl
#
# ito.alert - HP OpenView ITO alert for mon
#
# The first line from STDIN is summary information, adequate to send
# to a pager or email subject line.
#
#

$RCSid = q{$Id$};

=head1 NAME

B<ito.alert> - Route monitor for mon.

=head1 DESCRIPTION


=head1 SYNOPSIS

B<ito.alert [-D] severity responsible_group comment>

=head1 OPTIONS

=over 5

=item B<-d> Debug/Test

=back

=head1 MON CONFIGURATION EXAMPLE

 watch imail
        service smtp
        interval 5m
        monitor smtp3.monitor -t 70 -l /usr/local/mon/logs/imail_gv_YYYYMM.log
        period wd {Sun-Sat}
               alert mail.alert [EMAIL PROTECTED]
               alert ito.alert -d critical BNS 'Contact BNS on call person'
               alertafter 2
               alertevery 1h summary

=head1 AUTHOR

Jon Meek, [EMAIL PROTECTED]

=cut




use Getopt::Std;
use Sys::Hostname;
$MonHost  = hostname;

$SEND2ITO = q{/opt/OV/WAdmin/send2ito };

# /opt/OV/WAdmin/send2ito -n[hostname] -o[object] -a[application] -s[severity] 
-m[message_text]
# /opt/OV/WAdmin/send2ito -ngvbns1 -oanything -aITO -scritical -m"any text you want"

$TIME_OUT = 60;

#getopts ("d:S:s:g:h:t:l:uOT"); # Command line options

getopts ("S:s:g:h:t:l:u0TdD"); # Command line options

$GroupService = "$opt_g/$opt_s";

#
# Get the command line arguments
#
$Severity = shift(@ARGV);
$ResponsibleGroup = shift(@ARGV);
$Comment = shift(@ARGV);

$Summary=<STDIN>; # The summary line contains the list of failed hosts
chomp $Summary;

@FailedHosts = split(' ', $Summary);

$Details = '';
while ($in = <STDIN>) { # Get alert details
  $Details .= $in if $opt_D;;
}

$opt_d = 1;

if ($opt_d) {
  print STDERR "Summary $Summary\n";
  print STDERR "Details $Details\n";
  print STDERR "Arguments:\n";
  foreach $arg (@ARGV) {
    print STDERR "$arg\n";
  }
  print STDERR "\n";
}

$t = localtime($opt_t);
($wday,$mon,$day,$tm) = split (/\s+/, $t);

print STDERR "t: |$opt_t|  $wday,$mon,$day,$tm\n" if $opt_d;

#
# Run the ITO program
#

$Details =~ s/\n/; /g;       # Get details on one line
$Details =~ s/;\s+;\s+$/; /; # Clean up excess ; and spaces
$Details .= "$Comment";      # Tack on the comment field if it exists

foreach $h (@FailedHosts) { # Send individual ITO alerts for each failure

  ($hostname, $rest) = split(/\./, $h, 2);

  #$ITOcommand = qq{$SEND2ITO -n$ENV{HOST} -o$ENV{MON_GROUP} -a$ResponsibleGroup 
-s$Severity  -m"$Details"};

  if (length($Details) > 0) {
    $ITOcommand = qq{$SEND2ITO -n$ENV{HOST} -o$hostname -a$ResponsibleGroup 
-s$Severity -m"$Details"};
  } else {
    $ITOcommand = qq{$SEND2ITO -n$ENV{HOST} -o$hostname -a$ResponsibleGroup 
-s$Severity -m'$GroupService'};
  }

  print STDERR "ITOcommand: $ITOcommand\n" if $opt_d;

  $SIG{ALRM} = \&ReadTimeOut;

  eval {
    alarm($TIME_OUT);
    $result = system($ITOcommand);
    print STDERR "Cmd result: $result\n" if $opt_d;
    alarm(0);
  };

}

sub ReadTimeOut {
  die 'Read Timeout';
}


From [EMAIL PROTECTED] Wed Feb 28 19:41:28 2001
Date: Wed, 14 Feb 2001 10:36:25 +0100
From: Scott Prater <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: hpov.alert:  Alert script to generate events in HP Open View

    [ The following text is in the "Windows-1252" character set. ]

    [ Your display is set for the "ISO-8859-1" character set.  ]

    [ Some characters may be displayed incorrectly. ]

Below is a perl script I wrote to send alarms to HP OpenView, our network
management system.

Mon and this script solved the problem we faced of integrating
monitorization of services and systems without SNMP support into our overall
monitor structure (which is built around HP Open View, an SNMP-based network
management system).

I imagine that the alert script could be easily adapted to other such
SNMP-based management systems, such as Tivoli.

A brief description of the alert script (parameters, defaults, etc.) is
included in comments at the head of the script.  I assume knowledge of HP
OpenView, MIBs, OIDs, events, etc..

One caveat:  the script sends the alarm with the hostgroup as the
originating pseudo snmp agent.
This means that the hostgroup must be a single valid IP or domain name in
your network, in order for HP OpenView to correctly associate it with the
appropriate node.

I'm not familiar enough with mon to know if there's a way to extract the
specific machine that raised an alarm from the hostgroup list passed to the
alert scripts.  This would be a good thing.

As always, comments, suggestions, constructive criticisms gratefully
accepted.

Scott Prater

#####################################################

#!/usr/local/bin/perl/
#
# hpov.alert - generate event in HP OpenView
#
# Arguments:
#       -c:  severity of condition (Critical, Major, Minor, etc.)
#            Default is "Major".
#       -C:  Category of event.  Default is "Error Alarms".
#       -m:  address of HP OpenView manager.  Default is "localhost".
#       -o:  Event OID.  REQUIRED.  If event OID does not start with
#            a ".", default prefix is .1.3.6.1.4.1.11.2.17.1.0 for
#            event OID and info is passed in the MIB branch
#            .1.3.6.1.4.1.11.2.17.2.x.0
#
# Sends alert with hostgroup name as address of snmp agent that originated
the
# alarm.  This means that hostgroups that use this alert type must be valid
# IPs or domain names.
#
# Upalerts are sent with severity "Normal".  Should be used with rearm event
# OIDs in HP Open View.
#
# See the section "Configuration" below to change defaults.
#
# Scott Prater, [EMAIL PROTECTED], 2001.  Based on file.alert by
# Jim Trocki, [EMAIL PROTECTED]
#
# $Id$
#
#    Copyright (C) 1998, Jim Trocki
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA
#

$RCSID='$Id$';
use strict;
use vars qw($opt_d $opt_S $opt_s $opt_g $opt_h $opt_t $opt_l $opt_c $opt_C
$opt_m $opt_o $opt_u $opt_T $opt_O);
use Getopt::Std;

getopts ("d:S:s:g:h:t:l:c:C:m:o:uOT");

#---------------------------------------------------------#
# Configuration (edit as needed to suit your environment) #
#---------------------------------------------------------#

if (!$opt_o)
{
    die "Could not generate HPOV event:  no Event OID\n";
}

my $OV_BIN = "/opt/OV/bin";     # Path to HP OpenView bin directory
my $OV_EVENT = "ovevent";       # Name of HP OpenView program to generate alarms

my $SEVERITY = $opt_c || "Major";
my $CATEGORY = $opt_C || "Error Alarms";
my $MANAGER = $opt_m || "localhost";
my $OID = $opt_o;
my $DEFAULT_MIB_BRANCH = ".1.3.6.1.4.1.11.2.17";
my $DEFAULT_MIB_SUFFIX = ".0";
my $UPALERT_SEVERITY = "Normal";

#---------------------------------------------------------#
# End Configuration                                       #
#---------------------------------------------------------#

my $counter = 1;
my ($event_oid, $event_oid_branch, $event_oid_suffix);

my $summary=<STDIN>;
chomp $summary;
my $summary = $opt_S if ($opt_S);

if ($OID !~ /^\./)
{
    $event_oid = $DEFAULT_MIB_BRANCH . ".1.0." . $OID;
    $event_oid_branch = $DEFAULT_MIB_BRANCH . ".2";
    $event_oid_suffix = $DEFAULT_MIB_SUFFIX;
}
else
{
    $event_oid = $OID;
    $event_oid_branch = $OID;
    $event_oid_suffix = "";
}

my $ALERT = $ENV{"MON_ALERTTYPE"} || "UNKNOWN ALERT";
my $RETVAL = $ENV{"MON_RETVAL"} || 0;

# If this is an upalert, send rearm event OID to HPOV with proper severity
if ($opt_u)
{
   $SEVERITY = $UPALERT_SEVERITY;
}

my $t = localtime($opt_t);
my ($wday,$mon,$day,$tm) = split (/\s+/, $t);

# MIB tree structure
# First Var:  integer (for return code)
# Second var:  summary line
# Following vars:  detailed output, line by line

my $first_var = "$event_oid_branch.$counter$event_oid_suffix Integer
$RETVAL";
$counter++;
my $second_var = "$event_oid_branch.$counter$event_oid_suffix OctetString
\'$ALERT $opt_g $opt_s $opt_t --$wday $mon $day $tm-- $summary\'";
$counter++;
my $cmd =  "$OV_BIN/$OV_EVENT -s $SEVERITY -c \"$CATEGORY\" -a $opt_g
\"$MANAGER\" $event_oid $first_var $second_var";

#
# The remaining lines contain more detailed information:
# add them to the MIB branch.
#
while (<STDIN>) {
    chomp;
    $cmd .= " $event_oid_branch.$counter$event_oid_suffix OctetString
\'$_\'";
    $counter++;
}


# Send the alarm
my $exit_status = system($cmd);
if ($exit_status != 0)
{
    die ("Cannot send event to HPOV:  !$\n");
}

exit;


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

Reply via email to