Простой вывод
sar -H 30 100 | perl -lane '$,=qq(\t);if ($F[0] =~/\d\d:\d\d\:\d\d/) { $time=$F[0];shift @F;print "\n"} print $time,@F '
sar -dR -f /var/adm/sa/sa19 | perl -lane 'BEGIN{open F,"< dev_to_ASM.list";local $/="";$_= <F>; %h=(split /\t|\n/ , $_ );};$,=qq(\t);if ($F[0] =~/\d\d:\d\d\:\d\d/) { $time=$F[0];shift @F} print $time, $h{$F[0]},@F if $F[-1]>20'
Sar -d парсится скиптом
===== p_lsmap.pl ===
$DISKS=`cat disks.txt | tr "\n" "\|"`;
$NFR=0;
while ( $line = <> )
{
chomp ($line) ;
#skip empty, summary and head line
next if ( $line =~ /^$/ );
next if ( $line =~ /Average/ );
next if ( $line =~ /device/ );
#date extract for HP-UX
if ( $line =~ /^HP-UX/ ) {
@date = split(" ",$line);
next;
}
if ( $line =~ /[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ ) {
toprint() if $NFR;
( $m,$d,$Y ) = split ("/", $date[-1] );
( $time,$device,$busy,$avque,$rs,$ws,$blks,$avwait,$avserv ) = split ( " ", $line );
next unless ( $device );
$Sbusy = 0;$Savque = 0;$Srs = 0;$Sws = 0;$Sblks = 0;$Savwait = 0;$Savserv = 0; $Count = 0;
} else {
( $device,$busy,$avque,$rs,$ws,$blks,$avwait,$avserv ) = split ( " ", $line );
}
if ( $device =~ /$DISKS/ ) {
# print $device;
$Sbusy = $Sbusy + $busy;$Savque=$Savque+$avque;$Srs=$Srs+$rs;$Sws=$Sws+$ws;
$Sblks=$Sblks+$blks;$Savwait=$Savwait+$Savwait;$Savserv=$Savserv+$avserv;
$Count++;$NFR=1;
}
}
toprint() if $NFR;
exit;
sub toprint {
print join (" ",join("/",2000 + $Y,$m,$d),$time,sprintf("%.2f",$Sbusy/$Count),sprintf("%.2f",$Savque/$Count),$Srs,$Sws,sprintf("%.2f",$Sblks/2048),$Savwait,sprintf("%.2f",$Savserv/$Count)),"\n";
}
exit;
$NFR=0;
while ( $line = <> )
{
chomp ($line) ;
#skip empty, summary and head line
next if ( $line =~ /^$/ );
next if ( $line =~ /Average/ );
next if ( $line =~ /device/ );
#date extract for HP-UX
if ( $line =~ /^HP-UX/ ) {
@date = split(" ",$line);
next;
}
if ( $line =~ /[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ ) {
toprint() if $NFR;
( $m,$d,$Y ) = split ("/", $date[-1] );
( $time,$device,$busy,$avque,$rs,$ws,$blks,$avwait,$avserv ) = split ( " ", $line );
next unless ( $device );
$Sbusy = 0;$Savque = 0;$Srs = 0;$Sws = 0;$Sblks = 0;$Savwait = 0;$Savserv = 0; $Count = 0;
} else {
( $device,$busy,$avque,$rs,$ws,$blks,$avwait,$avserv ) = split ( " ", $line );
}
if ( $device =~ /$DISKS/ ) {
# print $device;
$Sbusy = $Sbusy + $busy;$Savque=$Savque+$avque;$Srs=$Srs+$rs;$Sws=$Sws+$ws;
$Sblks=$Sblks+$blks;$Savwait=$Savwait+$Savwait;$Savserv=$Savserv+$avserv;
$Count++;$NFR=1;
}
}
toprint() if $NFR;
exit;
sub toprint {
print join (" ",join("/",2000 + $Y,$m,$d),$time,sprintf("%.2f",$Sbusy/$Count),sprintf("%.2f",$Savque/$Count),$Srs,$Sws,sprintf("%.2f",$Sblks/2048),$Savwait,sprintf("%.2f",$Savserv/$Count)),"\n";
}
exit;
=====
файлик для gpuplot
======
# set terminal pngcairo transparent enhanced fontscale 1.0 size 500, 350
# set output 'approximate.1.png'
set style fill solid 0.40 noborder
set format y "%.1f"
set key inside center top vertical Left reverse enhanced autotitles nobox
set encoding utf8
set samples 500, 500
set xtics norangelimit
set xtics ("-π" -3.14159, "-π/2" -1.57080, 0.00000, "π/2" 1.57080, "π" 3.14159)
set title "Polynomial approximation of sin(x)"
set xrange [ -3.20000 : 3.20000 ] noreverse nowriteback
approx_1(x) = x - x**3/6
approx_2(x) = x - x**3/6 + x**5/120
approx_3(x) = x - x**3/6 + x**5/120 - x**7/5040
GPFUN_approx_1 = "approx_1(x) = x - x**3/6"
GPFUN_approx_2 = "approx_2(x) = x - x**3/6 + x**5/120"
GPFUN_approx_3 = "approx_3(x) = x - x**3/6 + x**5/120 - x**7/5040"
label1 = "x - {x^3}/3!"
label2 = "x - {x^3}/3! + {x^5}/5!"
label3 = "x - {x^3}/3! + {x^5}/5! - {x^7}/7!"
plot '+' using 1:(sin($1)):(approx_1($1)) with filledcurve title label1 lt 3, '+' using 1:(sin($1)):(approx_2($1)) with filledcurve title label2 lt 2, '+' using 1:(sin($1)):(approx_3($1)) with filledcurve title label3 lt 1, sin(x) with lines lw 1 lc rgb "black"
# set output 'approximate.1.png'
set style fill solid 0.40 noborder
set format y "%.1f"
set key inside center top vertical Left reverse enhanced autotitles nobox
set encoding utf8
set samples 500, 500
set xtics norangelimit
set xtics ("-π" -3.14159, "-π/2" -1.57080, 0.00000, "π/2" 1.57080, "π" 3.14159)
set title "Polynomial approximation of sin(x)"
set xrange [ -3.20000 : 3.20000 ] noreverse nowriteback
approx_1(x) = x - x**3/6
approx_2(x) = x - x**3/6 + x**5/120
approx_3(x) = x - x**3/6 + x**5/120 - x**7/5040
GPFUN_approx_1 = "approx_1(x) = x - x**3/6"
GPFUN_approx_2 = "approx_2(x) = x - x**3/6 + x**5/120"
GPFUN_approx_3 = "approx_3(x) = x - x**3/6 + x**5/120 - x**7/5040"
label1 = "x - {x^3}/3!"
label2 = "x - {x^3}/3! + {x^5}/5!"
label3 = "x - {x^3}/3! + {x^5}/5! - {x^7}/7!"
plot '+' using 1:(sin($1)):(approx_1($1)) with filledcurve title label1 lt 3, '+' using 1:(sin($1)):(approx_2($1)) with filledcurve title label2 lt 2, '+' using 1:(sin($1)):(approx_3($1)) with filledcurve title label3 lt 1, sin(x) with lines lw 1 lc rgb "black"
======
Комментариев нет:
Отправить комментарий