How to count number of connections from nginx workers to php-cgi unix socket?

I need to count number of connections to php's cgi unix socket (created with spawn-fci). When nginx initiates a connection to cgi socket one of spawned php processes accepts this connection, processes input and outputs data. But number of processes is limited and i want to be able to monitor amount of free processes. I tried all available tools (netstat, sockstat even lsof) but it seems there is no way to determine how many active connections from nginx to unix socket. Please advise.
 
See if fstat(1) (FreeBSD's own lsof which has been around since dinosaurs) has useful flags. Untested.
 
Same result. Actually it shows connections from nginx to local unix socket (and other tools like netstat too) but amount of this connections is always 16 on my server. It looks like nginx is always connected to this socket and do not initiates new connections. But this isn't true as i mentioned in my 1st post. I was wondering may be nginx is using a sort of persistent socket connection model and reproduced same nginx+php-cgi stack on linux. Netstat and lsof under linux are clearly showing new connections to php's socket e.g. amount of connections is changing after php file is requested and nginx is connecting to php-cgi socket.
 
Back
Top