X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=munin%2Fcubemap;h=19225beffde86ef3c43551edf4081469649c398d;hp=8079d6e4d750b86e92ed8f595a535046b76d5503;hb=99205463d64d82c99fe72f4e6000afc63e0604ba;hpb=c2c0b5f5eb8a04a61d9c861b3cb0946043a25f0e diff --git a/munin/cubemap b/munin/cubemap index 8079d6e..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 @@ -46,8 +50,13 @@ while (<$stats>) { chomp; 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"; - ++$streams{$stream}; - ++$total; + $stream =~ s/\?frag=.*//; + if (defined($streams{$stream})) { + ++$streams{$stream}; + ++$total; + } else { + ++$unknown; + } } close $stats; @@ -57,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 {