#!/bin/bash
# ccdb告警脚本
source /OSM/script/os_load_base.sh

CCDB_BACKUP_ALARM_ERRCODE=0x4000C91E
CCDB_BACKUP_ALARM_ID=0xFEA623417

if [ $# -lt 1 ];then
    ##ccdb_alarm.sh backup alarmtype
    echo "usage:"$0" alarm_func alarmtype"
    exit 1
fi

CCDB_BACKUP_ALARM()
{
 local CCDB_BACKUP_ALARM_TYPE=$1
 
 if [ -z "$CCDB_BACKUP_ALARM_TYPE" ];then
    OS_echo "[REPORT_ALARM] Invalid backup alarm type($CCDB_BACKUP_ALARM_TYPE)."
    return 1
 fi
 echo -e "alarm sendalarm $CCDB_BACKUP_ALARM_ID $CCDB_BACKUP_ALARM_TYPE ,$CCDB_BACKUP_ALARM_ERRCODE\nexit\n" | diagnose --auto &>/dev/null
 OS_echo "[REPORT_ALARM] report ccdb backup alarm type($CCDB_BACKUP_ALARM_TYPE)."
}

G_ACTION=$1
G_RES=0
shift 1
case ${G_ACTION} in
    "backup")
     CCDB_BACKUP_ALARM "$@"
     G_RES=$?
     ;;
    *)
     G_RES=1
     ;;
esac

exit ${G_RES}