I want to monitor metrics consumed by a specific process in real time, like cpu, memory etc.
I have evaluated various tools but found none suiting my needs.
pidstatcaptures all i want, it gives me good memory usage per process but it reports more cpu usage(even greater than the total cpu consumed by the machine)saris more likepidstatbut just dump all the data to file.psis more like snapshot tool, doesn't gives me real time stats
I am looking for a tool which can give me cpu usage for a process in real time.
I do not know of a tool that does specific process monitoring on an interval; but, something like that wouldn't be hard to write; here are some facts:
/proc/<pid>/statwill provide a lot of information on process stats./proc/<pid>/cmdlinewill provide the processes command line./proc/<pid>/environwill provide the environment variables that the process knows of./proc/<pid>/iofor IO stats./proc/<pid>/statmfor memory usage./proc/<pid>/statuswhich providesstatandstatmin human readable format./proc/<pid>/schedwill give you various CPU and load based stats of the process.You can read more with
man proc; you could easily write a daemon that pulls this information on an interval, and then stores it somewhere centrally, such as withgraphiteor Elastic stack.