Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
NUT -> upslog not working?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1746

PostPosted: Fri Dec 04, 2015 12:55 am    Post subject: NUT -> upslog not working? Reply with quote

Does anyone here use NUT?

I have been using it for some time and it's working fine; I have two UPS' connected over the network and am getting stats from them etc.

I wanted to start logging the telemetry so I can make some pretty graphs of the voltage fluctuations etc, but have gotten a bit stuck with the upslog program.

I can get it to work if I run it manually with the right params, but if I run it via. init.d, I get:

Code:

# /etc/init.d/upslog start
 * Starting upslog ...
 * start-stop-daemon: failed to start `/usr/bin/upslog'                   [ !! ]
 * ERROR: upslog failed to start


I suspect this is because it isn't set up, but I can't find a config file - There seems to be no documentation other than a single manpage entry for upslog, which mentions no config files, nor is there anything in /etc/conf.d or /etc/nut that look like it might be relevant.

Right now I'm thinking I should just kludge the /etc/init.d/upslog with the same command line that works when I run it manually; Just wanted a second opinion from someone in case I'm just being stupid.

What say ye??
Back to top
View user's profile Send private message
bbgermany
Veteran
Veteran


Joined: 21 Feb 2005
Posts: 1795
Location: Oranienburg/Germany

PostPosted: Fri Dec 04, 2015 9:00 am    Post subject: Reply with quote

Hi,

did you try to run "upslog" directly in your console and check for errors? Since I dont have an UPS running atm, I only get the following:

Code:

$ upslog
Network UPS Tools upslog 2.7.3
No UPS defined for monitoring - use -s <system>
$


greets, bb
_________________
1st: i5-4570, 16GB, 1.75TB
2nd: i5-4570, 16GB, 620GB
3rd: i5-4570, 16GB, 10,5TB
4th: Asus N61VN, 8GB, 240GB
5th: C2D T7200, 2GB, 16GB USB + NFS
Back to top
View user's profile Send private message
boozo
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3193

PostPosted: Fri Dec 04, 2015 11:28 am    Post subject: Reply with quote

Hi,

(Errf! thanks for the reminder... I should have done a report on b.g.o or an howto more than a year :oops: )

If I remember right, the problem come from ups{log,mon} init script (and/or their config files)
so maybe compare with mine ? :)

  • /etc/init.d/upslog
    Code:
    #!/sbin/runscript
    # Copyright 1999-2013 Gentoo Foundation
    # Distributed under the terms of the GNU General Public License v2
    # $Header: /var/cvsroot/gentoo-x86/sys-power/nut/files/nut-2.6.5-init.d-upslog,v 1.1 2013/08/12 18:35:12 robbat2 Exp $

    extra_started_commands="reload"

    depend() {
       use upsdrv
       after upsdrv
    }

    checkconfig() {
       if [ ! -f /etc/conf.d/upslog ] ; then
          eerror "Please create /etc/conf.d/upslog file"
          return 1
       fi
       return 0
    }

    start() {
       checkconfig || return $?

       ebegin "Starting upslog"
       start-stop-daemon --start --exec /usr/bin/upslog \
          --pidfile /var/run/upslog.pid \
          -- -p /var/run/upslog.pid ${UPSLOG_OPTS}
       eend $? "Failed to start upslog"
    }
     
    stop() {
       ebegin "Stopping upslog"
       start-stop-daemon --stop --quiet --pidfile /var/run/upslog.pid \
          --exec /usr/bin/upslog
       eend $? "Failed to stop upslog"
    }

    reload() {
       ebegin "Reloading upslog"
       start-stop-daemon --stop --signal HUP --oknodo --quiet \
          --pidfile /var/run/upslog.pid
       eend $?
    }

  • /etc/init.d/upsmon
    Code:
    #!/sbin/runscript
    # Copyright 1999-2013 Gentoo Foundation
    # Distributed under the terms of the GNU General Public License v2
    # $Id$

    extra_started_commands="reload"

    pidfile=/var/run/upsmon.pid
    bin=/usr/sbin/upsmon

    depend() {
       use net
    }

    start() {
       ebegin "Starting upsmon"
       start-stop-daemon --start --quiet --exec ${bin}
       eend $?
    }

    stop() {
       ebegin "Stopping upsmon"
       start-stop-daemon --stop --quiet --pidfile ${pidfile}
       eend $?
    }
    reload() {
       ebegin "Reloading upsmon"
       start-stop-daemon --stop --signal HUP --oknodo --quiet --pidfile ${pidfile}
       eend $?
    }

  • /etc/conf.d/upslog
    Code:
    UPSLOG_OPTS="-s eaton800@<hostname> -u <nut_username> -i 60 -l /var/log/upslog_eaton800.log"

  • # rc-update
    Code:
    (snip)
                   upsd   |      default                 
                   upsdrv |      default                 
                   upslog |      default                 
                   upsmon |      default   
    (snip)     


---- ps: I'm so sorry for my bad english ----
---- ps2: If this help, feel free to report it on b.g.o ----


Aside, an example from an Eaton EllipseEco 800 and a Nut server in standalone mode with ssl activated - I have a special user for nut and "Eaton800" is the ups name -
package.use (extract) wrote:
sys-power/nut -* ups_drivers_usbhid-ups ssl tcpd usb xml


/var/log/messages (extract) wrote:
usbhid-ups[1868]: Startup successful
upsd[1892]: listening on ::1 port 3493
upsd[1892]: listening on <hostname> port 3493
upsd[1892]: Connected to UPS [eaton800]: usbhid-ups-eaton800
upsd[1893]: Startup successful
upslog[1913]: Startup successful
upsmon[1933]: Startup successful
upsmon[1934]: Connected to <hostname> in SSL


Code:
$ ls -al /etc/nut/
total 60
drwxr-xr-x  3 root root   119  9 sept. 20:13 .
drwxr-xr-x 82 root root  8192 30 nov.  18:58 ..
drwxr-xr-x  2 root root    38 30 oct.   2014 certs
-rw-r--r--  1 root root  1544 28 oct.   2014 nut.conf
-rw-r--r--  1 root root  4878  9 sept. 20:09 ups.conf
-rw-r-----  1 root nut   4693 30 oct.   2014 upsd.conf
-rw-r-----  1 root nut   2413 30 oct.   2014 upsd.users
-rw-r-----  1 root nut  15365  9 sept. 20:12 upsmon.conf
-rw-r--r--  1 root root  4569 30 oct.   2014 upssched.conf


      /etc/nut/upsd.conf wrote:
      MAXAGE 15
      STATEPATH /var/lib/nut
      LISTEN <hostname> 3493
      LISTEN ::1 3493
      MAXCONN 1024
      CERTFILE /etc/nut/certs/upsd.pem

      /etc/nut/upsd.users wrote:
      [nut]
      password = <your_passwd>
      actions = SET
      instcmds = ALL

      [<nut_username>]
      password = <nut_username_passwd>
      upsmon master
      instcmds = shutdown.return
      instcmds = shutdown.stayoff
      instcmds = shutdown.stop

      /etc/nut/upsmon.conf wrote:
      RUN_AS_USER <nut_username>
      MONITOR eaton800@<host_name> 1 <nut_username> <nut_username_passwd> master
      MINSUPPLIES 1
      SHUTDOWNCMD "/sbin/shutdown -h +0"
      NOTIFYCMD /usr/bin/upsshed
      POLLFREQ 5
      POLLFREQALERT 5
      HOSTSYNC 15
      DEADTIME 15
      POWERDOWNFLAG /etc/killpower
      NOTIFYMSG ONLINE "UPS %s on line power"
      NOTIFYMSG ONBATT "UPS %s on battery"
      NOTIFYMSG LOWBATT "UPS %s battery is low"
      NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
      NOTIFYMSG COMMOK "Communications with UPS %s established"
      NOTIFYMSG COMMBAD "Communications with UPS %s lost"
      NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding"
      NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
      NOTIFYMSG NOCOMM "UPS %s is unavailable"
      NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"
      NOTIFYFLAG ONLINE SYSLOG
      NOTIFYFLAG ONBATT SYSLOG
      NOTIFYFLAG LOWBATT SYSLOG
      NOTIFYFLAG FSD SYSLOG
      NOTIFYFLAG COMMOK SYSLOG
      NOTIFYFLAG COMMBAD SYSLOG
      NOTIFYFLAG SHUTDOWN SYSLOG
      NOTIFYFLAG REPLBATT SYSLOG
      NOTIFYFLAG NOCOMM SYSLOG
      NOTIFYFLAG NOPARENT SYSLOG
      RBWARNTIME 43200
      NOCOMMWARNTIME 300
      FINALDELAY 5
      CERTPATH /etc/nut/certs
      CERTVERIFY 1
      FORCESSL 1



n.b.: Cherry on the pudding: my tiny notes if you really want to activate SSL for monitor
Code:
### Generate Openssl CRT and KEY server
$ openssl req -new -x509 -nodes -days 365 -out upsd.crt -keyout upsd.key
// n.b. Verifying : $ openssl x509 -enddate -noout -in <file>

### Use the following command to determine the hash of the certificate 8 hex characters (i.e. 8 hex characters)
$ openssl x509 -hash -noout -in upsd.crt

### Install the client-side certificate
# mkdir /etc/nut/certs
# chmod 0750 /etc/nut/certs
# cp upsd.crt /etc/nut/certs/<hex_hash_cert>.0
// n.b. If necessary : increment last file number (.0->.1->.2-> ...) until you get a unique filename that works

### Create the combined file for upsd
# cat upsd.crt upsd.key > upsd.pem
# chown root:nut upsd.pem
# chmod 0640 upsd.pem

### Install the server-side certificate
# mv upsd.pem /etc/nut/certs/upsd.pem
//Edit upsd.conf and specify $CERTFILE /path/to/upsd.pem
//n.b. Verifying the rights on directories and files

### Clean up the temporary files
# rm upsd.crt upsd.key


Edit: typos, bbcode, and forgot a conf. file...
_________________
" Un psychotique, c'est quelqu'un qui croit dur comme fer que 2 et 2 font 5, et qui en est pleinement satisfait.
Un névrosé, c'est quelqu'un qui sait pertinemment que 2 et 2 font 4, et ça le rend malade ! "
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1746

PostPosted: Sat Dec 05, 2015 10:51 am    Post subject: Reply with quote

bbgermany wrote:
Hi,

did you try to run "upslog" directly in your console and check for errors? Since I dont have an UPS running atm, I only get the following:

Code:

$ upslog
Network UPS Tools upslog 2.7.3
No UPS defined for monitoring - use -s <system>
$


greets, bb

Thanks :)

This is normal as, even if you have your UPS set up, you need to specify all the info about it to upslog as it doesn't seem to take a config file?

My problem is I can't see a way of providing this info to the init.d launch one, short of editing the init.d/upslog script, which is a nasty hacky way of doing things, and will probably get nuked by portage next time it updates NUT :S
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1746

PostPosted: Sat Dec 05, 2015 11:13 am    Post subject: Reply with quote

boozo wrote:
Hi,

(Errf! thanks for the reminder... I should have done a report on b.g.o or an howto more than a year :oops: )

If I remember right, the problem come from ups{log,mon} init script (and/or their config files)
so maybe compare with mine ? :)

[list][*]/etc/init.d/upslog
Code:
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/nut/files/nut-2.6.5-init.d-upslog,v 1.1 2013/08/12 18:35:12 robbat2 Exp $

extra_started_commands="reload"

depend() {
   use upsdrv
   after upsdrv
}

checkconfig() {
   if [ ! -f /etc/conf.d/upslog ] ; then
      eerror "Please create /etc/conf.d/upslog file"
      return 1
   fi
   return 0
}

start() {
   checkconfig || return $?

   ebegin "Starting upslog"
   start-stop-daemon --start --exec /usr/bin/upslog \
      --pidfile /var/run/upslog.pid \
      -- -p /var/run/upslog.pid ${UPSLOG_OPTS}
   eend $? "Failed to start upslog"
}
 
stop() {
   ebegin "Stopping upslog"
   start-stop-daemon --stop --quiet --pidfile /var/run/upslog.pid \
      --exec /usr/bin/upslog
   eend $? "Failed to stop upslog"
}

reload() {
   ebegin "Reloading upslog"
   start-stop-daemon --stop --signal HUP --oknodo --quiet \
      --pidfile /var/run/upslog.pid
   eend $?
}


Ah, yes! Your init.d/upslog is very different to mine - The checkconfig section is missing completely and the start section is different and missing all the params in my one!
I've copied your one over mine - This is a much more elegant way of feeding it the configs :)

Thanks so much! :D



For comparison, mine looked like this:
Code:
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/nut/files/nut-2.6.5-init.d-upslog,v 1.1 2013/08/12 18:35:12 robbat2 Exp $

extra_started_commands="reload"

pidfile=/var/run/upslog.pid
bin=/usr/bin/upslog

depend() {
   use upsdrv
   after upsdrv
}

checkconfig() {
   if [ ! -f /etc/conf.d/upslog ] ; then
      eerror "Please create /etc/conf.d/upslog file"
      return 1
   fi
   return 0
}

start() {
   ebegin "Starting upslog"
   start-stop-daemon --start --quiet --exec ${bin}
   eend $?
}

stop() {
   ebegin "Stopping upslog"
   start-stop-daemon --stop --quiet --pidfile ${pidfile}
   eend $?
}
reload() {
   ebegin "Reloading upslog"
   start-stop-daemon --stop --signal HUP --oknodo --quiet --pidfile ${pidfile}
   eend $?
}


There is one fly in the ointment tho' - I have two UPS that I wish to monitor but the way init.d/upslog is set up it'll only let me monitor one.

I'm not sure what the best solution is here; The more elegant way might be rejigging the init.d to launch multiple processes based on entries in the conf.d/upslog.

The quick and dirty way tho' is to copy it to upslog2 and tweak that to use a different PID and conf file :)

For now I'm playing with the format string as despite both UPS being made by APC they seem to spit out very different sets of data!
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 4334
Location: Dallas area

PostPosted: Sat Dec 05, 2015 12:53 pm    Post subject: Reply with quote

You can start the upslog program yourself, you don't need to use /etc/init.d/upslog.
That way you can monitor different ups
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.1 (no-pie & modified) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
boozo
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3193

PostPosted: Sat Dec 05, 2015 3:06 pm    Post subject: Reply with quote

What ? a fly problem too ? :lol:

For sure, an oneliner or a simple loop in script can do the job (i.e. create slaved users and parse a config file with all the $MONITOR ...)

I don't have a better way at the moment but anyway have a look here (see from 6.4 paragraph to 6.5 -> Typical setups for big servers with UPS redundancy) for working with more than 1 ups.

I'll have do some search about "upslog-ing" this use case. I'll post here if I find something interesting :wink:
_________________
" Un psychotique, c'est quelqu'un qui croit dur comme fer que 2 et 2 font 5, et qui en est pleinement satisfait.
Un névrosé, c'est quelqu'un qui sait pertinemment que 2 et 2 font 4, et ça le rend malade ! "
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1746

PostPosted: Sat Dec 05, 2015 6:54 pm    Post subject: Reply with quote

@Boozo - Yeah, the upsmon is quite flexible for multiple and layered UPS setups; By comparison upslog fees like it was added as an afterthought as the documentation for it is very thin on the ground.

@Moosey - That's what I'm doing at the moment!! :lol:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum