Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

NUT -> upslog not working?

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
Cyker
Veteran
Veteran
Posts: 1746
Joined: Thu Jun 15, 2006 7:43 pm

NUT -> upslog not working?

  • Quote

Post by Cyker » Fri Dec 04, 2015 12:55 am

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: Select all

# /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??
Top
bbgermany
Veteran
Veteran
User avatar
Posts: 1844
Joined: Mon Feb 21, 2005 8:19 am
Location: Oranienburg/Germany

  • Quote

Post by bbgermany » Fri Dec 04, 2015 9:00 am

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: Select all

$ upslog
Network UPS Tools upslog 2.7.3
No UPS defined for monitoring - use -s <system>
$
greets, bb
Desktop: Ryzen 7 5800X, 32GB, 2TB, RX7700XT
Noebook: Dell XPS 13 9370, 16GB, 1TB
Server #1: Ryzen 5 Pro 4650G, 64GB, 16.5TB
Server #2: Ryzen 4800H, 32GB, 22TB
Top
boozo
Advocate
Advocate
User avatar
Posts: 3193
Joined: Thu Jul 01, 2004 8:35 am

  • Quote

Post by boozo » Fri Dec 04, 2015 11:28 am

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: Select all

    #!/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: Select all

    #!/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: Select all

    UPSLOG_OPTS="-s eaton800@<hostname> -u <nut_username> -i 60 -l /var/log/upslog_eaton800.log"
  • # rc-update

    Code: Select all

    (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: Select all

$ 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: Select all

### 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 ! "
Top
Cyker
Veteran
Veteran
Posts: 1746
Joined: Thu Jun 15, 2006 7:43 pm

  • Quote

Post by Cyker » Sat Dec 05, 2015 10:51 am

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: Select all

$ 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
Top
Cyker
Veteran
Veteran
Posts: 1746
Joined: Thu Jun 15, 2006 7:43 pm

  • Quote

Post by Cyker » Sat Dec 05, 2015 11:13 am

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 ? :)
  • /etc/init.d/upslog

    Code: Select all

    #!/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: Select all

#!/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!
Top
Anon-E-moose
Watchman
Watchman
User avatar
Posts: 6566
Joined: Fri May 23, 2008 7:31 pm
Location: Dallas area

  • Quote

Post by Anon-E-moose » Sat Dec 05, 2015 12:53 pm

You can start the upslog program yourself, you don't need to use /etc/init.d/upslog.
That way you can monitor different ups
UM780 xtx, 6.18 zen kernel, gcc 15, openrc, wayland
minixforum m1-s1 max -- same software as above but used for ai learning


Zealots are gonna be zealots, just like haters are gonna be haters
Top
boozo
Advocate
Advocate
User avatar
Posts: 3193
Joined: Thu Jul 01, 2004 8:35 am

  • Quote

Post by boozo » Sat Dec 05, 2015 3:06 pm

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 ! "
Top
Cyker
Veteran
Veteran
Posts: 1746
Joined: Thu Jun 15, 2006 7:43 pm

  • Quote

Post by Cyker » Sat Dec 05, 2015 6:54 pm

@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:
Top
Post Reply

8 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy