From 43514ea7fbd18d518511a165b59c82b7e20ebd8d Mon Sep 17 00:00:00 2001 From: "Kwan, Louie" Date: Wed, 12 Dec 2018 15:54:30 -0500 Subject: [PATCH] [Enhancement] Add system active alarms in collect logs Currently the collect tool does not collect the active alarm list. i.e. it doesn't contain the output of "fm alarm-list" Although fm-event.log contains the history of events/alarms, it is quite time-consuming to vet the fm-event.log for which alarms were really active at the time of log collection. A dump of alarm-list to the collect log will greatly reduce this effort. Story: 2004478 Tasks: 28193 Change-Id: I663fb055c244b31a84e682481f94bff82f610b90 Signed-off-by: Kwan, Louie --- tools/collector/centos/collector.spec | 1 + tools/collector/scripts/collect_fm.sh | 41 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tools/collector/scripts/collect_fm.sh diff --git a/tools/collector/centos/collector.spec b/tools/collector/centos/collector.spec index 136c557c9..4de41526c 100644 --- a/tools/collector/centos/collector.spec +++ b/tools/collector/centos/collector.spec @@ -46,6 +46,7 @@ install -m 755 collect_patching.sh %{buildroot}%{_sysconfdir}/collect.d/collect_ install -m 755 collect_coredump.sh %{buildroot}%{_sysconfdir}/collect.d/collect_coredump install -m 755 collect_crash.sh %{buildroot}%{_sysconfdir}/collect.d/collect_crash install -m 755 collect_ima.sh %{buildroot}%{_sysconfdir}/collect.d/collect_ima +install -m 755 collect_fm.sh %{buildroot}%{_sysconfdir}/collect.d/collect_fm install -m 755 etc.exclude %{buildroot}%{_sysconfdir}/collect/etc.exclude install -m 755 run.exclude %{buildroot}%{_sysconfdir}/collect/run.exclude diff --git a/tools/collector/scripts/collect_fm.sh b/tools/collector/scripts/collect_fm.sh new file mode 100644 index 000000000..4ef489a4b --- /dev/null +++ b/tools/collector/scripts/collect_fm.sh @@ -0,0 +1,41 @@ +#! /bin/bash +# +# SPDX-License-Identifier: Apache-2.0 +# + + +# Loads Up Utilities and Commands Variables + +source /usr/local/sbin/collect_parms +source /usr/local/sbin/collect_utils + +SERVICE="alarms" +LOGFILE="${extradir}/${SERVICE}.info" + +function is_service_active { + active=`sm-query service management-ip | grep "enabled-active"` + if [ -z "$active" ] ; then + return 0 + else + return 1 + fi +} + +############################################################################### +# Only Controller +############################################################################### +if [ "$nodetype" = "controller" ] ; then + + is_service_active + if [ "$?" = "0" ] ; then + exit 0 + fi + + echo "${hostname}: System Alarm List .: ${LOGFILE}" + + # These go into the SERVICE.info file + delimiter ${LOGFILE} "fm alarm-list" + fm alarm-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE} +fi + +exit 0