Using (pprof) web on a headless box

927 views
Skip to first unread message

Traun Leyden

unread,
Jan 22, 2015, 8:35:15 PM1/22/15
to golan...@googlegroups.com

I'm running CentOS 6 in a Docker container, and I'm not running an X Server on it.

When I try to run the "web" command I get:

(pprof) web
Total: 6962 samples
Dropping nodes with <= 34 samples; edges with <= 6 abs(samples)
Loading web page file:////tmp/nJ2VpkjSyr.0.svg
Can't exec "/etc/alternatives/gnome-www-browser": No such file or directory at /usr/lib/go/pkg/tool/linux_amd64/pprof line 743.
Can't exec "/etc/alternatives/x-www-browser": No such file or directory at /usr/lib/go/pkg/tool/linux_amd64/pprof line 743.
Can't exec "google-chrome": No such file or directory at /usr/lib/go/pkg/tool/linux_amd64/pprof line 743.
Can't exec "firefox": No such file or directory at /usr/lib/go/pkg/tool/linux_amd64/pprof line 743.
Could not load web browser.

And unfortunately it doesn't even save the file to /tmp/EmBAQVn6Kr.0.svg -- it seems like it deletes it after it fails to find a web browser.

I tried installing firefox, and it doesn't work there either:

(pprof) web
Total: 6962 samples
Dropping nodes with <= 34 samples; edges with <= 6 abs(samples)
Loading web page file:////tmp/o7Z_W5cOVJ.0.svg
Can't exec "/etc/alternatives/gnome-www-browser": No such file or directory at /usr/lib/go/pkg/tool/linux_amd64/pprof line 743.
Can't exec "/etc/alternatives/x-www-browser": No such file or directory at /usr/lib/go/pkg/tool/linux_amd64/pprof line 743.
Can't exec "google-chrome": No such file or directory at /usr/lib/go/pkg/tool/linux_amd64/pprof line 743.
Error: no display specified
Could not load web browser.

Is there any way to just tell it to dump an svg file to the filesystem rather than trying to open a web browser?


Caleb Spare

unread,
Jan 22, 2015, 8:42:25 PM1/22/15
to Traun Leyden, golang-nuts
Hi Traun,

$ go tool pprof -h 2>&1 | grep svg
-svg Outputs a graph in SVG format

I haven't used that, but it seems like it ought to work.

-Caleb
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Traun Leyden

unread,
Jan 22, 2015, 8:46:57 PM1/22/15
to golan...@googlegroups.com, traun....@gmail.com

Thanks Caleb, that's just what I'm looking for.

Unfortunately I'm profiling a binary compiled with go 1.2, and that option doesn't seem available.  Oh well, at least I know it should work once I'm on a later version of go.

Benjamin Measures

unread,
Jan 22, 2015, 9:05:36 PM1/22/15
to golan...@googlegroups.com, traun....@gmail.com
On Friday, 23 January 2015 01:46:57 UTC, Traun Leyden wrote:
Unfortunately I'm profiling a binary compiled with go 1.2, and that option doesn't seem available.  Oh well, at least I know it should work once I'm on a later version of go.

Until then, you can fake firefox to do what you need:

cat <<"EOF" > /usr/bin/firefox
#!/bin/sh
[[ $# -eq 1 ]] || exit
tmpdir
=$(mktemp -d)
cat
"$1" > "$tmpdir/$(basename "$1")"
echo
"$tmpdir/$(basename "$1")" >&2
EOF
chmod
+x /usr/bin/firefox

go tool pprof test
.prof
(pprof) web
(pprof) /tmp/tmp.BLEjnCWQGZ/pprof001.svg

Traun Leyden

unread,
Jan 22, 2015, 9:34:17 PM1/22/15
to golang-nuts, Traun Leyden
Sorry, I take that back.  I had been looking at the interactive help rather than "go tool pprof --help", and I do see an -svg option.
Reply all
Reply to author
Forward
0 new messages