hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;
use RRDs;
use LWP::Simple;
sub version {
($VERSION = '$Revision: 1.15 $') =~ s/.*(\d+\.\d+).*/$1/;
return "default.pm $VERSION";
}
sub sample {
my %args=@_;
foreach my $item (@{$args{STREAM}}) {
my ($url,$description)=split /,/,$item;
($name=$url) =~ s/http\:\/\///g;
$name =~ s/\//_/g;
$name =~ s/:/_/g;
my $users=0;
my $unique=0;
my $bandwidth=0;
my $line="";
if ( ($args{METHOD} eq "lynx") || ( $url =~ ":") ) {
open LINES,"lynx -width 200 -dump $url|";
while (<LINES>) { if (/listeners/) { $line=$_; last; } }
close LINES;
}
else {
my @contents=split /\n|<[Bb][Rr]>/,LWP::Simple::get($url);
foreach (@contents) { if (/listeners/) { s/<.*?>//g; $line=$_; last; } }
}
if ($line ne "") {
$line =~ /at (\d+) kbps/, $bandwidth=$1;
$line =~ /with (\d+) of/, $users=$1;
$line =~ /\((\d+) uniq/, $unique=$1;
}
HotSaNICmod::do_rrd($name,"U",time,$users,$unique);
}
}
1;
# Stream Status: Stream is up at 128 kbps with 0 of 5 listeners (0 unique)
# Stream Status: Stream is up at 64 kbps with 21 of 32 listeners (20 unique)