When I execute top -u postgres or ps -C postgres -o %cpu,%mem,cmd in linux machine I am getting the list of postgres processors in my database machine. I need a consolidated %cpu and %ram usage by postgres.
1 Answer
Try and test:
top -b -n 1 -u tomcat | awk 'NR>7 { cpusum += $9; ramsum += $10; } END { print cpusum, ramsum; }'
4 Comments
Laurenz Albe
If it uses
top, it counts the shared memory segment multiple times.Raghavendra
I have received output as "247.5 418.1 ". What it means could you explain, please?
Raghavendra
I have received output as below. 247.5 418.1 What it means could you explain, please?
Tamas Szasz
First number is the total CPU usage, second one is the total memory used