アラームのスクリプト例
以下のサンプルは、通知として作成できる UNIX スクリプト ファイルの例です。アラームがしきい値のウォッチと共に設定またはクリアされるたびに、実行のためのスクリプトを指定できます。このスクリプト例は、sw_alrm_script という名前であり、sp のインストール時に SS-Tools/SwScript ディレクトリに配置されます。
casp1032jp
以下のサンプルは、通知として作成できる UNIX スクリプト ファイルの例です。アラームがしきい値のウォッチと共に設定またはクリアされるたびに、実行のためのスクリプトを指定できます。このスクリプト例は、
sw_alrm_script
という名前であり、CA Spectrum
のインストール時に SS-Tools/SwScript ディレクトリに配置されます。#!/bin/sh ########################################################### This is an example script that can used by users to perform important tasks upon threshold violation of a watch (Watch Status is #VIOLATED) or when an already violated watch becomes normal (Watch Status #is NORMAL). # # In each of the above cases, the user-specified script is executed (specified during watch creation) and provides twenty arguments. The arguments in ascending order are: # # 1) DATE - The date on which the watch was violated. # 2) TIME - The time at which the watch was violated. # 3) MTYPE_NAME - The model type of the watch. # 4) MODEL_HANDLE - The modelhandle of the model. # 5) MODEL_NAME - The model of the watch. # 6) INSTANCE - The instance (port, board, etc) for which the watch is either violated or reset. # 7) ALARM_ID - The ID of the alarm. # 8) CONDITION - The CONDITION of the alarm. # 9) CAUSE_CODE - The cause code of the alarm. # 10) REPAIR_PERSON - The repair person assigned to troubleshoot. # 11) ALARM_STATUS - The status of the alarm. # 12) SCRIPT_TYPE - This is set to "VIOLATED" if the script is getting executed upon violation and it is set to # "NORMAL" if the script is getting executed upon reset. # 13) WATCH_NAME - The name of the watch for which the script is executed. # 14) WATCH_CREATOR - The name of the creator of the watch. # 15) WATCH_SRC - The formula for the watch expression. # 16) WATCH_SRC_VAL - The value of the watch expression formula. # 17) WATCH_REF - The formula for threshold reference. # 18) WATCH_REF_VAL - The value of the threshold reference. # 19) WATCH_RES - The formula for threshold reset. # 20) WATCH_RES_VAL - The value of the threshold reset. ################################################################# ## Save the argument values into variables that could be used later. ## Remember that DATE is the first argument and WATCH_RES_VAL is the last argument. # IMPORTANT NOTE: ## Pay particular attention to the variable, "SCRIPT_TYPE". If the watch has a violated status, SCRIPT_TYPE is set to "VIOLATED". If a watch has normal status, SCRIPT_TYPE is set to "NORMAL". You can be use this to decide what to do when the watch is violated and when it is normal. while [ "$#" -ne 0 ] do case "$#" in 20) DATE=`echo "$1"`;; 19) TIME=`echo "$1"`;; 18) MTYPE_NAME=`echo "$1"`;; 17) MODEL_HANDLE=`echo "$1"`;; 16) MODEL_NAME=`echo "$1"`;; 15) INSTANCE=`echo "$1"`;; 14) ALARM_ID=`echo "$1"`;; 13) CONDITION=`echo "$1"`;; 12) CAUSE_CODE=`echo "$1"`;; 11) REPAIR_PERSON=`echo "$1"`;; 10) ALARM_STATUS=`echo "$1"`;; 9) SCRIPT_TYPE=`echo "$1"`;; 8) WATCH_NAME=`echo "$1"`;; 7) WATCH_CREATOR=`echo "$1"`;; 6) WATCH_SRC=`echo "$1"`;; 5) WATCH_SRC_VAL=`echo "$1"`;; 4) WATCH_REF=`echo "$1"`;; 3) WATCH_REF_VAL=`echo "$1"`;; 2) WATCH_RES=`echo "$1"`;; 1) WATCH_RES_VAL=`echo "$1"`;; esac shift done ## Compose a message that can be used, for example, to send mail. ## The composed message can be used for any other purpose as well. message() { echo "Watch Status Notification" echo "" echo "Watch Status is $1" echo "" echo "Date: $DATE" echo "Time: $TIME" echo "MType Name: $MTYPE_NAME" echo "Model Handle: $MODEL_HANDLE" echo "Model Name: $MODEL_NAME" echo "Instance: $INSTANCE" echo "Alarm ID: $ALARM_ID" echo "Condition: $CONDITION" echo "Cause Code: $CAUSE_CODE" echo "Repair Person: $REPAIR_PERSON" echo "Alarm Status: $ALARM_STATUS" echo "Watch Name: $WATCH_NAME" echo "Watch Creator: $WATCH_CREATOR" echo "Watch Expression: $WATCH_SRC" echo "Watch Expression Value: $WATCH_SRC_VAL" echo "Watch Reference: $WATCH_REF" echo "Watch Reference Value: $WATCH_REF_VAL" echo "Watch Reset: $WATCH_RES" echo "Watch Reset Value: $WATCH_RES_VAL"} ## Mail the composed message to the interested users. ## <USER LIST> is the list of mail recipients. message "$SCRIPT_TYPE" | mail <USER LIST>