New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RRDtool can generate errors to standard output which can corrupt images #2930
Comments
Good to know. What OS platform? Yea, and interesting. Looks like stderr is being redirected into stdout. |
Linux, Debian 10, PHP 7.3.4
igb@offsite9:~$ uname -a; cat /etc/debian_version ; php --version
Linux offsite9.batten.eu.org 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5+deb10u2 (2019-08-08) x86_64 GNU/Linux
10.0
PHP 7.3.4-2 (cli) (built: Apr 13 2019 19:05:48) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.4-2, Copyright (c) 1999-2018, by Zend Technologies
igb@offsite9:~$
… On 10 Sep 2019, at 11:10, Jimmy Conner ***@***.***> wrote:
Good to know. What OS platform? Yea, and interesting. Looks like stderr is being redirected into stdout.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#2930?email_source=notifications&email_token=AB4RBAJIIQQSXGEKB2ES77TQI5XBVA5CNFSM4IUZDGA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6KSN6A#issuecomment-529868536>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AB4RBANIPFRKDC7Q2HLJZCTQI5XBVANCNFSM4IUZDGAQ>.
|
* When working in pipe mode RRDtool appends stderr to stdout causing SVG graphing to break * Remove GIF87 as it's no longer supported
* When working in pipe mode RRDtool appends stderr to stdout causing SVG graphing to break * Removing GIF87 as it's no longer supported * Adding new Trim function
This should be resolved now. Please update lib/rrd.php and verify. |
Thanks, looks to be working. I will check in more depth in case there are other issues (the file differs in other, unrelated reasons lower down) but so far it looks good!
As an optimisation, would it be worth considering replacing
$okpos = strpos($output, 'OK u:');
with
$okpos = strpos($output, 'OK u:’, -50 /* or some similar value */);
?
As written, a search is going to be done over the SVG or PNG output of every invocation of rrdtool, which means every graph generated on every page load. As we know the string we are trying to trim is short, starting from close to the end of the string might be a worthwhile saving.
ian
… On 11 Sep 2019, at 03:03, Jimmy Conner ***@***.***> wrote:
This should be resolved now. Please update lib/rrd.php and verify.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#2930?email_source=notifications&email_token=AB4RBAL2FZF7KJ55M3HQSD3QJBGY5A5CNFSM4IUZDGA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6NAN6Y#issuecomment-530188027>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AB4RBALV52SKMDAMBC3BSZ3QJBGY5ANCNFSM4IUZDGAQ>.
|
In branch 1.2.x
In the apache2 log: |
OK, best to revert to Jimmy’s original fix. Presumably there are situations where the string that’s coming out of rrdtool is short, for some reason.
ian
… On 12 Sep 2019, at 15:17, Interduo ***@***.***> wrote:
2019/09/12 16:11:54 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_image.php[132]:rrdtool_function_graph(), /lib/rrd.php[2271]:rrdtool_execute(), /lib/rrd.php[242]:__rrd_execute(), /lib/rrd.php[359]:rrdtool_trim_output(), /lib/rrd.php[406]:strpos(), CactiErrorHandler())
--
2019/09/12 16:11:54 - ERROR PHP WARNING: strpos(): Offset not contained in string in file: /var/www/html/cacti/lib/rrd.php on line: 406
2019/09/12 16:11:46 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_image.php[132]:rrdtool_function_graph(), /lib/rrd.php[2271]:rrdtool_execute(), /lib/rrd.php[242]:__rrd_execute(), /lib/rrd.php[359]:rrdtool_trim_output(), /lib/rrd.php[406]:strpos(), CactiErrorHandler())
2019/09/12 16:11:46 - ERROR PHP WARNING: strpos(): Offset not contained in string in file: /var/www/html/cacti/lib/rrd.php on line: 406
2019/09/12 16:11:38 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_json.php[158]:rrdtool_function_graph(), /lib/rrd.php[2271]:rrdtool_execute(), /lib/rrd.php[242]:__rrd_execute(), /lib/rrd.php[359]:rrdtool_trim_output(), /lib/rrd.php[406]:strpos(), CactiErrorHandler())
2019/09/12 16:11:38 - ERROR PHP WARNING: strpos(): Offset not contained in string in file: /var/www/html/cacti/lib/rrd.php on line: 406
2019/09/12 16:11:38 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_json.php[158]:rrdtool_function_graph(), /lib/rrd.php[2271]:rrdtool_execute(), /lib/rrd.php[242]:__rrd_execute(), /lib/rrd.php[359]:rrdtool_trim_output(), /lib/rrd.php[406]:strpos(), CactiErrorHandler())
2019/09/12 16:11:38 - ERROR PHP WARNING: strpos(): Offset not contained in string in file: /var/www/html/cacti/lib/rrd.php on line: 406
2019/09/12 16:11:38 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_json.php[158]:rrdtool_function_graph(), /lib/rrd.php[2271]:rrdtool_execute(), /lib/rrd.php[242]:__rrd_execute(), /lib/rrd.php[359]:rrdtool_trim_output(), /lib/rrd.php[406]:strpos(), CactiErrorHandler())
2019/09/12 16:11:38 - ERROR PHP WARNING: strpos(): Offset not contained in string in file: /var/www/html/cacti/lib/rrd.php on line: 406
2019/09/12 16:11:38 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_json.php[158]:rrdtool_function_graph(), /lib/rrd.php[2271]:rrdtool_execute(), /lib/rrd.php[242]:__rrd_execute(), /lib/rrd.php[359]:rrdtool_trim_output(), /lib/rrd.php[406]:strpos(), CactiErrorHandler())
2019/09/12 16:11:38 - ERROR PHP WARNING: strpos(): Offset not contained in string in file: /var/www/html/cacti/lib/rrd.php on line: 406
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#2930?email_source=notifications&email_token=AB4RBAIALVS46SU5ED3TLT3QJJFNZA5CNFSM4IUZDGA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6SBIRQ#issuecomment-530846790>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AB4RBAJDEHHTEMAPL5J3273QJJFNZANCNFSM4IUZDGAQ>.
|
The function was actually not working. So, using a function that searches from the end, and passing by reference to for an additional speedup.
Describe the bug
Graphs of type SVG do not render; graphs of type PNG render correctly.
To Reproduce
Edit between SVG and PNG in Graph Templates; the graphs can be switched between rendering and producing an error.
Expected behavior
Graphs should render as they did on 1.2.5. Only change to system is switch from 1.2.5 to 1.2.6.
Screenshots
I have flicked everything to PNG other than the "Load Average" template. Once this is done, only the Load Average template fails to render.
Desktop (please complete the following information):
MacOS 10.14.6, latest Safari bits, latest Chrome bits (all unchanged since 1.2.5 was working).
Smartphone (please complete the following information):
n/a
Additional context
RRDtool 1.7.2 Copyright by Tobias Oetiker tobi@oetiker.ch
Compiled May 30 2019 23:12:11
The SVG file appears superficially correct: I have clicked "Save Image" from the broken image, and then opened the resulting SVG file with both Chrome and Safari, and it renders. However, it throws a warning:
"This page contains the following errors:
error on line 930 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error."
Looking at the saved SVG file, line 930 with cat -n is very suggestive:
924
925
926
927
928
929
930 OK u:0.03 s:0.00 r:0.02ians-macbook-air:Downloads igb$
The same has happened to the PNG files, but presumably PNG renderers are less fussy about stray characters:
ians-macbook-air:Downloads igb$ od -c cacti_graph_118.png | tail
0143120 7 227 307 あ ** ** 035 320 \a 201 374 \a \0 232 ! 024
0143140 \n ' M 232 d 354 U 364 017 270 \ 356 333 o 277 m
0143160 354 U \0 \0 9 360 371 037 \0 \0 \0
212 @ 376 003 0143200 \0 \0 \0 L 021 310 177 \0 \0 \0 200 ) 002 371 017 \0 0143220 \0 \0 0 E 8 g Μ ** 251 254 254 4 366 2 \0 \0 0143240 \0 \0 240 W 371 ? o $ 353 g 034 262 353 } \0 \0 0143260 \0 \0 I E N D 256 B
202 O K u : 00143300 . 0 5 s : 0 . 0 1 r : 0 . 0
0143320 5
0143321
ians-macbook-air:Downloads igb$
So it looks like a change has been made which causes part of the diagnostic calculations to be appended to images, which is accepted by PNG renders but not SVG renderers.
The problem can be localised to lib/rrd.php; I have replaced the 1.2.6 version with that taken from 1.2.5 and it fixes the problem. I then tried each patch in turn, and the problem is triggered by the changes in 14 lines starting at 289 which go from popen()ing the rrdtool command with the arguments on the command line, to popen()ing the rrdtool command reading from stdin and then passing the command in that way. I assume this somehow triggers different behaviour deeper in the code, which I do not have the skills to trace through. I am now running with the 1.2.6 lib/rrd.php but with the section from line 289 onwards replaced with the previous code from 1.2.5.
In summary: 1.2.6: does not render SVG. 1.2.6+ lib/rrd.php from 1.2.5: OK. Frankenstein version of 1.2.5 lib/rrd.php with the new code from line 289 onwards replaced with the corresponding code from 1.2.5: OK. And for confirmation, "cat -n | tail -2" on a saved version of one of the SVG graphs it now generates does not have the trailing CPU usage message.
The text was updated successfully, but these errors were encountered: