#!/usr/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/nut-pre-view-log - extract log information # # Copyright (c) 2014-2024 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2014-04-20 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------------- # exec 2>/tmp/nut-pre-view-log-trace-$$.log # set -x module_name=nut log_file=/var/log/messages log_tmp_file=/var/log/messages.${module_name} . /etc/config.d/${module_name} idx=1 driver_list='' while [ ${idx} -le ${NUT_SERVER_N} ] do eval archive='$NUT_SERVER_'${idx}'_ACTIVE' if [ "${archive}" = "yes" ] then eval driver='$NUT_SERVER_'${idx}'_DRIVER' echo "${driver_list}" | grep -q " ${driver}\\\\\[ " if [ $? -ne 0 ] then # not in list, add it driver_list="${driver_list} ${driver}\[|" fi fi idx=`expr ${idx} + 1` done grep -E -h "${driver_list} upsd\[| upsmon\[| upssched\[| upssched-cmd\[" ${log_file} > ${log_tmp_file} if [ $? -ne 0 ] then echo "Info: Nothing has been logged until now." > ${log_tmp_file} fi