Welcome! Log In Create A New Profile

Advanced

is there a way to get the ip address of the server running php-fpm?

Posted by iberkner 
is there a way to get the ip address of the server running php-fpm?
October 12, 2010 06:14AM
We are in a fastcgi configuration and profiling application load times,
would like to know which server the request is being processed on.
2010/10/12 Ilan Berkner <iberkner@gmail.com>:
> We are in a fastcgi configuration and profiling application load times,
> would like to know which server the request is being processed on.

Can you be more specific please ?
Re: is there a way to get the ip address of the server running php-fpm?
October 12, 2010 06:26AM
We are running a profile script which measures how long page load times
takes, how many queries run per page, etc.

One of the data parameters that I'd like to collect is which of the php-fpm
servers is actually running the php script.

$_SERVER["server_addr"] gives the web servers IP address.

One solution that I can think of is to have a unique configuration file
present on each application server that contains the IP address of that
server. This should work.

Someone else suggested using
http://php.net/manual/en/function.socket-getpeername.php but I don't have /
know how to get the socket resource to make the request.

Any thoughts / suggestions?

Thanks


2010/10/12 Jérôme Loyet <ml@fatbsd.com>

> 2010/10/12 Ilan Berkner <iberkner@gmail.com>:
> > We are in a fastcgi configuration and profiling application load times,
> > would like to know which server the request is being processed on.
>
> Can you be more specific please ?
>
if you're using nginx you can add:

fastcgi_param UPS_SERVER_ADDR $upstream_addr;

and get $_SERVER["UPS_SERVER_ADDR"].

That should work.

2010/10/12 Ilan Berkner <iberkner@gmail.com>:
> We are running a profile script which measures how long page load times
> takes, how many queries run per page, etc.
> One of the data parameters that I'd like to collect is which of the php-fpm
> servers is actually running the php script.
> $_SERVER["server_addr"] gives the web servers IP address.
> One solution that I can think of is to have a unique configuration file
> present on each application server that contains the IP address of that
> server.  This should work.
> Someone else suggested
> using http://php.net/manual/en/function.socket-getpeername.php but I don't
> have / know how to get the socket resource to make the request.
> Any thoughts / suggestions?
> Thanks
>
> 2010/10/12 Jérôme Loyet <ml@fatbsd.com>
>>
>> 2010/10/12 Ilan Berkner <iberkner@gmail.com>:
>> > We are in a fastcgi configuration and profiling application load times,
>> > would like to know which server the request is being processed on.
>>
>> Can you be more specific please ?
>
>
Re: is there a way to get the ip address of the server running php-fpm?
October 12, 2010 07:24AM
Thanks for your suggestion, but according to Nginx user group,

---
Variable $upstream_addr will be empty during creation request to
upstream.

variable $upstream_addr contains not a
single address, but a list of upstream addresses tried.
----

I'm going to test it out just to get an idea of what comes up...



2010/10/12 Jérôme Loyet <ml@fatbsd.com>

> if you're using nginx you can add:
>
> fastcgi_param UPS_SERVER_ADDR $upstream_addr;
>
> and get $_SERVER["UPS_SERVER_ADDR"].
>
> That should work.
>
> 2010/10/12 Ilan Berkner <iberkner@gmail.com>:
> > We are running a profile script which measures how long page load times
> > takes, how many queries run per page, etc.
> > One of the data parameters that I'd like to collect is which of the
> php-fpm
> > servers is actually running the php script.
> > $_SERVER["server_addr"] gives the web servers IP address.
> > One solution that I can think of is to have a unique configuration file
> > present on each application server that contains the IP address of that
> > server. This should work.
> > Someone else suggested
> > using http://php.net/manual/en/function.socket-getpeername.php but I
> don't
> > have / know how to get the socket resource to make the request.
> > Any thoughts / suggestions?
> > Thanks
> >
> > 2010/10/12 Jérôme Loyet <ml@fatbsd.com>
> >>
> >> 2010/10/12 Ilan Berkner <iberkner@gmail.com>:
> >> > We are in a fastcgi configuration and profiling application load
> times,
> >> > would like to know which server the request is being processed on.
> >>
> >> Can you be more specific please ?
> >
> >
>
Have you tried function: php_uname('n') to get the hostname of the
machine running the PHP script?
Re: is there a way to get the ip address of the server running php-fpm?
October 16, 2010 05:48PM
there's also posix_uname() too

On Sat, Oct 16, 2010 at 2:23 PM, Gabriel Hedges <klinky@gmail.com> wrote:
> Have you tried function: php_uname('n') to get the hostname of the
> machine running the PHP script?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 236
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready