Skip to content
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

phpfpm plugin with unix socket fails #499

Closed
sofixa opened this issue Jan 9, 2016 · 6 comments
Closed

phpfpm plugin with unix socket fails #499

sofixa opened this issue Jan 9, 2016 · 6 comments
Labels
bug unexpected problem or unintended behavior

Comments

@sofixa
Copy link

sofixa commented Jan 9, 2016

Hello, everybody.

Awesome work on telegraf, it's really a pleasure to use it, and i've had no issues with it whatsoever until recently.

I setup a webserver with nginx and php5-fpm, with communcation between them passing via the unix socket at /var/run/php5-fpm.sock.

Whenever i run telegraf, with -test and -debug, i get a rather long stacktrace, but with nothing that actually helps me debug:

* Plugin: phpfpm, Collection 1
panic: runtime error: index out of range

goroutine 22 [running]:
github.com/influxdb/telegraf/plugins/phpfpm.(*phpfpm).gatherServer(0xc8201c23c0, 0xc8201c22e1, 0x16, 0x7f9431fa77a0, 0xc8201d2380, 0x0, 0x0)
        /home/telebuild/go/src/github.com/influxdb/telegraf/plugins/phpfpm/phpfpm.go:138 +0x731
github.com/influxdb/telegraf/plugins/phpfpm.(*phpfpm).Gather.func1(0xc8201d13b0, 0xc8201d13c0, 0xc8201c23c0, 0x7f9431fa77a0, 0xc8201d2380, 0xc8201c22e1, 0x16)
        /home/telebuild/go/src/github.com/influxdb/telegraf/plugins/phpfpm/phpfpm.go:83 +0x7b
created by github.com/influxdb/telegraf/plugins/phpfpm.(*phpfpm).Gather
        /home/telebuild/go/src/github.com/influxdb/telegraf/plugins/phpfpm/phpfpm.go:84 +0x1d1

goroutine 1 [runnable]:
sync.runtime_Semacquire(0xc8201d13bc)
        /usr/local/go/src/runtime/sema.go:43 +0x26
sync.(*WaitGroup).Wait(0xc8201d13b0)
        /usr/local/go/src/sync/waitgroup.go:126 +0xb4
github.com/influxdb/telegraf/plugins/phpfpm.(*phpfpm).Gather(0xc8201c23c0, 0x7f9431fa77a0, 0xc8201d2380, 0x0, 0x0)
        /home/telebuild/go/src/github.com/influxdb/telegraf/plugins/phpfpm/phpfpm.go:87 +0x1fe
github.com/influxdb/telegraf.(*Agent).Test(0xc820028258, 0x0, 0x0)
        /home/telebuild/go/src/github.com/influxdb/telegraf/agent.go:197 +0x504
main.main()
        /home/telebuild/go/src/github.com/influxdb/telegraf/cmd/telegraf/telegraf.go:115 +0xe3c

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1696 +0x1

goroutine 5 [syscall]:
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
        /usr/local/go/src/os/signal/signal_unix.go:28 +0x37

goroutine 11 [runnable]:
github.com/influxdb/telegraf.(*Agent).Test.func1(0xc820016ea0, 0xc820016e40)
        /home/telebuild/go/src/github.com/influxdb/telegraf/agent.go:178 +0xc0
created by github.com/influxdb/telegraf.(*Agent).Test
        /home/telebuild/go/src/github.com/influxdb/telegraf/agent.go:185 +0xd6

goroutine 20 [IO wait]:
net.runtime_pollWait(0x7f9431fa87d0, 0x72, 0xc82000e1e0)
        /usr/local/go/src/runtime/netpoll.go:157 +0x60
net.(*pollDesc).Wait(0xc820173fe0, 0x72, 0x0, 0x0)
        /usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a
net.(*pollDesc).WaitRead(0xc820173fe0, 0x0, 0x0)
        /usr/local/go/src/net/fd_poll_runtime.go:78 +0x36
