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

Add namedprocess_namegroup_tcp_socket_count metric #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xunleii
Copy link
Member

@xunleii xunleii commented Jan 26, 2024

Un exemple des métriques produites

# HELP namedprocess_namegroup_tcp_socket_count Number of TCP sockets open by a process
# TYPE namedprocess_namegroup_tcp_socket_count gauge
namedprocess_namegroup_tcp_socket_count{groupname="(sd-pam)",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="(sd-pam)",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="Relay(1204)",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="Relay(1204)",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="Relay(2174)",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="Relay(2174)",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="Relay(28418)",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="Relay(28418)",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="Relay(28427)",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="Relay(28427)",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="Relay(835)",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="Relay(835)",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="Relay(9335)",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="Relay(9335)",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="SessionLeader",state="ESTABLISHED"} 60
namedprocess_namegroup_tcp_socket_count{groupname="SessionLeader",state="LISTEN"} 18
namedprocess_namegroup_tcp_socket_count{groupname="__debug_bin4170",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="__debug_bin4170",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="agetty",state="ESTABLISHED"} 20
namedprocess_namegroup_tcp_socket_count{groupname="agetty",state="LISTEN"} 6
namedprocess_namegroup_tcp_socket_count{groupname="containerd",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="containerd",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="cron",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="cron",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="curl",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="curl",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="dbus-daemon",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="dbus-daemon",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="dlv",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="dlv",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="dockerd",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="dockerd",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="fish",state="ESTABLISHED"} 50
namedprocess_namegroup_tcp_socket_count{groupname="fish",state="LISTEN"} 15
namedprocess_namegroup_tcp_socket_count{groupname="gopls",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="gopls",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="init",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="init",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="init-systemd(Ra",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="init-systemd(Ra",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="login",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="login",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="networkd-dispat",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="networkd-dispat",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="node",state="ESTABLISHED"} 70
namedprocess_namegroup_tcp_socket_count{groupname="node",state="LISTEN"} 21
namedprocess_namegroup_tcp_socket_count{groupname="packagekitd",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="packagekitd",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="polkitd",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="polkitd",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="process-exporte",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="process-exporte",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="python3",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="python3",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="python3.10",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="python3.10",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="rsyslogd",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="rsyslogd",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="sh",state="ESTABLISHED"} 30
namedprocess_namegroup_tcp_socket_count{groupname="sh",state="LISTEN"} 9
namedprocess_namegroup_tcp_socket_count{groupname="snapd",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="snapd",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="snapfuse",state="ESTABLISHED"} 80
namedprocess_namegroup_tcp_socket_count{groupname="snapfuse",state="LISTEN"} 24
namedprocess_namegroup_tcp_socket_count{groupname="ssh-agent",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="ssh-agent",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="subiquity-serve",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="subiquity-serve",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="sudo",state="ESTABLISHED"} 20
namedprocess_namegroup_tcp_socket_count{groupname="sudo",state="LISTEN"} 6
namedprocess_namegroup_tcp_socket_count{groupname="systemd",state="ESTABLISHED"} 20
namedprocess_namegroup_tcp_socket_count{groupname="systemd",state="LISTEN"} 6
namedprocess_namegroup_tcp_socket_count{groupname="systemd-journal",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="systemd-journal",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="systemd-logind",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="systemd-logind",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="systemd-resolve",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="systemd-resolve",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="systemd-udevd",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="systemd-udevd",state="LISTEN"} 3
namedprocess_namegroup_tcp_socket_count{groupname="unattended-upgr",state="ESTABLISHED"} 10
namedprocess_namegroup_tcp_socket_count{groupname="unattended-upgr",state="LISTEN"} 3

@xunleii xunleii marked this pull request as ready for review January 26, 2024 16:03
@xunleii xunleii force-pushed the feature/add-namedprocess_namegroup_tcp_socket_count-metrics branch from 85872ef to af67d8b Compare January 26, 2024 16:04
Some times, we need to know how many TCP socket are used by a process or
a group of process.
Adding this metrics allows to know precisely the number of socket
created and their states.
@xunleii xunleii force-pushed the feature/add-namedprocess_namegroup_tcp_socket_count-metrics branch from af67d8b to 1b1cc01 Compare January 26, 2024 16:27
@xunleii
Copy link
Member Author

xunleii commented Jan 26, 2024

Les process semblent être dupliqués, rendant la métrique fausse

EDIT: Au final non, ce sont bien des process différents
EDIT2: C'est pas bon

namedprocess_namegroup_tcp_socket_count{groupname="sh:2308",state="ESTABLISHED"} 8
namedprocess_namegroup_tcp_socket_count{groupname="sh:2308",state="LISTEN"} 2
namedprocess_namegroup_tcp_socket_count{groupname="sh:2308",state="TIME_WAIT"} 852
namedprocess_namegroup_tcp_socket_count{groupname="sh:2309",state="ESTABLISHED"} 7
namedprocess_namegroup_tcp_socket_count{groupname="sh:2309",state="LISTEN"} 2
namedprocess_namegroup_tcp_socket_count{groupname="sh:2309",state="TIME_WAIT"} 853
namedprocess_namegroup_tcp_socket_count{groupname="sh:2314",state="ESTABLISHED"} 7
namedprocess_namegroup_tcp_socket_count{groupname="sh:2314",state="LISTEN"} 2
namedprocess_namegroup_tcp_socket_count{groupname="sh:2314",state="TIME_WAIT"} 854

(groupname="EXE:PID")

@xunleii
Copy link
Member Author

xunleii commented Mar 5, 2024

C'est pas bon en fait ; /proc/X/net/tcp retourne la même valeur quel que soit le PID (X)

@xunleii
Copy link
Member Author

xunleii commented Mar 5, 2024

C'est pas bon en fait ; /proc/X/net/tcp retourne la même valeur quel que soit le PID (X)

Axe d'amélioration : https://gist.github.com/jkstill/5095725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant