Re: [Nut-upsuser] UPS/NUT with openSUSE 13.1

2015-09-03 Thread Roger Price

On Thu, 3 Sep 2015, Rob Groner wrote:

I’ve followed your excellent guide for setting up NUT in openSUSE 13.1.  
I’ve had great luck IN THE PAST, but for some reason now that I am 
trying to set it up again from scratch, I’m getting a weird error.


Everything works except for the UPS shutdown.  I put the script in 
/usr/lib/system/system-shutdown and made it executable.  In fact, if I 
execute it manually...it will shut down the UPS (and then bring it back 
up).  However, if I shut down normally, either the script does not 
execute, or the UPS simply fails to receive it.  In a previous system 
when I did this, it worked perfectly (almost too well, as I’d sometimes 
forget when simply rebooting the system that it had commanded the UPS to 
shutdown 20 seconds later…).  Do you have any suggestions as to why the 
script works fine when I execute it manually, but doesn’t work when the 
system actually shuts down?


Hello Bob, I'll reply via the NUT mailing list since others may be 
interested, and the list will archive the discussion.


Putting the shutdown script in /usr/lib/system/system-shutdown so that 
systemd will execute it as late as possible makes it difficult to debug 
what happens, or doesn't happen, since when the script is executed, it is 
no longer possible to write out any trace statements.


So I suggest that temporarily you use the systemd service unit approach 
which will place a record in /var/log/messages. This is easier to debug. 
Once you have found out why the required shutdown has not happened, you 
can test the fix, and when it works go back to using a script in 
/usr/lib/system/system-shutdown


Don't forget that you will have to initialize the service unit with a 
command such as

  systemctl --system reenable /etc/systemd/system/ups-delayed-shutdown.service

Best Regards,
Roger___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] UPS/NUT with openSUSE 13.1

2015-09-03 Thread Rob Groner
Roger,

Thank you for the help.

I tried what you suggested, going the system service unit route.  Well...that 
works.  So unfortunately, it doesn't provide a lot of debugging information. 
But I guess it also gives me a method I can move forward with.

I had preferred the shutdown script method because it was a little more 
straight-forward, and possibly more portable.  This guide is meant to help 
people get the UPS up and running, whatever their Linux distro. I don't know 
how common the systemd implementation is across various Linux distros.  

The fact that I had the script working perfectly a few months ago makes me 
suspect this might be an openSUSE bug, and maybe that version I used back then 
had been updated.  Now that I have a working solution, I might let my install 
update overnight and then try the shutdown script again.  I assume that to undo 
the systemd service unit method, I do something like "systemctl --system 
disable /etc/syst.."?

Rob Groner
Software Engineer Level II

RTD Embedded Technologies, Inc.
ISO 9001 and AS9100 Certified
Ph: +1 814-234-8087
www.rtd.com

-Original Message-
From: Nut-upsuser 
[mailto:nut-upsuser-bounces+rgroner=rtd@lists.alioth.debian.org] On Behalf 
Of Roger Price
Sent: Thursday, September 03, 2015 11:18 AM
To: nut-upsuser Mailing List 
Subject: Re: [Nut-upsuser] UPS/NUT with openSUSE 13.1

On Thu, 3 Sep 2015, Rob Groner wrote:

> I’ve followed your excellent guide for setting up NUT in openSUSE 
> 13.1. I’ve had great luck IN THE PAST, but for some reason now that I 
> am trying to set it up again from scratch, I’m getting a weird error.
> 
> Everything works except for the UPS shutdown.  I put the script in 
> /usr/lib/system/system-shutdown and made it executable.  In fact, if I 
> execute it manually...it will shut down the UPS (and then bring it 
> back up).  However, if I shut down normally, either the script does 
> not execute, or the UPS simply fails to receive it.  In a previous 
> system when I did this, it worked perfectly (almost too well, as I’d 
> sometimes forget when simply rebooting the system that it had 
> commanded the UPS to shutdown 20 seconds later…).  Do you have any 
> suggestions as to why the script works fine when I execute it 
> manually, but doesn’t work when the system actually shuts down?

Hello Bob, I'll reply via the NUT mailing list since others may be interested, 
and the list will archive the discussion.

Putting the shutdown script in /usr/lib/system/system-shutdown so that systemd 
will execute it as late as possible makes it difficult to debug what happens, 
or doesn't happen, since when the script is executed, it is no longer possible 
to write out any trace statements.

So I suggest that temporarily you use the systemd service unit approach which 
will place a record in /var/log/messages. This is easier to debug. 
Once you have found out why the required shutdown has not happened, you can 
test the fix, and when it works go back to using a script in 
/usr/lib/system/system-shutdown

Don't forget that you will have to initialize the service unit with a command 
such as
   systemctl --system reenable /etc/systemd/system/ups-delayed-shutdown.service

Best Regards,
Roger
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] functional bug in code /clients/nutclient.cpp

2015-09-03 Thread Charles Lepple
On Sep 3, 2015, at 9:11 AM, Charles Lepple  wrote:
> 
> Which options are you passing to ./configure?

Just noticed that this defaults to "no":


./configure --help
[...]
  --with-dev  build and install the development files (no)


-- 
Charles Lepple
clepple@gmail



___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] functional bug in code /clients/nutclient.cpp

2015-09-03 Thread Charles Lepple
On Sep 1, 2015, at 4:26 AM, Paul Vermeer  wrote:
> 
> Hi nut users, (this is a re-send from the correct account)
>  
> With pleasure, I have been using the code provided. Managed to get all 
> working properly, except for the nutclient lib in C.

As you have noticed, nutclient has a few rough edges. The original upsclient 
library has had a lot more testing, although it is written in straight C.

Be careful with some of the other nutclient wrappers. There are try/catch 
blocks that mask exceptions.
 
> Both functions stringset_to_strarr and stringvector_to_strarr have a similar 
> bug in play. Although trivial in code, the coded function does not operate as 
> intended.
> The pointer increment is missing (see added line marked yellow below 
> [pstr++;]), which results in the same element being updated over and over 
> again, and then only leaving the last element of the list in the array.
 
I created an issue on Github to track this: 
https://github.com/networkupstools/nut/issues/232 


Should be easy to fix, but we also need to add some unit tests to keep this 
sort of thing from cropping up again.

> Kind regards, Paul Vermeer.
>  
>  
> (also I could not find out how to ‘install’ the include files properly using 
> the autogen.sh / .configure and make and make install scripts. – had to copy 
> them manually as I’m no expert in make scripts)
 
I was going to suggest that we should compare your settings to what Linux 
distributions do to package nutclient, but neither Debian nor Ubuntu has 
packaged it (only libupsclient*), and I haven't looked at other distributions 
yet. (This might be a sign...)

Which options are you passing to ./configure?

-- 
Charles Lepple
clepple@gmail



___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser