I have this setup where several applications are going through the load balancer (HAproxy) and accessing the MySQL database.
Several applications -> HAproxy -> MySQL database
I would like to know which specific application is accessing the database. When I did a show processlist on the database, it shows the IP of the HAproxy (of course). Then I tried to do lsof on haproxy and mysql database but it didn't help me (or I just don't know to interpret the results properly). And finally I checked the haproxy logs but it didn't show anything.
Thanks.
I was also looking for a way to trace haproxy connections back to specific processes on various machines. This dinky little hackery looks on the haproxy machine for a host that you give it. It then goes over to the source machine and looks for the connections through to the backend databases.
The most basic part is running the
echo 'show sess' | socat stdio unix-connect:/tmp/haproxy
on the haproxy server itselfOutput looks like this: