pax_global_header00006660000000000000000000000064123563152340014516gustar00rootroot0000000000000052 comment=93dde35d2cc88a8730e1722a4a4d5aa12e1e79bd nagios-plugins-rabbitmq-1.2.0/000077500000000000000000000000001235631523400162545ustar00rootroot00000000000000nagios-plugins-rabbitmq-1.2.0/Build.PL000066400000000000000000000017321235631523400175530ustar00rootroot00000000000000#!/usr/bin/env perl use Module::Build; my $build = Module::Build->new ( dist_name => "nagios-plugins-rabbitmq", dist_version => "1.2.0", dist_author => 'James Casey (jamesc.000@gmail.com)', dist_abstract => 'Nagios checks for RabbitMQ using the management interface', installdirs => 'site', script_files => 'scripts', license => 'apache', module_name => "nagios-plugins-rabbitmq", requires => { "JSON" => "2.12", "LWP::UserAgent" => 0, "URI" => "1.35", "Pod::Usage" => 0, "Getopt::Long" => 0, }, recommends => { "Nagios::Plugin" => "0.33", }, configure_requires => { "Module::Build" => 0, }, build_requires => { "Module::Build" => 0, }, keywords => [ "RabbitMQ", "Management", "Nagios" ], ); $build->create_build_script; nagios-plugins-rabbitmq-1.2.0/LICENSE.txt000066400000000000000000000261361235631523400201070ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. nagios-plugins-rabbitmq-1.2.0/MANIFEST000066400000000000000000000005251235631523400174070ustar00rootroot00000000000000Makefile Build.PL LICENSE.txt MANIFEST This list of files META.yml README.md scripts/check_rabbitmq_aliveness scripts/check_rabbitmq_objects scripts/check_rabbitmq_overview scripts/check_rabbitmq_partition scripts/check_rabbitmq_shovels scripts/check_rabbitmq_server scripts/check_rabbitmq_queue scripts/check_rabbitmq_watermark META.json nagios-plugins-rabbitmq-1.2.0/MANIFEST.SKIP000066400000000000000000000011421235631523400201500ustar00rootroot00000000000000# Avoid version control files. \bRCS\b \bCVS\b ,v$ \B\.git\b \B\.svn\b \B\.cvsignore$ # Avoid Makemaker generated and utility files. \bMakefile$ \bblib \bMakeMaker-\d \bpm_to_blib$ \bblibdirs$ ^MANIFEST\.SKIP$ # Avoid Module::Build generated and utility files. \bBuild$ \bBuild.bat$ \b_build # Avoid Devel::Cover generated files \bcover_db # Avoid temp and backup files. ~$ \.tmp$ \.old$ \.bak$ \#$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid archives of this distribution \bnagios-plugins-rabbitmq-[\d\.\_]+ ^MYMETA.yml$ nagios-plugins-rabbitmq-1.2.0/META.json000066400000000000000000000021371235631523400177000ustar00rootroot00000000000000{ "abstract" : "Nagios checks for RabbitMQ using the management interface", "author" : [ "James Casey (jamesc.000@gmail.com)" ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.110930", "license" : [ "apache_2_0" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "nagios-plugins-rabbitmq", "prereqs" : { "build" : { "requires" : { "Module::Build" : 0 } }, "configure" : { "requires" : { "Module::Build" : 0 } }, "runtime" : { "recommends" : { "Nagios::Plugin" : "0.27" }, "requires" : { "Getopt::Long" : 0, "JSON" : "2.12", "LWP::UserAgent" : 0, "Pod::Usage" : 0, "URI" : "1.35" } } }, "release_status" : "stable", "resources" : { "license" : [ "http://apache.org/licenses/LICENSE-2.0" ] }, "version" : "v1.0.3" } nagios-plugins-rabbitmq-1.2.0/META.yml000066400000000000000000000011021235631523400175170ustar00rootroot00000000000000--- abstract: 'Nagios checks for RabbitMQ using the management interface' author: - 'James Casey (jamesc.000@gmail.com)' build_requires: Module::Build: 0 configure_requires: Module::Build: 0 generated_by: 'Module::Build version 0.3603' license: apache meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: nagios-plugins-rabbitmq recommends: Nagios::Plugin: 0.33 requires: Getopt::Long: 0 JSON: 2.12 LWP::UserAgent: 0 Pod::Usage: 0 URI: 1.35 resources: license: http://apache.org/licenses/LICENSE-2.0 version: v1.1.0 nagios-plugins-rabbitmq-1.2.0/Makefile000066400000000000000000000005101235631523400177100ustar00rootroot00000000000000sources: build ./Build dist build: perl Build.PL clean: build ./Build distclean @rm -f nagios-plugins-rabbitmq-*.tar.gz RabbitMQ-API-*.tar.gz _build $(RM) META.json META.yml install: mkdir -p $(DESTDIR)/usr/lib/nagios/plugins-rabbitmq cp scripts/* $(DESTDIR)/usr/lib/nagios/plugins-rabbitmq/ rsync -a etc $(DESTDIR) nagios-plugins-rabbitmq-1.2.0/README.md000077500000000000000000000041651235631523400175440ustar00rootroot00000000000000nagios-plugins-rabbitmq ======================= Overview -------- This package contains a set of nagios checks useful for monitoring a RabbitMQ server. They use the RabbitMQ management interface with is over HTTP and therefore have a very light profile on the nagios server. See the [documentation](http://www.rabbitmq.com/management.html) on the RabbitMQ management interface for more details on what it provides. Status ------ Currently we have 5 checks: - check\_rabbitmq\_aliveness - Use the `/api/aliveness-test` API to send/receive a message. - check\_rabbitmq\_server - Use the `/api/nodes` API to gather resource usage of the rabbitmq server node - check\_rabbitmq\_objects - Use a variety of APIs to count instances of various objects on the server. These include vhosts, exchanges, bindings, queues and channels. - check\_rabbitmq\_overview - Use the `/api/overview` API to collect the number of pending, ready and unacknowledged messages on the server - check\_rabbitmq\_queue - Use the `/api/queue` API to collect the number of pending, ready and unacknowledged messages and the number of consumers on a given queue - check\_rabbitmq\_watermark - Use the `/api/nodes` API to check to see if mem_alarm has been set to true - check\_rabbitmq\_connections - Use the `/api/connections` API to gather details of connections used, their state and their throughput See the relevant POD documentation/man pages for more information on usage. Licence ------- This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author ------ James Casey nagios-plugins-rabbitmq-1.2.0/etc/000077500000000000000000000000001235631523400170275ustar00rootroot00000000000000nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/000077500000000000000000000000001235631523400217665ustar00rootroot00000000000000nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/000077500000000000000000000000001235631523400232335ustar00rootroot00000000000000nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_aliveness.cfg000066400000000000000000000005561235631523400307310ustar00rootroot00000000000000define command{ command_name check_rabbitmq_aliveness command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_aliveness --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_aliveness_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_aliveness --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_connections.cfg000066400000000000000000000005661235631523400312630ustar00rootroot00000000000000define command{ command_name check_rabbitmq_connections command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_connections --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_connections_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_connections --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_objects.cfg000066400000000000000000000005461235631523400303700ustar00rootroot00000000000000define command{ command_name check_rabbitmq_objects command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_objects --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_objects_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_objects --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_overview.cfg000066400000000000000000000005521235631523400306020ustar00rootroot00000000000000define command{ command_name check_rabbitmq_overview command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_overview --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_overview_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_overview --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_partition.cfg000066400000000000000000000005561235631523400307510ustar00rootroot00000000000000define command{ command_name check_rabbitmq_partition command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_partition --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_partition_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_partition --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_queue.cfg000066400000000000000000000005741235631523400300640ustar00rootroot00000000000000define command{ command_name check_rabbitmq_queue command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_queue --extra-opts=$ARG1$ --queue=$ARG2$ } define command{ command_name check_rabbitmq_queue_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_queue --extra-opts=$ARG1$ --queue=$ARG2$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_server.cfg000066400000000000000000000005421235631523400302410ustar00rootroot00000000000000define command{ command_name check_rabbitmq_server command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_server --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_server_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_server --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_shovels.cfg000066400000000000000000000005461235631523400304220ustar00rootroot00000000000000define command{ command_name check_rabbitmq_shovels command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_shovels --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_shovels_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_shovels --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios-plugins/config/check_rabbitmq_watermark.cfg000066400000000000000000000005561235631523400307350ustar00rootroot00000000000000define command{ command_name check_rabbitmq_watermark command_line exec sudo /usr/lib/nagios/plugins/check_rabbitmq_watermark --extra-opts=$ARG1$ } define command{ command_name check_rabbitmq_watermark_by_ssh command_line exec ssh $HOSTADDRESS$ sudo /usr/lib/nagios/plugins/check_rabbitmq_watermark --extra-opts=$ARG1$ } nagios-plugins-rabbitmq-1.2.0/etc/nagios/000077500000000000000000000000001235631523400203075ustar00rootroot00000000000000nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/000077500000000000000000000000001235631523400214755ustar00rootroot00000000000000nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_aliveness.cfg000066400000000000000000000002001235631523400271550ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_aliveness]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_aliveness --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_connections.cfg000066400000000000000000000002041235631523400275120ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_connections]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_connections --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_objects.cfg000066400000000000000000000001741235631523400266270ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_objects]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_objects --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_overview.cfg000066400000000000000000000001761235631523400270460ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_overview]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_overview --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_partition.cfg000066400000000000000000000002001235631523400271750ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_partition]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_partition --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_queue.cfg000066400000000000000000000002071235631523400263170ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_queue]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_queue --extra-opts=$ARG1$ --queue=$ARG2$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_server.cfg000066400000000000000000000001721235631523400265020ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_server]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_server --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_shovels.cfg000066400000000000000000000001741235631523400266610ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_shovels]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_shovels --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/etc/nagios/nrpe.d/check_rabbitmq_watermark.cfg000066400000000000000000000002001235631523400271610ustar00rootroot00000000000000command[check_nrpe_check_rabbitmq_watermark]=exec /usr/lib/nagios/plugins-rabbitmq/check_rabbitmq_watermark --extra-opts=$ARG1$ nagios-plugins-rabbitmq-1.2.0/scripts/000077500000000000000000000000001235631523400177435ustar00rootroot00000000000000nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_aliveness000077500000000000000000000137001235631523400247010ustar00rootroot00000000000000#!/usr/bin/env perl ### check_rabbitmq_aliveness.pl # Use the management aliveness-check to send/receive a message through a vhost # Originally by Nathan Vonnahme, n8v at users dot sourceforge # dot net, July 19 2006 ############################################################################## # prologue use strict; use warnings; use Nagios::Plugin ; use LWP::UserAgent; use URI::Escape; use JSON; use vars qw($VERSION $PROGNAME $verbose $timeout); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); ############################################################################## # define and get the command line options. # see the command line option guidelines at # http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOPTIONS # Instantiate Nagios::Plugin object (the 'usage' parameter is mandatory) my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management aliveness-check to send/receive a message through a vhost.', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg(spec => 'vhost=s', help => "Specify the vhost to test (default: %s)", default => "/" ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # perform sanity checking on command line options ############################################################################## # check stuff. my $hostname=$p->opts->hostname; my $port=$p->opts->port; my $vhost=uri_escape($p->opts->vhost); my $url = sprintf("http%s://%s:%d/api/aliveness-test/%s", ($p->opts->ssl ? "s" : ""), $hostname, $port, $vhost); my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; $p->nagios_exit(CRITICAL, $bodyref->{'reason'}); } $res->code == 404 and $p->nagios_die("Not found: ".$p->opts->vhost); $res->code == 401 and $p->nagios_die("Access refused: ".$p->opts->vhost); if ($res->code < 200 or $res->code > 400 ) { $p->nagios_exit(CRITICAL, "Received ".$res->status_line." for vhost: ".$p->opts->vhost); } } my $bodyref = decode_json $res->content; $bodyref->{'status'} eq "ok" or $p->nagios_exit(CRITICAL, $res->content); my($code, $message) = (OK, "vhost: ".$p->opts->vhost); $p->nagios_exit( return_code => $code, message => $message ); =head1 NAME check_rabbitmq_aliveness - Nagios plugin using RabbitMQ management API to check liveness by send/receive a message through a vhost =head1 SYNOPSIS check_rabbitmq_aliveness [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to check that the server is alive. It declares a test queue, then publishes and consumes a message. It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item --vhost The vhost to create the test queue within (default: /) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =back =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_aliveness -H rabbit.example.com This returns a standard Nagios result: RABBITMQ_ALIVENESS OK - vhost: / You can choose a different vhost to use for the check also: check_rabbitmq_aliveness -H rabbit.example.com --vhost /foo =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1; nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_connections000066400000000000000000000224261235631523400252340ustar00rootroot00000000000000#!/usr/bin/env perl # # check_rabbitmq_connections # # Use the management APIs to check amount of connections # use strict; use warnings; use Nagios::Plugin qw(OK CRITICAL WARNING UNKNOWN); use Nagios::Plugin::Functions qw(%STATUS_TEXT); use LWP::UserAgent; use URI::Escape; use JSON; use vars qw($VERSION $PROGNAME $verbose $timeout); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management API to monitor connections.', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg( spec => 'warning|w=s', help => qq{-w, --warning=THRESHOLD[,THRESHOLD[,THRESHOLD[,THRESHOLD]]] Warning thresholds specified in order that the metrics are returned. Specify -1 if no warning threshold.}, ); $p->add_arg( spec => 'critical|c=s', help => qq{-c, --critical=THRESHOLD[,THRESHOLD[,THRESHOLD[,THRESHOLD]]] Critical thresholds specified in order that the metrics are returned. Specify -1 if no critical threshold.}, ); $p->add_arg( spec => 'clientuser=s', help => 'Specify the client username to limit the connections for (optional)', ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # perform sanity checking on command line options my %warning; if (defined $p->opts->warning) { my @warning = split(',', $p->opts->warning); $p->nagios_die("You should specify 1 to 4 ranges for --warning argument") unless $#warning < 4; $warning{'connections'} = shift @warning; $warning{'connections_notrunning'} = shift @warning; $warning{'receive_rate'} = shift @warning; $warning{'send_rate'} = shift @warning; } my %critical; if (defined $p->opts->critical) { my @critical = split(',', $p->opts->critical); $p->nagios_die("You should specify specify 1 to 4 ranges for --critical argument") unless $#critical < 4; $critical{'connections'} = shift @critical; $critical{'connections_notrunning'} = shift @critical; $critical{'receive_rate'} = shift @critical; $critical{'send_rate'} = shift @critical; } ############################################################################## # check stuff. my $hostname=$p->opts->hostname; my $port=$p->opts->port; my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); my $url = sprintf("http%s://%s:%d/api/connections", ($p->opts->ssl ? "s" : ""), $hostname, $port); my ($retcode, $result) = request($url); if ($retcode != 200) { $p->nagios_exit(CRITICAL, "$result : $url"); } my $values = {}; $values->{'connections'} = 0; $values->{'connections_notrunning'} = 0; $values->{'receive_rate'} = 0; $values->{'send_rate'} = 0; for my $connection (@$result) { if (not defined($p->opts->clientuser) or $p->opts->clientuser eq $connection->{"user"}) { $values->{'connections'}++; $values->{'connections_notrunning'}++ if $connection->{"state"} ne "running"; $values->{'receive_rate'} += $connection->{"recv_oct_details"}->{"rate"}; $values->{'send_rate'} += $connection->{"send_oct_details"}->{"rate"}; } } my @metrics = ("connections", "connections_notrunning", "receive_rate", "send_rate"); for my $metric (@metrics) { my $warning = undef; $warning = $warning{$metric} if (defined $warning{$metric} and $warning{$metric} ne -1); my $critical = undef; $critical = $critical{$metric} if (defined $critical{$metric} and $critical{$metric} ne -1); my $value = 0; $value = $values->{$metric} if defined $values->{$metric}; my $code = $p->check_threshold(check => $value, warning => $warning, critical=> $critical); $p->add_message($code, sprintf("$metric ".$STATUS_TEXT{$code}." (%d)", $value)) ; $p->add_perfdata(label=>$metric, value => $value, warning=>$warning, critical=> $critical); } my ($code, $message) = $p->check_messages(join_all=>', '); $p->nagios_exit(return_code => $code, message => $message); sub request { my ($url) = @_; my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; return (400, $bodyref->{'reason'}); } $res->code == 404 and return (404, "Not Found"); $res->code == 401 and return (401, "Access Refused"); $res->status_line =~ /Can\'t connect/ and return (500, "Connection Refused : $url"); if ($res->code < 200 or $res->code > 400 ) { return ($res->code, "Received ".$res->status_line); } } my $bodyref = decode_json $res->content; return($res->code, $bodyref); } =head1 NAME check_rabbitmq_connections - Nagios plugin using RabbitMQ management API to count the connections running, their state and optionally limit these checks to specific connected client user accounts. =head1 SYNOPSIS check_rabbitmq_connections [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to count the number of established connections, those that are not in state running and also their throughput. All values are published as performance metrics for the check. Critical and warning thresholds can be set for each of the metric. It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =item -w | --warning The warning levels for each count of connections established, connections in a non-running state (flow, blocked), receive rate and send rate. This field consists of one to four comma-separated thresholds. Specify -1 if no threshold for a particular count. =item -c | --critical The critical levels for each count of connections established, connections in a non-running state (flow, blocked), receive rate and send rate. This field consists of one to four comma-separated thresholds. Specify -1 if no threshold for a particular count. =item --clientuser Specify the client username to limit the connections checks for. =back =head1 THRESHOLD FORMAT The format of thresholds specified in --warning and --critical arguments is defined at . For example to be crtical if more than 5 connections, more than 2 connections not running, less than 200b/s received use --critical=5,2,200,-1 =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_connections -H localhost -w 1: -c 1: This returns a standard Nagios result: RABBITMQ_CONNECTIONS CRITICAL - connections CRITICAL (0), connections_notrunning WARNING (0), receive_rate OK (0) send_rate OK (0) | connections=0;;1: connections_notrunning=0;1:; receive_rate=0;; send_rate=0;; =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1; nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_objects000077500000000000000000000133651235631523400243500ustar00rootroot00000000000000#!/usr/bin/env perl # # check_rabbitmq_objects # # Use the management APIs to count various server objects - # vhost, exchange, binding, queue, channel # use strict; use warnings; use Nagios::Plugin ; use LWP::UserAgent; use URI::Escape; use JSON; use vars qw($VERSION $PROGNAME $verbose $timeout); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management to count various objects.', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # perform sanity checking on command line options ############################################################################## # check stuff. my $hostname=$p->opts->hostname; my $port=$p->opts->port; my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); my @calls = ("vhost", "exchange", "binding", "queue", "channel"); for my $call (@calls) { my $url = sprintf("http%s://%s:%d/api/%ss", ($p->opts->ssl ? "s" : ""), $hostname, $port, $call); my ($code, $result) = request($url); if ($code != 200) { $p->nagios_exit(CRITICAL, "$result : /api/". $call."s"); } # we're always returned a list - count it my $count = $#{$result}; $count = 0 if $count == -1; $p->add_message(OK, sprintf("$call (%.2f%%)", $count)) ; $p->add_perfdata(label=>$call, value => $count); } $p->nagios_exit(return_code => OK, message => "Gathered Object Counts"); sub request { my ($url) = @_; my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; return (400, $bodyref->{'reason'}); } $res->code == 404 and return (404, "Not Found"); $res->code == 401 and return (401, "Access Refused"); $res->status_line =~ /Can\'t connect/ and return (500, "Connection Refused : $url"); if ($res->code < 200 or $res->code > 400 ) { return ($res->code, "Received ".$res->status_line); } } my $bodyref = decode_json $res->content; return($res->code, $bodyref); } =head1 NAME check_rabbitmq_objects - Nagios plugin using RabbitMQ management API to count the number of various broker objects =head1 SYNOPSIS check_rabbitmq_objects [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to count the number of various broker objects. These are published as performance metrics for the check. Currently the following objects are counted: =over =item * vhost =item * exchange =item * binding =item * queue =item * channel =back It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =back =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_objects -H rabbit.example.com This returns a standard Nagios result: RABBITMQ_OBJECTS OK - Gathered Object Counts | vhost=1;; exchange=7;; binding=2;; queue=1;; channel=0;; =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1; nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_overview000077500000000000000000000173551235631523400245700ustar00rootroot00000000000000#!/usr/bin/env perl # # check_rabbitmq_overview # # Use the management APIs to count pending messages in broker # use strict; use warnings; use Nagios::Plugin qw(OK CRITICAL WARNING UNKNOWN); use Nagios::Plugin::Functions qw(%STATUS_TEXT); use LWP::UserAgent; use URI::Escape; use JSON; use vars qw($VERSION $PROGNAME $verbose $timeout); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management to count messages in server.', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg( spec => 'warning|w=s', help => qq{-w, --warning=INTEGER,INTEGER,INTEGER Warning thresholds specified in order that the metrics are returned. Specify -1 if no warning threshold.}, ); $p->add_arg( spec => 'critical|c=s', help => qq{-c, --critical=INTEGER,INTEGER,INTEGER Critical thresholds specified in order that the metrics are returned. Specify -1 if no critical threshold.}, ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # perform sanity checking on command line options my %warning; if (defined $p->opts->warning) { my @warning = split(',', $p->opts->warning); $p->nagios_die("You should specify three ranges for --warning argument") unless $#warning == 2; $warning{'messages'} = shift @warning; $warning{'messages_ready'} = shift @warning; $warning{'messages_unacknowledged'} = shift @warning; } my %critical; if (defined $p->opts->critical) { my @critical = split(',', $p->opts->critical); $p->nagios_die("You should specify three ranges for --critical argument") unless $#critical == 2; $critical{'messages'} = shift @critical; $critical{'messages_ready'} = shift @critical; $critical{'messages_unacknowledged'} = shift @critical; } ############################################################################## # check stuff. my $hostname=$p->opts->hostname; my $port=$p->opts->port; my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); my $url = sprintf("http%s://%s:%d/api/overview", ($p->opts->ssl ? "s" : ""), $hostname, $port); my ($retcode, $result) = request($url); if ($retcode != 200) { $p->nagios_exit(CRITICAL, "$result : /api/overview"); } my @metrics = ( "messages", "messages_ready", "messages_unacknowledged"); for my $metric (@metrics) { my $warning = undef; $warning = $warning{$metric} if (defined $warning{$metric} and $warning{$metric} != -1); my $critical = undef; $critical = $critical{$metric} if (defined $critical{$metric} and $critical{$metric} != -1); my $value = $result->{'queue_totals'}->{$metric}; my $code = $p->check_threshold(check => $value, warning => $warning, critical=> $critical); $p->add_message($code, sprintf("$metric ".$STATUS_TEXT{$code}." (%d)", $value)) ; $p->add_perfdata(label=>$metric, value => $value, warning=>$warning, critical=> $critical); } my ($code, $message) = $p->check_messages(join_all=>', '); $p->nagios_exit(return_code => $code, message => $message); sub request { my ($url) = @_; my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; return (400, $bodyref->{'reason'}); } $res->code == 404 and return (404, "Not Found"); $res->code == 401 and return (401, "Access Refused"); $res->status_line =~ /Can\'t connect/ and return (500, "Connection Refused : $url"); if ($res->code < 200 or $res->code > 400 ) { return ($res->code, "Received ".$res->status_line); } } my $bodyref = decode_json $res->content; return($res->code, $bodyref); } =head1 NAME check_rabbitmq_overview - Nagios plugin using RabbitMQ management API to count the messages pending on the broker =head1 SYNOPSIS check_rabbitmq_overview [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to count the number of pending, ready and unacknowledged messages. These are published as performance metrics for the check. Critical and warning thresholds can be set for each of the metrics. It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =item -w | --warning The warning levels for each count of messages, messages_ready and messages_unacknowledged. This field consists of three comma-separated integers. Specify -1 if no threshold for a particular count. =item -c | --critical The critical levels for each count of messages, messages_ready and messages_unacknowledged. This field consists of three comma-separated integers. Specify -1 if no threshold for a particular count =back =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_overview -H rabbit.example.com This returns a standard Nagios result: RABBITMQ_OVERVIEW OK - messages OK (25794) messages_ready OK (22971) messages_unacknowledged OK (2823) | messages=25794;; messages_ready=22971;; messages_unacknowledged=2823;; =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1; nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_partition000077500000000000000000000135531235631523400247270ustar00rootroot00000000000000#!/usr/bin/env perl ### check_rabbitmq_partition # Use the management API to check if partitions error conditions exist. # baseed on check_rabbitmq_watermark.pl, # Originally by Nathan Vonnahme, n8v at users dot sourceforge # dot net, July 19 2006 ############################################################################## # prologue use strict; use warnings; use Nagios::Plugin ; use LWP::UserAgent; use URI::Escape; use JSON; use vars qw($VERSION $PROGNAME $verbose $timeout); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); ############################################################################## # define and get the command line options. # see the command line option guidelines at # http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOPTIONS # Instantiate Nagios::Plugin object (the 'usage' parameter is mandatory) my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management API to check if the mem_alarm has been triggered', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'node|n=s', help => "Specify the node name (default is hostname)" ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # perform sanity checking on command line options ############################################################################## # check stuff. my $hostname=$p->opts->hostname; my $port=$p->opts->port; my $nodename = $p->opts->node; if (!$nodename) { $hostname =~ /^([a-zA-Z0-9-]*)/; $nodename = $1; } my $url = sprintf("http%s://%s:%d/api/nodes/rabbit\@%s", ($p->opts->ssl ? "s" : ""), $hostname, $port, $nodename); my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; $p->nagios_exit(CRITICAL, $bodyref->{'reason'}); } $res->code == 404 and $p->nagios_die("Not found"); $res->code == 401 and $p->nagios_die("Access refused"); if ($res->code < 200 or $res->code > 400 ) { $p->nagios_exit(CRITICAL, "Received ".$res->status_line); } } my $bodyref = decode_json $res->content; my $partitions=$bodyref->{'partitions'}; ref($partitions) eq "ARRAY" or $p->nagios_exit(CRITICAL, $res->content); scalar(@$partitions)==0 or $p->nagios_exit(CRITICAL, "Partitions detected: @$partitions"); my($code, $message) = (OK, "No Partitions"); $p->nagios_exit( return_code => $code, message => $message ); =head1 NAME check_rabbitmq_partition - Nagios plugin using RabbitMQ management API to check if a cluster partition has occured =head1 SYNOPSIS check_rabbitmq_partition [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to check if a cluster partition has occured. It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item -n | --node The node name (default is hostname) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =back =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_node -H rabbit.example.com This returns a standard Nagios result: RABBITMQ_NODE OK - No Partitions =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1; nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_queue000077500000000000000000000212351235631523400240360ustar00rootroot00000000000000#!/usr/bin/env perl # # check_rabbitmq_overview # # Use the management APIs to check a queue # use strict; use warnings; use Nagios::Plugin qw(OK CRITICAL WARNING UNKNOWN); use Nagios::Plugin::Functions qw(%STATUS_TEXT); use LWP::UserAgent; use URI::Escape; use JSON; use vars qw($VERSION $PROGNAME $verbose $timeout); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management API to monitor a specific queue.', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg(spec => 'vhost=s', help => "Specify the vhost where the queue resides (default: %s)", default => "/" ); $p->add_arg(spec => 'queue=s', help => "Specify the queue to check", required => 1 ); $p->add_arg( spec => 'warning|w=s', help => qq{-w, --warning=THRESHOLD[,THRESHOLD[,THRESHOLD[,THRESHOLD]]] Warning thresholds specified in order that the metrics are returned. Specify -1 if no warning threshold.}, ); $p->add_arg( spec => 'critical|c=s', help => qq{-c, --critical=THRESHOLD[,THRESHOLD[,THRESHOLD[,THRESHOLD]]] Critical thresholds specified in order that the metrics are returned. Specify -1 if no critical threshold.}, ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # perform sanity checking on command line options my %warning; if (defined $p->opts->warning) { my @warning = split(',', $p->opts->warning); $p->nagios_die("You should specify 1 to 4 ranges for --warning argument") unless $#warning < 4; $warning{'messages'} = shift @warning; $warning{'messages_ready'} = shift @warning; $warning{'messages_unacknowledged'} = shift @warning; $warning{'consumers'} = shift @warning; } my %critical; if (defined $p->opts->critical) { my @critical = split(',', $p->opts->critical); $p->nagios_die("You should specify specify 1 to 4 ranges for --critical argument") unless $#critical < 4; $critical{'messages'} = shift @critical; $critical{'messages_ready'} = shift @critical; $critical{'messages_unacknowledged'} = shift @critical; $critical{'consumers'} = shift @critical; } ############################################################################## # check stuff. my $hostname=$p->opts->hostname; my $port=$p->opts->port; my $vhost=uri_escape($p->opts->vhost); my $queue=$p->opts->queue; my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); my $url = sprintf("http%s://%s:%d/api/queues/%s/%s", ($p->opts->ssl ? "s" : ""), $hostname, $port, $vhost, $queue); my ($retcode, $result) = request($url); if ($retcode != 200) { $p->nagios_exit(CRITICAL, "$result : $url"); } my @metrics = ("messages", "messages_ready", "messages_unacknowledged", "consumers"); for my $metric (@metrics) { my $warning = undef; $warning = $warning{$metric} if (defined $warning{$metric} and $warning{$metric} ne -1); my $critical = undef; $critical = $critical{$metric} if (defined $critical{$metric} and $critical{$metric} ne -1); my $value = 0; $value = $result->{$metric} if defined $result->{$metric}; my $code = $p->check_threshold(check => $value, warning => $warning, critical=> $critical); $p->add_message($code, sprintf("$metric ".$STATUS_TEXT{$code}." (%d)", $value)) ; $p->add_perfdata(label=>$metric, value => $value, warning=>$warning, critical=> $critical); } my ($code, $message) = $p->check_messages(join_all=>', '); $p->nagios_exit(return_code => $code, message => $message); sub request { my ($url) = @_; my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; return (400, $bodyref->{'reason'}); } $res->code == 404 and return (404, "Not Found"); $res->code == 401 and return (401, "Access Refused"); $res->status_line =~ /Can\'t connect/ and return (500, "Connection Refused : $url"); if ($res->code < 200 or $res->code > 400 ) { return ($res->code, "Received ".$res->status_line); } } my $bodyref = decode_json $res->content; return($res->code, $bodyref); } =head1 NAME check_rabbitmq_queue - Nagios plugin using RabbitMQ management API to count the messages pending and consumers on a given queue =head1 SYNOPSIS check_rabbitmq_overview [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to count the number of pending, ready and unacknowledged messages and number of consumers. These are published as performance metrics for the check. Critical and warning thresholds can be set for each of the metrics. It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =item -w | --warning The warning levels for each count of messages, messages_ready, messages_unacknowledged and consumers. This field consists of one to four comma-separated thresholds. Specify -1 if no threshold for a particular count. =item -c | --critical The critical levels for each count of messages, messages_ready, messages_unacknowledged and consumers. This field consists of one to four comma-separated thresholds. Specify -1 if no threshold for a particular count. =back =head1 THRESHOLD FORMAT The format of thresholds specified in --warning and --critical arguments is defined at . For example to be crtical if more than 100 messages, more than 90 messages_ready, more than 20 messages_unacknowledged or no fewer than 10 consumers use --critical=100,90,20,10: =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_queue -H rabbit.example.com This returns a standard Nagios result: RABBITMQ_OVERVIEW OK - messages OK (25794) messages_ready OK (22971) messages_unacknowledged OK (2823) consumers OK (10) | messages=25794;; messages_ready=22971;; messages_unacknowledged=2823;; consumers=10;; =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1; nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_server000077500000000000000000000221211235631523400242130ustar00rootroot00000000000000#!/usr/bin/env perl ### check_rabbitmq_aliveness.pl # Use the management overview to check server statistics ############################################################################## # prologue use strict; use warnings; use Nagios::Plugin qw(OK CRITICAL WARNING UNKNOWN); use Nagios::Plugin::Functions qw(%STATUS_TEXT); use LWP::UserAgent; use URI::Escape; use JSON; use Data::Dumper; use vars qw($VERSION $PROGNAME $verbose $timeout $code $message); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); ############################################################################## # define and get the command line options. # see the command line option guidelines at # http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOPTIONS # Instantiate Nagios::Plugin object (the 'usage' parameter is mandatory) my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management node API to check server process parameters.', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'node|n=s', help => "Specify the node name (default is hostname)" ); $p->add_arg( spec => 'warning|w=s', help => qq{-w, --warning=INTEGER,INTEGER,INTEGER,INTEGER Warning thresholds specified in order that the metrics are returned. (Default : %s)}, # required => 1, default => "80,80,80,80", ); $p->add_arg( spec => 'critical|c=s', help => qq{-c, --critical=INTEGER,INTEGER,INTEGER,INTEGER Warning thresholds specified in order that the metrics are returned. (Default: %s) }, default => "90,90,90,90", ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # Check we have four values for warning and critical thresholds my @warning = split(',', $p->opts->warning); $p->nagios_die("You should specify four ranges for --warning argument") unless $#warning == 3; my @critical = split(',', $p->opts->critical); $p->nagios_die("You should specify four ranges for --critical argument") unless $#critical == 3; ############################################################################## # check stuff. my $hostname = $p->opts->hostname; my $nodename = $p->opts->node; if (!$nodename) { $hostname =~ /^([a-zA-Z0-9-]*)/; $nodename = $1; } my $port = $p->opts->port; my $path = "nodes/rabbit\@$nodename"; my $url = sprintf("http%s://%s:%d/api/%s", ($p->opts->ssl ? "s" : ""), $hostname, $port, $path); my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; $p->nagios_exit(CRITICAL, $bodyref->{'reason'}); } $res->code == 404 and $p->nagios_die("Not found: ".$path); $res->code == 401 and $p->nagios_die("Access refused: ".$path); if ($res->code < 200 or $res->code > 400 ) { $p->nagios_exit(CRITICAL, "Received ".$res->status_line." for path: ".$path); } } my $bodyref = decode_json $res->content; if (!$bodyref->{'running'}) { $p->nagios_exit(CRITICAL, "Not running: ".$path); } check($p, "Memory", $bodyref->{'mem_used'}, $bodyref->{'mem_limit'}, $warning[0], $critical[0]); check($p, "Process", $bodyref->{'proc_used'}, $bodyref->{'proc_total'}, $warning[1], $critical[1]); check($p, "FD", $bodyref->{'fd_used'}, $bodyref->{'fd_total'}, $warning[2], $critical[2]); check($p, "Sockets", $bodyref->{'sockets_used'}, $bodyref->{'sockets_total'}, $warning[3], $critical[3]); ($code, $message) = $p->check_messages(join_all=>', '); $p->nagios_exit( return_code=>$code, message=>$message); sub check { my $p = shift; my $label = shift; my $used = shift; my $limit = shift; my $warning = shift; my $critical = shift; if (!$p || !$used) { $p->nagios_exit( return_code=>CRITICAL, message=>'Unable to get values for '.$label); } else { my $value = percent($used, $limit); my $code = $p->check_threshold(check => $value, warning => $warning, critical => $critical); $p->add_message($code, sprintf("$label ".$STATUS_TEXT{$code}." (%.2f%%)", $value)) ; $p->add_perfdata(label=>$label, value => $value, uom=>"%", warning=>$warning, critical=>$critical); } } sub percent { my $num = shift; my $denom = shift; my $value = ($num/ $denom)*100; return sprintf("%.2f", $value) } sub structured { my $content = shift; $Data::Dumper::Terse = 1; # don't output names where feasible $Data::Dumper::Indent = 2; return Dumper($content); } =head1 NAME check_rabbitmq_server - Nagios plugin using RabbitMQ management API to check the server resource usage (processes, memory, file descriptors, and sock descriptors) =head1 SYNOPSIS check_rabbitmq_server [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to check the resource usage of the server. This check looks at the node statistics for the rabbit node on the host and examines the erlang memory, process and file descriptor usage. It provides performance data for each of these variables and allows for warning and criticality levels to be specified for each. It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item -w | --warning The warning levels, expressed as a percentage for each of memory, process, file descriptor and sockets usage. This field consists of four comma-separated integers. (default: 80,80,80,80) =item -c | --critical The critical levels, expressed as a percentage for each of memory, process, file descriptor and sockets usage. This field consists of four comma-separated integers. (default: 90,90,90,90) =item -n | --node The node name (default is hostname) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =back =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_server -H rabbit.example.com This returns a standard Nagios result: RABBITMQ_SERVER OK - Memory OK (6.19%) Process OK (0.01%) FD OK (2.53%) Sockets OK (0.86%) | Memory=6.19%;80;90 Process=0.01%;80;90 FD=2.53%;80;90 Sockets=0.86%;1;2 You can specify different warning and criticality levels. B<-w> and B<-c> both accept four comma-separated percentages which represent the thresholds for memory, process and file descriptor usage respectively. For example, to specify warnings for memory at 60%, process at 80%, file descriptors at 95%, and socket descriptors at 90%: check_rabbitmq_server -H rabbit.example.com -w 60,80,95,90 =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1; nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_shovels000077500000000000000000000144761235631523400244060ustar00rootroot00000000000000#!/usr/bin/perl -w use strict; use warnings; use JSON -support_by_pp; use LWP::UserAgent; use Nagios::Plugin; $::PROGRAM = "check_rabbitmq_shovels"; $::VERSION = "1.0"; # # main # MAIN: { run() unless caller(); } # # run() # --- sub run { my $np = Nagios::Plugin->new( plugin => $::PROGRAM, version => $::VERSION, blurb => "check that all the shovels of the given RabbitMQ host " . "are running", usage => "Usage: %s [-H host]", timeout => 5, ); # declare options $np->add_arg( spec => "hostname|host|H=s", help => "Specify the RabbitMQ host to query. Defaults to '%s'.", default => "localhost", ); $np->add_arg( spec => "port|P=s", help => "Specify the port number to query RabbitMQ on. Defaults to %s.", default => 55672, ); $np->add_arg( spec => "username|user|u=s", help => "Specify the username. Defaults to '%s'.", default => "guest", ); $np->add_arg( spec => "password|pass|p=s", help => "Specify the password. Defaults to '%s'.", default => "guest", ); # parse options $np->getopts; # -------------------------------------- # create and configure the JSON parser my $json = JSON->new; $json->allow_nonref->utf8->relaxed->escape_slash->loose; $json->allow_singlequote->allow_barekey; # construct the URL authority my $url_authority = $np->opts->username . ":" . $np->opts->password . '@' . $np->opts->hostname . ":" . $np->opts->port; # fetch the list of shovels alarm $np->opts->timeout; my $agent = LWP::UserAgent->new; my $response = $agent->get("http://$url_authority/api/shovels"); $np->nagios_exit( return_code => CRITICAL, message => "API error: ".$response->status_line ) unless $response->is_success; # decode the JSON my $shovels = eval { $json->decode($response->decoded_content || "[]") }; $np->nagios_exit( return_code => CRITICAL, message => "API error: could not parse JSON: $@" ) if $@; $np->nagios_exit( return_code => CRITICAL, message => "API error: empty JSON" ) unless @$shovels; # process the shovels my (@running, @blocked, @terminated); for my $shovel (@$shovels) { push @running, $shovel->{name} and next if $shovel->{state} eq "running"; push @blocked, $shovel->{name} and next if $shovel->{state} eq "blocked"; push @terminated, $shovel->{name} and next if $shovel->{state} eq "terminated"; } # construct the status message my ($status, @message); if (@running) { my $s = (my $n = @running) > 1 ? "s" : ""; unshift @message, "$n running shovel$s: @running"; $status = OK; } if (@blocked) { my $s = (my $n = @blocked) > 1 ? "s" : ""; unshift @message, "$n blocked shovel$s: @blocked"; $status = WARNING; } if (@terminated) { my $s = (my $n = @terminated) > 1 ? "s" : ""; unshift @message, "$n terminated shovel$s: @terminated"; $status = CRITICAL; } # return the appropriate status code and message $np->nagios_exit( return_code => $status, message => join ", ", @message, ); } 1 __END__ =pod =head1 NAME check_rabbitmq_shovels - Nagios plugin to check that all shovels of the given RabbitMQ host are running =head1 SYNOPSIS check_rabbitmq_shovels --hostname check_rabbitmq_shovels { --help | --man | --version } =head1 OPTIONS =head2 Program options =over =item B<-H>, B<--hostname> I Specify the RabbitMQ host to query. Defaults to C. =item B<-P>, B<--port> I Specify the port number to query RabbitMQ on. Defaults to 55672. =item B<-u>, B<--user>, B<--username> I Specify the username. Defaults to C. =item B<-p>, B<--pass>, B<--password> I Specify the password. Defaults to C. =item B<-t>, B<--timeout> I Specify the timeout period in seconds. Defaults to 5. =back =head2 Help options =over =item B<-?>, B<--usage> Print a short usage description, then exit. =item B<-h>, B<--help> Print a more detailed help screen, then exit. =item B<-V>, B<--version> Print the program name and version, then exit. =back =head1 DESCRIPTION This program is a Nagios plugin that uses the JSON over HTTP API to check that all shovels of the given RabbitMQ host are running. The default settings match the standard installation of RabbitMQ. The check returns C if all shovels are running, C if one or more shovels are blocked, C if one or more shovels are terminated. =head1 EXAMPLES With default settings, only the hostname need to be specified: check_rabbitmq_shovels -H It prints the global status and the details of the shovels, by decreasing order or criticity: RABBITMQ_SHOVELS OK - 3 running shovels: klonk zlott swish RABBITMQ_SHOVELS WARNING - 1 blocked shovel: klonk, 2 running shovels: zlott swish RABBITMQ_SHOVELS CRITICAL - 1 terminated shovel: zlott, 1 blocked shovel: klonk, 1 running shovel: swish In the case of an API error, the program will give an appropriate diagnostic: RABBITMQ_SHOVELS CRITICAL - API error: 401 Unauthorized RABBITMQ_SHOVELS CRITICAL - API error: 500 Can't connect to : RABBITMQ_SHOVELS CRITICAL - API error: could not parse JSON: malformed JSON string RABBITMQ_SHOVELS CRITICAL - API error: empty JSON =head1 SEE ALSO See L The RabbitMQ management plugin is described at L =head1 LICENSE Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR Sebastien Aperghis-Tramoni (sebastien@aperghis.net) nagios-plugins-rabbitmq-1.2.0/scripts/check_rabbitmq_watermark000077500000000000000000000144041235631523400247070ustar00rootroot00000000000000#!/usr/bin/env perl ### check_rabbitmq_watermark.pl # Use the management API to check if mem_alarm or disk_free_alarm has been triggered. # Originally by Nathan Vonnahme, n8v at users dot sourceforge # dot net, July 19 2006 ############################################################################## # prologue use strict; use warnings; use Nagios::Plugin ; use LWP::UserAgent; use URI::Escape; use JSON; use vars qw($VERSION $PROGNAME $verbose $timeout); $VERSION = '1.0'; # get the base name of this script for use in the examples use File::Basename; $PROGNAME = basename($0); ############################################################################## # define and get the command line options. # see the command line option guidelines at # http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOPTIONS # Instantiate Nagios::Plugin object (the 'usage' parameter is mandatory) my $p = Nagios::Plugin->new( usage => "Usage: %s [options] -H hostname", license => "", version => $VERSION, blurb => 'This plugin uses the RabbitMQ management API to check if the mem_alarm or disk_free_alarm has been triggered', ); $p->add_arg(spec => 'hostname|host|H=s', help => "Specify the host to connect to", required => 1 ); $p->add_arg(spec => 'port=i', help => "Specify the port to connect to (default: %s)", default => 55672 ); $p->add_arg(spec => 'node|n=s', help => "Specify the node name (default is hostname)" ); $p->add_arg(spec => 'username|user|u=s', help => "Username (default: %s)", default => "guest", ); $p->add_arg(spec => 'password|p=s', help => "Password (default: %s)", default => "guest" ); $p->add_arg(spec => 'vhost=s', help => "Specify the vhost to test (default: %s)", default => "/" ); $p->add_arg(spec => 'ssl|ssl!', help => "Use SSL (default: false)", default => 0 ); $p->add_arg(spec => 'proxy|proxy!', help => "Use environment proxy (default: true)", default => 1 ); # Parse arguments and process standard ones (e.g. usage, help, version) $p->getopts; # perform sanity checking on command line options ############################################################################## # check stuff. my $hostname=$p->opts->hostname; my $port=$p->opts->port; my $vhost=uri_escape($p->opts->vhost); my $nodename = $p->opts->node; if (!$nodename) { $hostname =~ /^([a-zA-Z0-9-]*)/; $nodename = $1; } my $url = sprintf("http%s://%s:%d/api/nodes/rabbit\@%s", ($p->opts->ssl ? "s" : ""), $hostname, $port, $nodename); my $ua = LWP::UserAgent->new(env_proxy => $p->opts->proxy); $ua->agent($PROGNAME.' '); $ua->timeout($p->opts->timeout); # Different security domains in 2.5 and 2.6 $ua->credentials("$hostname:$port", "RabbitMQ Management", $p->opts->username, $p->opts->password); $ua->credentials("$hostname:$port", "Management: Web UI", $p->opts->username, $p->opts->password); my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); if (!$res->is_success) { # Deal with standard error conditions - make the messages more sensible if ($res->code == 400) { my $bodyref = decode_json $res->content; $p->nagios_exit(CRITICAL, $bodyref->{'reason'}); } $res->code == 404 and $p->nagios_die("Not found"); $res->code == 401 and $p->nagios_die("Access refused"); if ($res->code < 200 or $res->code > 400 ) { $p->nagios_exit(CRITICAL, "Received ".$res->status_line); } } my $bodyref = decode_json $res->content; my @checks = ("mem_alarm", "disk_free_alarm"); for my $check (@checks) { if ($bodyref->{$check} eq 0) { $p->add_message(OK, "$check"); } else { $p->add_message(CRITICAL, "$check"); } } my($code, $message) = $p->check_messages(join_all=>', '); $p->nagios_exit( return_code => $code, message => $message ); =head1 NAME check_rabbitmq_watermark - Nagios plugin using RabbitMQ management API to check if the mem_alarm or disk_free_alarm has been triggered =head1 SYNOPSIS check_rabbitmq_watermark [options] -H hostname =head1 DESCRIPTION Use the management interface of RabbitMQ to check if the mem_alarm or disk_free_alarm has been triggered. It uses Nagios::Plugin and accepts all standard Nagios options. =head1 OPTIONS =over =item -h | --help Display help text =item -v | --verbose Verbose output =item -t | --timeout Set a timeout for the check in seconds =item -H | --hostname | --host The host to connect to =item --port The port to connect to (default: 55672) =item --ssl Use SSL when connecting (default: false) =item --vhost The vhost to create the test queue within (default: /) =item -n | --node The node name (default is hostname) =item --username | --user The user to connect as (default: guest) =item --pass The password for the user (default: guest) =back =head1 EXAMPLES The defaults all work with a standard fresh install of RabbitMQ, and all that is needed is to specify the host to connect to: check_rabbitmq_watermark -H rabbit.example.com This returns a standard Nagios result: RABBITMQ_ALIVENESS OK - vhost: / You can choose a different vhost to use for the check also: check_rabbitmq_watermark -H rabbit.example.com --vhost /foo =head1 ERRORS The check tries to provide useful error messages on the status line for standard error conditions. Otherwise it returns the HTTP Error message returned by the management interface. =head1 EXIT STATUS Returns zero if check is OK otherwise returns standard Nagios exit codes to signify WARNING, UNKNOWN or CRITICAL state. =head1 SEE ALSO See Nagios::Plugin(3) The RabbitMQ management plugin is described at http://www.rabbitmq.com/management.html =head1 LICENSE This file is part of nagios-plugins-rabbitmq. Copyright 2010, Platform 14. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 AUTHOR James Casey =cut 1;