1

I have written two scripts-one to stress the system and one to run vmstat etc. I am able to get the file outputs for vmstat etc but am not able to get the ones for stress as it tells me that the file cannot be found no matter how much I tweak the pathname.

Is it therefore possible to run stress at the same time as vmstat etc? What I want is a before and after picture of the system under stress which I can graph.

Which of these is the best option(or only option) to do this:

  1. run vmstat etc, then run stress, then run vmstat etc to compare?
  2. run vmstat and stress within the same script?
  3. run stress and get the output to file(if this is even possible?)
2

1 Answer 1

2

How about something like this:

  1. start vmstat with its output directed to a log file, and background it &
  2. [optional] sleep for a few seconds (to get a baseline) && [when sleep exits]
  3. start stress

e.g.

vmstat 1 20 > vmstat.log & sleep 5 && stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s

in this case, giving

$ cat vmstat.log 
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 780804  70184 855824    0    0   221    52  187  512  7  2 90  0  0
 0  0      0 780804  70184 855824    0    0     0     0  110  312  2  0 98  0  0
 0  0      0 780752  70184 855824    0    0     0     0   80  220  0  1 100  0  0
 0  0      0 780752  70192 855824    0    0     0    28  103  222  3  0 97  1  0
 0  0      0 780752  70192 855824    0    0     0     0  115  298  2  0 98  0  0
 2  0      0 780176  70192 855824    0    0     0     0   93  250  0  1 99  0  0
12  0      0 657848  70200 855824    0    0     0  2144  986 2014 60 40  1  0  0
14  0      0 657608  70208 855824    0    0     0    20 1418 2194 61 40  0  0  0
15  0      0 686376  70216 855824    0    0     0    20 1465 3681 58 42  0  0  0
14  0      0 598072  70228 855824    0    0     0    24 1503 3507 59 41  0  0  0
16  0      0 632880  70252 855812    0    0     0    96 1514 3235 63 38  0  0  0
14  0      0 656944  70280 856112    0    0     0   416 1465 2710 64 37  0  0  0
15  0      0 722508  70428 855764    0    0     0  2012 1184 2991 74 27  0  0  0
14  1      0 673924  70456 855768    0    0     0   140 1003 2344 65 35  0  0  0
14  0      0 565940  70464 855776    0    0     0    20  850 1953 60 40  0  0  0
 3  0      0 778332  70492 855760    0    0     0   140  906 1987 60 41  0  0  0
 0  0      0 782516  70500 855752    0    0     0    16  126  342  1  0 99  1  0
 0  0      0 782584  70500 855776    0    0     0     0   96  210  0  1 100  0  0
 1  0      0 788496  70500 855776    0    0     0     0  204  430 10  0 90  0  0
 0  0      0 788664  70500 855776    0    0     0     0  906 2988 16  2 82  0  0
4
  • That works! How can I filter the output though to certain columns in excel? And remove the line at the top which says "memory, swap, io etc?"
    – paul
    Feb 28, 2015 at 14:40
  • My go-to for that would be awk: you could use something like awk 'NR > 1 {print $13,$14,$15}' vmstat.log (or, equivalently, pipe the vmstat output through awk 'NR > 1 {print $13,$14,$15}' before sending it to the file). Alternatively, you could use Excel's import wizard to select columns. Feb 28, 2015 at 14:51
  • when I put it like this, it doesn't print any data. what might I be doing wrong? vmstat $INT $CNT awk 'NR > 1 {print $13,$14,$15}'> cpu.log & sleep 5 && stress --cpu $cores -t $seconds_to_run
    – paul
    Feb 28, 2015 at 15:50
  • You seem to be missing the pipe | between your vmstat command and the awk command: vmstat $INT $CNT | awk ... Feb 28, 2015 at 18:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .