Perl Code - Detail View


Date

Name

Plattform

Language

Kurzbeschreibung

Owner

Link

20.10.2002

xmpLog.pl

Unix

Perl

DBA Informationen über wichtige Vorgänge  in ein systemweites xmpdba.log schreiben

Gernot Ruban

 

DB2 ist ein Produkt der
IBM Corporation. Bitte
Copyright-  und Trademark-Hinweise beachten!

#!/usr/local/bin/perl -w
################################################################################
# xmpLOG    - Logging von DBA Process-Meldungen
# Called by - Command Level
# Calls     - xmpPerl.pm   - DBA Perl Package
#             Getopt       - Argument-Verwaltung
# Optionen  - xmpLOG.PL -a appl -s {I|W|E|S} [-t text]
# -a application (must)
#        -s status {Info|Wwarning|Error|Severe} (must)
#          -t text (optional)
#-------------------------------------------------------------------------------
# Autor     - GR /03.01.00 - V1.0 erste Version
# Changes   - GR /10.01.00 - V1.1 auf Package xmpPerl.pm umgestellt
# Changes   - GR /26.05.00 - V1.2 auf neue Script Strategie angepasst
# Changes   - GR /11.07.00 - V1.3 zunächst auf Logging in DBA CDB verzichtet
#-------------------------------------------------------------------------------
# Comments  Dieses Script sorgt für die Registrierung von Meldungen von der Shell
#           aus in DBA Log Datei.
#           PERL5LIB Environment Variable muss auf Perl Module Pfad zeigen!
#           Die Perl Modul Bibliothek xmpPerl arbeitet mit Umgebungsvariablen,
#           um an Autorisierungsinformationen zu gelangen.
################################################################################

# Modules ######################################################################
use strict;
use Getopt::Std;
use vars qw($opt_a $opt_s $opt_t);
use xmpPerl;
my  $rc;

# Argumente/Options prüfen #####################################################

getopts("a:s:t:");

if ( (! defined $opt_a )# Application
or   (! defined $opt_s ) )  {# Severity
   SaySyntax()}

if ($opt_s !~ /(I|W|E|S)/)  {
   print "$0 - Falsche Severity, bitte nur {I|W|E|S} angeben!\n";
   SaySyntax();
   }

$opt_a = uc $opt_a;
$opt_s = uc $opt_s;

################################################################################
# Wenn kein Text angegeben, Process Description beschaffen
################################################################################
if (! defined $opt_t ) {
   $opt_t = xmpPerl::getProcDescr()
}

################################################################################
# Protokollierung aufrufen
################################################################################
$rc = xmpPerl::LogLine("$opt_a $opt_s $opt_t");
################################################################################
# etwas ausgeben, wenn sonst alles ok war
################################################################################
if ( ($?==0)
   & ($rc==0) ) {}
else {
   print "$0 konnte nicht erfolgreich protokollieren ($rc).\n"
}
exit 0;

#################################################################################
########################################################## Sub Routines #########
# SaySyntax #####################################################################
sub SaySyntax {
die "Usage: perl $0 -a appl -s {I|W|E|S} [-t text]\n".
"-a Applikations- oder Prozess-Name\n".
"-s Severity (Info|Warnung|Error|Severe)\n".
"-t eine beliebige Fehlermeldung\n".
"abends ";
}

© Gernot Ruban