jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [fiber-100g/] [platform/] [linux.pm] - Rev 32

Compare with Previous - Blame - Download


package HotSaNICmod::OSdep;

use RRDs;

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

sub sample {
  my %args=@_;

#uncomment this for debug output to temp.txt
#all print will be done into the file
#$temp = "/opt/HotSaNIC/modules/sensors/temp.txt";
#open (TEMPFILE,">$temp");
#open (STDERR,">&TEMPFILE")  || die ("open STDERR failed");
#open (STDOUT,">&TEMPFILE")  || die ("open STDOUT failed");

  foreach (keys(%args)) {

    if (index($_,"IP") >= 0 ) {
      my ($dev,$oid,$port,$name)=split(/,/,$args{$_});

#      print "zacatek: $_ $dev $oid $port $name \n";

#      open(FILE,"/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2 ") || print time," ",$args{MODNAME},": Unable to tady open $dev $oid $name .\n";
#      $_=<FILE>;
#      chomp;
#      close FILE;

#      @array=split;
      my $num=4;
      my $scale1=0.1;
      my $scale2=0.01;
      my $scale3=0.001;
      my $scale4=0.0000001;
      my $add=0;

      my $ber=1;
      my $temp=2;
      my $rx1=3;
      my $snr1=4;
      my $rx2=5;
      my $rx2=6;
      my $preber=6;
      my $isi1=7;
      my $isi2=8;
#[root@jablonecka modules]# snmpwalk -c public -v 2c 10.33.154.1 .1.3.6.1.2.1.99.1.1.1.4 | grep 100349
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349201 = INTEGER: 606
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349202 = INTEGER: 325
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349203 = INTEGER: 1440
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349204 = INTEGER: 0
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349211 = INTEGER: 7137
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349212 = INTEGER: 1011
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349213 = INTEGER: 13413
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349214 = INTEGER: 1859
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349215 = INTEGER: 2270
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349216 = INTEGER: 2049
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349217 = INTEGER: 600
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349219 = INTEGER: 4
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349221 = INTEGER: 8727
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349222 = INTEGER: 1010
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349223 = INTEGER: 10281
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349224 = INTEGER: 1884
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349225 = INTEGER: 2270
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349226 = INTEGER: 2049
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349227 = INTEGER: 720
#SNMPv2-SMI::mib-2.99.1.1.1.4.100349229 = INTEGER: 6
#[root@jablonecka modules]# snmpwalk -c public -v 2c 10.33.154.1 1.3.6.1.2.1.47.1.1.1.1.2 | grep t49
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100100048 = STRING: "Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100100049 = STRING: "Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100100050 = STRING: "Ethernet49/3"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100100051 = STRING: "Ethernet49/4"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349100 = STRING: "Xcvr for Ethernet49"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349201 = STRING: "DOM Temperature Sensor for Ethernet49"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349202 = STRING: "DOM Voltage Sensor for Ethernet49"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349203 = STRING: "DOM Pre-FEC BER Sensor for Ethernet49"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349204 = STRING: "DOM Uncorrected BER Sensor for Ethernet49"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349210 = STRING: "Lane 0 for Xcvr for Ethernet49"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349211 = STRING: "DOM TX Bias Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349212 = STRING: "DOM TX Power Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349213 = STRING: "DOM RX Power Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349214 = STRING: "DOM SNR Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349215 = STRING: "DOM Residual ISI Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349216 = STRING: "DOM Level Transition Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349217 = STRING: "DOM TEC Current Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349219 = STRING: "DOM Laser Temperature Error Sensor for Ethernet49/1"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349220 = STRING: "Lane 1 for Xcvr for Ethernet49"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349221 = STRING: "DOM TX Bias Sensor for Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349222 = STRING: "DOM TX Power Sensor for Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349223 = STRING: "DOM RX Power Sensor for Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349224 = STRING: "DOM SNR Sensor for Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349225 = STRING: "DOM Residual ISI Sensor for Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349226 = STRING: "DOM Level Transition Sensor for Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349227 = STRING: "DOM TEC Current Sensor for Ethernet49/2"
#SNMPv2-SMI::mib-2.47.1.1.1.1.2.100349229 = STRING: "DOM Laser Temperature Error Sensor for Ethernet49/2"

#                $command = "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2";
                $command = "/usr/bin/snmpwalk -Cc -On -c public -v 1 $dev $oid | tr '\"' ' '";
                open (FILE,"$command|");
                while(<FILE>) {
                        $var=$_;
                                print ">>>>fiber>>>> : $_ \n";
                        if      ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}204 = INTEGER: +(.*)$/) {
                                $ber = $1*$scale2;
                                $ber=$ber;
                                print "ber : $ber \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}213 = INTEGER: +(.*)$/) {
                                $rx1 = 10* log(1000*$1*$scale4)/log(10);
                                print "rx1 : $rx1 \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}214 = INTEGER: +(.*)$/) {
                                $snr1 = $1*$scale2;
                                print "snr1 : $snr1 \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}201 = INTEGER: +(.*)$/) {
                                $temp = $1*$scale1;
                                print "temp : $temp \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}223 = INTEGER: +(.*)$/) {
                                $rx2 = 10* log(1000*$1*$scale4)/log(10);
                                print "rx2 : $rx2 \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}224 = INTEGER: +(.*)$/) {
                                $snr2 = $1*$scale2;
                                print "snr2 : $snr2 \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}203 = INTEGER: +(.*)$/) {
                                $preber = $1*$scale2;
                                print "preber : $preber \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}215 = INTEGER: +(.*)$/) {
                                $isi1 = $1*$scale2;
                                print "isi1 : $isi1 \n";
                        } elsif ($var =~ /^.1.3.6.1.2.1.99.1.1.1.4.1003${port}225 = INTEGER: +(.*)$/) {
                                $isi2 = $1*$scale2;
                                print "isi2 : $isi2 \n";
                        }
                }
                close(FILE);

      # build new database if needed
      if ( ! -e "rrd/$name.rrd" ) { system("./makerrd","$name","U") }

      # update database
      RRDs::update "rrd/$name.rrd",time.":".$ber.":".$temp.":".$rx1.":".$snr1.":".$rx2.":".$snr2.":".$preber.":".$isi1.":".$isi2;
      if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},":  unable to update `$name.rrd': $ERROR\n"; }

      }
    }
#uncomment this for debug output to temp.txt
#all print will be done into the file
#       close (TEMPFILE);
#       close (STDERR);
#       close (STDOUT);
  }

1;


Powered by WebSVN 2.2.1