net.(*netFD).Read(0xc820173f80, 0xc8201cb000, 0x1000, 0x1000, 0x0, 0x7f9431fa2050, 0xc82000e1e0)
        /usr/local/go/src/net/fd_unix.go:232 +0x23a
net.(*conn).Read(0xc8200282c0, 0xc8201cb000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/net.go:172 +0xe4
net/http.noteEOFReader.Read(0x7f9431fa8c08, 0xc8200282c0, 0xc8201434f8, 0xc8201cb000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/http/transport.go:1370 +0x67
net/http.(*noteEOFReader).Read(0xc8201c39e0, 0xc8201cb000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        <autogenerated>:126 +0xd0
bufio.(*Reader).fill(0xc820017380)
        /usr/local/go/src/bufio/bufio.go:97 +0x1e9
bufio.(*Reader).Peek(0xc820017380, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
        /usr/local/go/src/bufio/bufio.go:132 +0xcc
net/http.(*persistConn).readLoop(0xc8201434a0)
        /usr/local/go/src/net/http/transport.go:876 +0xf7
created by net/http.(*Transport).dialConn
        /usr/local/go/src/net/http/transport.go:685 +0xc78

goroutine 21 [select]:
net/http.(*persistConn).writeLoop(0xc8201434a0)
        /usr/local/go/src/net/http/transport.go:1009 +0x40c
created by net/http.(*Transport).dialConn
        /usr/local/go/src/net/http/transport.go:686 +0xc9d

My telegraf config is regular, as per its doc:

[[plugins.phpfpm]]
  urls = ["/var/run/php5-fpm.sock"]

The sock is present, and is with 666 rights, so telegraf should be able to access it.
The script that i found here works perfectly, so i suppose i am missing something between Telegraf and my sock rather than a php-fpm config issue.

What can I do so that Telegraf successfully connects to my sock? Thanks in advance to anybody who responds to my plead for help :)

PS: I tried enabling the pm.status variable in my php-fpm pool config, to /fpmstatus, but i am running a WordPress blog with a lot of redirections(i18n, cache, cdn) and my requests get redirected to the website and fail with a 404, so using the web to gather stats by Telegraf isn't an option, that's why i am trying to do it via the sock.

@sofixa
Copy link
Author

sofixa commented Jan 9, 2016

In fact, i just discovered my problem - the path to the sock should be prefixed by localhost:(so localhost:/var/run/php5-fpm.sock instead of just /var/run/php5-fpm.sock). That isn't very clear in the documentation of the plugin, so i propose that you edit it to mention that little detail.

@sparrc sparrc added the bug unexpected problem or unintended behavior label Jan 9, 2016
@sparrc
Copy link
Contributor

sparrc commented Jan 9, 2016

thanks for the detailed report 👍

@v9n
Copy link
Contributor

v9n commented Jan 14, 2016

Will submit PRs for this.

@sparrc
Copy link
Contributor

sparrc commented Jan 15, 2016

thanks @kureikain

@stvnwrgs
Copy link

For me it is still not working.

My config:

[[inputs.phpfpm]]
    urls = ["127.0.0.1:/var/run/php5-fpm.sock"]
2016/03/30 17:01:45 Error in input [phpfpm]: Socket doesn't exist  '127.0.0.1': stat 127.0.0.1: no such file or directory

@nsteinmetz
Copy link
Contributor

nsteinmetz commented Jun 30, 2016

@stvnwrgs

I had the same issue ; it was a little bit improved when I add a real bash to telegraf user (instead of /bin/false ; otherwise it failed to read the socket).

From #502, I added:

[[inputs.phpfpm]]
    urls = ["/var/run/php5-fpm.sock:status"]

If you look at the code, it's

    urls = ["`path_to_socket<:optional status function>"]

But I still have:

Error in input [phpfpm]: Socket doesn't exist  'localhost': stat localhost: no such file or director

Whereas I defined a socket. So arguments are not well parsed ?

What should be perms on socket? Seems 0666 is not enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants