Capture CPU and Memory usage dynamically
If you are looking for capturing CPU and Mem utilization dynamically for entire linux box, then following command can help you too:
CPU
vmstat -n 15 10| awk '{now=strftime("%Y-%m-%d %T "); print now $0}'> CPUDataDump.csv &
vmstat
is used for collection of CPU counters
-n
for delay value, in this case it's 15, that means after every 15 sec, stats will be collected.
then 10
is the number of intervals, there would be 10 iterations in this example
awk '{now=strftime("%Y-%m-%d %T "); print now $0}'
this will dump the timestamp of each iteration
in the end, the dump file with &
for continuation
Memory
free -m -s 10 10 | awk '{now=strftime("%Y-%m-%d %T "); print now $0}'> DataDumpMemoryfile.csv &
free
is for mem stats collection
-m
this is for units of mem (you can use -b
for bytes, -k
for kilobytes, -g
for gigabytes)
then 10
is the number of intervals (there would be 10 iterations in this example)
awk'{now=strftime("%Y-%m-%d %T "); print now $0}'
this will dump the timestamp of each iteration
in the end, the dump &
for continuation