#!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1999-08-18 04:42 PDT by . # Source directory was `/home/clay/src'. # # Existing files will *not* be overwritten unless `-c' is specified. # This format requires very little intelligence at unshar time. # "if test", "echo", "mkdir", and "sed" may be needed. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 8104 -r--r--r-- README # 1683 -rw-r--r-- alarm.pl # 1414 -rw-r--r-- informix.monitor # echo=echo if mkdir _sh21805; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= README ============== if test -f 'README' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'README' '(file already exists)' else $echo 'x -' extracting 'README' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'README' && X$Id: README,v 1.1 1999/08/18 11:40:33 clay Exp $ X XMonitors, alarms, and alert processing programs for INFORMIX Dynamic Server X X XTable of contents X----------------- X1. Introduction X2. Disclaimer X3. alarm.pl X a. Event-Severity codes X b. Sending alarms X c. host name and INFORMIXSERVER X4. informix.monitor X5. Monitoring i.Sell Application Server X6. SNPP Servers X7. References X8. Acknowledgements X X X1. Introduction X--------------- XThis distribution provide a set of tools to monitor INFORMIX-Online Dynamic XServer and the INFORMIX i.Sell Application Server. These tools were developed Xto ensure high availability of INFORMIX databases by constantly monitoring Xwarnings, errors, and online status of the databases. X XAnnouncements of new releases of this software are posted to Usenet X(comp.databases.informix). X X X2. Disclaimer X------------- XThe programs work fine for my environment. Some of the monitors and alarm/ Xalert processing programs have been running for many months and have proved Xto be highly reliable monitors for INFORMIX-Online Dynamic Server. Your Xmileage may very, though -- Please test before you deploy to a production Xenvironment. X X X3. alarm.pl X----------- Xalarm.pl is a Perl program to monitor alarms generated by INFORMIX IDS. XYou must set the ALARMPROGRAM configuration parameter to process event-alarms Xwith this program (See the INFORMIX-Online Dynamic Server Administrator's XGuide for additional information about ALARMPROGRAM). X Xa. Event-severity codes X----------------------- XThe INFORMIX Online engine reports an event-severity code to the ALARMPROGRAM. XSeverity codes are listed below (borrowed from the INFORMIX-Online Dynamic XServer Administrator's Guide). X X Severity Description X -------- ------------------------------------------------------------ X 1 Not noteworthy X Will not be reported to the alarm program X X 2 Information X No error has occurred, but some routine event completed X successfully (for example, checkpont of log backup completes). X X 3 Attention X This event does not compromise data or prevent the use of X the system; however, it warrants attention (for example, one X chunk of a mirrored pair goes down). X X 4 Emergency X Something unexpected occured that might compromise data or X access to data (assertion failure, or oncheck reports data X corrupt). X X 5 Fatal X Something unexpected occured and caused the database server X to fail. X Xb. Sending alerts X----------------- XIf the severity of the alarm is greater than 2, the alarm.pl program uses XSNPP (Simple Network Paging Protocol -- See RFC-1861) to send the alarm to Xa pager. X XThe program could easily be modified to send an Email message. Use the XMail::Send module to build Something like this (Warning: untested!): X X use Config; X use Mail::Send; X X my $backup_cmd = "onbar -l"; X my $exit_status = 0; X my $event_severity = $ARGV[0]; X my $event_class = $ARGV[1]; X my $event_msg = $ARGV[2]; X my $event_add_text = $ARGV[3]; X my $event_file = $ARGV[4]; X my $onconfig = $ENV{'ONCONFIG'}; X my $hostname = $Config{'myhostname'}; X X my %severity = ( X "3" => "Attention", X "4" => "Emergency", X "5" => "Fatal", X ); X X chomp $onconfig; X $database = (split /\./, $onconfig)[1]; X X if ($event_class == 23) { X `$backup_cmd 2>&1 >> /dev/null`; X $exit_status = $?; X } X X if ($event_severity > 2) { X $msg = new Mail::Send; X X $msg->to('clay@panix.com'); X $msg->subject('INFORMIX Alarm'); X X $fh = $msg->open; X X print $fh "System: $hostname\n"; X print $fh "Database: $database\n"; X print $fh "Alarm Severity: $severity{$event_severity}\n"; X print $fh "Message: $event_msg\n"; X X $exit_status = 1; X $fh->close X } X X exit $exit_status; X Xc. host name and INFORMIXSERVER X------------------------------- XThe host name and the INFORMIXSERVER name are included in the alert Xmessage -- This is extremely helpful information in a mutli-host, Xmulti-database server environment. The program obtains the host name Xfrom the Config module, and INFORMIXSERVER name from the value of the Xenvironment variable: X X my $informix_server = $ENV{'INFORMIXSERVER'} X my $hostname = $Config{'myhostname'}; X X X4. informix.monitor X------------------- XThere is a major problem with monitoring event-alarms with ALARMPROGRAM -- If Xthe database crashes, the engine will not be able to send an alarm. To ensure Xthe database is online and available, "mon", a service monitoring daemon (See XReferences), can monitor online status with the help of the Perl DBD::Informix Xmodule. X Xinformix.monitor is an INFORMIX-Online Dynamic Server monitor for mon. It uses XDBD::Informix to connect to the database and retrieve the database name. If Xit can't connect and retrieve the name, and alert is sent to a pager using XSNPP. X XA typical database alarm message looks like this: X X Subject: ALERT informix/database: shoe@raft is down (Wed Aug 4 15:05:24) X Date: Wed, 4 Aug 1999 15:05:26 -0700 (PDT) X From: Super-User X To: clay@skechers.com X X Summary output : shoe@raft is down X X Group : informix X Service : database X Time noticed : Wed Aug 4 15:05:24 1999 X Secs until next alert : 3600 X Members : shoe@raft shoe@motto spock@sparks shoe@groovy X skechers_main@boss X X Detailed text (if any) follows: X ------------------------------- X XA typical mon.cf configuration file using the informix.monitor is: X X hostgroup informix database@server X X watch informix X service database X interval 5m X monitor informix.monitor X period wd {Sun-Sat} X alert snpp.alert 8005551212 X alert mail.alert clay@panix.com X alertevery 1h X XIt works beautifully. X X X5. Monitoring i.Sell Application Server X--------------------------------------- XThe mon service monitoring daemon may be used to monitor the INFORMIX Xi.Sell E-Commerce/Application Server to ensure the server is alive and Xresponding to requests. The monitor checks the HTTP response of one of Xthe i.Sell administration ports with the http monitor included with the X"mon" distribution. This is a typical mon.cf configuration: X X watch app_servers X service http X interval 5m X monitor http.monitor -p 8840 X period wd {Sun-Sat} X alert snpp.alert 8005551212 X alert mail.alert clay@panix.com X alertevery 1h X X X6. SNPP Servers X--------------- X - Nextel X Server: pecos.nextel.com X Port: 444 X X - SkyTel X Server: snpp.skytel.com X Port 7777 X X - PageMart US X Server: pagemart.net X Port: 444 X X - PageMart Canada X Server: pmcl.net X Port: 444 X X X7. References X------------- X - Config module X On a command line, type: perldoc Config X X - RFC-1861 X http://info.internet.isi.edu:70/in-notes/rfc/files/rfc1861.txt X X - mon, the service monitoring daemon X http://www.kernel.org/software/mon/ X X - Net::SNPP Perl Module is part of the libnet bundle X http://www.perl.com/CPAN/modules/by-module/Net X X - Mail::Send is part of the Mail::Tools distribution X http://www.perl.com/CPAN/modules/by-module/Mail X X - DBI, the Perl Database Interface module X http://www.perl.com/CPAN/modules/by-module/DBI/ X X - DBD:Informix, the Database Driver for Informix X http://www.perl.com/CPAN/modules/by-module/DBD/ X X - SkyTel SNPP Specification X http://www.mtel.com/develop/snpp.html X X - INFORMIX-Online Dynamic Server Administrator's Guide X X X8. Acknowledgements X------------------- XSKECHERS USA, Inc., my employer X XInformix Software, Inc. X Tim Garritty, our Account Executive X Don Jennings and James Rollins, our i.Sell application development team X X XPlease feel free to contact via Email with questions, suggestions, or Xcomments: Clay Irving . X SHAR_EOF : || $echo 'restore of' 'README' 'failed' fi # ============= alarm.pl ============== if test -f 'alarm.pl' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'alarm.pl' '(file already exists)' else $echo 'x -' extracting 'alarm.pl' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'alarm.pl' && X#!/usr/local/bin/perl X# X# Process alarms from INFORMIX IDS X# X# $Id: alarm.pl,v 1.1 1999/08/14 15:59:01 clay Exp $ X# X# Copyright (C) 1999, SKECHERS USA, Inc. X# X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 2 of the License, or X# (at your option) any later version. X# X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# X# You should have received a copy of the GNU General Public License X# along with this program; if not, write to the Free Software X# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA X# X Xuse Config; Xuse Net::SNPP; X Xmy $backup_cmd = "onbar -l"; Xmy $exit_status = 0; Xmy $event_severity = $ARGV[0]; Xmy $event_class = $ARGV[1]; Xmy $event_msg = $ARGV[2]; Xmy $event_add_text = $ARGV[3]; Xmy $event_file = $ARGV[4]; Xmy $informix_server = $ENV{'INFORMIXSERVER'} Xmy $hostname = $Config{'myhostname'}; X Xmy %severity = ( X "3" => "Attention", X "4" => "Emergency", X "5" => "Fatal", X); X X Xif ($event_class == 23) { X `$backup_cmd 2>&1 >> /dev/null`; X $exit_status = $?; X} X Xif ($event_severity > 2) { X $snpp = Net::SNPP->new('pecos.nextel.com'); X $snpp->send( Pager => 8005551212, X Message => "$severity{$event_severity}: $hostname $informix_server $event_msg" X ) or die $snpp->message; X $exit_status = 1; X $snpp->quit; X} X Xexit $exit_status; SHAR_EOF : || $echo 'restore of' 'alarm.pl' 'failed' fi # ============= informix.monitor ============== if test -f 'informix.monitor' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'informix.monitor' '(file already exists)' else $echo 'x -' extracting 'informix.monitor' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'informix.monitor' && X#!/usr/local/bin/perl X# X# Monitor online status of INFORMIX IDS X# X# Arguements are "database@server" X# X# $Id: informix.monitor,v 1.2 1999/08/05 14:56:33 clay Exp $ X# X# Copyright (C) 1999, SKECHERS USA, Inc. X# X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 2 of the License, or X# (at your option) any later version. X# X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# X# You should have received a copy of the GNU General Public License X# along with this program; if not, write to the Free Software X# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA X# X Xuse DBI; X Xchomp($parm = $ARGV[0]); X($database, $server) = split /\@/, $parm; X X# Set environment variables X$ENV{LD_LIBRARY_PATH} = "/usr/informix/prod/lib:/usr/informix/prod/lib/esql"; X$ENV{INFORMIXDIR} = "/usr/informix/prod"; X$ENV{INFORMIXSERVER} = "$server"; X X# Attempt to connect to the database and get the database name X$dbh = DBI->connect($database, $username, $password, 'Informix'); X Xif (defined $dbh->{Name}) { X $dbh->disconnect; X exit 0; X} else { X print "$parm is down\n"; X exit 1; X} SHAR_EOF : || $echo 'restore of' 'informix.monitor' 'failed' fi rm -fr _sh21805 exit 0