Created
September 8, 2015 08:36
-
-
Save hiboma/2f9c67fc586a725e336a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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