From: "Halte, James" <JHALTE@ci.tacoma.wa.us>
To: "'tru64-unix-managers@ornl.gov'" <tru64-unix-managers@ornl.gov>
Subject: SUMMARY: timestamp with vmstat
Date: Wed, 15 Jul 2009 12:13:38 -0700 [thread overview]
Message-ID: <7A413832512CF64BA86648F34149D0302D3D3A9E73@mbtpu.Tacoma.lcl> (raw)
Thanks to all who contributed to this question. All of the responses were appreciated and helpful.
Mostly, the suggestions were to pipe the vmstat output into a command list that applies the time stamp to each line.
Example from Bluejay Adametz:
run in ksh
# vmstat | { while read LINE ; do echo `date +%H:%M` "$LINE" ; done ; }
I applied this to my script and it works.
I received other variations, but went with the above.
*****************************************************************
**Thanks very much to the other suggestions as well:
-Dr. Thomas P. Blinn : Suggested using an inline solution as above, and using "awk" to further enhance the script.
-Joe Fletcher: create a loop:
while true
do
date
vmstat 1 1
sleep 60
done >> logfile
-James Sainsbury:
dated_vmstat() {
vmstat 60 50 | while read line
do
printf "%-6.6s %s\n" "`date +%H:%M`" "$line"
done
}
-Shaun Racine: Suggested using the 'collect' utility.
-James Eiler: Suggested piping the vmstat output to a timestamp script.
#!/bin/ksh
while read INPUT; do
echo `date +"%a %h %d %T"`:: "$INPUT"
done
******************************************************************
Original Post (jhalte):
I currently have a cronjob that runs at the top of the hour for every hour of the day. This cronjob calls a script to run vmstat once every 60 seconds 59 times, and send output to a log file. This basically will run vmstat once per minute, for 59 minutes.
crontab
0 * * * * /runDirectory/vmstat_by_minute
Script "vmstat_by_minute" (summary, not exact syntax)
-adds start time stamp >> myTargetFile
-executes vmstat 60 59 >> myTargetFile
-adds Completion time stamp >> myTargetFile
Since this is run once/hour, I can time stamp the start and end,
but would like to time stamp each line (minute) of vmstat output.
Logfile output Example:
Begin vmstat running on ras2 at: 20080103_0000
Virtual Memory Statistics: (pagesize = 8192)
procs memory pages intr cpu
r w u act free wire fault cow zero react pin pout in sy cs us sy id
10 937 54 300K 157K 47K 1G 110M 257M 921 98M 0 97 7K 3K 1 2 97
8 932 54 300K 157K 47K 31513 4999 6838 0 4095 0 113 10K 4K 1 4 95
9 931 54 300K 157K 47K 15170 1079 3388 0 1009 0 95 7K 3K 1 2 97
.
.
.
8 927 54 300K 157K 47K 15099 1085 3401 0 1024 0 93 7K 3K 1 2 97
V M S T A T Server2 C O M P L E T E at: 20080103_0000
What I'd like is
Begin vmstat running on ras2 at: 20080103_0000
Virtual Memory Statistics: (pagesize = 8192)Virtual Memory Statistics: (pagesize = 8192)
procs memory pages intr cpu
Time r w u act free wire fault...in sy cs us sy id
01:01 10 937 54 300K 157K 47K 1G ...97 7K 3K 1 2 97
01:02 10 937 54 300K 157K 47K 1G ...97 7K 3K 1 2 97
Any suggestions would be greatly appreciated.
----------------------------------------------------------------------------
Thank you, and please feel free to contact me by phone or email.
James Halte
Tacoma Power - T&D EMS Senior Engineer
Office: (253) 502-8094
Cell: (253) 381-4088
reply other threads:[~2009-07-15 19:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox