#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2018,2019,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/usr/sbin/cluster/events/utils/cl_msg.sh 1.3.1.1 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2008,2015 # 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 # @(#) 7d4c34b 43haes/usr/sbin/cluster/events/utils/cl_msg.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM #================================================ # The following, commented line enforces coding # standards when this file is edited via vim. #================================================ # vim:tabstop=4:shiftwidth=4:expandtab:smarttab #================================================ ############################################################################### # # Name: cl_msg # # This routine logs messages to syslog and standard error. If the string # specified by message_id can't be found, default_message will be displayed. # # Arguments: message default_message # Usage: cl_msg -e Error_Type -s Setid -c Catalog -m message_id default_message # Returns: 0 - success # 2 - bad number of arguments # Environment: VERBOSE_LOGGING,PATH,NLSPATH, HACMP_SETID, MSG_CAT # ############################################################################### PROGNAME=${0##*/} TIME="$(date +"%h %e %Y %H:%M:%S")" No_Error=0 ERROR=1 MSG1=$(dspmsg scripts.cat 3010 "\n!!!!!!!!!! ERROR !!!!!!!!!!\n") unset MSG_CAT MSG_TYPE MSG_ID SET_ID if [[ $VERBOSE_LOGGING == "high" ]] then set -x version='1.3.1.1' fi usage () { print -n -u2 "$TIME " # leave this message alone since it is our error message and is right dspmsg scripts.cat 999 "usage: $PROGNAME -e Message_Type -s Setid -c Catalog -m message_id default_message\n" $PROGNAME >&2 exit 2 } while getopts "e:s:c:m:" opt ;do case "$opt" in c ) : Message catalog used for the message MSG_CAT=$OPTARG ;; e ) : Error or standard message. "0" is standard MSG_TYPE=$OPTARG ;; m ) : Message ID in given set and catalog MSG_ID=$OPTARG ;; s ) : Message set ID in given catalog SET_ID="-s $OPTARG" ;; esac done shift $((OPTIND-1)) # : All the rest is the default message and data - "$@" # if [[ -z $MSG_CAT ]] then MSG_CAT=scripts.cat fi if [[ -z $MSG_TYPE ]] then MSG_TYPE="$No_Error" fi if [[ -z $MSG_ID ]] then usage fi # Get syslog configuration file typeset SYSLOG_CONF="" SYSLOG_CONF=$(clgetsyslog) # Use default configuration file for any kind of failures if (( $? != 0 )) then SYSLOG_CONF="/etc/syslog.conf" fi # : Look up the message in the catalog # MSG=$(dspmsg $SET_ID $MSG_CAT $MSG_ID "$@" 2>&1) # : This is where we print out the parts of the message when we have : an error. We also write to the syslog if it is configured. # if (( $MSG_TYPE != $No_Error )) then print -u2 "***************************" # : Find the file to which syslog goes # grep '^user.notice' ${SYSLOG_CONF} | read skip SYSLOG_FILE rest if [[ -n $SYSLOG_FILE ]] then if [[ ! -f $SYSLOG_FILE ]] then # : If the syslog is configured, we will create the file if it : doesnt exist. # touch $SYSLOG_FILE fi # : note that logger adds its own timestamp on the dspmsg # logger -t "PowerHA SystemMirror for AIX" $DEFAULT_MSG fi # : This is an error message so we display it as such. # print -u2 $TIME $MSG1 print -u2 "***************************" fi print -u2 $TIME $MSG # : Finally, synchronize the syslog file but only if syslog is configured and : the file exists. # if [[ -n $SYSLOG_FILE && -s $SYSLOG_FILE ]] then clsynclog $SYSLOG_FILE fi exit $rc