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,$name)=split(/,/,$args{$_}); # print "zacatek: $_ $dev $oid $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"; # $_=; # chomp; # close FILE; # @array=split; my $num=4; my $scale1=0.1; my $scale2=0.001; my $add=0; my $freq=1; my $power=2; my $signal=3; my $temp=4; my $snr=5; my $qam=0; my $bw=0; #5 signal #6 snr #7 ber #8 temp #9 max speed #10 speed #12 tx freq #13 rx freq #14 tx speed #15 rx speed #18 atpc en dis #19 tx power #20 acm en dis #21 tx qam #22 rx qam #23 tx bw #24 rx bw # $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() { $var=$_; # print ">>>>>>>> : $_ \n"; if ($var =~ /^.*.23688.1.1.12.. = STRING: +(.*)$/) { $freq = $1; $freq =~ s/ MHz //g; $freq=$freq*$scale2; # print "freq : $freq \n"; } elsif ($var =~ /^.*.23688.1.1.19.. = INTEGER: +(.*)$/) { $power = $1; # print "power : $power \n"; } elsif ($var =~ /^.*.23688.1.1.5.. = Gauge32: +(.*)$/) { $signal = $1 * -1; # print "signal : $signal \n"; } elsif ($var =~ /^.*.23688.1.1.8.. = INTEGER: +(.*)$/) { $temp = $1; # print "temp : $temp \n"; } elsif ($var =~ /^.*.23688.1.1.6.. = Gauge32: +(.*)$/) { $snr = $1; $snr=$1*$scale1+$add; # print "snr : $snr \n"; } elsif ($var =~ /^.*.23688.1.1.21.. = INTEGER: +(.*)$/) { $qam = $1; $rate=$1*$scale1+$add; # print "qam : $qam \n"; } elsif ($var =~ /^.*.23688.1.1.23.. = Gauge32: +(.*)$/) { $bw = $1; # print "bw : $bw \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.":".$freq.":".$power.":".$signal.":".$temp.":".$snr.":".$qam.":".$bw; 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; WebSVN - hotsanic - Blame - Rev 36 - /trunk/modules/wireless-sd/platform/linux.pm
  jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [wireless-sd/] [platform/] [linux.pm] - Blame information for rev 36

 

Line No. Rev Author Line

Powered by WebSVN 2.2.1