blob: 66701281863668e0982d12288c92304713d0bdd0 [file] [log] [blame]
Artem Senicheve8837d52020-06-07 11:59:04 +03001#!/bin/bash
2#
3# config: 123 20
4# @brief: Collect host's logs
5#
6
Patrick Williamsc8047cf2022-12-03 06:40:44 -06007# shellcheck source=/dev/null # library comes from phosphor-debug-collector repo.
Patrick Williamsdfee0da2021-04-13 21:38:11 -05008. "${DREPORT_INCLUDE}/functions"
Artem Senicheve8837d52020-06-07 11:59:04 +03009
10DESCRIPTION="Host logs"
11LOGS_PATH="/var/lib/obmc/hostlogs"
12
13if [[ -d ${LOGS_PATH} ]]; then
Patrick Williamsbb4e0932022-12-08 06:23:27 -060014 # Manual flush of the log buffer for all service instances
15 INSTANCES="$(systemctl list-units --type=service --state=running --full | \
Artem Senicheve8837d52020-06-07 11:59:04 +030016 awk '/hostlogger@/{print $1}')"
Patrick Williamsbb4e0932022-12-08 06:23:27 -060017 for SVC in ${INSTANCES}; do
18 log_info "Flush ${SVC}..."
19 if ! systemctl kill --signal SIGUSR1 "${SVC}"; then
20 log_warning "Unable to flush ${SVC}"
21 fi
22 done
Artem Senicheve8837d52020-06-07 11:59:04 +030023
Patrick Williamsbb4e0932022-12-08 06:23:27 -060024 # Copy log directory
25 add_copy_file "${LOGS_PATH}" "${DESCRIPTION}"
Artem Senicheve8837d52020-06-07 11:59:04 +030026fi