#!/usr/bin/perl # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # # # Licensed Materials - Property of IBM # # (C) COPYRIGHT International Business Machines Corp. 2000,2019 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG ###################################################################### # # # Module: ldpdef # # # # Purpose: # # ldpdef - Load predefined event conditions and responses. # # # # Syntax: # # ldpdef [-h] -c|-r [-D selection_string] Filename # # # # Flags: # # -h Help --- writes this command's usage statement to stdout. # # # # -c Specifies that the input file contains predefined event # # conditions. # # # # -r Specifies that the input file contains predefined event # # responses. # # # # -s Specifies that the input file contains predefined sensor # # resources. # # # # -D selection_string Delete any event conditions or responses # # matching the selection string before # # loading the predefined event conditions # # or responses in the input file. The # # selection string must be enclosed in # # double or single quotes. # # # # Operands: # # Filename The name of the input file containing the predefined # # event conditions or responses. The input file must be # # in stanza format (see mkrsrc command for examples of # # input file format) and must reside in directory # # /opt/rsct/cfg/pdefs. # # # # Exit Values: # # 0 Command completed successfully. # # 1 Command terminated due to an error. # # # # # # Change Activity: # # 040122 JAC 103019: Add -s option for predefined sensors. # # # ###################################################################### # sccsid = "@(#)11 1.6 src/rsct/rm/ER/cli/install/bin/ldpdef.perl, ERrm.predef, rsct_rady, rady2035a 11/12/15 16:39:54" use lib "/opt/rsct/pm"; use locale; use Getopt::Std; use CT_cli_utils qw(printIMsg printEMsg); $PROGNAME = "ldpdef"; # Program Name for messages $MSGCAT = "errmcli.cat"; # msg catalogue for this cmd $CTDIR = "/opt/rsct"; # RSCT root directory $CTBINDIR = "$CTDIR/bin"; # Cluster Bin directory path $LSMSG = "$CTBINDIR/ctdspmsg"; # list / display message routine $ENV{'MSGMAPPATH'} = "$CTDIR/msgmaps"; # msg maps used by $LSMSG $PDEFDIR = "/opt/rsct/cfg/pdefs"; if (getopts ('chrsD:') && (@ARGV == 1 || $opt_h)) { if ($opt_h) { &printIMsg("IMsgldpdefUsage2"); exit(0); } ($PdefFileName) = @ARGV; #$ResourceClass = $opt_c ? "IBM.Condition" : "IBM.EventResponse"; if ($opt_c) { $ResourceClass = "IBM.Condition";} if ($opt_r) { $ResourceClass = "IBM.EventResponse";} if ($opt_s) { $ResourceClass = "IBM.Sensor";} if ( ($opt_c && $opt_r) || ($opt_c && $opt_s) || ($opt_r && $opt_s) ) { &printEMsg("EMsgldpdefBadComboOptions"); exit(1); } if (!$opt_c && !$opt_r && !$opt_s) { &printEMsg("EMsgldpdefMissingReqOption"); exit(1); } if (!( -e "$PDEFDIR/$PdefFileName" ) || !( -r "$PDEFDIR/$PdefFileName" )) { &printEMsg("EMsgldpdefBadInputFile"); exit(1); } if ($opt_D) { system "$CTBINDIR/rmrsrc -s \'$opt_D\' $ResourceClass"; } system "$CTBINDIR/mkrsrc -f $PDEFDIR/$PdefFileName $ResourceClass"; $RC = ($? >> 8); } else { &printEMsg("EMsgldpdefBadArguments"); exit(1); } exit($RC);