jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
129simandlpackage 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 ) {
2330simandl my ($dev,$oid,$name)=split(/,/,$args{$_});
2429simandl 
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.001;
35 my $scale2=0.01;
36 my $add=0;
37 
38 my $freq=1;
39 my $mcs=2;
40 my $signal=3;
41 my $txsec=4;
42 my $rate=5;
43 my $noise=0;
44 
45# $command = "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2";
46 $command = "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid";
47 open (FILE,"$command|");
48 while(<FILE>) {
49 $var=$_;
50 if ($var =~ /^.*.1.1.1.8.1.6.. = INTEGER: +(.*)$/) {
51 $freq = $1;
52 $freq=$1*$scale1+$add;
53 #print "freq : $freq \n";
54 } elsif ($var =~ /^.*.1.1.1.8.1.7.. = INTEGER: +(.*)$/) {
55 $mcs = $1;
56 } elsif ($var =~ /^.*.1.1.1.8.1.8.. = INTEGER: +(.*)$/) {
57 $signal = $1;
58 } elsif ($var =~ /^.*.1.1.1.8.1.9.. = INTEGER: +(.*)$/) {
59 $txsec = $1;
60 } elsif ($var =~ /^.*.1.1.1.8.1.12.. = INTEGER: +(.*)$/) {
61 $rssi = $1;
62 } elsif ($var =~ /^.*.1.1.1.8.1.13.. = Gauge32: +(.*)$/) {
63 $rate = $1;
64 $rate=$1*$scale1+$add;
65 } elsif ($var =~ /^.*.1.1.1.8.1.14.. = INTEGER: +(.*)$/) {
66 $noise = $1;
67 }
68 }
69 close(FILE);
70 
71 # build new database if needed
72 if ( ! -e "rrd/$name.rrd" ) { system("./makerrd","$name","U") }
73 
74 # update database
75 RRDs::update "rrd/$name.rrd",time.":".$freq.":".$mcs.":".$signal.":".$txsec.":".$rssi.":".$rate.":".$noise;
76 if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to update `$name.rrd': $ERROR\n"; }
77 
78 }
79 }
80#uncomment this for debug output to temp.txt
81#all print will be done into the file
82# close (TEMPFILE);
83# close (STDERR);
84# close (STDOUT);
85 }
86 
871;
88 

Powered by WebSVN 2.2.1