Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Icecast and MRTG for FreeBSD

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Dev Branches
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Sat Mar 29, 2008 9:44 am    Post subject: Icecast and MRTG for FreeBSD Reply with quote

This parser script working on FreeBSD 6.2

Script name listeners.pl. Need chmod 755 listeners.pl
For work mrtg as deamon need add to mrtg.cnf:
RunAsDaemon: Yes
Interval: 5

For moderators:
Please add it post to http://icecast.imux.net/viewtopic.php?t=337

#!/usr/bin/perl

use strict;
#get the number of listeners on a icecast stream
#(find out total bytes later)

my $staturl = qq~http://domain.tld:8000/admin/stats~;
my $user = 'admin';
my $pass = 'pass';
my $stream = "stream";
my $uptime = '420 days';

my $listeners = 0;
my $sources = 0;

#get listeners
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $staturl);
$req->authorization_basic($user, $pass);
my $stats = $ua->request($req)->as_string;
$stats =~ /<listeners>(\d+)<\/listeners>/;
$listeners = $1;
$stats =~ /<sources>(\d+)<\/sources>/;
$sources = $1;
if (!$listeners) {$listeners = 0;}
if (!$sources) {$sources = 0;}

#get uptime
use Date::Manip;
my $stuff = `ps -o pid,command,lstart | sort | grep iceca` ;
my @stuff = split(/\n/,$stuff);
$stuff[0] =~ /iceca\s+(.*?)$/gi;
my $start = ParseDate($1);
my $now = ParseDate("Now");
my $delta = DateCalc($start,$now);
$uptime = Delta_Format($delta,0,"%dh days %hv hours");

print qq~$listeners\n$sources\n$uptime\n$stream\n~;
exit;
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Dev Branches All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber