活运活用, 用Perl写了一个看AIX主机网卡流量的脚本, 差不多和"Hello, World"一样简单了.

#!/home/oracle/dbaperl/bin/perl -w
#
use AIX::Perfstat;

my $nettotal = AIX::Perfstat::netinterface_total();

my $preipkt = $nettotal->{ipackets};
my $preopkt = $nettotal->{opackets};
my $preibyt = $nettotal->{ibytes};
my $preobyt = $nettotal->{obytes};

while(1)
{
  sleep(10);
  $nettotal = AIX::Perfstat::netinterface_total();
  print($nettotal->{ipackets} - $preipkt,",");
  print($nettotal->{ibytes} - $preibyt, ",");
  print($nettotal->{opackets} - $preopkt,",");
  print($nettotal->{obytes} - $preobyt, "\n");
  $preipkt = $nettotal->{ipackets};
  $preopkt = $nettotal->{opackets};
  $preibyt = $nettotal->{ibytes};
  $preobyt = $nettotal->{obytes};
}

    输出的样本数据, 前面加个时间就更好了.

209293,25449294,179547,45651583
217798,26535501,188151,47684198
204486,25331561,175493,45920902
204652,25110514,175301,45952904
205024,25172192,176165,46227715
202194,24638398,172954,45765479

    只能一步一步来了. 好象需要加上Int64位运算支持, 才能准确显示数据.