![]() ![]() Total="$(free -m | grep Mem | tr -s ' ' | cut -d ' ' -f 2)" Top -b -n 1| grep -w influxd | tr -s ' ' | cut -d ' ' -f 10 | tee -a data/cpu.csvĮcho "TIME_STAMP,Memory Usage (MB)" | tee -a data/mem.csv & LT_HOME=`cd "$PRGDIR/." pwd`Įcho "TIME_STAMP, Usage%" | tee -a data/cpu.csv Note that the filter string you use should properly filter out others and only leave a single line. You can monitor any process you require by simply replacing the relevant name here “ grep -w influxd”. Here I am monitoring influxd, a time series database process. After that result of appended to a file using tee command. In these scripts I run the top command in a loop and use grep command to only filter out the rest and get the line I need and then do some text processing using cut and tr. So I came up with two shell scripts which use Linux top and free commands to undertake this task for me. Hi all, recently I had to do some performance tests at work at AdroitLogic and I wanted to monitor CPU usage and memory usage of a process continuously and get that output to a file so that I can use them to analyze more later with graphs and stuff.
0 Comments
Leave a Reply. |