Hello all, I know it can be done but don't know the command.
I would like to run vmstat via cron, I don't know a good interval and don't want huge logs but want stats pretty often.
Please someone who uses vmstat via cron let me know what your script looks like.
Thank you
Ikon
September 8, 2008, 12:52pm
2
We run this everymorning at 12:02 am:
vmstat 60 1440 > /path/to/vmstat.`date +%d`
This will write to a file every minute for 24 hours then create a new file and start over.
We then have another script that summarizes the data and builds graphs and emails them everyday.
Can you post or IM the other script too, a graph would be a cool visual feature. I am not sure what is required for it to run and display right but if I can I think id like to use it.
Thanks.
Ikon
September 8, 2008, 2:18pm
4
Its acutally a collection of several scripts. I import all the vmstat datainto a sql database and then have a whole website that builds the graphs (images) as requested using Perl GD:Graph Link:GD::Graph - Graph Plotting Module for Perl 5 - search.cpan.org
Here is a sample of the graph that is built:
GD:Graph is not a difficult module to use.
02 0 * * * (path to script)
Is that correct?
For this to be a script it would be...
#/bin/bash
vmstat 60 1440 > /path/to/vmstat.`date +%d`
Is that right?
Sorry I am somewhat new to scripts and cron...
Thank you for your help.
ikon:
We run this everymorning at 12:02 am:
vmstat 60 1440 > /path/to/vmstat.`date +%d`
This will write to a file every minute for 24 hours then create a new file and start over.
Where would this create the file? In the /path/to/vmstat? If so can I path it to another dir?
Ikon
September 9, 2008, 2:15pm
8
Put it whereever you want.
in this case it would be in /path/to/ with a filename of vmstat.01 (01 = date)
OK I thought so, sorry for being over cautious.
One more question...
I manually ran it to test and I got a file name of "vmstat.date +%d"
What in the code did I miss?
I have it like such...
vmstat 60 1440 >/home/user/vmstat/vmstat.'date +%d'
you need to use the backtick (same key as ~) - not single quote
From:
vmstat 60 1440 >/home/user/vmstat/vmstat.'date +%d'
To:
vmstat 60 1440 >/home/user/vmstat/vmstat.`date +%d`
edit: to include the code
Ahh yup that did it... thank you so much for your help this is exactly what I needed.
Hi,
If you're interesting in drawing charts from vmstat log files,
you should try vmstax. You upload your log files, the charts
are built and then you export them as image(png).
[http://www.michenux.net/vmstax-build-vmstat-charts-1.html ]Vmstax | Michenux