From 99205463d64d82c99fe72f4e6000afc63e0604ba Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 22 Apr 2018 20:19:27 +0200 Subject: [PATCH] Make the Munin plugin stop count keepalive clients in the total. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Now that we have better control of HLS, it's better to just label these as “unknown” and not count them in the stream total. --- munin/cubemap | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/munin/cubemap b/munin/cubemap index b292982..19225be 100755 --- a/munin/cubemap +++ b/munin/cubemap @@ -34,10 +34,14 @@ while (<$config>) { close $config; my $total = 0; +my $unknown = 0; if ($mode eq 'config') { print "total.label Total number of viewers\n"; print "total.type GAUGE\n"; print "total.min 0\n"; + print "unknown.label Number of connections not watching a stream\n"; + print "unknown.type GAUGE\n"; + print "unknown.min 0\n"; } open my $stats, "<", $stats_filename @@ -47,8 +51,12 @@ while (<$stats>) { my ($ip, $fd, $mark, $stream, $connected_time, $bytes_sent, $loss_bytes, $loss_events) = /^(\S+) (\d+) (\d+) (\S+) (\d+) (\d+) (\d+) (\d+)/ or die "Invalid stats format"; $stream =~ s/\?frag=.*//; - ++$streams{$stream}; - ++$total; + if (defined($streams{$stream})) { + ++$streams{$stream}; + ++$total; + } else { + ++$unknown; + } } close $stats; @@ -58,6 +66,7 @@ if ($mode ne 'config') { printf "${stream_name}.value %d\n", $streams{$stream}; } printf "total.value %d\n", $total; + printf "unknown.value %d\n", $unknown; } sub stream_name { -- 2.39.2