]> git.sesse.net Git - cubemap/commitdiff
Added some Munin plugins.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 16 Aug 2013 09:29:54 +0000 (11:29 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 16 Aug 2013 09:29:54 +0000 (11:29 +0200)
README
munin/cubemap_input [new file with mode: 0755]

diff --git a/README b/README
index 4410010d148cde515898ffb7af9b49ddff91a97b..c3175167d742928b2c454662b6cbb5f4faa11bfb 100644 (file)
--- a/README
+++ b/README
@@ -42,6 +42,19 @@ are OK, and then exec() the new version, which deserializes everything and
 keeps going.
 
 
 keeps going.
 
 
+Munin plugins:
+
+These can be dropped directly into /etc/munin/plugins. If you don't put
+the files in the expected default locations, you probably want some
+configuration in /etc/munin/plugin-conf.d/cubemap or similar, like this:
+
+[cubemap*]
+user <something>
+env.cubemap_config /etc/cubemap/cubemap.config
+env.cubemap_stats /var/lib/cubemap/cubemap.stats
+env.cubemap_input_stats /var/lib/cubemap/cubemap-input.stats
+
+
 Legalese: 
 
 Copyright 2013 Steinar H. Gunderson <sgunderson@bigfoot.com>.
 Legalese: 
 
 Copyright 2013 Steinar H. Gunderson <sgunderson@bigfoot.com>.
diff --git a/munin/cubemap_input b/munin/cubemap_input
new file mode 100755 (executable)
index 0000000..00b6ec3
--- /dev/null
@@ -0,0 +1,37 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use Munin::Plugin;
+
+my $input_stats_filename = $ENV{"cubemap_input_stats"} // "/var/lib/cubemap/cubemap-input.stats";
+
+my $mode = $ARGV[0] // "print";
+if ($mode eq 'config') {
+       print "graph_title Cubemap inputs\n";
+       print "graph_category network\n";
+       print "graph_vlabel viewers\n";
+}
+
+open my $stats, "<", $input_stats_filename
+       or die "$input_stats_filename: $!";
+while (<$stats>) {
+       chomp;
+       my ($url, $bytes_received, $data_bytes_received, $connection_time) =
+               /^(\S+) (\d+) (\d+) (-|\d+)/ or die "Invalid stats format";
+       my $stream_name = stream_name($url);
+       if ($mode eq 'config') {
+               print "${stream_name}.label Data input bitrate of $url\n";
+               print "${stream_name}.type DERIVE\n";
+               print "${stream_name}.min 0\n";
+       } else {
+               printf "${stream_name}.value %d\n", $data_bytes_received * 8;
+       }
+}
+close $stats;
+       
+sub stream_name {
+       my $stream = shift;
+       $stream =~ y/a-z0-9/_/c;
+       return $stream;
+}