- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sar -d formatting
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
тАО01-22-2009 07:08 PM
тАО01-22-2009 07:08 PM
sar -d -f sa07 > sa07-disk.out
Now what I'm trying to figure out is if there's any way to get dates in front of every entry in my output by reformatting it via a script or set of commands.. I'm ultimately trying to import this data into a spreadsheet to sort and look at highest to lowest colums, but I also need to know the times for each of the entries I'm interested in.
Any ideas that can be shared would be greatly appreciated.
Thanks,
/KPS
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 07:44 PM
тАО01-22-2009 07:44 PM
Re: sar -d formatting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 08:50 PM
тАО01-22-2009 08:50 PM
SolutionSeveral years ago, I did just that. Albeit,
it was for Solaris servers but the logic
is the same.
Here is the Perl script:
#!/usr/bin/perl
# 00:00:00 device %busy avque r+w/s blks/s avwait avserv
#use strict;
use Getopt::Std;
use File::Basename;
use vars qw(@Header $z %Disk %RW @Keyspaces @Onetime $Time
$FF $SAFile $Disk @WholeComplex $RW %WholeComplex @Servdata
$Realmonth $Month $Sec $Min $Hour $DayOfMonth $Month $Year
$Result $FR $DayOfWeek $DayofYear $IsDST);
($Sec, $Min, $Hour, $DayOfMonth, $Month, $Year, $DayOfWeek, $DayofYear, $IsDST) = localtime ;
# localtime returns January..December as 0..11.
$Realmonth = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)[$Month];
$Month++;
$Year = 1900 + $Year;
($::opt_f) = (); #avoid warning message
getopts('f:');
$::SAFile = $::opt_f;
if (! "$SAFile" ) {
$FF = "";
} else {
$FF = "-f $SAFile";
}
$FR = basename($SAFile);
print "Processing SAR file $SAFile ($FR)\n";
$Result1 = "/mydir/mysrv-sar-data/${FR}${Realmonth}${Year}-DISK_RWS.txt";
$Result2 = "/mydir/mysrv-sar-data/${FR}${Realmonth}${Year}-DISK_BUSY.txt";
$Result3 = "/mydir/mysrv-sar-data/${FR}${Realmonth}${Year}-DISK_AVSERV.txt";
open(To1, ">$Result1") or die "ERROR: Can't open $Result: $!";
open(To2, ">$Result2") or die "ERROR: Can't open $Result: $!";
open(To3, ">$Result3") or die "ERROR: Can't open $Result: $!";
open(FROM,"sar -d $FF | awk '! /%/ && ! /,/ {print}'|") || die "Cannot open sar data";
while (
chomp;
if (/:/ .. /^$/) {
@Keyspaces = split(/\s+/, $_);
if (grep(/:/, $_)) {
$Time = $Keyspaces[0];
printf To1 "\n$Time ";
printf To2 "\n$Time ";
printf To3 "\n$Time ";
if (! grep(/\bTimeStamp/, @Header)) {
push @Header, "\nTimeStamp ";
}
}
$Disk{$Time} = $Keyspaces[1];
$Busy{$Time} = $Keyspaces[2];
$Avserv{$Time} = $Keyspaces[$#{Keyspaces}];
$RW{$Time} = $Keyspaces[4];
printf To1 "$RW{$Time} ";
printf To2 "$Busy{$Time} ";
printf To3 "$Avserv{$Time} ";
if (! grep(/\b$Disk{$Time}/, @Header)) {
push @Header, "$Disk{$Time} ";
}
}
}
printf To1 "@Header\n";
printf To2 "@Header\n";
printf To3 "@Header\n";
exit(0);
In this specific case, I save different
metrics into different files, but it
is quite easy to put them into the same file :)
I also just tested my old script on Fedora 10
server and it worked. Here are parts of
myhost-sa15Jan2009-DISK_RWS.txt:
...
10:30:01 0.00
10:30:01 0.00
10:30:01 0.00
10:30:01 0.00
10:30:01 0.00
10:30:01 0.00
10:30:01 4.33
10:30:01 4.33
10:30:01 4.33
10:30:01 0.00
10:30:01 0.00
10:40:01 0.03
10:40:01 0.00
10:40:01 0.00
10:40:01 0.00
...
I hope it helps you,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 08:53 PM
тАО01-22-2009 08:53 PM
Re: sar -d formatting
(so that you can compare them with what
gets reported via my Perl script):
Linux 2.6.27.9-159.fc10.i686 (bmyhost.mydom.dom) 01/16/2009
12:00:02 AM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz awai
t svctm %util
12:10:02 AM dev8-0 0.71 1.20 17.36 26.33 0.03 39.9
0 1.19 0.08
12:10:02 AM dev8-1 0.00 0.00 0.00 0.00 0.00 0.0
0 0.00 0.00
12:10:02 AM dev8-2 0.40 0.00 8.09 20.49 0.02 42.7
6 1.11 0.04
12:10:02 AM dev8-3 0.29 0.53 9.17 33.47 0.01 37.2
5 2.67 0.08
12:10:02 AM dev8-4 0.00 0.00 0.00 0.00 0.00 0.0
0 0.00 0.00
12:10:02 AM dev8-5 0.02 0.67 0.09 38.00 0.00 22.0
8 22.00 0.04
12:10:02 AM dev8-6 0.00 0.00 0.00 0.00 0.00 0.0
0 0.00 0.00
12:10:02 AM dev8-7 0.00 0.00 0.00 0.00 0.00 0.0
0 0.00 0.00
12:10:02 AM dev8-16 0.00 0.00 0.00 0.00 0.00 0.0
0 0.00 0.00
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 05:59 AM
тАО01-23-2009 05:59 AM
Re: sar -d formatting
/KPS