From ee80222a09d1f27a612f37913b15e522d5c11699 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Wed, 28 May 2014 17:43:09 +0200 Subject: [PATCH] Fixed 'icecast' graph to support newer statistics page format --- lib/icecast.pm | 26 ++++++++++++++++---------- man/man5/monitorix.conf.5 | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/icecast.pm b/lib/icecast.pm index 4d44882..abca1bb 100644 --- a/lib/icecast.pm +++ b/lib/icecast.pm @@ -160,9 +160,6 @@ sub icecast_update { my $rrd = $config->{base_lib} . $package . ".rrd"; my $icecast = $config->{icecast}; - my @ls; - my @br; - my $n; my $rrdata = "N"; @@ -183,14 +180,23 @@ sub icecast_update { } $data =~ s/\n//g; - undef(@ls); - undef(@br); + + my $iceold; + my $icenew; + my @bl_pairs; + my @ls; + my @br; + foreach my $i (split(',', $icecast->{desc}->{$ils})) { - my $m = "Mount Point " . trim($i); - my ($l) = ($data =~ m/$m.*?Current Listeners:<\/td>(\d*?)<\/td>/g); - my ($b) = ($data =~ m/$m.*?Bitrate:<\/td>(\d*?)<\/td><\/tr>/g); - $l = 0 unless defined($l); - $b = 0 unless defined($b); + $i = trim($i); + $i =~ s/\//\\\//g; + $iceold .= '

Mount Point ' . $i . '<\/h3><\/td>.*?(?:Bitrate:<\/td>(\d*?)<\/td><\/tr>)?Current Listeners:<\/td>(\d*?)<\/td><\/tr>.*?<\/table>.*?'; + $icenew .= '

Mount Point ' . $i . '<\/h3>.*?(?:Bitrate:<\/td>(\d*?)<\/td><\/tr>)?Listeners \(current\):<\/td>(\d*?)<\/td><\/tr>.*?<\/table>.*?'; + } + (@bl_pairs) = ($data =~ m/$iceold/); + (@bl_pairs) = ($data =~ m/$icenew/) if !scalar(@bl_pairs); + + while(my ($b, $l) = splice(@bl_pairs, 0, 2)) { push(@ls, $l); push(@br, $b); } diff --git a/man/man5/monitorix.conf.5 b/man/man5/monitorix.conf.5 index 8af7359..f68c086 100644 --- a/man/man5/monitorix.conf.5 +++ b/man/man5/monitorix.conf.5 @@ -1646,7 +1646,7 @@ Default value: \fIhttp://localhost:8000/status.xsl\fP .P .BI desc .RS -This is a comma-separated list of mountpoints configured for every URL specified in the \fBlist\fP option. +This is a comma-separated list of Mount Points configured for every URL specified in the \fBlist\fP option. IMPORTANT: the Mount Points must be specified in the same order that appears in the Icecast Server Status page. .P .br