Created
October 28, 2013 11:45
-
-
Save tkhn/7195462 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 | |
| # Usage: check_sphinx_search.pl INDEX QUERY MIN-RESULTS | |
| # Example: check_sphinx_search.pl products iphone 15000 | |
| use strict; | |
| my $cmd = "search --limit 0 --index ${ARGV[0]} ${ARGV[1]}"; | |
| my $min = $ARGV[2]; | |
| my $output = `$cmd`; | |
| if($?) { | |
| bark("search command failed"); | |
| } | |
| $output =~ s/\n//g; | |
| if($output !~ m/matches of (\d+)/) { | |
| bark("search command had unexpected output"); | |
| } | |
| if($1 <= $min) { | |
| bark("${1} matches found - too low (expected over ${min})"); | |
| } | |
| print "OK - ${1} matches found\n"; | |
| exit; | |
| sub bark { | |
| print "CRITICAL - ${_[0]}\n"; | |
| exit; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment