Logging VMStat data to file

vmstat is a command that you run.

To generate one week of Virtual Memory stats spaced out at ten second intervals (less the last one) is 60,479 10 second intervals

So the command you want is:

nohup vmstat 10 604879 > myvmstatfile.dat &

This will make a very big file myvmstatfile.dat

EDIT: RobKielty (The & will put this job in the background, the nohup will prevent the task from hanging up when you logout of the command shell. If you ran this command it would be prudent to monitor the disk partition to which this file was being written to. Use df -h /path/to/directory/where/outputfile/resides to monitor the disk space usage.)

I have no idea what you need to do with the data, so I can't help you there.

Create a crontab entry (crontab -e) like this

0 0 * * 0  /path/to/my/vmstat_script.sh 

The file vmstat_script.sh will contain the follow bash script commands.

#!/bin/bash
# vmstat_script.sh
vmstat 10 604879 > myvmstatfile.dat
mv myvmstatfile.dat myvmstatfile.dat.`date +%Y-%m-%d`

This will create one file per week with a name like myvmstatfile.dat.2012-07-01

Tags:

Linux

Unix