How to load vmstat info into a database

1. Create the database with tables labelled with hostname,date, and all the vmstat fields in order. Put a unique constraint on the hostname_date.

$ vmstat 1 1 | grep avm
r b avm fre re pi po fr sr cy in sy cs us sy id wa pc ec

2. setup a command to pipe inserts right into the database, in my case I pipe into a remote command:

echo “insert command to generate” | ssh $remotehost sql

‘sql’ above is a script that connects via tds to a Windows database ( yea I know, Windows ).

3. Create a simple capture job and run it every 15 minutes:

Cut and Paste Version

4. I just run this command every 15 minutes. Because of constraints anything already loaded just fails.
( loadvmstat “09-25-2008” ; echo ; echo ) | ssh nad0019linux01 sql

Here is an example of a report made with MicroSoft Visual Studio pulling from the database ( double click to see the details ):

Leave a Reply

Your email address will not be published. Required fields are marked *