Link to home
Start Free TrialLog in
Avatar of peter
peterFlag for United States of America

asked on

vmstat format for mobile device

Hi everyone,
I need to format vmstat , this script should format vmstat for easy reading on cell phones etc,  I am looking to send the output to email every three hours.

Output should look like this:

Sat Feb 18 11:15:48 PST 2012
1 processes are waiting
0 processes are blocked


Thank you!
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

There are many ways to format this, but I'd use awk:
#!/bin/bash

TMPF=/tmp/vm.$$

date > $TMPF

vmstat | tail -1 | awk '{print $1 " processes are waiting\n" $2 " processes are blocked"}' >> $TMPF

cat $TMPF | mail -s "vmstat output" fred@example.com

rm $TMPF

Open in new window


Then add
    0 */3 * * * /path/to/above/script.sh

The above assumes that all of the commands specified are in /bin or /usr/bin. since that's the PATH which will be used - if they aren't, put in the full path to the commands.
Avatar of peter

ASKER

ok, let me give this a shot : )
Avatar of peter

ASKER

Works great!
What if I wanted to add a log to this so it writes and keeps it for a week or so then starts a new one??
ASKER CERTIFIED SOLUTION
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial