- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script to add time
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 01:37 AM
тАО04-21-2006 01:37 AM
Has anyone developed a script or can give me a clue on how to go about for the following.
I have collected iostat output running with interval of 600 secs and for a count of 144 - thus it runs for 24 hrs, the output is redirected to a file. Now If I want to insert the time in the stats file , knowing the start time and the interval - how can I do this ? e.g. I start to collect iostat as
iostat 600 144 > iostat.out
at say 10:00 on 210406 then I want to insert the date:time for each entry in the iostat output. The output for a particular interval is seperated by blank lines (you can see running the command for small interval and count to see the output file)
so if output is like
c100t6d0 113 12.9 1.0
c100t5d0 21 4.1 1.0
c100t6d0 120 17.6 1.0
c100t5d0 43 5.5 1.0
.
.
and so on. and I want to have output like
210406#10:00 c100t6d0 113 12.9 1.0
210406#10:00 c100t5d0 21 4.1 1.0
210406#10:10 c100t6d0 120 17.6 1.0
210406#10:10 c100t5d0 43 5.5 1.0
.
.
and so on. Also the date change should be taken into account as the stats are for 24 hrs or more.
Thanks a lot,
Ninad
Solved! Go to Solution.
- Tags:
- iostat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 01:48 AM
тАО04-21-2006 01:48 AM
Re: Script to add time
IOSTAT=`iostat 5 5`
echo "`date` $IOSTAT" >> iostat.out
or something like that...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 02:01 AM
тАО04-21-2006 02:01 AM
Re: Script to add time
The problem with your suggestion is that each time the iostat runs it first shows the stats till that point in time - or something like that as the first output and then it shows the actual stats collected for the mentioned interval - this is one problem. The second problem is that if I get the iostat output in IOSTAT variable then there are no new line characters seperating the outputs for each disk.
Can you suggest some alternative.
Thanks,
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 02:03 AM
тАО04-21-2006 02:03 AM
Re: Script to add time
sar -d 1 1|awk 'NR > 4 {print "'"`date +%d%m%y`"'#"$0}'
output looks like this
210406#09:00:18 c8t0d0 6.00 0.50 4 24 1.86 19.72
210406# c19t0d0 2.00 0.50 2 16 0.73 16.09
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 02:15 AM
тАО04-21-2006 02:15 AM
Re: Script to add time
Thats a nice one, but I want to use iostat as it gives the disk stats for all disks, where as sar gives stats for the most used disks - Please correct me if I am wrong.
Thanks,
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 02:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 02:19 AM
тАО04-21-2006 02:19 AM
Re: Script to add time
with GNU-awk it's a oneliner, a nearly identical perl solution should be easy.
- I skip empty lines.
- Note, that depending an your header lines of iostat, you have to change for padding.
- Your date format consists of 10chars - thats
the number of blanks in the first print statement.
iostat ... | gawk -v head=2 'NR<=head {print " ",$0}; NR>head && NF {print strftime("%d%m%y#%H:%M"),$0}'
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 02:41 AM
тАО04-21-2006 02:41 AM
Re: Script to add time
iostat|awk 'NR > 3 {print "'"`date +%d%m%y#%T `"'"$0}'
210406#09:40:15 c8t0d0 0 0.0 1.0
210406#09:40:15 c19t0d0 0 0.0 1.0
210406#09:40:15 c19t3d0 0 0.0 1.0
210406#09:40:15 c8t3d0 0 0.0 1.0
210406#09:40:15 c8t1d0 0 0.0 1.0
210406#09:40:15 c8t2d0 0 0.0 1.0
210406#09:40:15 c19t1d0 0 0.0 1.0
210406#09:40:15 c19t2d0 0 0.0 1.0
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2006 02:49 AM
тАО04-21-2006 02:49 AM
Re: Script to add time
Thats exactly what I wanted.
Thanks a lot for the wonderful help.
Peter,
Unfortunately I dont have gawk currently. But will use your suggestion some time latter.
Thanks,
Ninad