![]() ![]() |
hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;use RRDs;sub version {($VERSION = '$Revision: 1.0 $') =~ s/.*(\d+\.\d+).*/$1/;my $platform;foreach (keys(%INC)) { $platform=$_ if $_ =~ /platform/; }return "$platform $VERSION";}sub sample {#uncomment this for debug output to temp.txt#all print will be done into the file#$temp = "/opt/HotSaNIC/modules/bgp/temp.txt";#open (TEMPFILE,">$temp");#open (STDERR,">&TEMPFILE") || die ("open STDERR failed");#open (STDOUT,">&TEMPFILE") || die ("open STDOUT failed");my %args=@_;$mtime=(stat("rrd"))[9];$now=time;utime $now,$now,"rrd";$IWCONF = $args{IWCONFIG};$IWLIST = $args{IWLIST};$hostap = $args{HOSTAP};my @IFACES=();my @IFMACS=();foreach (keys(%args)) {if (index($_,"IFACE:") >=0 ) {(undef,$device)=split /:/;push @IFACES,$device;}}foreach (keys(%args)) {if (index($_,"MAC,") >=0 ) {(undef,$dev,$mac)=split /,/;push @IFMACS,"$dev,$mac";}}foreach $device (@IFACES) {if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }} # foreachmy $asnum = 0;my $pathlen = 0;my $refcnt = 0;my $signal = 0;my $voltage = 0;$command = "cat /tmp/bgp.txt";open (FILE,"$command|");while(<FILE>) {$var=$_;if ($var =~ /^10/) {@path=split(" ",$var);$pathlen=scalar(@path);if ($pathlen > 2) {# print "line: $pathlen";# print "line: $_";$asnum = $path[$pathlen-2];$pathlen = $pathlen-2;# print "$asnum $pathlen\n";if ( ! -e "rrd/$asnum.rrd" ) { system("./makerrd","$asnum","U") }RRDs::update "rrd/$asnum.rrd",time.":".$pathlen.":".$refcnt.":".$signal.":".$voltage;# if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$asnum.rrd': $ERROR"; }if ($ERROR = RRDs::error) { print time," bgp: unable to update `$asnum.rrd': $ERROR\n"; }$pathlen = 0;}}} # whileclose(FILE);#uncomment this for debug output to temp.txt#all print will be done into the file# close (TEMPFILE);# close (STDERR);# close (STDOUT);}1;