jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
134simandlpackage 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.001;
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#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.3.16842752 = INTEGER: 1
63#txpower .1.3.6.1.4.1.119.2.3.69.501.8.1.1.4.16842752 = STRING: "+11.0"
64#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.5.16842752 = INTEGER: 1
65#rssi .1.3.6.1.4.1.119.2.3.69.501.8.1.1.6.16842752 = STRING: "-47.2"
66#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.7.16842752 = INTEGER: 1
67#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.8.16842752 = STRING: "-57"
68#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.9.16842752 = INTEGER: 0
69#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.10.16842752 = STRING: "**"
70#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.11.16842752 = INTEGER: 1
71#temp .1.3.6.1.4.1.119.2.3.69.501.8.1.1.12.16842752 = STRING: "+29.2"
72#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.13.16842752 = INTEGER: 127
73#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.14.16842752 = STRING: "0.0E-10"
74#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.3.8585216 = STRING: "**"
75#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.3.8650752 = STRING: "**"
76#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.4.8585216 = INTEGER: 0
77#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.4.8650752 = INTEGER: 0
78#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.5.8585216 = STRING: "**"
79#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.5.8650752 = STRING: "**"
80#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.6.8585216 = INTEGER: 0
81#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.6.8650752 = INTEGER: 0
82#.1.3.6.1.4.1.119.2.3.69.501.4.2.1.4.16842752 = STRING: "82500.000"
83#tx freq .1.3.6.1.4.1.119.2.3.69.501.4.2.1.3.16842752 = STRING: "72500.000"
84 
85# $command = "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2";
86 $command = "/usr/bin/snmpwalk -Cc -On -c public -v 1 $dev $oid | tr '\"' ' '";
87 open (FILE,"$command|");
88 while(<FILE>) {
89 $var=$_;
90# print ">>>>>>>> : $_ \n";
91 if ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.4.2.1.3.16842752 = STRING: +(.*)$/) {
92 $freq = $1;
93 $freq=$freq*$scale2;
94# print "freq : $freq \n";
95 } elsif ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.8.1.1.4.16842752 = STRING: +(.*)$/) {
96 $power = $1*1;
97# print "power : $power \n";
98 } elsif ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.8.1.1.6.16842752 = STRING: +(.*)$/) {
99 $signal = $1 * 1;
100# print "signal : $signal \n";
101 } elsif ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.8.1.1.12.16842752 = STRING: +(.*)$/) {
102 $temp = $1*1;
103# print "temp : $temp \n";
104 } elsif ($var =~ /^.*.193.223.2.7.1.1.43.110101 = STRING: +(.*)$/) {
105 $snr = $1*1;
106# print "snr : $snr \n";
107 } elsif ($var =~ /^.*.193.223.2.7.1.1.3.110101 = STRING: +(.*)$/) {
108 $qam = $1;
109 $qam=~ s/_QAM//g;
110 $qam= log($qam)/log(2);
111# print "qam : $qam \n";
112 } elsif ($var =~ /^.*.193.223.2.7.1.1.9.110101 = INTEGER: +(.*)$/) {
113 if ($1 == 302) {$bw=2};
114 if ($1 == 300) {$bw=1.5};
115 if ($1 == 298) {$bw=1};
116 if ($1 == 273) {$bw=.75};
117 if ($1 == 272) {$bw=.5};
118 if ($1 == 271) {$bw=.25};
119 if ($1 == 270) {$bw=.125};
120 if ($1 == 302) {$bw=2};
121# print "bw : $bw \n";
122 }
123 }
124 close(FILE);
125 
126 # build new database if needed
127 if ( ! -e "rrd/$name.rrd" ) { system("./makerrd","$name","U") }
128 
129 # update database
130 RRDs::update "rrd/$name.rrd",time.":".$freq.":".$power.":".$signal.":".$temp.":".$snr.":".$qam.":".$bw;
131 if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to update `$name.rrd': $ERROR\n"; }
132 
133 }
134 }
135#uncomment this for debug output to temp.txt
136#all print will be done into the file
137# close (TEMPFILE);
138# close (STDERR);
139# close (STDOUT);
140 }
141 
1421;
143 

Powered by WebSVN 2.2.1