Created
October 27, 2010 22:24
-
-
Save kastner/650150 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -w | |
# -*- perl -*- | |
=head1 NAME | |
sphinx - Plugin to monitor various sphinx (searchd) stats | |
=head1 CONFIGURATION | |
No configuration | |
=head1 AUTHORS | |
Original Author: Erik Kastner | |
=head1 LICENSE | |
Unknown license | |
=head1 MAGIC MARKERS | |
#%# family=auto | |
#%# capabilities=autoconf | |
=cut | |
use Munin::Plugin; | |
my $search_bin = "/usr/bin/searchd"; | |
if ($ARGV[0] and $ARGV[0] eq "autoconf") { | |
if (-r $search_bin) { | |
print "yes\n"; | |
exit 0; | |
} else { | |
print "no ($search_bin found)\n"; | |
exit 0; | |
} | |
} | |
my %stats; | |
&fetch_stats; | |
if ($ARGV[0] and $ARGV[0] eq "config") { | |
print "graph_args --base 1000 -l 0"; | |
print "graph_vlabel Number\n"; | |
print "graph_title Sphinx Searches\n"; | |
print "graph_category search\n"; | |
print "searches.label total searches\n"; | |
print "searches.draw LINE2\n"; | |
exit 0; | |
} | |
print "searches.value ", $mems{'command_search'}, "\n" | |
if exists $mems{'command_search'}; | |
exit 0; | |
sub fetch_stats { | |
my @output = `$search_bin --status`; | |
for $_ (@output) { | |
if (/^(\w+):\s*([\d\.]+)\s/i) { | |
$mems{"$1"} = $2; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
put this in /usr/share/munin/plugins/sphinx