jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
133simandlpackage HotSaNICmod::OSdep;
2 
3use RRDs;
4 
5sub version {
6 ($VERSION = '$Revision: 1.4 $') =~ s/.*(\d+\.\d+).*/$1/;
7 return "$^O.pm $VERSION";
8 }
9 
10sub sample {
11 my %args=@_;
12 
13#uncomment this for debug output to temp.txt
14#all print will be done into the file
15#$temp = "/opt/HotSaNIC/modules/sensors/temp.txt";
16#open (TEMPFILE,">$temp");
17#open (STDERR,">&TEMPFILE") || die ("open STDERR failed");
18#open (STDOUT,">&TEMPFILE") || die ("open STDOUT failed");
19 
20 foreach (keys(%args)) {
21 
22 if (index($_,"IP") >= 0 ) {
23 my ($dev,$oid,$name)=split(/,/,$args{$_});
24 
25# print "zacatek: $_ $dev $oid $name \n";
26 
27# 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";
28# $_=<FILE>;
29# chomp;
30# close FILE;
31 
32# @array=split;
33 my $num=4;
34 my $scale1=0.1;
35 my $scale2=0.000001;
36 my $add=0;
37 
38 my $freq=1;
39 my $power=2;
40 my $signal=3;
41 my $temp=4;
42 my $snr=5;
43 my $qam=0;
44 my $bw=0;
45 #5 signal .1.3.6.1.4.1.193.223.2.7.1.1.1.110101 = STRING: "-29.8"
46 #6 snr .1.3.6.1.4.1.193.223.2.7.1.1.43.110101 = STRING: "30.3"
47 #7 ber
48 #8 temp
49 #9 max speed
50 #10 speed
51 #12 tx freq SNMPv2-SMI::enterprises.193.223.2.7.1.1.13.110101 = INTEGER: 83000000
52 #13 rx freq
53 #14 tx speed
54 #15 rx speed
55 #18 atpc en dis
56 #19 tx power .1.3.6.1.4.1.193.223.2.7.1.1.2.110101 = STRING: "10.8"
57 #20 acm en dis
58 #21 tx qam SNMPv2-SMI::enterprises.193.223.2.7.1.1.3.110101 = STRING: "128_QAM"
59 #22 rx qam
60 #23 tx bw SNMPv2-SMI::enterprises.193.223.2.7.1.1.9.110101 = INTEGER: 302
61 #24 rx bw
62 
63# $command = "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2";
64# print "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2";
65 $command = "/usr/bin/snmpwalk -Cc -On -c public -v 1 $dev $oid | tr '\"' ' '";
66 open (FILE,"$command|");
67 while(<FILE>) {
68 $var=$_;
69# print ">>>>>>>> : $name \n";
70# print ">>>>>>>> : $_ \n";
71 if ($var =~ /^.*.193.223.2.7.1.1.13.110101 = INTEGER: +(.*)$/) {
72 $freq = $1;
73 $freq=$freq*$scale2;
74# print "freq : $freq \n";
75 } elsif ($var =~ /^.*.193.223.2.7.1.1.2.110101 = STRING: +(.*)$/) {
76 $power = $1*1;
77# print "power : $power \n";
78 } elsif ($var =~ /^.*.193.223.2.7.1.1.1.110101 = STRING: +(.*)$/) {
79 $signal = $1 * 1;
80# print "signal : $signal \n";
81 } elsif ($var =~ /^.*.23688.1.1.8.. = INTEGER: +(.*)$/) {
82 $temp = $1*1;
83# print "temp : $temp \n";
84 } elsif ($var =~ /^.*.193.223.2.7.1.1.43.110101 = STRING: +(.*)$/) {
85 $snr = $1*1;
86# print "snr : $snr \n";
87 } elsif ($var =~ /^.*.193.223.2.7.1.1.3.110101 = STRING: +(.*)$/) {
88 $qam = $1;
89 $qam=~ s/_QAM//g;
90 $qam= log($qam)/log(2);
91# print "qam : $qam \n";
92 } elsif ($var =~ /^.*.193.223.2.7.1.1.9.110101 = INTEGER: +(.*)$/) {
93 if ($1 == 302) {$bw=2};
94 if ($1 == 300) {$bw=1.5};
95 if ($1 == 298) {$bw=1};
96 if ($1 == 273) {$bw=.75};
97 if ($1 == 272) {$bw=.5};
98 if ($1 == 271) {$bw=.25};
99 if ($1 == 270) {$bw=.125};
100 if ($1 == 302) {$bw=2};
101# print "bw : $bw \n";
102 }
103 }
104 close(FILE);
105 
106 # build new database if needed
107 if ( ! -e "rrd/$name.rrd" ) { system("./makerrd","$name","U") }
108 
109 # update database
110 RRDs::update "rrd/$name.rrd",time.":".$freq.":".$power.":".$signal.":".$temp.":".$snr.":".$qam.":".$bw;
111 if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to update `$name.rrd': $ERROR\n"; }
112 
113 }
114 }
115#uncomment this for debug output to temp.txt
116#all print will be done into the file
117# close (TEMPFILE);
118# close (STDERR);
119# close (STDOUT);
120 }
121 
1221;
123 

Powered by WebSVN 2.2.1