unixsurfer / haproxytool

A tool to interact with HAProxy via stats socket
Apache License 2.0
85 stars 8 forks source link

how to show current connection/Session? #3

Closed hos7ein closed 7 years ago

hos7ein commented 7 years ago

hi

how can i show(monitor) current connection or Session per server?

tnx

unixsurfer commented 7 years ago

Hi,

You can use scur metric like this: haproxytool server -D <dir_path> -m scur <server>

From HAproxy documentation:

  1. scur [LFBS]: current sessions
hos7ein commented 7 years ago

tnx @unixsurfer

when i use of nbproc in haproxy , better use of one single socket file for all cpu cores ? or use of separate files for each cpu core?

unixsurfer commented 7 years ago

You need to bind each HAProxy process to a different UNIX stats socket, and then use -D argument to point to the directory with all UNIX stats socket files.

unixsurfer commented 7 years ago

@hos7ein , may I close this ticket?

hos7ein commented 7 years ago

@unixsurfer oh yeah, Thank you.

hos7ein commented 7 years ago

@unixsurfer hi again

I bind each HAProxy process to a different UNIX stats socket, and then use -D argument to point to the directory with all UNIX stats socket files.But when run this command :

haproxytool server -D /var/lib/haproxy -m scur nginx-b-dev

It does not display anything! below is output :

https://paste.fedoraproject.org/paste/-JSp~WjY4F5hJdLtLcXyvF5M1UNdIGYhyRLivL9gydE=

But when I run this command it's working :

https://paste.fedoraproject.org/paste/PXBpnxFW31G-T2nDocNn2F5M1UNdIGYhyRLivL9gydE=

Is something wrong?

tnx

unixsurfer commented 7 years ago

Hi @hos7ein,

In the first case you gave the server name and you got back the current sessions only of that server. In the second case you didn't pass a server name and therefore the tool return the requests served by all servers.

So, the tool worked as expected.

Could you please read the help of server ( haproxytool server --help) command and let me know which part isn't clear to you?

Cheers, Pavlos

hos7ein commented 7 years ago

tnx @unixsurfer for response

Imaging “nginx-b-dev” is server name in “nginx-dev” backend. How can I see real time request on “nginx-b-dev” server?

Thank you

unixsurfer commented 7 years ago

you can do it with: haproxytool server -r --backend=nginx-dev nginx-b-dev

Please read the help message from information.