storalert2bug: "|xargs sudo /usr/local/sbin/storage_alert2bug.sh" |
inet_interfaces = localhost 10.211.int.int |
nobody ALL=(ALL) NOPASSWD: /usr/local/sbin/storage_alert2bug.sh |
#!/bin/bash readonly storage_alert="$*" # alert from storage is argument, can be any number of words readonly progname=`/bin/basename $0` readonly loggerinfo="logger -t ${progname} Info:" readonly loggerwarning="logger -t ${progname} Warning:" readonly loggerproblem="logger -t ${progname} Problem:" #### function: error ######### # args: multiple # what: print args to STDERR # err() { echo ; echo "Problem: $*" ; echo ${loggerproblem} "$*" exit 1 } # it must be at least one argument if [ $# -eq 0 ]; then err "It must be at least one argument, exiting." fi # temp file and cleanup of same tmp_file=/tmp/${progname}.tmp # --- CLEANING SUBROUTINE tmp_file_cleaning () { [ -f ${tmp_file}.$$ ] && rm ${tmp_file}.$$ } # --- cleaning in case of script termination and regular exit trap tmp_file_cleaning HUP INT QUIT ABRT EXIT ${loggerinfo} ======== Start at `date +'%Y-%m-%dT%H-%M-%S_%Z'` =============== # find which storage sends alert storage_hostname=`echo "${storage_alert}" | awk -F\Subject: '{print $2}' | awk -F\: '{print $1}'` # create temp file used to file a bug echo "From: ca-labops-support_grp@domain.com Subject: ${storage_hostname}: Defects and Faults @product = Storage @component = Problems @version = unspecified @op_sys = Solaris @platform = Other @priority = P2 @severity = normal -------------------------------------------------------------------- Note: Please login to ${storage_hostname} and see details !!!! --------------------------------------------------------------------" \ | tee ${tmp_file}.$$ echo ${storage_alert} |\ sed 's/From/\nFrom/' |\ sed 's/Return-Path/\nReturn-Path/' |\ sed 's/X-Original-To/\nX-Original-To/' |\ sed 's/Delivered-To/\nDelivered-To/' |\ sed 's/Received/\nReceived/' |\ sed 's/Message-Id/\nMessage-Id/' |\ sed 's/To/\nTo/' |\ sed 's/Subject/\n\nSubject/' |\ sed 's/SUNW-MSG-ID/\n\nSUNW-MSG-ID/' |\ sed 's/EVENT-TIME/\n\nEVENT-TIME/' |\ sed 's/PLATFORM/\n\nPLATFORM/' |\ sed 's/SOURCE/\n\nSOURCE/' |\ sed 's/EVENT-ID/\n\nEVENT-ID/' |\ sed 's/DESC/\n\nDESC/' |\ sed 's/AUTO-RESPONSE/\n\nAUTO-RESPONSE/' |\ sed 's/IMPACT/\n\nIMPACT/' |\ sed 's/REC-ACTION/\n\nREC-ACTION/' |\ sed 's/SEE/\n\nSEE/' |\ tee -a ${tmp_file}.$$ # now file the bug /usr/share/bugzilla/email_in.pl < ${tmp_file}.$$ || \ err "cannot file bug for alert from ${storage_hostname}" ${loggerinfo} A bug has been filed for the alert from ${storage_hostname} ${loggerinfo} ======== Finish at `date +'%Y-%m-%dT%H-%M-%S_%Z'` =============== exit 0 |
postfix/local[14404]: 5B73F1757: to=<storalert2bug@ca-sysadmin.domain.com>, relay=local, delay=0.18, delays=0.06/0.02/0/0.1, dsn=2.0.0, status=sent (delivered to command: xargs sudo /usr/local/sbin/storage_alert2bug.sh) |