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

num_threads don't match with /proc/[pid]/stat #325

Open
DesireWithin opened this issue Nov 12, 2024 · 0 comments
Open

num_threads don't match with /proc/[pid]/stat #325

DesireWithin opened this issue Nov 12, 2024 · 0 comments

Comments

@DesireWithin
Copy link

Hello,
Here is a sh script which I want to monitor by process_exporter, it is executed by the command:

/bin/sh /home/hsinfo/macs1.5/mon_macs

The abstract logic of the mon_macs is as follows

while :; do
    check if another java is running:
    if running:
        echo "All good"
    else:
        restart java
    sleep 30
done

My config of process_exporter is as follows:

process_names:
  - name: "{{.ExeFull}}-{{.PID}}"
    exe:
    - /bin/sh
    cmdline:
    - /home/hsinfo/macs1.5/mon_macs

the /proc/[pid]/stat is as follows, the num_threads(20) is 1 if I understand correctly:

20063 (mon_macs) S 1 20054 2690 0 -1 4202496 1532500 12691165 0 1 344 769 1841 2339 20 0 1 0 7638028330 118898688 516 18446744073709551615 4194304 5098220 140727778541152 140727778539256 140342315869436 0 65536 6 65536 18446744071579423654 0 0 17 0 0 0 0 0 0 7196144 7232144 9105408 140727778546874 140727778546912 140727778546912 140727778549722 0

Here is the part of metrics output

# HELP namedprocess_namegroup_num_procs number of processes in this group
# TYPE namedprocess_namegroup_num_procs gauge
namedprocess_namegroup_num_procs{groupname="/bin/sh-179576"} 2
.....
# HELP namedprocess_namegroup_num_threads Number of threads
# TYPE namedprocess_namegroup_num_threads gauge
namedprocess_namegroup_num_threads{groupname="/bin/sh-179576"} 2
....
# HELP namedprocess_namegroup_states Number of processes in states Running, Sleeping, Waiting, Zombie, or Other
# TYPE namedprocess_namegroup_states gauge
namedprocess_namegroup_states{groupname="/bin/sh-179576",state="Other"} 0
namedprocess_namegroup_states{groupname="/bin/sh-179576",state="Running"} 0
namedprocess_namegroup_states{groupname="/bin/sh-179576",state="Sleeping"} 2
namedprocess_namegroup_states{groupname="/bin/sh-179576",state="Waiting"} 0
namedprocess_namegroup_states{groupname="/bin/sh-179576",state="Zombie"} 0
....
# HELP namedprocess_namegroup_threads_wchan Number of threads in this group waiting on each wchan
# TYPE namedprocess_namegroup_threads_wchan gauge
namedprocess_namegroup_threads_wchan{groupname="/bin/sh-179576",wchan="do_wait"} 1
namedprocess_namegroup_threads_wchan{groupname="/bin/sh-179576",wchan="hrtimer_nanosleep"} 1

And here is pstree output:

$> pstree 179576
mon_macs-+-java---60*[{java}]
         `-sleep

I'm not familiar with Linux programming, maybe is not an issue, but may I ask why?

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

No branches or pull requests

1 participant