1#!/bin/bash
2#
3# config: 123 20
4# @brief: Collect host's logs
5#
6
7. ${DREPORT_INCLUDE}/functions
8
9DESCRIPTION="Host logs"
10LOGS_PATH="/var/lib/obmc/hostlogs"
11
12if [[ -d ${LOGS_PATH} ]]; then
13  # Manual flush of the log buffer for all service instances
14  INSTANCES="$(systemctl list-units --type=service --state=running --full | \
15               awk '/hostlogger@/{print $1}')"
16  for SVC in ${INSTANCES}; do
17    log_info "Flush ${SVC}..."
18    if ! systemctl kill --signal SIGUSR1 ${SVC}; then
19      log_warning "Unable to flush ${SVC}"
20    fi
21  done
22
23  # Copy log directory
24  add_copy_file "${LOGS_PATH}" "${DESCRIPTION}"
25fi
26