Enhance the systemd collect plugin to gather more systemd init data
This update adds the following systemd-analyze commands to the systemd
collect plugin to help debug initialization issues:
- systemd-analyze
- systemd-analyze blame
- systemd-analyze critical-chain
This update also fixes a silently handled syntax bug in the recently
added run_command from update [1] related to the sleep_time variable.
This update also fixes the current systemd-analyze plot command that
was broken by calling it by the run_command by the same update [1].
[1] https://review.opendev.org/c/starlingx/utilities/+/936202
Test Plan:
PASS: Verify collect package build and install
PASS: Verify shellcheck static analysis
PASS: Verify manual run of the updated collect_sustemd plugin
PASS: Verify collect, including content, from a local & remote host
Closes-Bug: 2111344
Change-Id: Ia362abb4a66fc0d860a312a2326459bca196c569
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
@@ -1,24 +1,51 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# Copyright (c) 2024 Wind River Systems, Inc.
|
||||
# Copyright (c) 2024-2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# Loads Up Utilities and Commands Variables
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/local/sbin/collect_parms
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/local/sbin/collect_utils
|
||||
|
||||
# set defaults for shellcheck
|
||||
: "${extradir:=/tmp}"
|
||||
: "${hostname:=$(hostname)}"
|
||||
|
||||
SERVICE="systemd"
|
||||
LOGFILE="${extradir}/${SERVICE}.info"
|
||||
DEPFILE="${extradir}/${SERVICE}_service_dependencies.info"
|
||||
PLOTFILE="${extradir}/${SERVICE}-startup-plot.svg"
|
||||
PLOTCMD="timeout 10 systemd-analyze plot > ${PLOTFILE}"
|
||||
|
||||
###############################################################################
|
||||
# Systemd analysis
|
||||
###############################################################################
|
||||
echo "${hostname}: Systemd analyze .........: ${LOGFILE}"
|
||||
echo "extra:${extradir} and hostname:${hostname}"
|
||||
|
||||
run_command "timeout 10 systemd-analyze plot > ${PLOTFILE}" "${LOGFILE}"
|
||||
delimiter "${LOGFILE}" "${PLOTCMD}"
|
||||
eval "${PLOTCMD}"
|
||||
|
||||
run_command "timeout 10 systemd-analyze" "${LOGFILE}"
|
||||
run_command "timeout 10 systemd-analyze blame" "${LOGFILE}"
|
||||
run_command "timeout 10 systemd-analyze critical-chain" "${LOGFILE}"
|
||||
run_command "timeout 10 systemd-analyze critical-chain --fuzz=1s" "${LOGFILE}"
|
||||
{
|
||||
echo "$(date): Collecting systemd service dependencies ; declared and inherited"
|
||||
echo ""
|
||||
|
||||
# Loop over all installed services (active + inactive)
|
||||
while read -r svc _
|
||||
do
|
||||
echo -e "\n### Dependencies for: ${svc} ###"
|
||||
systemctl show "${svc}" --property=After,Before 2>> "${COLLECT_ERROR_LOG}"
|
||||
done < <(systemctl list-unit-files --type=service --no-legend 2>> "${COLLECT_ERROR_LOG}")
|
||||
|
||||
} > "${DEPFILE}"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2019, 2024 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2019, 2024-2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##########################################################################################
|
||||
|
||||
source /etc/collect/collect_timeouts
|
||||
@@ -331,22 +330,22 @@ function run_command () {
|
||||
secs=${duration%%.*}
|
||||
|
||||
if [ ${secs} -ge ${COLLECT_RUNCMD_XLARGE_THRESHOLD} ] ; then
|
||||
sleep_time ${COLLECT_RUNCMD_XLARGE_DELAY}
|
||||
sleep_time=${COLLECT_RUNCMD_XLARGE_DELAY}
|
||||
sleep_time_str="${COLLECT_RUNCMD_XLARGE_DELAY}"
|
||||
|
||||
elif [ ${secs} -gt ${COLLECT_RUNCMD_LARGE_THRESHOLD} ] ; then
|
||||
sleep_time ${COLLECT_RUNCMD_LARGE_DELAY}
|
||||
sleep_time=${COLLECT_RUNCMD_LARGE_DELAY}
|
||||
sleep_time_str="${COLLECT_RUNCMD_LARGE_DELAY}"
|
||||
|
||||
else
|
||||
msec=${duration#*.}
|
||||
|
||||
if [ ${msec} -gt ${COLLECT_RUNCMD_MEDIUM_THRESHOLD} ] ; then
|
||||
sleep_time ${COLLECT_RUNCMD_MEDIUM_DELAY}
|
||||
sleep_time=${COLLECT_RUNCMD_MEDIUM_DELAY}
|
||||
sleep_time_str="${COLLECT_RUNCMD_MEDIUM_DELAY}"
|
||||
|
||||
elif [ ${msec} -gt ${COLLECT_RUNCMD_SMALL_THRESHOLD} ] ; then
|
||||
sleep_time ${COLLECT_RUNCMD_SMALL_DELAY}
|
||||
sleep_time=${COLLECT_RUNCMD_SMALL_DELAY}
|
||||
sleep_time_str="${COLLECT_RUNCMD_SMALL_DELAY}"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user