hotsanic |
Subversion Repositories: |
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,$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";
# $_=<FILE>;
# 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 .1.3.6.1.4.1.193.223.2.7.1.1.1.110101 = STRING: "-29.8"
#6 snr .1.3.6.1.4.1.193.223.2.7.1.1.43.110101 = STRING: "30.3"
#7 ber
#8 temp
#9 max speed
#10 speed
#12 tx freq SNMPv2-SMI::enterprises.193.223.2.7.1.1.13.110101 = INTEGER: 83000000
#13 rx freq
#14 tx speed
#15 rx speed
#18 atpc en dis
#19 tx power .1.3.6.1.4.1.193.223.2.7.1.1.2.110101 = STRING: "10.8"
#20 acm en dis
#21 tx qam SNMPv2-SMI::enterprises.193.223.2.7.1.1.3.110101 = STRING: "128_QAM"
#22 rx qam
#23 tx bw SNMPv2-SMI::enterprises.193.223.2.7.1.1.9.110101 = INTEGER: 302
#24 rx bw
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.3.16842752 = INTEGER: 1
#txpower .1.3.6.1.4.1.119.2.3.69.501.8.1.1.4.16842752 = STRING: "+11.0"
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.5.16842752 = INTEGER: 1
#rssi .1.3.6.1.4.1.119.2.3.69.501.8.1.1.6.16842752 = STRING: "-47.2"
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.7.16842752 = INTEGER: 1
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.8.16842752 = STRING: "-57"
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.9.16842752 = INTEGER: 0
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.10.16842752 = STRING: "**"
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.11.16842752 = INTEGER: 1
#temp .1.3.6.1.4.1.119.2.3.69.501.8.1.1.12.16842752 = STRING: "+29.2"
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.13.16842752 = INTEGER: 127
#.1.3.6.1.4.1.119.2.3.69.501.8.1.1.14.16842752 = STRING: "0.0E-10"
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.3.8585216 = STRING: "**"
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.3.8650752 = STRING: "**"
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.4.8585216 = INTEGER: 0
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.4.8650752 = INTEGER: 0
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.5.8585216 = STRING: "**"
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.5.8650752 = STRING: "**"
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.6.8585216 = INTEGER: 0
#.1.3.6.1.4.1.119.2.3.69.501.8.2.1.6.8650752 = INTEGER: 0
#.1.3.6.1.4.1.119.2.3.69.501.4.2.1.4.16842752 = STRING: "82500.000"
#tx freq .1.3.6.1.4.1.119.2.3.69.501.4.2.1.3.16842752 = STRING: "72500.000"
# $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 ">>>>>>>> : $_ \n";
if ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.4.2.1.3.16842752 = STRING: +(.*)$/) {
$freq = $1;
$freq=$freq*$scale2;
# print "freq : $freq \n";
} elsif ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.8.1.1.4.16842752 = STRING: +(.*)$/) {
$power = $1*1;
# print "power : $power \n";
} elsif ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.8.1.1.6.16842752 = STRING: +(.*)$/) {
$signal = $1 * 1;
# print "signal : $signal \n";
} elsif ($var =~ /^.*.1.3.6.1.4.1.119.2.3.69.501.8.1.1.12.16842752 = STRING: +(.*)$/) {
$temp = $1*1;
# print "temp : $temp \n";
} elsif ($var =~ /^.*.193.223.2.7.1.1.43.110101 = STRING: +(.*)$/) {
$snr = $1*1;
# print "snr : $snr \n";
} elsif ($var =~ /^.*.193.223.2.7.1.1.3.110101 = STRING: +(.*)$/) {
$qam = $1;
$qam=~ s/_QAM//g;
$qam= log($qam)/log(2);
# print "qam : $qam \n";
} elsif ($var =~ /^.*.193.223.2.7.1.1.9.110101 = INTEGER: +(.*)$/) {
if ($1 == 302) {$bw=2};
if ($1 == 300) {$bw=1.5};
if ($1 == 298) {$bw=1};
if ($1 == 273) {$bw=.75};
if ($1 == 272) {$bw=.5};
if ($1 == 271) {$bw=.25};
if ($1 == 270) {$bw=.125};
if ($1 == 302) {$bw=2};
# 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;