polewpackage.blogg.se

Shell script to monitor cpu and memory usage in linux
Shell script to monitor cpu and memory usage in linux






shell script to monitor cpu and memory usage in linux

Here is some sample output for only 2 log periods (at logging loop iterations 2 and 3): _11:15:54, INFO, = START of loop count 2 = View the output live with: less -N -follow-name +F ~/cpu_log.log Run it at a high priority with the soft real-time Round Robin (rr) scheduler so it can log even when your system freezes: sudo chrt -rr 1 path/to/eRCaGuy_dotfiles/useful_scripts/cpu_logger.py It allows me to write reports to Google like this: Chrome Google Meet CPU usage is still too high (see plots and CPU usage during Google Meet with my camera ON vs OFF). It logs continuously to a set of rotating log files. Here's a logging script I wrote and use: cpu_logger.py. their command without further arguments, as in /usr/bin/firefox)Īfter you've used a Spreadsheet to create a graph to see when your CPU load went through the roof, you can then search this file for the nearest time to see what process has caused it.Ģ2:57:42 up 1 day, 4:38, 4 users, load average: 1.00, 1.26, 1.21Ģ2:57:43 up 1 day, 4:38, 4 users, load average: 0.92, 1.24, 1.21Ģ2:57:44 up 1 day, 4:38, 4 users, load average: 0.92, 1.24, 1.21Ģ2:57:45 up 1 day, 4:38, 4 users, load average: 0.92, 1.24, 1.21Ġ.8 0.5 /usr/lib/gnome-panel/clock-applet This is just the top 10, and just their CPU Usage, Memory Usage and the first argument (i.e. Note that this is not the full boat-load of information top would give you. This will append the Top 10 most CPU hungry processes to a file ps.log every five seconds. So, additionally, run this (or use his answer for this part): while true do (echo "%CPU %MEM ARGS $(date)" & ps -e -o pcpu,pmem,args -sort=pcpu | cut -d" " -f1-5 | tail) > ps.log sleep 5 done You can then import this file into Gnumeric or the OpenOffice spreadsheet to create a nice graph (select 'separated by spaces' on import).Īs Scaine noticed, this won't be enough to diagnose the problem.

shell script to monitor cpu and memory usage in linux

This will log your cpu load every second and append it to a file uptime.log. This works very well: while true do uptime > uptime.log sleep 1 done








Shell script to monitor cpu and memory usage in linux