├── README.rst ├── LICENSE └── check_ceph.pl /README.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Ceph Nagios Plugin 3 | ================== 4 | 5 | Description 6 | ----------- 7 | 8 | This plugin checks the health of a ceph cluster. 9 | 10 | 11 | Usage 12 | ---- 13 | 14 | The plugin usage is given in the source code as the following:: 15 | 16 | Usage: check_ceph [-m|--mon] [-k|--key] 17 | -m, --mon=ADDRESS[,ADDRESS,ADDRESS] 18 | IP address(es) of ceph monitors 19 | -k, --key=string 20 | secret key to access the ceph cluster 21 | -h, --help 22 | Print detailed help screen 23 | 24 | 25 | Nagios Plugins 26 | -------------- 27 | 28 | You can read about Nagios plugin development here: 29 | 30 | http://nagiosplug.sourceforge.net/developer-guidelines.html 31 | 32 | In particular, you will likely be interested in learning about `plugin output `_. 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, New Dream Network, LLC (DreamHost) 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | 26 | BSD License: 27 | http://www.opensource.org/licenses/BSD-2-Clause 28 | -------------------------------------------------------------------------------- /check_ceph.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Author: Dallas Kashuba 3 | 4 | # Copyright (c) 2012, New Dream Network, LLC (DreamHost) 5 | # All rights reserved. 6 | # 7 | # Licenced available at ./LICENSE in the ceph-nagios-plugin source. 8 | 9 | use strict; 10 | use Getopt::Long qw(:config no_ignore_case); 11 | 12 | my ($mon_ips, $key); 13 | my $CEPH = '/usr/bin/ceph'; 14 | my $HELP = 0; 15 | 16 | my %STATUSCODE = ( 17 | 'OK' => '0', 18 | 'WARNING' => '1', 19 | 'CRITICAL' => '2', 20 | 'UNKNOWN' => '3', 21 | ); 22 | 23 | my $usage = < \$mon_ips, 39 | "k|key=s" => \$key, 40 | "h|help" => \$HELP, 41 | ); 42 | 43 | if ( $HELP || !$result ) { 44 | print $usage; 45 | exit ($STATUSCODE{'UNKNOWN'}); 46 | } 47 | 48 | if (! -x $CEPH) { 49 | print "Where is the ceph binary? Not here: $CEPH\n"; 50 | exit ($STATUSCODE{'UNKNOWN'}); 51 | 52 | } 53 | 54 | # run ceph command and grab output 55 | my $cephcmd = "ceph "; 56 | $cephcmd .= "-m $mon_ips " if $mon_ips; 57 | $cephcmd .= "--key $key " if $key; 58 | $cephcmd .= "health"; 59 | 60 | open(CEPHOUT, "$cephcmd |") or exit ($STATUSCODE{'UNKNOWN'}); 61 | while (defined( my $line = )) { 62 | chomp $line; 63 | 64 | my $health_status = ''; 65 | if (($health_status) = ($line =~ m/(HEALTH_(OK|WARN|ERR))/ )) { 66 | print "status: '$health_status'\n"; 67 | if ($health_status =~ /^HEALTH_OK/) { 68 | exit ($STATUSCODE{'OK'}); 69 | } 70 | elsif ($health_status =~ /^HEALTH_WARN/) { 71 | exit ($STATUSCODE{'WARNING'}); 72 | } 73 | elsif ($health_status =~ /^HEALTH_ERR/) { 74 | exit ($STATUSCODE{'CRITICAL'}); 75 | } 76 | else { 77 | exit ($STATUSCODE{'UNKNOWN'}); 78 | } 79 | } 80 | } 81 | close (CEPHOUT); 82 | 83 | # if we got to here, something didn't work right... 84 | exit ($STATUSCODE{'UNKNOWN'}); 85 | --------------------------------------------------------------------------------