Operating System - HP-UX
1820390 Members
3628 Online
109623 Solutions
New Discussion юеВ

How to generate graph with the sar reports

 
sanwin
Frequent Advisor

How to generate graph with the sar reports

Hi,
Could anyone help in generating the performance graphs using the sar data file.

regards,
sanwin
2 REPLIES 2
VK2COT
Honored Contributor

Re: How to generate graph with the sar reports

Hello,

There are many, many ways. Some commercial, some open-source.

I wonder why can't you use Glance + MeasureWare? Possibly licensing issue?

Anyway, here are some of many possibilities
(listed here in random order):

a) Commercial SarCheck:

http://www.sarcheck.com/

b) Open-source Ksar sar grapher:

http://ksar.atomique.net/download.html

c) Perl scripts based on modules like GIFgraph::bars.
One example for Linux (relativey easy to port to HP-UX):

http://linuxshellaccount.blogspot.com/2008/01/linux-perl-script-to-graph-out-paging.html

d) Download the data into an Excel or other type of
spreadsheet and graph it within it.

Here is a simple CSV file creation for CPU utilisation in 10 iterations (just to give
you an idea how simple it is):

sar -u 10 10 | tr -s ' ' ',' > cpu.csv

e) Use Gnuplot. Some examples:

http://www.itworld.com/nls_unixsar021024
http://in2nix.com/examples/index.html

f) Open-source Sargraph (inputs data into gnuplot):

http://www.mayoxide.com/sargraph/

g) Open-source RRDtool:

http://oss.oetiker.ch/rrdtool/
http://haroon.sis.utoronto.ca/rrd/scripts/

h) Open-source Cacti( front-end to RRDtool):

http://www.cacti.net/

And so on.

Cheers,

VK2COT

PS. Many years ago (I think somewhere around 1999) , I wrote the following Perl script that generated three CSV files
for Solaris servers. They were then imported into Excel...

#!/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;
$Realmonth = "Jan";

($::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 = "/sardata/${FR}${Realmonth}${Year}-DSK_RWS.txt";
$Result2 = "/sardata/${FR}${Realmonth}${Year}-DSK_BUSY.txt";
$Result3 = "/sardata/${FR}${Realmonth}${Year}-DSK_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";
close(To1);
close(To2);
close(To3);
close(FROM);
exit;

foreach $z (sort keys %WholeComplex) {
print "$z $WholeComplex{$z}\n";
}

exit(0);
VK2COT - Dusan Baljevic
SumitBiswas
New Member

Re: How to generate graph with the sar reports

After sar report is collected, next step is to visualize the report. For that https://github.com/sumitbiswasgit/sarbox can be used which will help to display numbers into graphs for different categories.