jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [crusader/] [platform/] [default.pm] - Blame information for rev 11

 

Line No. Rev Author Line
111simandlpackage HotSaNICmod::OSdep;
2 
3use RRDs;
4 
5sub version {
6 ($VERSION = '$Revision: 1.0 $') =~ s/.*(\d+\.\d+).*/$1/;
7 my $platform;
8 foreach (keys(%INC)) { $platform=$_ if $_ =~ /platform/; }
9 return "$platform $VERSION";
10}
11 
12sub sample {
13 
14#uncomment this for debug output to temp.txt
15#all print will be done into the file
16#$temp = "/opt/HotSaNIC/modules/crusader/temp.txt";
17#open (TEMPFILE,">$temp");
18#open (STDERR,">&TEMPFILE") || die ("open STDERR failed");
19#open (STDOUT,">&TEMPFILE") || die ("open STDOUT failed");
20 
21#print "l1 ahoj \n";
22 
23 my %args=@_;
24 
25 $mtime=(stat("rrd"))[9];
26 $now=time;
27 
28 utime $now,$now,"rrd";
29 
30 my @IFACES=();
31 
32 foreach (keys(%args)) {
33 if (index($_,"IFACE:") >=0 ) {
34 (undef,$device)=split /:/;
35 push @IFACES,$device;
36 }
37 }
38 
39 
40 foreach $device (@IFACES) {
41 my $rate = 0;
42 my $quality = 0;
43 my $signal = 0;
44 my $noise = 0;
45 my $mode = 0;
46 
47 $command = "/opt/HotSaNIC/modules/crusader/crgetsig";
48 $command = "cat /tmp/crusader.txt";
49 open (FILE,"$command|");
50 while(<FILE>) {
51 $var=$_;
52 if ($var =~ /^\+ (.*) #.*/) {
53 $signal = $1;
54 }
55 }
56 close(FILE);
57 $rate=$rate*1;
58 print "l1 $device $signal \n";
59 
60 if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
61 RRDs::update "rrd/$device.rrd",time.":".$rate.":".$quality.":".$signal.":".$noise;
62 if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$device.rrd': $ERROR"; }
63 
64 }
65#uncomment this for debug output to temp.txt
66#all print will be done into the file
67# close (TEMPFILE);
68# close (STDERR);
69# close (STDOUT);
70}
711;

Powered by WebSVN 2.2.1