[Nut-upsuser] Premature end of script headers: upsimage.cgi

ben thielsen bthielsen at safarivideonetworks.com
Fri Jul 10 03:17:32 UTC 2009


Charles Lepple wrote:
> On Thu, Jul 9, 2009 at 6:31 PM, ben
> thielsen<bthielsen at safarivideonetworks.com> wrote:
>> Jean Delvare wrote:
> [...]
>>> You could try running upsimage.cgi manually, maybe you'll get a useful
>>> error message.
>> good idea, thanks.  i can't seem to figure out how though.  running the
>> program without any arguments produces output that seems to perhaps be the
>> beginnings of a png image, which would make sense, but it appears to be
>> incomplete.  i've tried a few approaches to passing arguments from the
>> shell, but none seem to have an impact on the output.
> 
> You might need to change "host=ups at example.org" to
> host=ups%40example.org" on the command line. (I don't have NUT set up
> on this machine, so I can't verify that, though.)
> 
>> some additional information - i've since added another smart-ups 1500 (not
>> xlm), connected via usb to this same server, and it draws the voltage graph
>> without incident.
> 
> Are both UPSes listed in /etc/nut/hosts.conf?
>

i believe i've made some progress here.

to answer your last question first, yes, both are listed in hosts.conf, 
and both appear as expected on the overview stats page.  the only 
difference between the two in terms of what's displayed is on the 
individual status pages, where the usb unit draws the voltage graph 
properly.

regarding execution of upsimage.cgi from a shell - after learning a bit 
more about cgi - as i understand it, variables/arguments are obtained 
from envvars set by the parent process.  so, i hijacked upsimage.cgi and 
collected the envvars set for both charge and voltage, to hopefully 
compare a working execution with the seemingly broken one and mirror 
apache's process as closely as possible.

i'm not 100% confident in my results at the moment, because i wasn't 
able to produce a valid png on the filesystem with my method, but there 
does seem to be some deviation between the two executions.  when called 
for voltage, upsimage.cgi prints "Floating point exception" to stderr 
and prints nothing to stout - whereas when called for charge, it doesn't 
complain to stderr, and prints what appear to be the beginnings of a 
png, preceded by:

Pragma: no-cache
Content-type: image/png
(and a blank line)

so there seems to at least be some indication of normal execution.  here 
is output:

charge:

 >source /var/www/wwwtmp/nut-charge_envvars_export.txt
bash: BASH_VERSINFO: readonly variable
bash: EUID: readonly variable
bash: PPID: readonly variable
bash: SHELLOPTS: readonly variable
bash: UID: readonly variable

 >./upsimage.cgi > /var/www/pics/charge.png 

 >

voltage:

 >source /var/www/wwwtmp/nut-voltage_envvars_export.txt 

bash: BASH_VERSINFO: readonly variable
bash: EUID: readonly variable
bash: PPID: readonly variable
bash: SHELLOPTS: readonly variable
bash: UID: readonly variable

 >./upsimage.cgi > /var/www/ltn.lvc.com/pics/voltage.png 

Floating point exception
 >

regrettably, i'm not quite sure what the next step might be here.

fwiw, i compiled upsimage.cgi from subversion/trunk and got the same 
result, although i simply dropped that single file in place as opposed 
to actually doing a make install.

regards
-ben



More information about the Nut-upsuser mailing list