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