process=1
####
$process=1;
####
print datehradr":"datemmadjr...
####
# perl's print doesn't add in the \n for you
print "$datehradr:$datemmadjr...\n"
####
sar -n DEV -f sa17|perl -a -ne'
BEGIN {
$mydate="2008-02-17";
$lastdate=99;
}
{
$process=0;
if ( substr($F[2],0,3) eq "eth" ) {
$process=1;
}
if ( substr($F[2],0,3) eq "bon" ) {
$process=1;
}
if ( $F[2] eq "eth0" ) {
$process=1;
}
if ( ! ( $F[1] eq "AM" || $F[1] eq "PM" ) ) {
$process=0;
}
if ( $F[2] eq "IFACE" ) {
$process=0;
}
if ( $process == 0 ) {
next;
}
$currentdate=$F[0];
if ( $lastdate != $currentdate && $lastdate != 99 )
{
print "$datehradj:$datemmadj:$datessadj $myeth0 $myeth1\n";
$mybond0=0;
$myeth0=0;
}
if ( $F[2] eq "eth0" ) {
$myeth0=$F[5];
}
if ( $F[2] eq "eth0" ) {
$myeth1=$F[6];
}
$filetime=$F[0];
$filehour=substr($filetime,0,2);
$fileminute=substr($filetime,3,2);
$filesecond=substr($filetime,6,2);
if ( $F[1] eq "AM" && $filehour == 12 ) {
$filehour="00";
}
if ( $F[1] eq "PM" && $filehour < 12 ) {
$filehour=$filehour+12;
}
$filedaysecs=(($filehour*60*60)+($fileminute*60));
$dateadj=(int(( $filedaysecs + 300 ) / 600) * 600);
$datehradj=int(((int(( $filedaysecs + 300 ) / 600) * 600)) / 3600 );
$datemmadj=int((((int(( $filedaysecs + 300 ) / 600) * 600)) % 3600 ) / 60 );
if ( $datehradj == 0 ) {
$datehradj="00";
}
if ( length($datehradj) == 1 ) {
$datehradj="0$datehradj";
}
if ( $datemmadj == 0 ) {
$datemmadj="00";
}
$datessadj="00";
$lastdate=$F[0];
}
END {
print "$datehradj:$datemmadj:$datessadj $myeth0 $myeth1\n";
}' >> sarnetwork