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
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;
printf "${stream_name}.value %d\n", $streams{$stream};
}
printf "total.value %d\n", $total;
+ printf "unknown.value %d\n", $unknown;
}
sub stream_name {