Monitor your Oracle database by 12C em and send the message to you
主要为了总结下12C em的自带脚本提取额自身Incident,Event等,并通过短信告警的功能,每DBAer的监控方式很多,这里只总结和记录下目前适合我们的一种简单粗暴但很灵活的监控方式,其他童鞋如果想参考,必须具备如下条件:
1)对12C em的告警规则及配置非常明确;
2)公司内部必须已有一个短信平台或者短信猫;
3)官方提取的12C em的告警脚本及简单的Shell编程能力;
待补充
#!/bin/sh#
LOG_FILE=/net/myhost/logs/oscmdNotify.log
echo ‘-------------’ >> $LOG_FILE
echo ‘issue_type=’ $ISSUE_TYPE >> $LOG_FILE
echo ‘notif_type=’ $NOTIF_TYPE >> $LOG_FILE
echo ‘message=’ $MESSAGE >> $LOG_FILE
echo ‘message_url’ = M E S S A G E U R L > > MESSAGE_URL >> MESSAGEURL>>LOG_FILE
echo ‘severity=’ $SEVERITY >> $LOG_FILE
echo ‘severity_code’ = S E V E R I T Y C O D E > > SEVERITY_CODE >> SEVERITYCODE>>LOG_FILE
echo ‘ruleset_name=’ $RULESET_NAME >> $LOG_FILE
echo ‘rule_name=’ $RULE_NAME >> $LOG_FILE
echo ‘rule_owner=’ $RULE_OWNER >> $LOG_FILE
echo ‘repeat_count=’ $REPEAT_COUNT >> $LOG_FILE
echo ‘categories_count’ = C A T E G O R I E S C O U N T > > CATEGORIES_COUNT >> CATEGORIESCOUNT>>LOG_FILE
echo ‘category_1’ = C A T E G O R Y 1 > > CATEGORY_1 >> CATEGORY1>>LOG_FILE
echo ‘category_2’ = C A T E G O R Y 2 > > CATEGORY_2 >> CATEGORY2>>LOG_FILE
echo ‘category_code_1’ = C A T E G O R Y C O D E 1 > > CATEGORY_CODE_1 >> CATEGORYCODE1>>LOG_FILE
echo ‘category_code_2’ = C A T E G O R Y C O D E 2 > > CATEGORY_CODE_2 >> CATEGORYCODE2>>LOG_FILE
echo ‘category_codes_count’ = C A T E G O R Y C O D E S C O U N T > > CATEGORY_CODES_COUNT >> CATEGORYCODESCOUNT>>LOG_FILE
#event
if [ $ISSUE_TYPE -eq 1 ]
then
echo ‘host_name=’ $HOST_NAME >> $LOG_FILE
echo ‘event_type=’ $EVENT_TYPE >> $LOG_FILE
echo ‘event_name=’ $EVENT_NAME >> $LOG_FILE
echo ‘event_occurrence_time=’ $EVENT_OCCURRENCE_TIME >> $LOG_FILE
echo ‘event_reported_time=’ $EVENT_REPORTED_TIME >> $LOG_FILE
echo ‘sequence_id=’ $SEQUENCE_ID >> $LOG_FILE
echo ‘event_type_attrs=’ $EVENT_TYPE_ATTRS >> $LOG_FILE
echo ‘source_obj_name=’ $SOURCE_OBJ_NAME >> $LOG_FILE
echo ‘source_obj_type=’ $SOURCE_OBJ_TYPE >> $LOG_FILE
echo ‘source_obj_owner=’ $SOURCE_OBJ_OWNER >> $LOG_FILE
echo ‘target_name’ = T A R G E T N A M E > > TARGET_NAME >> TARGETNAME>>LOG_FILE
echo ‘target_url’ = T A R G E T U R L > > TARGET_URL >> TARGETURL>>LOG_FILE
echo ‘target_owner=’ $TARGET_OWNER >> $LOG_FILE
echo ‘target_type=’ $TARGET_TYPE >> $LOG_FILE
echo ‘target_version=’ $TARGET_VERSION >> $LOG_FILE
echo ‘lifecycle_status=’ $TARGET_LIFECYCLE_STATUS >> $LOG_FILE
echo ‘assoc_incident_escalation_level’ = $ASSOC_INCIDENT_ESCALATION_LEVEL >> $LOG_FILE
echo ‘assoc_incident_id’ = A S S O C I N C I D E N T I D > > ASSOC_INCIDENT_ID >> ASSOCINCIDENTID>>LOG_FILE
echo ‘assoc_incident_owner’ = A S S O C I N C I D E N T O W N E R > > ASSOC_INCIDENT_OWNER >> ASSOCINCIDENTOWNER>>LOG_FILE
echo ‘assoc_incident_acknowledged_by_owner’ = $ASSOC_INCIDENT_ACKNOWLEDGED_BY_OWNER >> $LOG_FILE
echo ‘assoc_incident_acknowledged_details’ = $ASSOC_INCIDENT_ACKNOWLEDGED_DETAILS >> $LOG_FILE
echo ‘assoc_incident_priority’ = A S S O C I N C I D E N T P R I O R I T Y > > ASSOC_INCIDENT_PRIORITY >> ASSOCINCIDENTPRIORITY>>LOG_FILE
echo ‘assoc_incident_status’ = A S S O C I N C I D E N T S T A T U S > > ASSOC_INCIDENT_STATUS >> ASSOCINCIDENTSTATUS>>LOG_FILE
echo ‘ca_job_status’ = C A J O B S T A T U S > > CA_JOB_STATUS >> CAJOBSTATUS>>LOG_FILE
echo ‘event_context_attrs’ = E V E N T C O N T E X T A T T R S > > EVENT_CONTEXT_ATTRS >> EVENTCONTEXTATTRS>>LOG_FILE
echo ‘last_updated_time’ = L A S T U P D A T E D T I M E > > LAST_UPDATED_TIME >> LASTUPDATEDTIME>>LOG_FILE
echo ‘sequence_id’ = S E Q U E N C E I D > > SEQUENCE_ID >> SEQUENCEID>>LOG_FILE
echo ‘test_date_attr_noref’ = T E S T D A T E A T T R N O R E F > > TEST_DATE_ATTR_NOREF >> TESTDATEATTRNOREF>>LOG_FILE
echo ‘test_raw_attr_noref’ = T E S T R A W A T T R N O R E F > > TEST_RAW_ATTR_NOREF >> TESTRAWATTRNOREF>>LOG_FILE
echo ‘test_str_attr1’ = T E S T S T R A T T R 1 > > TEST_STR_ATTR1 >> TESTSTRATTR1>>LOG_FILE
echo ‘test_str_attr2’ = T E S T S T R A T T R 2 > > TEST_STR_ATTR2 >> TESTSTRATTR2>>LOG_FILE
echo ‘test_str_attr3’ = T E S T S T R A T T R 3 > > TEST_STR_ATTR3 >> TESTSTRATTR3>>LOG_FILE
echo ‘test_str_attr4’ = T E S T S T R A T T R 4 > > TEST_STR_ATTR4 >> TESTSTRATTR4>>LOG_FILE
echo ‘test_str_attr5’ = T E S T S T R A T T R 5 > > TEST_STR_ATTR5 >> TESTSTRATTR5>>LOG_FILE
echo ‘test_str_attr_ref’ = T E S T S T R A T T R R E F > > TEST_STR_ATTR_REF >> TESTSTRATTRREF>>LOG_FILE
echo ‘total_occurrence_count’ = T O T A L O C C U R R E N C E C O U N T > > TOTAL_OCCURRENCE_COUNT >> TOTALOCCURRENCECOUNT>>LOG_FILE
fi
#incident
if [ $ISSUE_TYPE -eq 2 ]
then
echo ‘action_msg=’ $ACTION_MSG >> $LOG_FILE
echo ‘incident_id=’ $INCIDENT_ID >> $LOG_FILE
echo ‘incident_creation_time=’ $INCIDENT_CREATION_TIME >> $LOG_FILE
echo ‘incident_owner=’ $INCIDENT_OWNER >> $LOG_FILE
echo ‘incident_acknowledged_by_owner’ = $INCIDENT_ACKNOWLEDGED_BY_OWNER >> $LOG_FILE
echo ‘incident_status’ = I N C I D E N T S T A T U S > > INCIDENT_STATUS >> INCIDENTSTATUS>>LOG_FILE
echo ‘last_modified_by=’ $LAST_MODIFIED_BY >> $LOG_FILE
echo ‘last_updated_time=’ $LAST_UPDATED_TIME >> $LOG_FILE
echo ‘assoc_event_count=’ $ASSOC_EVENT_COUNT >> $LOG_FILE
echo ‘adr_incident_id=’ $ADR_INCIDENT_ID >> $LOG_FILE
echo ‘occurrence_count=’ $OCCURRENCE_COUNT >> $LOG_FILE
echo ‘escalated=’ $ESCALATED >> $LOG_FILE
echo ‘escalated_level=’ $ESCALATED_LEVEL >> $LOG_FILE
echo ‘priority=’ $PRIORITY >> $LOG_FILE
echo ‘priority_code’ = P R I O R I T Y C O D E > > PRIORITY_CODE >> PRIORITYCODE>>LOG_FILE
echo ‘ticket_id=’ $TICKET_ID >> $LOG_FILE
echo ‘ticket_status=’ $TICKET_STATUS >> $LOG_FILE
echo ‘ticket_url=’ $TICKET_ID_URL >> $LOG_FILE
echo ‘total_duplicate_count=’ $TOTAL_DUPLICATE_COUNT >> $LOG_FILE
echo ‘source_count=’ $EVENT_SOURCE_COUNT >> $LOG_FILE
echo ‘event_source_1_host_name’ = KaTeX parse error: Double subscript at position 15: EVENT_SOURCE_1_̲HOST_NAME >>LOG_FILE
echo ‘event_source_1_target_guid’ = KaTeX parse error: Double subscript at position 15: EVENT_SOURCE_1_̲TARGET_GUID >>LOG_FILE
echo ‘event_source_1_target_name’ = KaTeX parse error: Double subscript at position 15: EVENT_SOURCE_1_̲TARGET_NAME >>LOG_FILE
echo ‘event_source_1_target_owner’ = KaTeX parse error: Double subscript at position 15: EVENT_SOURCE_1_̲TARGET_OWNER >>LOG_FILE
echo ‘event_source_1_target_type’ = KaTeX parse error: Double subscript at position 15: EVENT_SOURCE_1_̲TARGET_TYPE >>LOG_FILE
echo ‘event_source_1_target_url’ = KaTeX parse error: Double subscript at position 15: EVENT_SOURCE_1_̲TARGET_URL >>LOG_FILE
echo ‘event_source_1_target_lifecycle_status’ = $EVENT_SOURCE_1_TARGET_LIFECYCLE_STATUS >> $LOG_FILE
echo ‘event_source_1_target_version’ = $EVENT_SOURCE_1_TARGET_VERSION >> $LOG_FILE
fi
exit 0
链接: https://docs.oracle.com/cd/E24628_01/doc.121/e24473/notification.htm#EMADM9811
因为我们使用的SUSE Linux的OS,所有使用Curl来实现短信告警,告警的格式: