Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging VMStat data to file

Tags:

linux

unix

I am trying to create some capacity planning reports and one of the requrements is to have info on Memory usage for a few Unix Servers.

Now my knowledge of Unix is very low. I usually just log on and run a few scripts.

But for this report I need to gather VMStat data and produce reports based on previous the previous weeks data broken down by hour which is an average of Vmstat data taken every 10 seconds.

So first question: is VMStat logging on by default and if so what location on the server is the data output to?

If not how can I set this up?

Thanks

like image 283
Sutty1000 Avatar asked Jul 02 '12 13:07

Sutty1000


People also ask

What information can vmstat provide?

Virtual memory statistics reporter, also known as vmstat , is a Linux command-line tool that reports various bits of system information. Things like memory, paging, processes, IO, CPU, and disk scheduling are all included in the array of information provided.

What is WA in vmstat?

wa. The wa column details the percentage of time the CPU was idle with pending local disk I/O and NFS-mounted disks. If there is at least one outstanding I/O to a disk when wait is running, the time is classified as waiting for I/O.


1 Answers

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

like image 53
jim mcnamara Avatar answered Oct 26 '22 15:10

jim mcnamara