pax_global_header00006660000000000000000000000064131424055360014515gustar00rootroot0000000000000052 comment=fd370ad7c1c574cc56ddc8c92d14d343bf28f1f1 nrpe-ng-0.2.0/000077500000000000000000000000001314240553600130625ustar00rootroot00000000000000nrpe-ng-0.2.0/.gitignore000066400000000000000000000004311314240553600150500ustar00rootroot00000000000000# Compiled python modules. *.pyc # Vim swap files .*.swp # Setuptools distribution folder. /dist/ # Python egg metadata, regenerated from source files by setuptools. /*.egg-info /*.egg # Debian pybuild temporary directory /.pybuild/ # Python code coverage metadata /.coverage nrpe-ng-0.2.0/COPYING000066400000000000000000000432541314240553600141250ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. nrpe-ng-0.2.0/MANIFEST.in000066400000000000000000000003511314240553600146170ustar00rootroot00000000000000include config/check_nrpe_ng.cfg include config/nagios_check_nrpe_ng.cfg include config/nrpe-ng.cfg include COPYING include Makefile include man/nrpe-ng.1 include man/nrpe-ng.cfg.5 include README.md include setup.cfg include TODO.md nrpe-ng-0.2.0/Makefile000066400000000000000000000017161314240553600145270ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. PYTHON3 := $(shell which python3) all: flake8 clean: find $(CURDIR) -name .git -prune -o -name \*.pyc -type f -print0 | \ xargs -0 rm flake8: $(PYTHON3) -m flake8 $(CURDIR) nrpe-ng-0.2.0/README.md000066400000000000000000000057401314240553600143470ustar00rootroot00000000000000nrpe-ng: The next generation Nagios Remote Plugin Executor ========================================================== This is a rewrite from the ground up of NRPE. This set of programs allows you to run Nagios check scripts on a remote host. FEATURES -------- * Real, proper SSL (TLS, actually). The server/executor component needs a key and certificate, and can optionally validate clients against a provided SSL certificate authority (or the system one). The client also validates the server name given in certificates and can validate the certificate against the system CA list or a provided CA. * Safe command-line argument passing. Arguments are passed without any interpolation to the check script. Missing arguments are simply passed as empty arguments. Quoting within the configuration file is respected. * Named arguments are supported. If you had trouble working out what $ARG7$ in your check script was for, you can now call it something sensible instead. WHY? IS NRPE NOT GOOD ENOUGH? ----------------------------- No. It has several weaknesses and issues that make it unsuitable: 1. Its SSL mode does very little for security. It does not use certificates or keys. It simply does a plain DH Key Exchange using a well-known "secret", and cannot validate that the client or server it is talking to is correctly authorised. It prevents passive snooping of the connection, but does not help against man-in-the-middle attacks. 2. Its command-line argument passing capability is riddled with security holes. All commands are run by passing them to a shell, which exposes a great number of attacks using shell expansion characters. Why now? The command-line execution mode of NRPE was disabled in the packages currently (as of this writing) in Debian Jessie in response to CVE-2014-2913 (Debian bug #745272). I felt I really needed this functionality, but the bugs are too severe to fix properly. I felt that re-implementing it from the ground up with the features that I want was a good thing to do. DISCLAIMER ---------- This project is not endorsed nor authorised by Nagios Enterprises, LLC. I just picked the name as it seemed to be a good name to describe an improved re-implementation of NRPE. LICENSE ------- Copyright (C) 2014-17 Chris Boot This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. nrpe-ng-0.2.0/TODO.md000066400000000000000000000002731314240553600141530ustar00rootroot00000000000000TODO LIST ========= General things that need doing: * Set up unit testing and write some tests! * Write some more documentation including man pages nrpe-ng-0.2.0/config/000077500000000000000000000000001314240553600143275ustar00rootroot00000000000000nrpe-ng-0.2.0/config/check_nrpe_ng.cfg000066400000000000000000000040101314240553600175700ustar00rootroot00000000000000# # Configuration file for check_nrpe_ng # # # This is a configuration file for the check_nrpe_ng client program. The client # runs on your Nagios monitoring host and connects to the nrpe-ng server in # order to run commands remotely. # # This configuration file is used for additional configuration options that are # too cumbersome to provide on the command-line, such as SSL options. # SSL KEY AND CERTIFICATE FILE # # The client may optionally present an SSL certificate to servers that it # connects to in order to authenticate itself to clients. This is enabled in # the server by enabling the ssl_verify_client option. # # HINT: If you're using Puppet, you can use the current node's Puppet SSL key # and certificate and avoid having to set up your own SSL infrastructure just # for nrpe-ng. # # Default: [both blank] # ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem # ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key # SSL SERVER VERIFICATION # # When connecting to a server, the client will check that the certificate # provided by the client is valid, including that it has not expired and that # the host name in the certificate matches the host that the client is # connecting to. This option allows you to disable this strict checking, but be # aware that doing so is a security risk. # # Default: 1 # ssl_verify_server=1 # SSL CERTIFICATE AUTHORITY # # This directive is only used with SSL client verification (above). By default, # nrpe-ng will load your system's standard Certificate Authority list. With # client verification enabled, that will permit any valid certificate presented # from any valid CA, which is probably not what you want. By supplying a path # to a PEM-encoded file containing one or more certificates, these certificates # will be loaded _instead_ of your OS list, allowing much finer validation. # # HINT: If you're using Puppet, you can use the cached copy of the Puppet CA # certificate and avoid having to set up your own SSL infrastructure just # for nrpe-ng. # # Default: [blank] # ssl_ca_file= nrpe-ng-0.2.0/config/nagios_check_nrpe_ng.cfg000066400000000000000000000007421314240553600211400ustar00rootroot00000000000000 # this command runs a program $ARG1$ with no arguments define command { command_name check_nrpe_ng command_line /usr/bin/check_nrpe_ng -C /etc/nagios/check_nrpe_ng.cfg -H $HOSTADDRESS$ -c $ARG1$ } # this command runs a program $ARG1$ with one additional argument ($ARG2$, # which becomes $ARG1$ on the nrpe-ng server) define command { command_name check_nrpe_ng_1arg command_line /usr/bin/check_nrpe_ng -C /etc/nagios/check_nrpe_ng.cfg -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ } nrpe-ng-0.2.0/config/nrpe-ng.cfg000066400000000000000000000222771314240553600163700ustar00rootroot00000000000000# # Configuration file for nrpe-ng # # # This is a configuration file for the nrpe-ng server daemon. The server is run # on the remote hosts that you wish to run the check scripts on, and hence this # configuration file has to be there too. This is not the configuration file # for the client tool that is run by Nagios, which connects to remote hosts. # # Note that this configuration file is deliberately very similar to the Nagios # NRPE configuration file, in order to be able to read the original nrpe.cfg # file if desired # NAGIOS NRPE COMPATIBILITY # # If you wish to use nrpe-ng as a drop-in replacement for Nagios NRPE, # uncomment the line below in order to import its configuration first. You may # override any configuration settings below. Please note that nrpe-ng is NOT # compatible with NRPE's network protocol, and you will need to use # check_nrpe_ng to communicate with nrpe-ng. # # include=/etc/nagios/nrpe.cfg # LOG FACILITY # # The syslog facility that should be used for logging purposes. This can be any # of the standard facility names (lower-cased). # # Default: daemon # log_facility=daemon # PID FILE # # The name of the file in which nrpe-ng should write its process ID number. # The file is only written if the NRPE daemon is started by the root user. # # Default: /run/nagios/nrpe-ng.pid pid_file=/run/nagios/nrpe-ng.pid # SERVER PORT NUMBER # # Port number that nrpe-ng will listen for connections on. Note that nrpe-ng is # not compatible with Nagios NRPE's wire protocol, so it is recommended to use # a different port to NRPE's (5666). # # Default: 59546 server_port=59546 # SERVER ADDRESS # # IP address that nrpe-ng will bind to. This may be either an IPv4 or IPv6 # address. If you use the IPv4 wildcard address (0.0.0.0) the service will only # be available via IPv4; if you use the IPv6 unspecified address (::) the # service will be available by IPv6 and will probably also be available via # IPv4 depending on your networking configuration. # # Default: :: # server_address=:: # NRPE USER # # This determines the effective user that the NRPE daemon should run as. # You can either supply a username or a UID. # # Default: nagios # nrpe_user=nagios # NRPE GROUP # # This determines the effective group that the NRPE daemon should run as. # You can either supply a group name or a GID. # # Default: nagios # nrpe_group=nagios # ALLOWED HOST ADDRESSES # # This is an optional comma-delimited list of IP addresses that are allowed to # talk to the NRPE daemon. Network addresses with a bit mask (i.e. # 192.168.1.0/24) are also supported. This is a very rudimentary check and is # by no means a replacement for a proper firewall. # # For more fine-grained security, consider using SSL client authentication # (below). # # NOTE: nrpe-ng is not fully compatible with NRPE with regards to this # parameter: it does not support hostnames. # # Default: [blank] # allowed_hosts= # SSL KEY AND CERTIFICATE FILE # # A valid SSL key and certificate are REQUIRED when running an nrpe-ng server. # These is used for encrypting and authenticating connections from clients, so # that the client can be sure it is talking to the correct server - and is thus # a good defence against man-in-the-middle attacks. # # HINT: If you're using Puppet, you can use the current node's Puppet SSL key # and certificate and avoid having to set up your own SSL infrastructure just # for nrpe-ng. # # Default: [both blank] ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key # SSL CLIENT VERIFICATION # # If you enable the option below, clients connecting to this server will be # forced to present an SSL certificate before being able to send commands to # this server instance. The certificate will be checked for validity against # the loaded SSL CA list (see below), that it has not yet expired, and so on. # This is a good security measure to cryptographically authenticate that # requests are indeed coming from an authorised server. # # Default: 0 # ssl_verify_client=0 # SSL CERTIFICATE AUTHORITY # # This directive is only used with SSL client verification (above). By default, # nrpe-ng will load your system's standard Certificate Authority list. With # client verification enabled, that will permit any valid certificate presented # from any valid CA, which is probably not what you want. By supplying a path # to a PEM-encoded file containing one or more certificates, these certificates # will be loaded _instead_ of your OS list, allowing much finer validation. # # HINT: If you're using Puppet, you can use the cached copy of the Puppet CA # certificate and avoid having to set up your own SSL infrastructure just # for nrpe-ng. # # Default: [blank] # ssl_ca_file= # COMMAND ARGUMENT PROCESSING # # This option determines whether or not nrpe-ng will allow clients to pass # arguments to commands that are executed. This is far less risky with nrpe-ng # than with Nagios NRPE because of the manner that commands are executed: # commands are run directly and not using a shell, but you should still # consider carefully before you enable this option. # # If you DO decide to use this option, please also take a look at allowed_hosts # and/or the SSL client security modes above. # # Default: 0 # dont_blame_nrpe=0 # BASH COMMAND SUBTITUTION # # This option is deliberately NOT supported in nrpe-ng for security reasons. If # your configuration file enables this option, nrpe-ng will refuse to start. # # Default: 0 # allow_bash_command_substitution=0 # COMMAND PREFIX # # This option allows you to prefix all commands with a user-defined command. # This can be used to wrap ALL check commands with another command, for example # sudo(8). This is probably a very bad idea. Arguments in the command prefix # are not supported, and will be passed to the check command verbatim. # # Default: [blank] # command_prefix= # DEBUGGING OPTION # # This option determines whether or not debugging messages are produced. # # Default: 0 # debug=0 # COMMAND TIMEOUT # # This specifies the maximum number of seconds that nrpe-ng will allow plugins # to run. If they take longer, they will be killed. # # Default: 60 # command_timeout=60 # CONNECTION TIMEOUT # # This specifies the maximum number of seconds that nrpe-ng will wait for a # connection to be established before closing the connection. This can be seen # if a network problem stops the SSL session being established even though the # underlying TCP connection has established OK. # # Default: 300 # connection_timeout=300 # INCLUDE CONFIG FILE # # This directive allows you to include definitions from an external config # file. If the file does not exist or is not readable, it is silently ignored. # include=/path/to/somefile.cfg # INCLUDE CONFIG DIRECTORY # # This directive allows you to include definitions from config files (with a # .cfg extension) in one or more directories (with recursion). # include_dir=/path/to/somedirectory # COMMAND DEFINITIONS # # Command definitions that this daemon will run. Definitions # are in the following format: # # command[]= # # When the daemon receives a request to return the results of # it will execute the command specified by the argument. # Below are some examples using static arguments: # # command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1 # command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 # command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200 # command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10 # command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z # If you enable command argument processing (dont_blame_nrpe, above) you may # include variables in the command definition that will be substituted for the # values given by the client. Variables have the format $varname$, and are # compatible with NRPE or Nagios arguments of the form $ARGn$. # # Here are some examples using argument passing, with NRPE-compatible names: # # command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ # command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$ # command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ # command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$ # # And here are the same examples using arbitrary variable names: # # command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $warn$ -c $crit$ -p $path$ # command[check_load]=/usr/lib/nagios/plugins/check_load -w $warn$ -c $crit$ # command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $warn$ -c $crit$ -s $state$ # command[check_users]=/usr/lib/nagios/plugins/check_users -w $warn$ -c $crit$ # LOCAL CONFIGURATION # # You may prefer to keep your command definitions outside your main nrpe-ng.cfg # file. The line below includes a standard configuration file also used by NRPE # that you may choose to put your definitions in. include=/etc/nagios/nrpe_local.cfg # Alternatively, you may prefer to store them in multiple files, which may be # easier to use with configuration management or packaging systems. Again, the # line below is a standard NRPE path for compatibility. include_dir=/etc/nagios/nrpe.d/ nrpe-ng-0.2.0/man/000077500000000000000000000000001314240553600136355ustar00rootroot00000000000000nrpe-ng-0.2.0/man/nrpe-ng.1000066400000000000000000000041531314240553600152700ustar00rootroot00000000000000.\" Hey, EMACS: -*- nroff -*- .\" (C) Copyright 2014-17 Chris Boot .\" .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH NRPE-NG 1 "2014-11-07" "nrpe-ng" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME nrpe-ng \- the next generation Nagios Remote Plugin Executor .SH SYNOPSIS .B nrpe-ng \fB\-c\fR \fICONFIG_FILE\fR .RI [ options ] .SH DESCRIPTION \fBnrpe-ng\fR is a rewrite of NRPE, the Nagios Remote Plugin Executor. It is a combination of a daemon, \fBnrpe-ng\fR, and a client program, \fBcheck_nrpe_ng\fR, which work in concert to run Nagios check scripts on remote hosts. This man page is for the daemon component that runs on the hosts on which you wish to run the check programs. .SH OPTIONS This program supports the following options: .TP .B \-h Show a summary of the available command-line options. .TP .B \-v Display the program's version number and exit. .TP .B \-\-debug Enable debugging mode, which produces much more verbose logging but prevents the program from logging to syslog. .TP \fB\-\-c\fR \fICONFIG_FILE\fR, \fB\-\-config\fR \fICONFIG_FILE\fR Specify the configuraiton file to use when running the daemon. This option is required. .TP \fB\-d\fR, \fB\-\-daemon\fR Fork the program and continue running in the background as a daemon. This mode is the default, so neither of these options need to be given to gain this behaviour. .TP .B \-f Do \fBnot\fR fork into the background and remain in the foreground. This option is the opposite of \fB\-d\fR or \fB\-\-daemon\fR, and may be useful for debugging. .SH SEE ALSO .BR nrpe-ng.cfg (5), https://github.com/bootc/nrpe-ng nrpe-ng-0.2.0/man/nrpe-ng.cfg.5000066400000000000000000000017271314240553600160360ustar00rootroot00000000000000.\" Hey, EMACS: -*- nroff -*- .\" (C) Copyright 2014-17 Chris Boot .\" .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH NRPE-NG.CFG 5 "2014-11-07" "nrpe-ng" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME nrpe-ng.cfg \- configuration file for \fBnrpe-ng\fR .SH SYNOPSIS .B /etc/nagios/nrpe-ng.cfg .SH DESCRIPTION TODO .SH FILES .I /etc/nagios/nrpe-ng.cfg .SH SEE ALSO .BR nrpe-ng (1), https://github.com/bootc/nrpe-ng nrpe-ng-0.2.0/nrpe_ng/000077500000000000000000000000001314240553600145125ustar00rootroot00000000000000nrpe-ng-0.2.0/nrpe_ng/__init__.py000066400000000000000000000015021314240553600166210ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # This page is intentionally left blank. nrpe-ng-0.2.0/nrpe_ng/client.py000066400000000000000000000227311314240553600163470ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import argparse import logging import os.path import requests import sys import urllib.parse import warnings try: from requests.packages.urllib3.exceptions import SubjectAltNameWarning except ImportError: SubjectAltNameWarning = None from .config import NrpeConfig, ConfigError from .defaults import CLIENT_CONFIG, CLIENT_CONFIG_PATH from .syslog import SyslogFormatter from .version import __version__ log = logging.getLogger(__name__) rootlog = logging.getLogger() NAGIOS_OK = 0 NAGIOS_WARNING = 1 NAGIOS_CRITICAL = 2 NAGIOS_UNKNOWN = 3 class Client: """nrpe-ng: the next generation Nagios Remote Plugin Executor""" def __init__(self): epilog = """ Copyright (C) 2014-17 Chris Boot """ parser = argparse.ArgumentParser(description=self.__doc__, epilog=epilog) parser.add_argument('--version', action='version', version=__version__) parser.add_argument('--debug', action='store_true', help='print verbose debugging information') parser.add_argument('-C', dest='config_file', help='use the given configuration file') parser.add_argument('-H', dest='host', required=True, help='the address of the host running nrpe-ng') parser.add_argument('-p', type=int, dest='port', default=CLIENT_CONFIG['port'], help='the port on which the daemon is listening ' '(default: %(default)s)') parser.add_argument('-t', type=int, dest='timeout', default=CLIENT_CONFIG['timeout'], help='connection timeout in seconds ' '(default: %(default)s)') parser.add_argument('-u', action='store_true', dest='timeout_unknown', help='socket timeouts return UNKNOWN state ' 'instead of CRITICAL') parser.add_argument('-c', dest='command', default=None, help='the command to run run on the remote host') parser.add_argument('-a', dest='args', nargs='+', action='append', help='arguments that should be passed to the ' 'command') self.argparser = parser def setup_logging(self): # Add a console handler console = logging.StreamHandler() self.console_log = console rootlog.addHandler(console) def parse_args(self): args = self.argparser.parse_args() # Re-process args to flatten the list if args.args: args.args = [item for sublist in args.args for item in sublist] self.args = args def reload_config(self): config_file = self.args.config_file # If the user has not specified a configuration file, but a file exists # in the standard location, use it. if config_file is None and os.path.lexists(CLIENT_CONFIG_PATH): config_file = CLIENT_CONFIG_PATH cfg = NrpeConfig(CLIENT_CONFIG, self.args, config_file) # In debug mode, set the log level to DEBUG if cfg.debug: rootlog.setLevel(logging.DEBUG) else: # Silence the requests library as we catch its exceptions and # output our own summary messages logging.getLogger('requests').setLevel(logging.CRITICAL) # Don't output exception stack traces self.console_log.formatter = SyslogFormatter() self.cfg = cfg def make_request(self): if self.cfg.command: command = urllib.parse.quote_plus(self.cfg.command) url = "https://{host}:{port}/v1/check/{command}".format( host=self.cfg.host, port=self.cfg.port, command=command) else: url = "https://{host}:{port}/v1/version".format( host=self.cfg.host, port=self.cfg.port) req = { 'url': url, 'headers': { 'User-Agent': "{prog}/{ver}".format( prog=self.argparser.prog, ver=__version__), }, 'timeout': self.cfg.timeout, 'allow_redirects': False, } if self.cfg.args: # Convert the array of arguments into a dict of key=value pairs # Arguments of the form key=value are simply split up, but # arguments with no '=' are assigned to ARGx keys like NRPE does args = {} argn = 1 for arg in self.cfg.args: kv = arg.split('=', 2) if len(kv) == 1: key = 'ARG{}'.format(argn) args[key] = kv[0] argn = argn + 1 # increment ARGx argument counter else: key = kv[0] args[key] = kv[1] req['method'] = 'POST' req['data'] = args else: req['method'] = 'GET' # Configure SSL server certificate verification if self.cfg.ssl_verify_server: if self.cfg.ssl_ca_file: req['verify'] = self.cfg.ssl_ca_file else: req['verify'] = True else: # Do not verify server certificates req['verify'] = False # Configure SSL client certificates if self.cfg.ssl_key_file and self.cfg.ssl_cert_file: req['cert'] = (self.cfg.ssl_cert_file, self.cfg.ssl_key_file) return requests.request(**req) def run(self): self.setup_logging() self.parse_args() try: self.reload_config() except ConfigError as e: log.error(e.args[0]) log.error("config file '{}' contained errors, aborting".format( self.args.config_file)) sys.exit(1) if self.cfg.debug: import pprint pp = pprint.PrettyPrinter(indent=4) pp.pprint(self.cfg._get_kwargs()) try: with warnings.catch_warnings(): # Ignore urllib3's (embedded into requests) subjectAltName # warning unconditionally. It is highly likely that the # certificates used with nrpe-ng lack a subjectAltName so just # allow them to keep working silently; if/when requests or # urllib3 makes this fail, people will realise quickly enough. if SubjectAltNameWarning: warnings.simplefilter('ignore', category=SubjectAltNameWarning) r = self.make_request() except requests.exceptions.Timeout: log.error("{host}: Request timed out".format( host=self.cfg.host)) if self.cfg.timeout_unknown: sys.exit(NAGIOS_UNKNOWN) else: sys.exit(NAGIOS_CRITICAL) except requests.exceptions.RequestException as e: # Why do I have to do this?! Such insanity should not be necessary # to obtain the actual underlying exception that caused the request # to fail. wrapped = e while wrapped.__cause__ or wrapped.__context__: wrapped = wrapped.__cause__ or wrapped.__context__ # This additional insanity is now needed to get a nice textual # error that's presentable to a user. message = str(wrapped) if isinstance(wrapped, OSError): message = wrapped.strerror log.error("{host}: {err}".format( host=self.cfg.host, err=message), exc_info=True) sys.exit(NAGIOS_UNKNOWN) # When no command is requested, this is a version request. if self.cfg.command is None: if r.status_code == 200: # nrpe-ng 0.2 has a version endpoint print(r.text) sys.exit(NAGIOS_OK) try: # older versions don't, but they set the Server header. This # might also be helpful if the request fails. print(r.headers['Server']) sys.exit(NAGIOS_OK) except KeyError: print("unknown version: {}".format(r.reason)) sys.exit(NAGIOS_WARNING) if r.status_code != 200: print(r.reason) sys.exit(NAGIOS_UNKNOWN) try: result = int(r.headers['X-NRPE-Result']) except: result = NAGIOS_UNKNOWN sys.stdout.write(r.text) sys.exit(result) def main(): return Client().run() if __name__ == "__main__": main() nrpe-ng-0.2.0/nrpe_ng/commands.py000066400000000000000000000066331314240553600166750ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import logging import re import shlex import subprocess import tornado.process from datetime import timedelta from tornado import gen from tornado.ioloop import IOLoop from .defaults import EXEC_PATH log = logging.getLogger(__name__) @gen.coroutine def terminate_hard(subproc, attempts=3, interval=1): for signal in [subproc.proc.terminate, subproc.proc.kill]: for _ in range(attempts): try: signal() except ProcessLookupError: pass try: yield gen.with_timeout( timedelta(seconds=interval), subproc.wait_for_exit(raise_error=False)) except gen.TimeoutError: pass else: return class CommandTimedOutError(Exception): def __init__(self): super(CommandTimedOutError, self).__init__('CommandTimedOutError') class Command: # Regular expression to match argument placeholders ARG_RE = re.compile(r'\$(?P\w+)\$') def __init__(self, cfg, cmdstr): self.cfg = cfg self.cmd = shlex.split(cmdstr) @gen.coroutine def execute(self, args={}): env = { 'PATH': EXEC_PATH, } # Initialise the arguments list with the split up command prefix run_args = shlex.split(self.cfg.command_prefix) # Add the actual command and its arguments for arg in self.cmd: mo = self.ARG_RE.search(arg) if not mo: run_args.append(arg) continue var = mo.group('arg') run_args.append(args.get(var, '')) log.debug('Executing: {}'.format(subprocess.list2cmdline(run_args))) proc = tornado.process.Subprocess( run_args, stdout=tornado.process.Subprocess.STREAM, close_fds=True, env=env) try: exit, stdout = yield gen.with_timeout( timedelta(seconds=self.cfg.command_timeout), [ proc.wait_for_exit(raise_error=False), proc.stdout.read_until_close(), ]) except gen.TimeoutError: IOLoop.current().add_callback(terminate_hard, proc) raise CommandTimedOutError if exit < 0 and not stdout: stdout = "Terminated by signal {}\n".format(-exit) return (exit, stdout) def __repr__(self): return "{klass}('{command}')".format( klass=self.__class__.__name__, command=subprocess.list2cmdline(self.cmd)) def __str__(self): return subprocess.list2cmdline(self.cmd) nrpe-ng-0.2.0/nrpe_ng/config.py000066400000000000000000000203211314240553600163270ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import os from argparse import Namespace from configparser import RawConfigParser, NoOptionError, ParsingError, \ _default_dict class NrpeConfigParser(RawConfigParser): def __init__(self, defaults=None, dict_type=_default_dict, allow_no_value=False): RawConfigParser.__init__(self, defaults, dict_type, allow_no_value) self.main_section = __name__ def __getattr__(self, name): try: return self.get(self.main_section, self.main_section, name) except NoOptionError: raise AttributeError def _read(self, fp, fpname): """Parse a sectioned setup file. The sections in setup file contains a title line at the top, indicated by a name in square brackets (`[]'), plus key/value options lines, indicated by `name: value' format lines. Continuations are represented by an embedded newline then leading whitespace. Blank lines, lines beginning with a '#', and just about everything else are ignored. """ if self.main_section in self._sections: cursect = self._sections[self.main_section] else: cursect = self._dict() cursect['__name__'] = self.main_section self._sections[self.main_section] = cursect optname = None lineno = 0 e = None # None, or an exception while True: line = fp.readline() if not line: break lineno = lineno + 1 # comment or blank line? if line.strip() == '' or line[0] in '#;': continue if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR": # no leading whitespace continue # continuation line? if line[0].isspace() and optname: value = line.strip() if value: cursect[optname].append(value) # an option line? else: mo = self._optcre.match(line) if mo: optname, vi, optval = mo.group('option', 'vi', 'value') optname = self.optionxform(optname.rstrip()) # This check is fine because the OPTCRE cannot # match if it would set optval to None if optval is not None: if vi in ('=', ':') and ';' in optval: # ';' is a comment delimiter only if it follows # a spacing character pos = optval.find(';') if pos != -1 and optval[pos-1].isspace(): optval = optval[:pos] optval = optval.strip() # allow empty values if optval == '""': optval = '' self._handle_set_option(cursect, optname, optval) else: # valueless option handling cursect[optname] = optval else: # a non-fatal parsing error occurred. set up the # exception but keep going. the exception will be # raised at the end of the file and will contain a # list of all bogus lines if not e: e = ParsingError(fpname) e.append(lineno, repr(line)) # if any parsing errors occurred, raise an exception if e: raise e # join the multi-line values collected while reading all_sections = [self._defaults] all_sections.extend(list(self._sections.values())) for options in all_sections: for name, val in list(options.items()): if isinstance(val, list): options[name] = '\n'.join(val) def _handle_set_option(self, cursect, optname, optval): if optname == 'include': self._handle_include(optval) elif optname == 'include_dir': self._handle_include_dir(optval) else: cursect[optname] = [optval] def _handle_include(self, path): self.read(path) def _handle_include_dir(self, path): for subdir, dirs, files in os.walk(path): for file in files: if file.endswith('.cfg'): self.read(os.path.join(subdir, file)) class ConfigError(Exception): def __init__(self, message, exception): super(ConfigError, self).__init__(message) self.exception = exception class NrpeConfig(Namespace): def __init__(self, defaults={}, args=Namespace(), config_file=None): self.__defaults = defaults self.__args = args self.__config_file = config_file self.reload() def _get_kwargs(self): return sorted((k, v) for k, v in self.__dict__.items() if not k.startswith('_')) def merge_into(self, ns): for key, value in vars(ns).items(): setattr(self, key, value) def get_defaults(self): defaults = Namespace() for key, value in self.__defaults.items(): setattr(defaults, key, value) return defaults def get_args(self): return self.__args def read_config_file(self): f = self.__config_file config = NrpeConfigParser() parsed = Namespace() secname = config.main_section # default ini "section" for all config # If there isn't a config file to read, stop now if not f: return parsed # Attempt to read the config file try: with open(f) as fp: config.readfp(fp, f) except IOError as e: raise ConfigError( "{f}: failed to read file: {err}".format( f=f, err=e.strerror), e) # Look for each key in __defaults, and transfer it to 'parsed' for key in self.__defaults: # Skip keys that aren't defined in the config file if not config.has_option(secname, key): continue dt = type(self.__defaults[key]) value = config.get(secname, key) if dt is bool: # is it a bool? try: value = config.getboolean(secname, key) except ValueError as e: raise ConfigError( "{f}: {key}: expected a boolean but got '{value}'" .format(f=f, key=key, value=value), e) elif dt is int: # is int an integer? try: value = config.getint(secname, key) except ValueError as e: raise ConfigError( "{f}: {key}: expected an integer but got '{value}'" .format(f=f, key=key, value=value), e) elif dt is list: # Split into words separated by ',' value = [x.strip() for x in value.split(',')] setattr(parsed, key, value) # To allow a sub-class to parse extra things self.read_extra_config(config, parsed) return parsed def read_extra_config(self, config, parsed): pass def reload(self): self.merge_into(self.get_defaults()) self.merge_into(self.read_config_file()) self.merge_into(self.get_args()) nrpe-ng-0.2.0/nrpe_ng/defaults.py000066400000000000000000000031061314240553600166730ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. PORT = 59546 EXEC_PATH = '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' CLIENT_CONFIG_PATH = '/etc/nagios/check_nrpe_ng.cfg' CLIENT_CONFIG = { 'port': PORT, 'timeout': 10, 'ssl_verify_server': True, 'ssl_ca_file': '', 'ssl_cert_file': '', 'ssl_key_file': '', } SERVER_CONFIG = { 'allow_bash_command_substitution': False, 'allowed_hosts': [], 'command_prefix': '', 'command_timeout': 60, 'connection_timeout': 300, 'debug': False, 'dont_blame_nrpe': False, 'log_facility': 'daemon', 'nrpe_group': 'nagios', 'nrpe_user': 'nagios', 'pid_file': '/run/nagios/nrpe-ng.pid', 'server_address': '::', 'server_port': PORT, 'ssl_verify_client': False, 'ssl_ca_file': '', 'ssl_cert_file': '', 'ssl_key_file': '', } nrpe-ng-0.2.0/nrpe_ng/http/000077500000000000000000000000001314240553600154715ustar00rootroot00000000000000nrpe-ng-0.2.0/nrpe_ng/http/__init__.py000066400000000000000000000014301314240553600176000ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. nrpe-ng-0.2.0/nrpe_ng/http/handler.py000066400000000000000000000101361314240553600174610ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import logging import re import sys from tornado import gen, web from tornado.escape import native_str from ..commands import CommandTimedOutError from ..version import __version__ log = logging.getLogger(__name__) VERSION = "nrpe-ng/{ver}".format(ver=__version__) class NrpeHandler(web.RequestHandler): def initialize(self): self.cfg = self.application.cfg # Regular expression for dealing with IPv4-mapped IPv6 IPV4_MAPPED_IPV6_RE = re.compile(r'^::ffff:(?P\d+\.\d+\.\d+\.\d+)$') def prepare(self): # Check request against allowed hosts list if self.cfg.allowed_hosts: host = self.request.remote_ip # Handle IPv4-mapped IPv6 as IPv4 mo = self.IPV4_MAPPED_IPV6_RE.search(host) if mo: host = mo.group('ipv4') # Check whether the host is listed in allowed_hosts if host not in self.cfg.allowed_hosts: raise web.HTTPError(403, "Not in allowed_hosts: {}".format( host)) def set_default_headers(self): self.set_header('Server', VERSION) class VersionHandler(NrpeHandler): def get(self): self.set_header('Content-Type', 'text/plain') self.write(VERSION) class CommandHandler(NrpeHandler): def prepare(self): super(NrpeHandler, self).prepare() # Find the command in the configuration cmd = self.path_kwargs['cmd'] command = self.cfg.commands.get(cmd) if not command: raise web.HTTPError(404, "Unknown command: {}".format(cmd)) self.cmd_name = cmd self.command = command @gen.coroutine def _execute_check(self, args={}): try: (returncode, stdout) = yield self.command.execute(args) except CommandTimedOutError: self.send_error(504, reason='Command execution timed out') log.error('Command timed out: {}'.format(self.cmd_name)) except: self.send_error(500, reason='Internal command execution error') log.exception('Unexpected error {e} running {c}'.format( e=sys.exc_info()[0], c=self.cmd_name)) else: self.set_header('Content-Type', 'text/plain') self.set_header('X-NRPE-Result', returncode) self.write(stdout) @gen.coroutine def head(self, cmd): self.set_header('Content-Type', 'text/plain') @gen.coroutine def get(self, cmd): yield self._execute_check() @gen.coroutine def post(self, cmd): if not self.cfg.dont_blame_nrpe: self.send_error(405, reason='Command arguments are disabled') log.warning('rejecting request: command arguments disabled') return # Convert the POST arguments into a simple hash of strings. The # body_arguments are otherwise a hash of lists of byte strings. body_args = self.request.body_arguments args = {k: native_str(body_args[k][0]) for k in body_args} yield self._execute_check(args) class NrpeApplication(web.Application): def __init__(self, cfg): self.cfg = cfg super(NrpeApplication, self).__init__([ (r'/v1/check/(?P[^/]+)', CommandHandler), (r'/v1/version', VersionHandler), ]) def update_config(self, cfg): self.cfg = cfg nrpe-ng-0.2.0/nrpe_ng/http/server.py000066400000000000000000000073441314240553600173610ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import logging import socket import ssl import sys from tornado.httpserver import HTTPServer from tornado.netutil import bind_sockets from .handler import NrpeApplication log = logging.getLogger(__name__) class NrpeHTTPServer(HTTPServer): def initialize(self, cfg): self.cfg = cfg # Check we have a certificate and key defines if not cfg.ssl_cert_file or not cfg.ssl_key_file: log.error('a valid ssl_cert_file and ssl_key_file are required, ' 'aborting') sys.exit(1) # Set up the SSL context try: ssl_context = ssl.create_default_context( purpose=ssl.Purpose.CLIENT_AUTH, cafile=cfg.ssl_ca_file) except IOError as e: log.error('cannot read ssl_ca_file: {}'.format(e.args[1])) sys.exit(1) self.ssl_context = ssl_context # Enable client certificate verification if wanted if cfg.ssl_verify_client: ssl_context.verify_mode = ssl.CERT_REQUIRED # Load our own certificate into the server try: ssl_context.load_cert_chain( certfile=cfg.ssl_cert_file, keyfile=cfg.ssl_key_file) except IOError as e: log.error('cannot read ssl_cert_file or ssl_key_file: {}' .format(e.args[1])) sys.exit(1) self.app = NrpeApplication(cfg) # Set up the HTTPServer instance super(NrpeHTTPServer, self).initialize( self.app, no_keep_alive=True, ssl_options=ssl_context, idle_connection_timeout=cfg.connection_timeout, body_timeout=cfg.connection_timeout) # Because Tornado unconditionally sets IPV6_V6ONLY on IPv6 sockets, we # need a means to preserve old behaviour. This should only be an issue # when listening to '::' for IPv6 any-address. Tornado will listen both # the IPv4 and IPv6 any-address when the bind address is blank, so just # set the address to be empty if we encounter '::'. server_address = cfg.server_address if server_address == '::': server_address = '' try: self.sockets = bind_sockets(port=cfg.server_port, address=server_address) except socket.error as e: log.error('failed to bind socket: {}'.format(e.args[1])) sys.exit(1) # Prevent tornado from logging HTTP requests if not self.cfg.debug: logging.getLogger('tornado.access').disabled = True def start(self): # We can't do the add_sockets() until after we have forked, otherwise # Tornado's eventfd is closed during the fork (and there's no sane way # of preserving it). self.add_sockets(self.sockets) def update_config(self, cfg): self.cfg = cfg self.app.update_config(cfg) # TODO: What options can we update dynamically? nrpe-ng-0.2.0/nrpe_ng/server/000077500000000000000000000000001314240553600160205ustar00rootroot00000000000000nrpe-ng-0.2.0/nrpe_ng/server/__init__.py000066400000000000000000000015341314240553600201340ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from .server import Server def main(): return Server().run() nrpe-ng-0.2.0/nrpe_ng/server/__main__.py000066400000000000000000000015441314240553600201160ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from .server import Server if __name__ == "__main__": Server().run() nrpe-ng-0.2.0/nrpe_ng/server/config.py000066400000000000000000000030121314240553600176330ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import re from ..config import NrpeConfig from ..commands import Command class ServerConfig(NrpeConfig): # Regular expression for parsing command name options from the config file CMD_RE = re.compile(r'^command\[(?P[^]]+)\]$') def read_extra_config(self, config, parsed): secname = config.main_section # default ini "section" for all config # Parse the list of commands commands = {} for key in config.options(secname): mo = self.CMD_RE.search(key) if not mo: continue name = mo.group('cmd') value = config.get(secname, key) cmd = Command(self, value) commands[name] = cmd parsed.commands = commands nrpe-ng-0.2.0/nrpe_ng/server/server.py000066400000000000000000000224771314240553600177140ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import argparse import grp import logging import pwd import signal import socket import sys from daemon.daemon import DaemonContext from daemon.pidfile import TimeoutPIDLockFile from lockfile import AlreadyLocked from tornado import gen from tornado.ioloop import IOLoop from .config import ServerConfig from ..config import ConfigError from ..defaults import SERVER_CONFIG from ..http.server import NrpeHTTPServer from ..syslog import SyslogHandler, facility as syslog_facility from ..version import __version__ log = logging.getLogger(__name__) rootlog = logging.getLogger() class Server: """nrpe-ng: the next generation Nagios Remote Plugin Executor""" def __init__(self): epilog = """ Copyright (C) 2014-17 Chris Boot """ parser = argparse.ArgumentParser(description=self.__doc__, epilog=epilog) parser.add_argument('--version', action='version', version=__version__) parser.add_argument('--debug', action='store_true', help='print verbose debugging information') parser.add_argument('-c', '--config', dest='config_file', required=True, help='use the given configuration file') parser.add_argument('-d', '--daemon', action='store_true', default=True, help='run as a standalone daemon (default)') parser.add_argument('-f', action='store_false', dest='daemon', help='do not fork into the background') self.argparser = parser self.cfg = None def setup_logging(self): rootlog.setLevel(logging.INFO) # Add a syslog handler with default values syslog = SyslogHandler(ident=self.argparser.prog, facility=syslog_facility('daemon'), formatter=logging.Formatter) rootlog.addHandler(syslog) self.log_syslog = syslog # Add a console handler console = logging.StreamHandler() rootlog.addHandler(console) def parse_args(self): self.args = self.argparser.parse_args() def reload_config(self): immutable = [ 'nrpe_group', 'nrpe_user', 'pid_file', 'server_address', 'server_port', # FIXME: it would be nice if we _could_ change these: 'ssl_ca_file', 'ssl_cert_file', 'ssl_key_file', 'ssl_verify_client', ] cfg = ServerConfig(SERVER_CONFIG, self.args, self.args.config_file) # We don't allow bash-style command substitution at all, it's bad if cfg.allow_bash_command_substitution: raise ConfigError( 'bash-style command substitution is not supported') # Update the syslog facility from the config file try: log_facility = syslog_facility(cfg.log_facility) except ValueError: raise ConfigError( 'invalid log_facility: {}'.format(cfg.log_facility)) # Check for changes to variables we can't reload if self.cfg: for key in immutable: if getattr(self.cfg, key) == getattr(cfg, key): continue log.warning('value of {key} changed, but needs a restart to ' 'take effect'.format(key=key)) # !!! IMPORTANT: Beyond this point, no ConfigErrors should be raised # Is the value of 'debug' changing? if not self.cfg or self.cfg.debug != cfg.debug: # In debug mode: # - don't send output to syslog # - set the log level to DEBUG if we're not daemonising if cfg.debug: rootlog.setLevel(logging.DEBUG) if not cfg.daemon: rootlog.removeHandler(self.log_syslog) else: rootlog.setLevel(logging.INFO) if not cfg.daemon: rootlog.addHandler(self.log_syslog) self.cfg = cfg # Update the syslog facility from the config file self.log_syslog.facility = log_facility # Set the default timeout on sockets socket.setdefaulttimeout(cfg.connection_timeout) def handle_signal(self, signal_number, stack_frame): log.debug('received signal {}'.format(signal_number)) if signal_number == signal.SIGHUP: IOLoop.instance().add_callback_from_signal(self.sighup_callback) elif signal_number == signal.SIGTERM: IOLoop.instance().add_callback_from_signal(self.sigterm_callback) else: log.error('unexpected signal received') def sighup_callback(self): log.info('received SIGHUP, reloading configuration...') try: self.reload_config() self.httpd.update_config(self.cfg) log.info('configuration updated') except ConfigError as e: log.error(e.args[0]) log.error("config file '{}' contained errors, not updated".format( self.args.config_file)) if self.cfg.debug: import pprint pp = pprint.PrettyPrinter(indent=4) pp.pprint(self.cfg._get_kwargs()) @gen.coroutine def sigterm_callback(self): log.info('received SIGTERM, shutting down...') self.httpd.stop() io_loop = IOLoop.current() deadline = io_loop.time() + self.cfg.command_timeout while io_loop.time() < deadline: if not io_loop._callbacks and not io_loop._timeouts: break log.info('waiting for requests to complete...') yield gen.sleep(1) io_loop.stop() def setup(self): # Determine the uid and gid to change to try: nrpe_uid = pwd.getpwnam(self.cfg.nrpe_user).pw_uid except KeyError: log.error('invalid nrpe_user: {}'.format(self.nrpe_user)) sys.exit(1) try: nrpe_gid = grp.getgrnam(self.cfg.nrpe_group).gr_gid except KeyError: log.error('invalid nrpe_group: {}'.format(self.nrpe_group)) sys.exit(1) # Prepare Daemon Context dctx = DaemonContext( detach_process=self.cfg.daemon, files_preserve=[], uid=nrpe_uid, gid=nrpe_gid, initgroups=True, ) dctx.signal_map.update({ signal.SIGHUP: self.handle_signal, signal.SIGTERM: self.handle_signal, }) self.daemon_context = dctx # Prepare PID file if self.cfg.daemon: dctx.pidfile = TimeoutPIDLockFile(self.cfg.pid_file) # If we are not daemonising, don't redirect stdout or stderr if not self.cfg.daemon: dctx.stdout = sys.stdout dctx.stderr = sys.stderr def run(self): self.setup_logging() self.parse_args() try: self.reload_config() self.setup() except ConfigError as e: log.error(e.args[0]) log.error("config file '{}' contained errors, aborting".format( self.args.config_file)) sys.exit(1) if self.cfg.debug: import pprint pp = pprint.PrettyPrinter(indent=4) pp.pprint(self.cfg._get_kwargs()) httpd = NrpeHTTPServer(self.cfg) self.httpd = httpd for sock in httpd.sockets: self.daemon_context.files_preserve.append(sock.fileno()) sn = sock.getsockname() log.info('server listening on {addr} port {port}'.format( addr=sn[0], port=sn[1])) try: with self.daemon_context: log.info('listening for connections') # don't wire the server sockets into the IOLoop until after the # fork to avoid the eventfd socket getting closed during # forking httpd.start() IOLoop.current().start() except AlreadyLocked: log.error('there is already another process running (PID {})' .format(self.daemon_context.pidfile.read_pid())) sys.exit(1) except KeyboardInterrupt: pass except SystemExit: raise except: log.exception('unhandled exception, %s', sys.exc_info()) finally: log.warning('shutting down') httpd.stop() self.daemon_context.close() nrpe-ng-0.2.0/nrpe_ng/syslog.py000066400000000000000000000104111314240553600164010ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import logging import syslog PRIORITY_NAMES = { 'emerg': syslog.LOG_EMERG, 'alert': syslog.LOG_ALERT, 'crit': syslog.LOG_CRIT, 'err': syslog.LOG_ERR, 'warning': syslog.LOG_WARNING, 'notice': syslog.LOG_NOTICE, 'info': syslog.LOG_INFO, 'debug': syslog.LOG_DEBUG, } FACILITY_NAMES = { 'kern': syslog.LOG_KERN, 'user': syslog.LOG_USER, 'mail': syslog.LOG_MAIL, 'daemon': syslog.LOG_DAEMON, 'auth': syslog.LOG_AUTH, 'syslog': syslog.LOG_SYSLOG, 'lpr': syslog.LOG_LPR, 'news': syslog.LOG_NEWS, 'uucp': syslog.LOG_UUCP, 'cron': syslog.LOG_CRON, # 'authpriv': syslog.LOG_AUTHPRIV, # not in syslog module # 'ftp': syslog.LOG_FTP, # not in syslog module 'local0': syslog.LOG_LOCAL0, 'local1': syslog.LOG_LOCAL1, 'local2': syslog.LOG_LOCAL2, 'local3': syslog.LOG_LOCAL3, 'local4': syslog.LOG_LOCAL4, 'local5': syslog.LOG_LOCAL5, 'local6': syslog.LOG_LOCAL6, 'local7': syslog.LOG_LOCAL7, } # Must be in ascending priority order PRIORITY_MAP = [ (logging.DEBUG, syslog.LOG_DEBUG), (logging.INFO, syslog.LOG_INFO), (logging.WARNING, syslog.LOG_WARNING), (logging.ERROR, syslog.LOG_ERR), (logging.CRITICAL, syslog.LOG_CRIT), ] def priority(priority): if isinstance(priority, int): return priority elif str(priority) == priority: if priority not in PRIORITY_NAMES: raise ValueError("Unknown priority: %r" % priority) return PRIORITY_NAMES[priority] else: raise TypeError("Priority not an integer or a valid string: {}".format( priority)) def facility(facility): if isinstance(facility, int): return facility elif str(facility) == facility: if facility not in FACILITY_NAMES: raise ValueError("Unknown facility: %r" % facility) return FACILITY_NAMES[facility] else: raise TypeError("Facility not an integer or a valid string: {}".format( facility)) def encodePriority(fac, pri): """ Encode the facility and priority. You can pass in strings or integers - if strings are passed, the FACILITY_NAMES and PRIORITY_NAMES mapping dictionaries are used to convert them to integers. """ fac = facility(fac) pri = priority(pri) return fac | pri def mapPriority(level): for lvl, prio in PRIORITY_MAP: if level <= lvl: return prio return syslog.LOG_CRIT class SyslogFormatter(logging.Formatter): def formatException(self, ei): """Return a blank string for all exceptions.""" return '' class SyslogHandler(logging.Handler): """ Reimplementation of logging.handlers.SysLogHandler that uses the python native syslog module. """ def __init__(self, ident=None, facility=syslog.LOG_USER, options=syslog.LOG_PID, formatter=SyslogFormatter): logging.Handler.__init__(self) self.facility = facility self.formatter = formatter() if ident: syslog.openlog(ident, logoption=options, facility=facility) else: syslog.openlog(logoption=options, facility=facility) def emit(self, record): """ Emit a record. """ msg = self.format(record) # Encode the facility and priority to an integer prio = encodePriority(self.facility, mapPriority(record.levelno)) syslog.syslog(prio, msg) nrpe-ng-0.2.0/nrpe_ng/version.py000066400000000000000000000015341314240553600165540ustar00rootroot00000000000000# This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # This should be the only line in this file. __version__ = '0.2.0' nrpe-ng-0.2.0/setup.cfg000066400000000000000000000002121314240553600146760ustar00rootroot00000000000000[nosetests] cover-erase = 1 cover-branches = 1 cover-inclusive = 1 cover-package = nrpe_ng #cover-min-percentage = 100 with-coverage = 1 nrpe-ng-0.2.0/setup.py000077500000000000000000000043251314240553600146030ustar00rootroot00000000000000#!/usr/bin/python3 # This file is part of nrpe-ng. # Copyright (C) 2014-17 Chris Boot # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys from distutils.util import convert_path from setuptools import setup, find_packages # Check that we are running on Python 3.2 or higher. This is required for # argparse, ssl.SSLContext and probably a few other things. if sys.version_info < (3, 4): print('This program requires Python 3.4 or greater.') sys.exit(1) # Read the version number from nrpe_ng/version.py. This avoids needing to # query setuptools for the version at run-time. main_ns = {} ver_path = convert_path('nrpe_ng/version.py') with open(ver_path) as ver_file: exec(ver_file.read(), main_ns) setup( name='nrpe-ng', version=main_ns['__version__'], description='Next-generation Nagios remote plugin agent', author='Chris Boot', author_email='bootc@bootc.net', license='GPL-2+', url='https://github.com/bootc/nrpe-ng/', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Environment :: Console', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: GNU General Public License v2 or later ' '(GPLv2+)', 'Topic :: System :: Systems Administration', ], packages=find_packages(), entry_points={ 'console_scripts': [ 'check_nrpe_ng = nrpe_ng.client:main', 'nrpe-ng = nrpe_ng.server:main', ], }, install_requires=[ 'python-daemon>=2', 'requests', 'tornado>=4.4', ], )