0

Please help. So, I'm given a task to monitor a particular process in CentOS.

There are certain requirements.

  1. Can't monitor using PID, because once process is killed or dead, solution is of no use.
  2. It'll be great if I could know how much is the consumption of each thread of a process.

I've researched enough but with no success.

Thanks in advance.

techworm
  • 41
  • 6

1 Answers1

1

I am uncertain what exactly you are trying to achieve, but this is how I would proceed:

Suggested Approaches

Multiple Process IDs per process name

top -H -p $(pgrep <process_name> | paste -s -d, -)

Single Process ID per process name

top -H -p $(pgrep <process_name>)

Further reading

Suggestion

Maybe think about implementing a solution like Prometheus with Node Exporter or Zabbix or Nagios.

YoshiMbele
  • 767
  • 1
  • 12
  • thanks so much. let's say i have a python process running in my machine and i want to track how much ram, cpu it's consuming. that's my need. i need continuous monitoring for a certain process. – techworm Jun 01 '22 at 10:51
  • also, `top | grep "firefox"` is giving me the expected output. but when i try to redirect it to a file it shows blank. can you help me with that. `top | grep "firefox" > /home/a/firefoxutilization.txt` is what i'm running. – techworm Jun 01 '22 at 11:37
  • You can redirect the top output itself into a file (press ctrl+c to stop the output) and then grep the output file after capturing the top data. [Capture output of top comamnd](https://stackoverflow.com/questions/11729720/how-to-capture-the-output-of-a-top-command-in-a-file-in-linux) might come in handy. If you put your application into a docker container you could think about resource constraining / monitoring that way. – YoshiMbele Jun 01 '22 at 11:53