#!/usr/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/nut-show-status - show nut status # # 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. #---------------------------------------------------------------------------------- # load eislib etc. . /var/install/include/eislib #exec 2>/tmp/nut-show-status-trace-$$.log #set -x module_name='nut' tmp_file=/tmp/nut-show-status.${module_name} . /etc/config.d/${module_name} # debug #NUT_CLIENT_MODE='yes' #NUT_CLIENT_UPSMON_UPSNAME='ups' #NUT_CLIENT_UPSMON_SERVER_IP='192.168.1.11' if [ "${START_NUT}" = "yes" ] then if [ "${NUT_CLIENT_MODE}" = "yes" ] then echo "${NUT_CLIENT_UPSMON_SERVER_IP}" | grep -q ":" if [ $? -eq 0 ] then # ip address and port has been given ipaddr=`echo "${NUT_CLIENT_UPSMON_SERVER_IP}" | cut -d: -f1` ipport=`echo "${NUT_CLIENT_UPSMON_SERVER_IP}" | cut -d: -f2` if [ -z "${ipport}" ] then ipport="3493" fi else # only an ip address has been given ipaddr="${NUT_CLIENT_UPSMON_SERVER_IP}" ipport="3493" fi elif [ "${NUT_SERVER_MODE}" = "yes" ] then ipaddr='127.0.0.1' echo "${NUT_SERVER_LISTEN_ADDRESSES}" | grep -q "127.0.0.1" if [ $? -eq 0 ] then ipport=`echo "${NUT_SERVER_LISTEN_ADDRESSES}" | 's#^.*127\.0\.0\.1:\([[:digit:]]*\),.*$#\1#'` else ipport='3493' fi fi ups_lines="`upsc -L ${ipaddr}:${ipport} | tr '\n' ','`" { echo "Available UPSes:" echo _ifs="${IFS}" IFS=',' for UPS in ${ups_lines} do echo "--------------------------------------------------" echo "${UPS}" echo "--------------------------------------------------" ups_name=`echo "${UPS}" | cut -d: -f1` echo echo "List of connected clients:" echo upsc -c ${ups_name}@${ipaddr}:${ipport} echo echo "Variables:" echo upsc ${ups_name}@${ipaddr}:${ipport} echo upscmd -l ${ups_name}@${ipaddr}:${ipport} echo done IFS=${_ifs} echo "done." } > ${tmp_file} /var/install/bin/show-doc.cui --title 'Show ups status' ${tmp_file} rm -f ${tmp_file} fi exit 0