jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [traffic/] [platform/] [linux.pm] - Rev 1

Compare with Previous - Blame - Download


package HotSaNICmod::OSdep;

sub version {
  ($VERSION = '$Revision: 1.10 $') =~ s/.*(\d+\.\d+).*/$1/;
  return "$^O.pm $VERSION";
  }

sub sample {
  my %args=@_;

  my %devin;
  my %devout;
  my %sampletime;

  # first sample device stats
  #
  open(IN,"/proc/net/dev");
  while(<IN>) {
    chomp;
    if ( /:/ ) {
      my ($combined, $a, undef, undef, undef, undef, undef, undef, $output, $e)=split;
      ($name, $input)=split(":",$combined);
      if(!$input) { ($input, $output) = ($a, $e); }
      $devin{$name}=$input;
      $devout{$name}=$output;
      $sampletime{$name}=time;
      }
    }
  close(IN);

  # then feed all configured items into the DBs
  #
  foreach my $entry (@{$args{DEV}}) {
    my ($host,undef,$item,$dbname,undef,undef,$description,$maxin,$maxout)=HotSaNICmod::common::get_names($entry);
    if ($host eq "") {
      my $devin=$devin{$item} || "U";
      my $devout=$devout{$item} || "U";
      my $sampletime=$sampletime{$item} || time;

      # if max-transmission is not set, assume 100 MBit.
      #
      my $max=$maxin;
      if ($max < $maxout) { $max=$maxout };
      if ($max == 0) { $max=12500000; }

      HotSaNICmod::do_rrd($dbname,$max,$sampletime,$devin,$devout);
      }
    }
  }

1;


Powered by WebSVN 2.2.1