Perl监控AIX的网卡流量

    活运活用, 用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位运算支持, 才能准确显示数据.

发表留言:

« Previous | Main | Next »

英语900句 | English 900

  • In this country, the weather is usually very awful.
  • 在这个国家, 天气通常十分恶劣.
  • It is a very beautiful country with many mountains.
  • 这是一个多山的美丽国度.
  • This country is famous for its beautiful lakes.
  • 这个国家以其美丽的湖泊而闻名于世.
  • The land in this region is rather dry and parched.
  • 这片土地十分干燥.
  • Along the northern coast of this continent, there are many crags.
  • 沿该大陆的北海岸线上有许多峭壁.