Skip to content

Instantly share code, notes, and snippets.

@kastner
Created October 27, 2010 22:24
Show Gist options
  • Save kastner/650150 to your computer and use it in GitHub Desktop.
Save kastner/650150 to your computer and use it in GitHub Desktop.
#!/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;
}
}
}
@kastner
Copy link
Author

kastner commented Oct 27, 2010

put this in /usr/share/munin/plugins/sphinx

cd /etc/munin/plugins
ln -s /usr/share/munin/plugins/sphinx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment