|
|
60de42 |
From fefd8cc479b11d87fb4c4db69465de977fa94984 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: HideoYamauchi <renayama19661014@ybb.ne.jp>
|
|
|
60de42 |
Date: Tue, 20 Dec 2016 08:31:59 +0900
|
|
|
60de42 |
Subject: [PATCH] Mid: Alert: Set SNMP_PERSISTENT_DIR directory for the
|
|
|
60de42 |
snmp-trap tool.
|
|
|
60de42 |
|
|
|
60de42 |
---
|
|
|
60de42 |
extra/alerts/alert_snmp.sh.sample | 31 +++++++++++++++++++++++++------
|
|
|
60de42 |
1 file changed, 25 insertions(+), 6 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/extra/alerts/alert_snmp.sh.sample b/extra/alerts/alert_snmp.sh.sample
|
|
|
60de42 |
index fcdcd7e..48a2fe3 100644
|
|
|
60de42 |
--- a/extra/alerts/alert_snmp.sh.sample
|
|
|
60de42 |
+++ b/extra/alerts/alert_snmp.sh.sample
|
|
|
60de42 |
@@ -62,6 +62,7 @@ trap_fencing_tasks_default="all"
|
|
|
60de42 |
trap_resource_tasks_default="all"
|
|
|
60de42 |
trap_monitor_success_default="false"
|
|
|
60de42 |
trap_add_hires_timestamp_oid_default="true"
|
|
|
60de42 |
+trap_snmp_persistent_dir_default="/var/lib/pacemaker/snmp"
|
|
|
60de42 |
|
|
|
60de42 |
: ${trap_binary=${trap_binary_default}}
|
|
|
60de42 |
: ${trap_version=${trap_version_default}}
|
|
|
60de42 |
@@ -72,6 +73,7 @@ trap_add_hires_timestamp_oid_default="true"
|
|
|
60de42 |
: ${trap_resource_tasks=${trap_resource_tasks_default}}
|
|
|
60de42 |
: ${trap_monitor_success=${trap_monitor_success_default}}
|
|
|
60de42 |
: ${trap_add_hires_timestamp_oid=${trap_add_hires_timestamp_oid_default}}
|
|
|
60de42 |
+: ${trap_snmp_persistent_dir=${trap_snmp_persistent_dir_default}}
|
|
|
60de42 |
|
|
|
60de42 |
if [ "${trap_add_hires_timestamp_oid}" = "true" ]; then
|
|
|
60de42 |
hires_timestamp="HOST-RESOURCES-MIB::hrSystemDate s ${CRM_alert_timestamp}"
|
|
|
60de42 |
@@ -93,30 +95,41 @@ is_in_list() {
|
|
|
60de42 |
return 1
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+if [ -z ${SNMP_PERSISTENT_DIR} ]; then
|
|
|
60de42 |
+ export SNMP_PERSISTENT_DIR="${trap_snmp_persistent_dir}"
|
|
|
60de42 |
+ # mkdir for snmp trap tools.
|
|
|
60de42 |
+ if [ ! -d ${SNMP_PERSISTENT_DIR} ]; then
|
|
|
60de42 |
+ mkdir -p ${SNMP_PERSISTENT_DIR}
|
|
|
60de42 |
+ fi
|
|
|
60de42 |
+fi
|
|
|
60de42 |
+
|
|
|
60de42 |
+rc=0
|
|
|
60de42 |
case "$CRM_alert_kind" in
|
|
|
60de42 |
node)
|
|
|
60de42 |
is_in_list "${trap_node_states}" "${CRM_alert_desc}"
|
|
|
60de42 |
[ $? -ne 0 ] && exit 0
|
|
|
60de42 |
|
|
|
60de42 |
- "${trap_binary}" -v "${trap_version}" ${trap_options} \
|
|
|
60de42 |
+ output=`"${trap_binary}" -v "${trap_version}" ${trap_options} \
|
|
|
60de42 |
-c "${trap_community}" "${CRM_alert_recipient}" "" \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationTrap \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationNode s "${CRM_alert_node}" \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationDescription s "${CRM_alert_desc}" \
|
|
|
60de42 |
- ${hires_timestamp}
|
|
|
60de42 |
+ ${hires_timestamp} 2>&1`
|
|
|
60de42 |
+ rc=$?
|
|
|
60de42 |
;;
|
|
|
60de42 |
fencing)
|
|
|
60de42 |
is_in_list "${trap_fencing_tasks}" "${CRM_alert_task}"
|
|
|
60de42 |
[ $? -ne 0 ] && exit 0
|
|
|
60de42 |
|
|
|
60de42 |
- "${trap_binary}" -v "${trap_version}" ${trap_options} \
|
|
|
60de42 |
+ output=`"${trap_binary}" -v "${trap_version}" ${trap_options} \
|
|
|
60de42 |
-c "${trap_community}" "${CRM_alert_recipient}" "" \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationTrap \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationNode s "${CRM_alert_node}" \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationOperation s "${CRM_alert_task}" \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationDescription s "${CRM_alert_desc}" \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationReturnCode i ${CRM_alert_rc} \
|
|
|
60de42 |
- ${hires_timestamp}
|
|
|
60de42 |
+ ${hires_timestamp} 2>&1`
|
|
|
60de42 |
+ rc=$?
|
|
|
60de42 |
;;
|
|
|
60de42 |
resource)
|
|
|
60de42 |
is_in_list "${trap_resource_tasks}" "${CRM_alert_task}"
|
|
|
60de42 |
@@ -131,7 +144,7 @@ case "$CRM_alert_kind" in
|
|
|
60de42 |
exit
|
|
|
60de42 |
fi
|
|
|
60de42 |
|
|
|
60de42 |
- "${trap_binary}" -v "${trap_version}" ${trap_options} \
|
|
|
60de42 |
+ output=`"${trap_binary}" -v "${trap_version}" ${trap_options} \
|
|
|
60de42 |
-c "${trap_community}" "${CRM_alert_recipient}" "" \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationTrap \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationNode s "${CRM_alert_node}" \
|
|
|
60de42 |
@@ -141,10 +154,16 @@ case "$CRM_alert_kind" in
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationStatus i ${CRM_alert_status} \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationReturnCode i ${CRM_alert_rc} \
|
|
|
60de42 |
PACEMAKER-MIB::pacemakerNotificationTargetReturnCode i ${CRM_alert_target_rc} \
|
|
|
60de42 |
- ${hires_timestamp}
|
|
|
60de42 |
+ ${hires_timestamp} 2>&1`
|
|
|
60de42 |
+ rc=$?
|
|
|
60de42 |
;;
|
|
|
60de42 |
esac
|
|
|
60de42 |
;;
|
|
|
60de42 |
*)
|
|
|
60de42 |
;;
|
|
|
60de42 |
esac
|
|
|
60de42 |
+
|
|
|
60de42 |
+if [ $rc -ne 0 ]; then
|
|
|
60de42 |
+ echo "${trap_binary} returned error : rc=${rc} ${output}"
|
|
|
60de42 |
+fi
|
|
|
60de42 |
+
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|