Update crashDumpMgr to source config from envfile
This commit updates the crashDumpMgr service in order to: - Cleanup of current service naming and packaging to follow the standard Linux naming convention: - Repackage /etc/init.d/crashDumpMgr to /usr/sbin/crash-dump-manager - Rename crashDumpMgr.service to crash-dump-manager.service - Add EnvironmentFile to crash-dump-manager service file to source configuration from /etc/default/crash-dump-manager. - Update ExecStart of crash-dump-manager service to use parameters from EnvironmentFile - Update crash-dump-manager service dependencies to run after config.service. - Update logrotate configuration to support the retention polices of the maximum files. The “rotate 1” option was removed to permit crash-dump-manager to manage pruning old files. - Modify the crash-dump-manager script to enable updates to the max_files parameter to a lower value. If there are currently more files than the new max_files value, the oldest files will be deleted the next time a crash dump file needs to be stored, thus adhering to the new max_files values. Test Plan: PASS: Build ISO and perform a fresh install. Verify the new crash-dump-manager service is enabled and working as expected. PASS: Add and apply new crashdump service parameters and force a kernel panic. Verify that after the reboot, the max_files, max_used, min_available and max_size values are updated accordingly to the service parameters values. PASS: Verify that the crashdump files are rotated as expected. Story: 2010893 Task: 48910 Change-Id: I4a81fcc6ba456a0d73067b77588ee4a125e44e62 Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com>
This commit is contained in:
parent
df8989e2a1
commit
23143abbca
@ -350,8 +350,8 @@ install -m 700 -p -D %{_buildsubdir}/alarm/scripts/mtcalarm.init %{buildroot}%{_
|
|||||||
# TODO: Init hack. Should move to proper module
|
# TODO: Init hack. Should move to proper module
|
||||||
install -m 755 -p -D %{_buildsubdir}/scripts/hwclock.sh %{buildroot}%{_sysconfdir}/init.d/hwclock.sh
|
install -m 755 -p -D %{_buildsubdir}/scripts/hwclock.sh %{buildroot}%{_sysconfdir}/init.d/hwclock.sh
|
||||||
install -m 644 -p -D %{_buildsubdir}/scripts/hwclock.service %{buildroot}%{_unitdir}/hwclock.service
|
install -m 644 -p -D %{_buildsubdir}/scripts/hwclock.service %{buildroot}%{_unitdir}/hwclock.service
|
||||||
install -m 755 -p -D %{_buildsubdir}/scripts/crashDumpMgr %{buildroot}%{_sysconfdir}/init.d/crashDumpMgr
|
install -m 755 -p -D %{_buildsubdir}/scripts/crash-dump-manager %{buildroot}%{_sysconfdir}/init.d/crash-dump-manager
|
||||||
install -m 644 -p -D %{_buildsubdir}/scripts/crashDumpMgr.service %{buildroot}%{_unitdir}/crashDumpMgr.service
|
install -m 644 -p -D %{_buildsubdir}/scripts/crash-dump-manager.service %{buildroot}%{_unitdir}/crash-dump-manager.service
|
||||||
|
|
||||||
# systemd service files
|
# systemd service files
|
||||||
install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.service %{buildroot}%{_unitdir}/fsmon.service
|
install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.service %{buildroot}%{_unitdir}/fsmon.service
|
||||||
@ -435,7 +435,7 @@ install -m 755 -d %{buildroot}/var/run
|
|||||||
/bin/systemctl enable rsyncd.service
|
/bin/systemctl enable rsyncd.service
|
||||||
/bin/systemctl enable goenabled.service
|
/bin/systemctl enable goenabled.service
|
||||||
/bin/systemctl enable mtcalarm.service
|
/bin/systemctl enable mtcalarm.service
|
||||||
/bin/systemctl enable crashDumpMgr.service
|
/bin/systemctl enable crash-dump-manager.service
|
||||||
|
|
||||||
%post -n mtce-hostw
|
%post -n mtce-hostw
|
||||||
/bin/systemctl enable hostw.service
|
/bin/systemctl enable hostw.service
|
||||||
@ -509,7 +509,7 @@ install -m 755 -d %{buildroot}/var/run
|
|||||||
%{_sysconfdir}/init.d/mtcClient
|
%{_sysconfdir}/init.d/mtcClient
|
||||||
%{_sysconfdir}/init.d/mtcalarm
|
%{_sysconfdir}/init.d/mtcalarm
|
||||||
%{_sysconfdir}/init.d/hwclock.sh
|
%{_sysconfdir}/init.d/hwclock.sh
|
||||||
%{_sysconfdir}/init.d/crashDumpMgr
|
%{_sysconfdir}/init.d/crash-dump-manager
|
||||||
|
|
||||||
%{_unitdir}/runservices.service
|
%{_unitdir}/runservices.service
|
||||||
%{_unitdir}/goenabled.service
|
%{_unitdir}/goenabled.service
|
||||||
@ -519,7 +519,7 @@ install -m 755 -d %{buildroot}/var/run
|
|||||||
%{_unitdir}/mtcClient.service
|
%{_unitdir}/mtcClient.service
|
||||||
%{_unitdir}/hbsClient.service
|
%{_unitdir}/hbsClient.service
|
||||||
%{_unitdir}/hwclock.service
|
%{_unitdir}/hwclock.service
|
||||||
%{_unitdir}/crashDumpMgr.service
|
%{_unitdir}/crash-dump-manager.service
|
||||||
|
|
||||||
# Binaries
|
# Binaries
|
||||||
%{local_bindir}/mtcAgent
|
%{local_bindir}/mtcAgent
|
||||||
|
14
mtce/debian/deb_folder/crash-dump-manager.service
Normal file
14
mtce/debian/deb_folder/crash-dump-manager.service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Crash Dump Manager
|
||||||
|
After=network.target config.target
|
||||||
|
Before=sshd.service
|
||||||
|
DefaultEnabled=true
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=no
|
||||||
|
EnvironmentFile=/etc/default/crash-dump-manager
|
||||||
|
ExecStart=/usr/sbin/crash-dump-manager --max-size $MAX_SIZE --max-files $MAX_FILES --max-used $MAX_USED --min-available $MIN_AVAILABLE
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -1,12 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Crash Dump Manager
|
|
||||||
After=network.target
|
|
||||||
Before=sshd.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
RemainAfterExit=no
|
|
||||||
ExecStart=/etc/init.d/crashDumpMgr --max-size 5Gi
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -2,7 +2,7 @@ etc/bmc/server_profiles.d/sensor_hp360_v1_ilo_v4.profile
|
|||||||
etc/bmc/server_profiles.d/sensor_hp380_v1_ilo_v4.profile
|
etc/bmc/server_profiles.d/sensor_hp380_v1_ilo_v4.profile
|
||||||
etc/bmc/server_profiles.d/sensor_quanta_v1_ilo_v4.profile
|
etc/bmc/server_profiles.d/sensor_quanta_v1_ilo_v4.profile
|
||||||
etc/collect.d/collect_bmc
|
etc/collect.d/collect_bmc
|
||||||
etc/init.d/crashDumpMgr
|
etc/default/crash-dump-manager
|
||||||
etc/init.d/fsmon
|
etc/init.d/fsmon
|
||||||
etc/init.d/goenabled
|
etc/init.d/goenabled
|
||||||
etc/init.d/hbsClient
|
etc/init.d/hbsClient
|
||||||
@ -22,6 +22,7 @@ etc/services.d/controller/mtcTest
|
|||||||
etc/services.d/storage/mtcTest
|
etc/services.d/storage/mtcTest
|
||||||
etc/services.d/worker/mtcTest
|
etc/services.d/worker/mtcTest
|
||||||
etc/syslog-ng/conf.d/mtce.conf
|
etc/syslog-ng/conf.d/mtce.conf
|
||||||
|
etc/systemd/system-preset/
|
||||||
usr/lib/ocf/resource.d/platform/mtcAgent
|
usr/lib/ocf/resource.d/platform/mtcAgent
|
||||||
usr/local/bin/fsmond
|
usr/local/bin/fsmond
|
||||||
usr/local/bin/hbsAgent
|
usr/local/bin/hbsAgent
|
||||||
@ -31,6 +32,7 @@ usr/local/bin/mtcClient
|
|||||||
usr/local/bin/mtcalarmd
|
usr/local/bin/mtcalarmd
|
||||||
usr/local/bin/mtclogd
|
usr/local/bin/mtclogd
|
||||||
usr/local/bin/wipedisk
|
usr/local/bin/wipedisk
|
||||||
|
usr/sbin/crash-dump-manager
|
||||||
usr/sbin/dmemchk.sh
|
usr/sbin/dmemchk.sh
|
||||||
usr/sbin/fsync
|
usr/sbin/fsync
|
||||||
usr/share/mtce/hwclock.service
|
usr/share/mtce/hwclock.service
|
||||||
|
@ -36,6 +36,7 @@ override_dh_auto_install:
|
|||||||
|
|
||||||
# Configuration files
|
# Configuration files
|
||||||
install -m 600 -p -D scripts/mtc.ini $(SYSCONFDIR)/mtc.ini
|
install -m 600 -p -D scripts/mtc.ini $(SYSCONFDIR)/mtc.ini
|
||||||
|
install -m 600 -p -D scripts/crash-dump-manager_envfile $(SYSCONFDIR)/default/crash-dump-manager
|
||||||
install -m 600 -p -D scripts/mtc.conf $(SYSCONFDIR)/mtc.conf
|
install -m 600 -p -D scripts/mtc.conf $(SYSCONFDIR)/mtc.conf
|
||||||
install -m 600 -p -D fsmon/scripts/fsmond.conf $(SYSCONFDIR)/mtc/fsmond.conf
|
install -m 600 -p -D fsmon/scripts/fsmond.conf $(SYSCONFDIR)/mtc/fsmond.conf
|
||||||
install -m 600 -p -D hwmon/scripts/hwmond.conf $(SYSCONFDIR)/mtc/hwmond.conf
|
install -m 600 -p -D hwmon/scripts/hwmond.conf $(SYSCONFDIR)/mtc/hwmond.conf
|
||||||
@ -65,13 +66,13 @@ override_dh_auto_install:
|
|||||||
install -m 755 -d $(SBINDIR)
|
install -m 755 -d $(SBINDIR)
|
||||||
install -m 700 -p -D fsync/fsync $(SBINDIR)/fsync
|
install -m 700 -p -D fsync/fsync $(SBINDIR)/fsync
|
||||||
install -m 755 -d $(SBINDIR)
|
install -m 755 -d $(SBINDIR)
|
||||||
|
install -m 755 -p -D scripts/crash-dump-manager $(SBINDIR)/crash-dump-manager
|
||||||
install -m 700 -p -D pmon/scripts/pmon-restart $(LOCAL_SBINDIR)/pmon-restart
|
install -m 700 -p -D pmon/scripts/pmon-restart $(LOCAL_SBINDIR)/pmon-restart
|
||||||
install -m 700 -p -D pmon/scripts/pmon-start $(LOCAL_SBINDIR)/pmon-start
|
install -m 700 -p -D pmon/scripts/pmon-start $(LOCAL_SBINDIR)/pmon-start
|
||||||
install -m 700 -p -D pmon/scripts/pmon-stop $(LOCAL_SBINDIR)/pmon-stop
|
install -m 700 -p -D pmon/scripts/pmon-stop $(LOCAL_SBINDIR)/pmon-stop
|
||||||
|
|
||||||
# init script files
|
# init script files
|
||||||
install -m 755 -d $(INITDIR)
|
install -m 755 -d $(INITDIR)
|
||||||
install -m 755 -p -D scripts/crashDumpMgr $(INITDIR)/crashDumpMgr
|
|
||||||
install -m 700 -p -D scripts/mtcClient $(INITDIR)/mtcClient
|
install -m 700 -p -D scripts/mtcClient $(INITDIR)/mtcClient
|
||||||
install -m 700 -p -D scripts/hbsClient $(INITDIR)/hbsClient
|
install -m 700 -p -D scripts/hbsClient $(INITDIR)/hbsClient
|
||||||
install -m 700 -p -D hwmon/scripts/lsb/hwmon $(INITDIR)/hwmon
|
install -m 700 -p -D hwmon/scripts/lsb/hwmon $(INITDIR)/hwmon
|
||||||
@ -148,8 +149,12 @@ override_dh_auto_install:
|
|||||||
install -m 755 -d $(ROOT)/var
|
install -m 755 -d $(ROOT)/var
|
||||||
install -m 755 -d $(ROOT)/var/run
|
install -m 755 -d $(ROOT)/var/run
|
||||||
|
|
||||||
|
# Presets
|
||||||
|
install -d $(SYSCONFDIR)/systemd/system-preset
|
||||||
|
install -m 544 scripts/55-crash-dump-manager.preset $(SYSCONFDIR)/systemd/system-preset
|
||||||
|
|
||||||
override_dh_installsystemd:
|
override_dh_installsystemd:
|
||||||
dh_installsystemd --name crashDumpMgr
|
dh_installsystemd --name crash-dump-manager
|
||||||
dh_installsystemd --name fsmon
|
dh_installsystemd --name fsmon
|
||||||
dh_installsystemd --name goenabled
|
dh_installsystemd --name goenabled
|
||||||
dh_installsystemd --name hbsClient
|
dh_installsystemd --name hbsClient
|
||||||
|
1
mtce/src/scripts/55-crash-dump-manager.preset
Normal file
1
mtce/src/scripts/55-crash-dump-manager.preset
Normal file
@ -0,0 +1 @@
|
|||||||
|
enable crash-dump-manager.service
|
@ -5,7 +5,7 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
|
||||||
CRASHDUMPMGR_TAG=${CRASHDUMPMGR_TAG:-"crashDumpMgr"}
|
CRASHDUMPMGR_TAG=${CRASHDUMPMGR_TAG:-"crash-dump-manager"}
|
||||||
|
|
||||||
RETVAL=0
|
RETVAL=0
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ RETVAL=0
|
|||||||
DEFAULT_MAX_SIZE=5368709120 # "5GiB"
|
DEFAULT_MAX_SIZE=5368709120 # "5GiB"
|
||||||
DEFAULT_MAX_FILES=4
|
DEFAULT_MAX_FILES=4
|
||||||
UNLIMITED="unlimited"
|
UNLIMITED="unlimited"
|
||||||
|
DEFAULT="default"
|
||||||
DEFAULT_MAX_USED="${UNLIMITED}" # Assign UNLIMITED to DEFAULT_MAX_USED
|
DEFAULT_MAX_USED="${UNLIMITED}" # Assign UNLIMITED to DEFAULT_MAX_USED
|
||||||
DEFAULT_MIN_REMAINDER_PERCENT=10
|
DEFAULT_MIN_REMAINDER_PERCENT=10
|
||||||
MIN_REMAINDER_MINIMUM=1073741824 # 1GiB in bytes
|
MIN_REMAINDER_MINIMUM=1073741824 # 1GiB in bytes
|
||||||
@ -141,9 +142,15 @@ function manage_crash_dumps()
|
|||||||
vmcore_size_hr=$(${NUMFMT_TO_HR} ${vmcore_size})
|
vmcore_size_hr=$(${NUMFMT_TO_HR} ${vmcore_size})
|
||||||
|
|
||||||
# Manage max number of files
|
# Manage max number of files
|
||||||
if [ "$(ls -A ${CRASH_BUNDLE_DIR} | wc -l)" -ge "${max_files}" ]; then
|
files_in_crash_bundle_dir=$(ls -A ${CRASH_BUNDLE_DIR} | wc -l)
|
||||||
oldest_vmcore=$(ls -t ${CRASH_BUNDLE_DIR} | tail -2 | head -1)
|
num_files_to_remove=$((files_in_crash_bundle_dir-max_files+1))
|
||||||
oldest_vmcore_size=$(stat --format='%s' ${oldest_vmcore})
|
|
||||||
|
if [ "${num_files_to_remove}" -ge 1 ]; then
|
||||||
|
files_to_remove=$(ls -t ${CRASH_BUNDLE_DIR} | tail -$((num_files_to_remove+1)) | head -$((num_files_to_remove)))
|
||||||
|
files_to_remove_size=0
|
||||||
|
for file in ${files_to_remove}; do
|
||||||
|
files_to_remove_size+=$(stat --format='%s' ${file})
|
||||||
|
done
|
||||||
max_files_saved=true
|
max_files_saved=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -156,8 +163,8 @@ function manage_crash_dumps()
|
|||||||
# if the ${CRASH_BUNDLE_DIR} contains the maximum number of files, the available and used_space
|
# if the ${CRASH_BUNDLE_DIR} contains the maximum number of files, the available and used_space
|
||||||
# need to be updated to the value after deleting the oldest crash dump file.
|
# need to be updated to the value after deleting the oldest crash dump file.
|
||||||
if [ "${max_files_saved}" = true ] ; then
|
if [ "${max_files_saved}" = true ] ; then
|
||||||
available=$((available+oldest_vmcore_size))
|
available=$((available+files_to_remove_size))
|
||||||
used_space=$((used_space-oldest_vmcore_size))
|
used_space=$((used_space-files_to_remove_size))
|
||||||
fi
|
fi
|
||||||
available_hr=$(${NUMFMT_TO_HR} ${available})
|
available_hr=$(${NUMFMT_TO_HR} ${available})
|
||||||
log "new vmcore detected (size:${vmcore_size}:${vmcore_size_hr}) ;" \
|
log "new vmcore detected (size:${vmcore_size}:${vmcore_size_hr}) ;" \
|
||||||
@ -194,9 +201,11 @@ function manage_crash_dumps()
|
|||||||
|
|
||||||
else
|
else
|
||||||
if [ "${max_files_saved}" = true ] ; then
|
if [ "${max_files_saved}" = true ] ; then
|
||||||
# delete oldest vmcore file
|
for file in ${files_to_remove}; do
|
||||||
log "removing oldest vmcore file: ${oldest_vmcore}"
|
# delete old vmcore file
|
||||||
rm -rf "${CRASH_BUNDLE_DIR}/${oldest_vmcore}"
|
log "removing old vmcore file: ${file}"
|
||||||
|
rm -rf "${CRASH_BUNDLE_DIR}/${file}"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
log "creating bundle from ${entry}"
|
log "creating bundle from ${entry}"
|
||||||
${IONICE_CMD} ${NICE_CMD} ${TAR_CMD} ${OTHER_BUNDLE}_${time}.tar -C ${CRASH_DIR} $(basename ${entry})
|
${IONICE_CMD} ${NICE_CMD} ${TAR_CMD} ${OTHER_BUNDLE}_${time}.tar -C ${CRASH_DIR} $(basename ${entry})
|
||||||
@ -284,7 +293,11 @@ while [[ $# -gt 0 ]]; do
|
|||||||
|
|
||||||
--min-available)
|
--min-available)
|
||||||
shift
|
shift
|
||||||
min_available=$(${NUMFMT_FROM_HR} "$(normalize_size_format "${1}")")
|
if [ "${1}" = "${DEFAULT}" ]; then
|
||||||
|
min_available=""
|
||||||
|
else
|
||||||
|
min_available=$(${NUMFMT_FROM_HR} "$(normalize_size_format "${1}")")
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
13
mtce/src/scripts/crash-dump-manager.service
Normal file
13
mtce/src/scripts/crash-dump-manager.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Crash Dump Manager
|
||||||
|
After=network.target config.target
|
||||||
|
Before=sshd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=no
|
||||||
|
EnvironmentFile=/etc/default/crash-dump-manager
|
||||||
|
ExecStart=/usr/sbin/crash-dump-manager --max-size $MAX_SIZE --max-files $MAX_FILES --max-used $MAX_USED --min-available $MIN_AVAILABLE
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
4
mtce/src/scripts/crash-dump-manager_envfile
Normal file
4
mtce/src/scripts/crash-dump-manager_envfile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
MAX_FILES=4
|
||||||
|
MAX_SIZE=5Gi
|
||||||
|
MAX_USED=unlimited
|
||||||
|
MIN_AVAILABLE=default
|
@ -1,12 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Crash Dump Manager
|
|
||||||
After=network.target
|
|
||||||
Before=sshd.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
RemainAfterExit=no
|
|
||||||
ExecStart=/etc/init.d/crashDumpMgr --max-size 5Gi
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,14 +1,12 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2020-2021 Wind River Systems, Inc.
|
# Copyright (c) 2020-2021,2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
/var/log/crash/vmcore.tar
|
/var/log/crash/vmcore_*.tar
|
||||||
/var/log/crash/vmcore_first.tar
|
|
||||||
{
|
{
|
||||||
size 1K
|
size 1K
|
||||||
start 1
|
start 1
|
||||||
rotate 1
|
|
||||||
missingok
|
missingok
|
||||||
notifempty
|
notifempty
|
||||||
compress
|
compress
|
||||||
|
Loading…
Reference in New Issue
Block a user