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 

Can't get accurate graphs using mrtg and configs posted here

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
ufm



Joined: 10 Jun 2011
Posts: 2

PostPosted: Tue Jun 14, 2011 1:02 am    Post subject: Can't get accurate graphs using mrtg and configs posted here Reply with quote

Hi all. I didn't want to bump any of the existing threads for this, so I hope that it's ok if I create a new thread.

For reference, I've followed all of the instructions in these threads to get graphing with mrtg and icecast working:

http://icecast.imux.net/viewtopic.php?t=337
http://icecast.imux.net/viewtopic.php?t=6439

We are a small community radio station streaming on the internet, and after looking around, this seems to be the best solution for getting some listener graphs for the station. However, I'm having a hell of a time getting this working properly and have completely run out of ideas.

Our streaming server runs multiple streams for other various stations. I'm trying to only gather data from our mountpoint/stream and display that data. I don't know if the scripts are grabbing data for all of the streams, but the number that's being displayed is incredibly inaccurate (sample below). The number displayed doesn't even represent the amount of listeners across all streams combined.

I'm coming to you guys for help on this one. I have no idea what else I'm missing, but it's probably very simple.

Here is the script that I'm using:

Code:

#!/usr/bin/perl

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

my $staturl = qq~http://[my server]:[streaming port]/admin/stats~;
my $user = '[admin username]';
my $pass = '[admin pass]';
#my $stream = "[name of the mount point/stream]";
my $uptime = '0 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;
while ($stats =~ /<listeners>(\d+)<\/listeners><listenurl>/g) {
    $listeners += int($1);
    }
    $stats =~ /<sources>(\d+)<\/sources>/;
    $sources = $1;
    if (!$listeners) {$listeners = 0;}
    if (!$sources) {$sources = 0;}

    #get uptime
#    use Date::Manip;
#    my $stuff = `ps --no-headers -C icecast -o pid,fname,lstart --sort lstart`;
#    my @stuff = split(/\n/,$stuff);
#    $stuff[0] =~ /icecast\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$stream\n~;
    print qq~$listeners\n$sources\n$uptime\n~;
#    $stream\n~;
    exit;


I commented out all of the uptime stuff because I don't really need it, and the stats gathering and displaying is happening on a different machine that icecast isn't running on.


Here is my mrtg.cfg

Code:
######################################################################
# Multi Router Traffic Grapher -- Sample Configuration File
######################################################################
# This file is for use with mrtg-2.5.4c

# Global configuration
WorkDir: [path to www/dir where stats are displayed]
WriteExpires: Yes

# [name] listener graphs
Title[^]: Traffic Analysis for
WithPeak[_]: dwmy
XSize[_]: 600
YSize[_]: 200
Title[^]: Graphs:
Target[ufmlive]:`[path to script]`
Options[ufmlive]: noinfo,nopercent,integer,gauge
#Options[ufmlive]: noinfo,nopercent,integer,absolute
#Options[ufmlive]: noinfo
MaxBytes[ufmlive]: 9999999999
AbsMax[ufmlive]: 9999999999
Title[ufmlive]: [stream] Listeners
PageTop[ufmlive]: <H1>[stream] Listeners</H1>
YLegend[ufmlive]: # of connections
ShortLegend[ufmlive]: L/s
Legend1[ufmlive]: # of listeners
Legend2[ufmlive]: # of sources
Legend3[ufmlive]: Maximal # of listeners
Legend4[ufmlive]: Maximal # of sources
LegendI[ufmlive]: &nbsp;# of listeners:
LegendO[ufmlive]: &nbsp;# of sources:


I have a cron job running every 5 minutes to gather, display and update the data:

Code:

0,5,10,15,20,25,30,35,40,46,50,55 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg >/dev/null 2>&1



At 18:53 (-7h GMT) I took stats, and snapped this pic of the graph (click to enlarge):


At that exact moment, there were a combined total of 78 active connections to our streaming server, and only 4 connections to the stream that I'm trying to pull stats for.

I've blanked out some of the sensitive info because of my own paranoia. But can assure you that the data in the brackets [] is correct.

Thank you for your help.
Back to top
View user's profile Send private message
als



Joined: 14 Oct 2008
Posts: 18

PostPosted: Wed Jun 15, 2011 6:03 pm    Post subject: Reply with quote

Does this perl script if you run it from the command prompt give you an adequate result (e.g. first line - listeners count, second line - sources count?
Back to top
View user's profile Send private message
ufm



Joined: 10 Jun 2011
Posts: 2

PostPosted: Wed Jun 15, 2011 6:46 pm    Post subject: Reply with quote

It doesn't. I ran it just now and it returned:
Code:

117
14
0 days


At that moment there were 129 listeners across the entire server, and 12 sources. But on the stream I need data for, there were only 5 listeners.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server 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