how to display date along with vmstat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to display date along with vmstat
# 1  
Old 09-23-2008
how to display date along with vmstat

Hi Unix Gurus,
I have a script which runs vmstat and puts the output to a file.
I am pulling the runq,usr,sys,idle columns using awk

vmstat 2|awk {'print $1,$14,$15,$16'}

Now within this command is there any way i can pass the date too.
Please do let me know.


Thanks in advance.
Arun
# 2  
Old 09-23-2008
Something like this:

Code:
vmstat 2|awk -v d="`date "+%Y-%m-%d"`" '{print $1,$14,$15,$16 " date: " d}'

Regards
# 3  
Old 09-23-2008
MySQL thanks it works

Smilie
Thank you very much for helping.
this works great for me

thanks again.
Arun:
# 4  
Old 09-23-2008
oops sorry
I have added the time along, but i am seeing that the time is not changing at all.

Any help

$vmstat 5 12|awk -v d="`date "+%Y-%m-%d-%H-%M-%S"`" '{print $1":"$14":"$15":"$16 ":" d}'
::::2008-09-23-14-57-26
System::::2008-09-23-14-57-26
::::2008-09-23-14-57-26
kthr::::2008-09-23-14-57-26
-----::::2008-09-23-14-57-26
r:us:sy:id:2008-09-23-14-57-26
7:87:6:6:2008-09-23-14-57-26
4:79:5:15:2008-09-23-14-57-26
5:86:3:11:2008-09-23-14-57-26
6:89:4:7:2008-09-23-14-57-26
6:88:5:6:2008-09-23-14-57-26
6:90:3:6:2008-09-23-14-57-26
5:87:5:7:2008-09-23-14-57-26
6:89:5:6:2008-09-23-14-57-26

Thanks
Arun
# 5  
Old 09-23-2008
To get the actual time with every record:
Code:
vmstat 5 12|
awk '{"date +%Y-%m-%d-%H-%M-%S"|getline d
close("date +%Y-%m-%d-%H-%M-%S")
print $1":"$14":"$15":"$16 ":" d}'

Regards
# 6  
Old 09-24-2008
MySQL Thanks Genius Sir it works now

It works like a charm now,
thank you very much for helping.

Arun:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

[Solved] Need help in date display

Hi, I have one hp-ux sytem date display problem when viewed remotely hostA 21: date Fri Jul 5 11:18:51 SST 2013 hostA 22: remsh hostB -l username -n date 2013年07月05日 11時32分27秒 But on actual system it display correctly:confused: hostB 21: date Fri Jul 5 11:40:33 SST 2013 (4 Replies)
Discussion started by: jorendain
4 Replies

2. Shell Programming and Scripting

How to display a date, 30 days from the current date?

Well guys, I know the right syntax for displaying the current date is $(date). However, I am planning to send emails to some customers which displays their subscription date, and then the expiry. The expiry being 30 days from the current date. What would the right syntax be? (6 Replies)
Discussion started by: xxxx
6 Replies

3. UNIX for Dummies Questions & Answers

how to display date with filename??

Hi i am currently using below command in shell script and calling it from cron job. This is to take daily backup with the date as suffix to the file.When i try i unable to get the date suffixed to the backup file. Please help me as to wt's wrong in this or how to get the date added to the... (5 Replies)
Discussion started by: abhi_n123
5 Replies

4. UNIX for Dummies Questions & Answers

Date format Display Help

I have tried various arguments to get the date display as "Mar 10". I have tried date +"%c" -------> Wed Mar 10 11:51:21 EST 2010 date +"%b%d%Y_%H%M%S" --------> Mar102010_115121 date +"%b%d" -------> Mar10 date +"%t%b%e" ... (3 Replies)
Discussion started by: moveaix
3 Replies

5. UNIX for Dummies Questions & Answers

Date Display Format

Hello People, How can I display the date in a continuous format along with the time as below : 20091001_154547 i.e yyyymmdd_hhmmss format. Thanks. (3 Replies)
Discussion started by: sushant172
3 Replies

6. Shell Programming and Scripting

display filename with date

Hi buddies, I have a doubt. I want to display filename with date in the following format.Is there any way to do this. Kindly give me the solution. I want to display the result in the following manner. test1.txt 03/28/2008 testlog.log 02/20/2008 Please let me know one solution how to do... (1 Reply)
Discussion started by: pstanand
1 Replies

7. UNIX for Dummies Questions & Answers

vmstat output with date & timestamp

Hello all This is a sample vmstat output ... $ vmstat 2 2 kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr hx hx hx hx in sy cs us sy id 1 0 0 23105784 7810488 323 767 1742 5 5 0 0 0 0 0 0 683 780 457 43 ... (9 Replies)
Discussion started by: luft
9 Replies

8. Shell Programming and Scripting

Date display

Hello, Is there any easy way to write a script to display the date for the previous day? I have a script which queries a sybase database, and pull the data for certain time period. I'd like to know how you can get the day for previous day, something like: date - 1! Thanks, Frank (2 Replies)
Discussion started by: FrankC
2 Replies

9. Solaris

display date n Time

Hi Friends, Can any one guide me regarding 'Display the date and time' command other than the command 'date' thanks n regards SsRrIi (1 Reply)
Discussion started by: SsRrIi
1 Replies

10. Shell Programming and Scripting

PHP:display by date

Can php + MySQL display stuff out of table by its date.? e.g. In a table have id, date, title, details can php display the info three weeks before the date in the db? What fuction would i use? (3 Replies)
Discussion started by: perleo
3 Replies
Login or Register to Ask a Question