Monitors for INFORMIX IDS and i.Sell Application Server
Posted in 1999
Topics: Backup & Restore, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration, Security, Permissions & Auditing, Licensing & Editions
Provided below is a Perl program to monitor alarms from INFORMIX IDS. If
the severity of the alarm is greater than 2, the program uses SNPP (Simple
Network Paging Protocol -- See RFC-1861) to send the alarm to a pager. I
monitor multiple database instances on multiple machines, so I find it
helpful to send the machine name with the database name.
#!/usr/local/bin/perl
#
# Process alarms from INFORMIX IDS
#
# $Id: alarm.pl,v 1.1 1999/08/14 15:59:01 clay Exp $
#
# Copyright (C) 1999, SKECHERS USA, Inc.
#
# 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
#
use Config;
use Net::SNPP;
my $backup_cmd = "onbar -l";
my $exit_status = 0;
my $event_severity = $ARGV[0];
my $event_class = $ARGV[1];
my $event_msg = $ARGV[2];
my $event_add_text = $ARGV[3];
my $event_file = $ARGV[4];
my $onconfig = $ENV{'ONCONFIG'};
my $hostname = $Config{'myhostname'};
my %severity = (
"3" => "Attention",
"4" => "Emergency",
"5" => "Fatal",
);
chomp $onconfig;
$database = (split /\\./, $onconfig)[1];
if ($event_class == 23) {
`$backup_cmd 2>&1 >> /dev/null`;
$exit_status = $?;
}
if ($event_severity > 2) {
$snpp = Net::SNPP->new('pecos.nextel.com');
$snpp->send( Pager => 8005551212,
Message => "$severity{$event_severity}: $hostname $database $event_msg"
) or die $snpp->message;
$exit_status = 1;
$snpp->quit;
}
exit $exit_status;
The program could easily be modified to send an Email message. Use the
Mail::Send module to build Something like this (Warning: untested!):
use Config;
use Mail::Send;
my $backup_cmd = "onbar -l";
my $exit_status = 0;
my $event_severity = $ARGV[0];
my $event_class = $ARGV[1];
my $event_msg = $ARGV[2];
my $event_add_text = $ARGV[3];
my $event_file = $ARGV[4];
my $onconfig = $ENV{'ONCONFIG'};
my $hostname = $Config{'myhostname'};
my %severity = (
"3" => "Attention",
"4" => "Emergency",
"5" => "Fatal",
);
chomp $onconfig;
$database = (split /\\./, $onconfig)[1];
if ($event_class == 23) {
`$backup_cmd 2>&1 >> /dev/null`;
$exit_status = $?;
}
if ($event_severity > 2) {
$msg = new Mail::Send;
$msg->to('clay@panix.com');
$msg->subject('INFORMIX Alarm');
$fh = $msg->open;
print $fh "System: $hostname\\n";
print $fh "Database: $database\\n";
print $fh "Alarm Severity: $severity{$event_severity}\\n";
print $fh "Message: $event_msg\\n";
$exit_status = 1;
$fh->close
}
exit $exit_status;
There is a major problem with monitoring alarms from the database -- If the
database crashes, the engine will not be able to send an alarm. To ensure
the database is online and available for use, I use "mon", a service
monitoring daemon (See References). The INFORMIX IDS monitor is provided
below. It uses DBD::Informix to connect to the database and retrieve the
database name. If it can't connect and retrieve the name, and alert is
sent to a pager using SNPP.
#!/usr/local/bin/perl
#
# Monitor online status of INFORMIX IDS
#
# Arguements are "database@server"
#
# $Id: informix.monitor,v 1.2 1999/08/05 14:56:33 clay Exp $
#
# Copyright (C) 1999, SKECHERS USA, Inc.
#
# 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
#
use DBI;
chomp($parm = $ARGV[0]);
($database, $server) = split /\\@/, $parm;
# Set environment variables
$ENV{LD_LIBRARY_PATH} = "/usr/informix/prod/lib:/usr/informix/prod/lib/esql";
$ENV{INFORMIXDIR} = "/usr/informix/prod";
$ENV{INFORMIXSERVER} = "$server";
# Attempt to connect to the database and get the database name
$dbh = DBI->connect($database, $username, $password, 'Informix');
if (defined $dbh->{Name}) {
$dbh->disconnect;
exit 0;
} else {
print "$parm is down\\n";
exit 1;
}
A typical mon.cf configuration file using the informix.monitor is:
hostgroup informix database@server
watch informix
service database
interval 5m
monitor informix.monitor
period wd {Sun-Sat}
alert snpp.alert 8005551212
alert mail.alert clay@panix.com
alertevery 1h
It works beautifully.
Finally, I use the INFORMIX i.Sell E-Commerce/Application Server. I needed
a monitor to ensure the application server is alive and responding to
requests. I monitor one of the i.Sell administration ports with the
"out of the box" http monitor included with the "mon" distribution. This
is a typical mon.cf configuration:
watch app_servers
service http
interval 5m
monitor http.monitor -p 8840
period wd {Sun-Sat}
alert snpp.alert 8005551212
alert mail.alert clay@panix.com
alertevery 1h
References:
- RFC-1861: http://info.internet.isi.edu:70/in-notes/rfc/files/rfc1861.txt
- mon, the service monitoring daemon, is found at:
http://www.kernel.org/software/mon/
- Net::SNPP Perl Module is part of the libnet bundle:
http://www.perl.com/CPAN/modules/by-module/Net
- Mail::Send is part of the Mail::Tools distribut
Clay,
Pack these into a shell archive, add a README.1st file and post it to
the IIUG Software Repository (email to software@iiug.org) so everyone can
find it in perpetuity and you too can answer posts asking about that
event pager you wrote by pointing folk at the Repository.
Art S. Kagel
Clay Irving wrote:
>
> Provided below is a Perl program to monitor alarms from INFORMIX IDS. If
> the severity of the alarm is greater than 2, the program uses SNPP (Simple
> Network Paging Protocol -- See RFC-1861) to send the alarm to a pager. I
> monitor multiple database instances on multiple machines, so I find it
> helpful to send the machine name with the database name.
>
> #!/usr/local/bin/perl
> #
> # Process alarms from INFORMIX IDS
> #
> # $Id: alarm.pl,v 1.1 1999/08/14 15:59:01 clay Exp $
> #
> # Copyright (C) 1999, SKECHERS USA, Inc.
> #
> # 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
> #
>
> use Config;
> use Net::SNPP;
>
> my $backup_cmd = "onbar -l";
> my $exit_status = 0;
> my $event_severity = $ARGV[0];
> my $event_class = $ARGV[1];
> my $event_msg = $ARGV[2];
> my $event_add_text = $ARGV[3];
> my $event_file = $ARGV[4];
> my $onconfig = $ENV{'ONCONFIG'};
> my $hostname = $Config{'myhostname'};
>
> my %severity = (
> "3" => "Attention",
> "4" => "Emergency",
> "5" => "Fatal",
> );
>
> chomp $onconfig;
> $database = (split /\\./, $onconfig)[1];
>
> if ($event_class == 23) {
> `$backup_cmd 2>&1 >> /dev/null`;
> $exit_status = $?;
> }
>
> if ($event_severity > 2) {
> $snpp = Net::SNPP->new('pecos.nextel.com');
> $snpp->send( Pager => 8005551212,
> Message => "$severity{$event_severity}: $hostname $database $event_msg"
> ) or die $snpp->message;
> $exit_status = 1;
> $snpp->quit;
> }
>
> exit $exit_status;
>
> The program could easily be modified to send an Email message. Use the
> Mail::Send module to build Something like this (Warning: untested!):
>
> use Config;
> use Mail::Send;
>
> my $backup_cmd = "onbar -l";
> my $exit_status = 0;
> my $event_severity = $ARGV[0];
> my $event_class = $ARGV[1];
> my $event_msg = $ARGV[2];
> my $event_add_text = $ARGV[3];
> my $event_file = $ARGV[4];
> my $onconfig = $ENV{'ONCONFIG'};
> my $hostname = $Config{'myhostname'};
>
> my %severity = (
> "3" => "Attention",
> "4" => "Emergency",
> "5" => "Fatal",
> );
>
> chomp $onconfig;
> $database = (split /\\./, $onconfig)[1];
>
> if ($event_class == 23) {
> `$backup_cmd 2>&1 >> /dev/null`;
> $exit_status = $?;
> }
>
> if ($event_severity > 2) {
> $msg = new Mail::Send;
>
> $msg->to('clay@panix.com');
> $msg->subject('INFORMIX Alarm');
>
> $fh = $msg->open;
>
> print $fh "System: $hostname\\n";
> print $fh "Database: $database\\n";
> print $fh "Alarm Severity: $severity{$event_severity}\\n";
> print $fh "Message: $event_msg\\n";
>
> $exit_status = 1;
> $fh->close
> }
>
> exit $exit_status;
>
> There is a major problem with monitoring alarms from the database -- If the
> database crashes, the engine will not be able to send an alarm. To ensure
> the database is online and available for use, I use "mon", a service
> monitoring daemon (See References). The INFORMIX IDS monitor is provided
> below. It uses DBD::Informix to connect to the database and retrieve the
> database name. If it can't connect and retrieve the name, and alert is
> sent to a pager using SNPP.
>
> #!/usr/local/bin/perl
> #
> # Monitor online status of INFORMIX IDS
> #
> # Arguements are "database@server"
> #
> # $Id: informix.monitor,v 1.2 1999/08/05 14:56:33 clay Exp $
> #
> # Copyright (C) 1999, SKECHERS USA, Inc.
> #
> # 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
> #
>
> use DBI;
>
> chomp($parm = $ARGV[0]);
> ($database, $server) = split /\\@/, $parm;
>
> # Set environment variables
> $ENV{LD_LIBRARY_PATH} = "/usr/informix/prod/lib:/usr/informix/prod/lib/esql";
> $ENV{INFORMIXDIR} = "/usr/informix/prod";
> $ENV{INFORMIXSERVER} = "$server";
>
> # Attempt to connect to the database and get the database name
> $dbh = DBI->connect($database, $username, $password, 'Informix');
>
> if (defined $dbh->{Name}) {
> $dbh->disconnect;
> exit 0;
> } else {
> print "$parm is down\\n";
> exit 1;
> }
>
> A typical mon.cf configuration file using the informix.monitor is:
>
> hostgroup informix database@server
>
> watch informix
> service database
> interval 5m
> monitor informix.monitor
> period wd {Sun-Sat}
> alert snpp.alert 8005551212
> alert mail.alert clay@panix.com
> alertevery 1h
>
> It works beautifully.
>
> Finally, I use the INFORMIX i.Sell E-Commerce/Application Server. I needed
> a monitor to ensure the application server is alive and responding to
> requests. I monitor one of the i.Sell administration ports with the
> "out of the box" http monitor included with the @@DQ@
On Mon, 16 Aug 1999 12:19:09 -0400, Art S. Kagel <kagel@bloomberg.net> wrote: >Clay, > Pack these into a shell archive, add a README.1st file and post it to >the IIUG Software Repository (email to software@iiug.org) so everyone can >find it in perpetuity and you too can answer posts asking about that >event pager you wrote by pointing folk at the Repository. Done. The package is now found at: ftp://ftp.iiug.org/pub/informix/pub/alarm.Z -- Clay Irving <clay@panix.com> What are our schools for if not indoctrination against Communism? - Richard Milhous Nixon