Skip to content

Instantly share code, notes, and snippets.

@hiboma
Created September 8, 2015 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiboma/2f9c67fc586a725e336a to your computer and use it in GitHub Desktop.
Save hiboma/2f9c67fc586a725e336a to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
::main(@ARGV);
sub print_config {
printf <<"....";
graph_scale no
graph_title Mogilefs queryworker stats
graph_vlabel aaa
graph_category mogilefs
bored_queryworkers.draw AREA
bored_queryworkers.label bored_queryworkers
bored_queryworkers.colour 4444ff
processing_queries.draw STACK
processing_queries.label processing_queries
processing_queries.colour ff0000
pending_queries.draw STACK
pending_queries.label pending_queries
pending_queries.colour ffff00
....
}
sub main {
my @args = @_;
if(@args && $args[0] eq 'config') {
print_config();
exit;
}
my $stats = `echo '!stats' | nc 192.168.3.39 7001`;
foreach my $line ( split "\n", $stats) {
my ($category, $value) = split ' ', $line;
if ($category =~ m/(pending_queries|processing_queries|bored_queryworkers)/) {
printf "%s.value %d\n", $category, $value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment