Lee Marzke on 14 Nov 2009 09:11:58 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] CyberPower UPS-- "powerpanel" monitoring software segfaults


Greg Helledy wrote:
>> I know nothing about that model UPS, but I'd highly recommend trying the 
>> Network UPS Tools (NUT) package:
>>
>> 	http://www.networkupstools.org/
>>
>> A google search for "cyberpower CP550SL nut" suggests that other people have 
>> successfully used that UPS with NUT.
>>
>>
>>     
>
> I have installed nut, gone through the steps creating configuration 
> files, and gotten it working, sort of.  I used the directions here:
> http://blog.shadypixel.com/monitoring-a-ups-with-nut-on-debian-or-ubuntu-linux/
>
> I have two issues:
> 1.  The software doesn't seem to be loading at startup.  If I execute 
> the "upsdrvctl start" command, I do get:
>
> itchy:/etc/nut# upsdrvctl start
> Network UPS Tools - UPS driver controller 2.2.2
> Network UPS Tools: 0.29 USB communication driver - core 0.33 (2.2.2)
>
>
> I fired up the SysVInit tool KSysV.  Service "nut" is listed as starting 
> up at runlevel 5, but the following are not, nor are they listed in the 
> services I can choose from to add:  upsdrvctl, upsd, upsmon
>
> 2.  The gui monitoring tool, KNutClient, can't establish a connection 
> with the device even after I execute "upsdrvctl start".  The address I 
> entered is "CP550HG".
>
> The files I think are relevant are:
>
> # /etc/nut/ups.conf
> [CP550HG]
> driver = usbhid-ups
> port = auto
>
> # /etc/nut/upsd.conf
> ACL all 0.0.0.0/0
> ACL localhost 127.0.0.1/32
> ACCEPT localhost
> REJECT all
>
> # /etc/nut/upsd.users
> [local_mon]
>      password = (password snipped)
>      allowfrom = localhost
>      upsmon master
>
> # /etc/nut/upsmon.conf
> MONITOR CP550HG@localhost 1 local_mon (password snipped) master
> POWERDOWNFLAG /etc/killpower
> SHUTDOWNCMD "/sbin/shutdown -h now"
>
> This is a Debian Lenny machine with all updates applied.
> Kernel is 2.6.26-2-686
> KDE is 3.5.10
>
> Any insights would be appreciated.
>
> Greg
>
>   
Did you start upsmon ?

Was there a SysV startup script ?

Here is an old SysV script that might help,  I think this is from a
RedHat system.
But you can run things manually by reference to the script.

Lee Marzke

===

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          nut
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Network UPS Tools initscript
# Description:       This script take care of starting and stopping the
#                    Network UPS Tools components. When needed, it also
#                    handle the UPS hardware shutdown.
### END INIT INFO

# Author: Arnaud Quette <aquette@debian.org>

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
NAME=nut
DESC="Network UPS Tools"
DEFAULT=/etc/default/nut
. /lib/lsb/init-functions

[ -f $DEFAULT ] || exit 0
. $DEFAULT

pid_dir=/var/run/nut
upsmon_pid=${pid_dir}/upsmon.pid
upsd_pid=${pid_dir}/upsd.pid
upsd=/usr/local/sbin/upsd
upsmon=/usr/local/sbin/upsmon
log=">/dev/null 2>/dev/null"

# Check if /var/run/nut exists and has the correct perms
check_var_directory() {
    [ ! -d ${pid_dir} ] && mkdir -p ${pid_dir} \
        && chown root:nut ${pid_dir} \
        && chmod 770 ${pid_dir}
}

start_stop_server () {
  case "$START_UPSD" in
    y|Y|yes|YES|Yes)
      case "$1" in
        start)
          ! /usr/local/bin/upsdrvctl start >/dev/null 2>&1  &&  \
            log_progress_msg "(upsdrvctl failed)" || log_progress_msg
"upsdrvctl"
          start-stop-daemon -S -q -p $upsd_pid -x $upsd >/dev/null 2>&1
          ;;
        stop)
      upsd -c stop >/dev/null 2>&1
          #OUT start-stop-daemon -K -o -q -p $upsd_pid -n upsd
>/dev/null 2>&1
          ! /usr/local/bin/upsdrvctl stop >/dev/null 2>&1  &&  \
            log_progress_msg "(upsdrvctl failed)" || log_progress_msg
"upsdrvctl"
          ;;
      esac
      ;;
    n|N|no|NO|No|*)
      return 1
      ;;
  esac
}

start_stop_client () {
  case "$START_UPSMON" in
    y|Y|yes|YES|Yes)
      case "$1" in
        start)
          start-stop-daemon -S -q -p $upsmon_pid -x $upsmon >/dev/null 2>&1
          ;;
        stop)
      upsmon -c stop
          #start-stop-daemon -K -o -q -p $upsmon_pid -n upsmon
>/dev/null 2>&1
          ;;
      esac
      ;;
    n|N|no|NO|No|*)
      return 1
      ;;
  esac
}

case "$1" in

  start)
    log_daemon_msg "Starting $DESC"
    check_var_directory
    start_stop_server start && log_progress_msg "upsd"
    start_stop_client start && log_progress_msg "upsmon"
    log_end_msg 0
    ;;

  stop)
    log_daemon_msg "Stopping $DESC"
    start_stop_server stop && log_progress_msg "upsd"
    start_stop_client stop && log_progress_msg "upsmon"
    log_end_msg 0
    ;;

  reload)
    $upsd   -c reload >/dev/null 2>&1
    $upsmon -c reload >/dev/null 2>&1
    ;;

  restart|force-reload)
    log_daemon_msg "Restarting $DESC"
    start_stop_client stop
    start_stop_server stop
    sleep 5
    check_var_directory
    start_stop_server start && log_progress_msg "upsd"
    start_stop_client start && log_progress_msg "upsmon"
    log_end_msg 0
    ;;

  poweroff)
    flag=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p' /etc/nut/upsmon.conf`
    wait_delay=`sed -ne 's#^ *POWEROFF_WAIT= *\(.*\)$#\1#p'
/etc/default/nut`
    if [ -f "$flag" ] ; then
      if /usr/local/sbin/upsmon -K >/dev/null 2>&1 ; then
    log_daemon_msg "Shutting down the UPS ..."
    sleep 1
    if /usr/local/bin/upsdrvctl shutdown ; then
      sleep 5
      log_progress_msg "Waiting for UPS to cut the power"
      log_end_msg 0
    else
      log_progress_msg "Shutdown failed."
      log_progress_msg "Waiting for UPS batteries to run down"
      log_end_msg 0
    fi
    if [ "$wait_delay" ] ; then
      log_daemon_msg " (will reboot after $wait_delay) ..."
      sleep "$wait_delay"
      /etc/init.d/reboot
    fi
      else
        log_daemon_msg "Power down flag is not set (UPS shutdown not
needed)"
      fi
    else
        if [ -z "$flag" ] ; then
      log_daemon_msg  
"##########################################################"
      log_progress_msg "## POWERDOWNFLAG is not defined in
/etc/nut/upsmon.conf ##"
      log_progress_msg
"##                                                      ##"
      log_progress_msg "## Please read the Manual page
upsmon.conf(5)           ##"
      log_progress_msg
"##########################################################"
      log_end_msg 0
        fi
    fi
    ;;

  *)
    N=/etc/init.d/$NAME
    log_daemon_msg "Usage" "$N
{start|stop|reload|restart|force-reload|poweroff}" >&2
    log_end_msg 0
    exit 1
    ;;

esac

exit 0



___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug