From f422450df9cfdbbaa440ca4045d7033b36996c9a Mon Sep 17 00:00:00 2001 From: Gerhard Lausser Date: Tue, 19 Oct 2010 19:23:10 +0200 Subject: [PATCH] *init --- AUTHORS | 1 + COPYING | 340 ++++++++ INSTALL | 229 ++++++ Makefile.am | 6 + NEWS | 0 README | 325 ++++++++ TODO | 6 + configure.in | 119 +++ plugins-scripts/Makefile.am | 55 ++ plugins-scripts/NWC/Cisco.pm | 97 +++ .../NWC/Cisco/Component/CpuSubsystem.pm | 136 ++++ .../Cisco/Component/EnvironmentalSubsystem.pm | 62 ++ .../NWC/Cisco/Component/FanSubsystem.pm | 114 +++ .../NWC/Cisco/Component/MemSubsystem.pm | 128 ++++ .../NWC/Cisco/Component/SupplySubsystem.pm | 120 +++ .../Cisco/Component/TemperatureSubsystem.pm | 197 +++++ .../NWC/Cisco/Component/VoltageSubsystem.pm | 124 +++ plugins-scripts/NWC/Component/SNMP.pm | 86 +++ plugins-scripts/NWC/Device.pm | 724 ++++++++++++++++++ plugins-scripts/NWC/MIBII.pm | 8 + .../NWC/MIBII/Component/InterfaceSubsystem.pm | 309 ++++++++ plugins-scripts/Nagios/MiniPlugin.pm | 396 ++++++++++ plugins-scripts/check_nwc_health.pl | 275 +++++++ plugins-scripts/subst.in | 64 ++ 24 files changed, 3921 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100644 TODO create mode 100644 configure.in create mode 100644 plugins-scripts/Makefile.am create mode 100644 plugins-scripts/NWC/Cisco.pm create mode 100644 plugins-scripts/NWC/Cisco/Component/CpuSubsystem.pm create mode 100644 plugins-scripts/NWC/Cisco/Component/EnvironmentalSubsystem.pm create mode 100644 plugins-scripts/NWC/Cisco/Component/FanSubsystem.pm create mode 100644 plugins-scripts/NWC/Cisco/Component/MemSubsystem.pm create mode 100644 plugins-scripts/NWC/Cisco/Component/SupplySubsystem.pm create mode 100644 plugins-scripts/NWC/Cisco/Component/TemperatureSubsystem.pm create mode 100644 plugins-scripts/NWC/Cisco/Component/VoltageSubsystem.pm create mode 100644 plugins-scripts/NWC/Component/SNMP.pm create mode 100644 plugins-scripts/NWC/Device.pm create mode 100644 plugins-scripts/NWC/MIBII.pm create mode 100644 plugins-scripts/NWC/MIBII/Component/InterfaceSubsystem.pm create mode 100644 plugins-scripts/Nagios/MiniPlugin.pm create mode 100644 plugins-scripts/check_nwc_health.pl create mode 100644 plugins-scripts/subst.in diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..6206f022 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Gerhard Lausser diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..60549be5 --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library 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) 19yy + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) 19yy 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 Library General +Public License instead of this License. diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..54caf7c1 --- /dev/null +++ b/INSTALL @@ -0,0 +1,229 @@ +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +will cause the specified gcc to be used as the C compiler (unless it is +overridden in the site shell script). + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..23522dc5 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,6 @@ +## Process this file with automake to produce Makefile.in + +SUBDIRS = plugins-scripts + +dist-hook: + make diff --git a/NEWS b/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/README b/README new file mode 100644 index 00000000..99ed0048 --- /dev/null +++ b/README @@ -0,0 +1,325 @@ +check_nwc_health Nagios Plugin README +--------------------- + +This plugin checks the hardware health of HP Proliant servers with the +hpasm software installed. It uses the hpasmcli command to acquire the +condition of the system's critical components like cpus, power supplies, +temperatures, fans and memory modules. Newer versions also use SNMP. + +* For instructions on installing this plugin for use with Nagios, + see below. In addition, generic instructions for the GNU toolchain + can be found in the INSTALL file. + +* For major changes between releases, read the CHANGES file. + +* For information on detailed changes that have been made, + read the Changelog file. + +* This plugins is self documenting. All plugins that comply with + the basic guidelines for development will provide detailed help when + invoked with the '-h' or '--help' options. + +You can check for the latest plugin at: + http://www.consol.de/opensource/nagios/check-hpasm + +Send mail to gerhard.lausser@consol.de for assistance. +Please include the OS type and version that you are using. +Also, run the plugin with the '-v' option and provide the resulting +version information. Of course, there may be additional diagnostic information +required as well. Use good judgment. + + +How to "compile" the check_nwc_health script. +-------------------------------------------------------- + +1) Run the configure script to initialize variables and create a Makefile, etc. + + ./configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP --with-perl=PATH_TO_PERL --with-noinst-level=LEVEL --with-degrees=UNIT --with-perfdata --with-hpacucli + + a) Replace BASEDIRECTORY with the path of the directory under which Nagios + is installed (default is '/usr/local/nagios') + b) Replace SOMEUSER with the name of a user on your system that will be + assigned permissions to the installed plugins (default is 'nagios') + c) Replace SOMEGRP with the name of a group on your system that will be + assigned permissions to the installed plugins (default is 'nagios') + d) Replace PATH_TO_PERL with the path where a perl binary can be found. + Besides the system wide perl you might have installed a private perl + just for the nagios plugins (default is the perl in your path). + e) Replace LEVEL with one of ok, warning, critical or unknown. + If the required hpasm-rpm is not installed, the check_nwc_health plugin + will exit with the level specified. If you chose ok, the message + will say "ok - .... hpasm is not installed". This is different from + the "ok - hardware working fine" if hpasm was found. + The default is to treat a missing hpasm package as ok. + f) Replace UNIT with one of celsius or fahrenheit. The hpasmcli "show temp" + prints temperatures both in units of celsius and fahrenheit. With the + --with-degrees option you can decide which units will be shown in an + alarm message. + The default is "celsius". + g) You can tell check_nwc_health to output performance data by default if + you call configure with the --enable-perfdata option. + h) You can tell check_nwc_health to check the raid status with the hpacucli command + if you call configure with the --enable-hpacucli option. + You need the hpacucli rpm. + +2) "Compile" the plugin with the following command: + + make + + This will produce a "check_nwc_health" script. You will also find + a "check_nwc_health.pl" which you better ignore. It is the base for + the compilation filled with placeholders. These will be replaced during + the make process. + + +3) Install the compiled plugin script with the following command: + + make install + + The installation procedure will attempt to place the plugin in a + 'libexec/' subdirectory in the base directory you specified with + the --prefix argument to the configure script. + + +4) Verify that your configuration files for Nagios contains + the correct paths to the new plugin. + + +5) Add this line to /etc/sudoers: + nagios ALL=NOPASSWD: /sbin/hpasmcli + or ths, if you also installed the hpacu package + nagios ALL=NOPASSWD: /sbin/hpasmcli, /usr/sbin/hpacucli + + + +Command line parameters +----------------------- + +-v, --verbose + Increased verbosity will print how check_nwc_health communicates with the + hpasm daemon and which values were acquired. + +-t, --timeout + The number of seconds after which the plugin will abort. + +-b, --blacklist + If some components of your system are missing (mostly the secondary + power supply bay is empty) and you tolerate this, then blacklist the + missing/failed component to avoid false alarms. + The value for this option is a slash-separated list of components to + ignore. + Example: -b p:1,2/f:2/t:3,4/c:1/d:0-1,0-2 + means: ignore power supplies #1 and #2, fan #2, temperature #3 and #4, + cpu #1 and dimms #1 and #2 in cartridge #0. + +-c, --customthresh + Override the machine-default temperature thresholds. + Example: -c 1:60/4:80/5:50 + Sets limit for temperature 1 to 60 degrees, temperature 4 to 80 degrees + and temperature 5 to 50 degrees. You get the consecutive numbers by + calling check_nwc_health -v + ... + checking temperatures + 1 processor_zone temperature is 46 (62 max) + 2 cpu#1 temperature is 43 (73 max) + 3 i/o_zone temperature is 54 (68 max) + 4 cpu#2 temperature is 46 (73 max) + 5 power_supply_bay temperature is 38 (55 max) + +-p, --perfdata + Add performance data to the output even if you did not compile check_nwc_health + with --with-perfdata in step 1. + + + +SNMP and Memory Modules +----------------------- +Older hardware does not always show valuable information when queried for +the health of memory modules. Maybe it's because older modules do not support +error checking at all. + + +1. no cpqHeResMemModule +--------------------------------------------------------------------------- + +2. collapsed cpqHeResMemModule +--------------------------------------------------------------------------- + +Some (older) systems do not support the cpqHeResMemModuleEntry table. +Either there is no oid with 1.3.6.1.4.1.232.6.2.14.11.1 at all +or there is a single oid like + +Example: +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.1 = INTEGER: 524288 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.2 = INTEGER: 262144 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.3 = INTEGER: 0 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.4 = INTEGER: 524288 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.5 = INTEGER: 262144 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.6 = INTEGER: 0 + + ^-- module number + ^-- cartridge number (0 = system board) + ^-- size + +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.6 = INTEGER: 0 + +I compared 300 systems and found out that with +1.3.6.1.4.1.232.6.2.14.11.1... = +no1 is always 1 +no2 is always 0 +no3 is the number of memory slots (including the empty ones). +no4 is always 0. It is probably the health status of the +overall memory subsystem. I don't know. +I will implement 0 = ok, not 0 = ask compaq + +cpqSiMemECCStatus provides no usable information. All my test systems +showed 0 which is an undocumented value. + +function get_size(cpqHeResMemModuleEntry) will return 1. + +3. cpqHeResMemModule containing crap +--------------------------------------------------------------------------- + +grepping for cpqSiMemBoardSize shows 4 modules +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.1 = INTEGER: 262144 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.2 = INTEGER: 262144 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.3 = INTEGER: 0 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.4 = INTEGER: 262144 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.5 = INTEGER: 262144 +iso.3.6.1.4.1.232.2.2.4.5.1.3.0.6 = INTEGER: 0 + +grepping for cpqHeResMemEntry shows one module with zero values +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.0 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.2.0.0 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.3.0.0 = "" +iso.3.6.1.4.1.232.6.2.14.11.1.4.0.0 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.5.0.0 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.6.0.0 = Hex-STRING: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + +4. cpqHeResMemModuleEntry and cpqSiMemModuleEntry use different table indexes +--------------------------------------------------------------------------- + +cpqSiMemBoardIndex 1.3.6.1.4.1.232.2.2.4.5.1.1 +cpqSiMemModuleIndex 1.3.6.1.4.1.232.2.2.4.5.1.2 + +cpqHeResMemBoardIndex 1.3.6.1.4.1.232.6.2.14.11.1.1 +cpqHeResMemModuleIndex 1.3.6.1.4.1.232.6.2.14.11.1.2 + + +cpqSiMemBoardIndex +SNMPv2-SMI::enterprises.232.2.2.4.5.1.1.0.1 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.2.2.4.5.1.1.0.2 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.2.2.4.5.1.1.0.3 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.2.2.4.5.1.1.0.4 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.2.2.4.5.1.1.0.5 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.2.2.4.5.1.1.0.6 = INTEGER: 0 + +cpqHeResMemBoardIndex +SNMPv2-SMI::enterprises.232.6.2.14.11.1.1.1.1 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.6.2.14.11.1.1.1.2 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.6.2.14.11.1.1.1.3 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.6.2.14.11.1.1.1.4 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.6.2.14.11.1.1.1.5 = INTEGER: 0 +SNMPv2-SMI::enterprises.232.6.2.14.11.1.1.1.6 = INTEGER: 0 + +It is not possible to use the SNMP-table-indices to identify the +corresponding he-entry. Matching is done with nested loops. + +5. even worse: cpqHeResMemBoardIndex and cpqSiMemBoardIndex don't match +--------------------------------------------------------------------------- + +cpqSiMemBoardIndex +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.1 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.2 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.3 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.4 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.5 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.6 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.7 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.1.8 = INTEGER: 1 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.1 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.2 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.3 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.4 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.5 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.6 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.7 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.2.8 = INTEGER: 2 +iso.3.6.1.4.1.232.2.2.4.5.1.1.3.1 = INTEGER: 3 + +cpqHeResMemBoardIndex +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.1 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.2 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.3 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.4 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.5 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.6 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.7 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.0.8 = INTEGER: 0 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.1 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.2 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.3 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.4 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.5 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.6 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.7 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.1.8 = INTEGER: 1 +iso.3.6.1.4.1.232.6.2.14.11.1.1.2.1 = INTEGER: 2 + + +Redundant fans +----------------------- +I saw one old server which had only half of the possible fans installed. + +Fan# 1 2 3 4 5 6 + +cpqHeFltTolFanPresent yes no yes no yes no +cpqHeFltTolFanRedundant no no no no no no +cpqHeFltTolFanRedundantPartner 2 1 4 3 6 5 +cpqHeFltTolFanCondition ok other ok other ok other +cpqHeFltTolFanLocation cpu cpu cpu cpu io io + +Normally this would result in +... +fan #1 (cpu) is not redundant +fan #2 (cpu) is not redundant +fan #3 (cpu) is not redundant +fan #4 (cpu) is not redundant +fan #5 (ioboard) is not redundant +fan #6 (ioboard) is not redundant +WARNING - fan #1 (cpu) is not redundant, fan #2 (cpu) is not redundant, fan #3 (cpu) is not redundant, fan #4 (cpu) is not redundant, fan #5 (ioboard) is not redundant, fan #6 (ioboard) is not redundant + +However it was the server's owner decision not to install fan pairs but only one fan per location, so for him this is a false alert. + +By using --ignore-fan-redundancy check_nwc_health only looks at the cpqHeFltTolFanCondition and ignores dependencies between two fans, so the result is: + +fan 1 speed is normal, pctmax is 50%, location is cpu, redundance is no, partner is 2 +fan 3 speed is normal, pctmax is 50%, location is cpu, redundance is no, partner is 4 +fan 5 speed is normal, pctmax is 50%, location is ioboard, redundance is no, partner is 6 +OK - System: 'proliant ml370 g3', ... + + +A snmp forwarding trick +----------------------- +local - where check_nwc_health runs +remote - where a proliant can be reached +proliant - where the snmp agent runs + +remote: +ssh -R6667:localhost:6667 local +socat tcp4-listen:6667,reuseaddr,fork UDP:proliant:161 + +local: +socat udp4-listen:161,reuseaddr,fork tcp:localhost:6667 +check_nwc_health --hostname 127.0.0.1 + + +Sample data from real machines +------------------------------ +If you think check_nwc_health is not working correctly, send me the output of snmpwalk +snmpwalk .... 1.3.6.1.4.1.232 + + +-- +Gerhard Lausser diff --git a/TODO b/TODO new file mode 100644 index 00000000..99c9b564 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +- interface up down, operstatus +- traffic, in, out, 2xthresholds? +- errors +- cpu +- mem +- load diff --git a/configure.in b/configure.in new file mode 100644 index 00000000..1339efa6 --- /dev/null +++ b/configure.in @@ -0,0 +1,119 @@ +dnl Process this file with autoconf to produce a configure script. +AC_REVISION ($Revision: 1.150 $) +AC_PREREQ(2.58) +AC_INIT(check_nwc_health,0.99) +AM_INIT_AUTOMAKE([1.9 tar-pax]) +AC_CANONICAL_HOST + +RELEASE=1 +AC_SUBST(RELEASE) + +AC_PREFIX_DEFAULT(/usr/local/nagios) + +dnl Figure out how to invoke "install" and what install options to use. +AC_PROG_INSTALL +AC_SUBST(INSTALL) + +AC_PROG_MAKE_SET +AC_PROG_AWK + +WARRANTY="This plugin comes with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugin under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n" +AC_SUBST(WARRANTY) + +SUPPORT="Send email to gerhard.lausser@consol.de if you have questions\nregarding use of this software.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n" +AC_SUBST(SUPPORT) + +AC_ARG_WITH(nagios_user, + ACX_HELP_STRING([--with-nagios-user=USER], + [set user name to run nagios]), + with_nagios_user=$withval, + with_nagios_user=nagios) +AC_ARG_WITH(nagios_group, + ACX_HELP_STRING([--with-nagios-group=GROUP], + [set group name to run nagios]), + with_nagios_group=$withval, + with_nagios_group=nagios) +AC_SUBST(with_nagios_user) +AC_SUBST(with_nagios_group) +INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group" +AC_SUBST(INSTALL_OPTS) +AC_ARG_WITH(noinst_level, + ACX_HELP_STRING([--with-noinst-level=LEVEL], + [error level if nwc_health is not installed]), + with_noinst_level=$withval, + with_noinst_level=unknown) +AC_SUBST(NOINSTLEVEL, $with_noinst_level) +AC_ARG_WITH(degrees, + ACX_HELP_STRING([--with-degrees=UNIT], + [which temperature unit to use. (celsius or fahrenheit)]), + with_degrees=$withval, + with_degrees=unknown) +case "$with_degrees" in + fahrenheit) + AC_SUBST(CELSIUS, 0) + ;; + *) + AC_SUBST(CELSIUS, 1) + ;; +esac +AC_ARG_ENABLE([perfdata], +[ --enable-perfdata wether to output perfdata (default=no)], ,enable_perfdata=no) +if test x"$enable_perfdata" = xyes ; then + AC_SUBST(PERFDATA, 1) +else + AC_SUBST(PERFDATA, 0) +fi +AC_ARG_ENABLE([extendedinfo], +[ --enable-extendedinfo wether to output extended info (default=no)], ,enable_extendedinfo=no) +if test x"$enable_extendedinfo" = xyes ; then + AC_SUBST(EXTENDEDINFO, 1) +else + AC_SUBST(EXTENDEDINFO, 0) +fi +AC_ARG_ENABLE([hwinfo], +[ --disable-hwinfo wether to output model desc., serial no., bios version (default=yes)], ,enable_hwinfo=yes) + +if test x"$enable_hwinfo" = xyes ; then + AC_SUBST(HWINFO, 1) +else + AC_SUBST(HWINFO, 0) +fi + + +case "$host_os" in + *hp*) + defaulttrustedpath=/bin:/sbin:/usr/bin:/usr/sbin:/usr/contrib/bin + ;; + *) + defaulttrustedpath=/bin:/sbin:/usr/bin:/usr/sbin + ;; +esac + +EXTRAS= +dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH + +dnl Checks for programs. +AC_PATH_PROG(SH,sh) +AC_PATH_PROG(PERL,perl) + +dnl allow them to override the path of perl +AC_ARG_WITH(perl, + ACX_HELP_STRING([--with-perl=PATH], + [sets path to perl executable]), + with_perl=$withval,with_perl=$PERL) +AC_SUBST(PERL, $with_perl) + +AC_OUTPUT( + Makefile + plugins-scripts/Makefile + plugins-scripts/subst +) + +ACX_FEATURE([with],[perl]) +ACX_FEATURE([with],[nagios-user]) +ACX_FEATURE([with],[nagios-group]) +ACX_FEATURE([with],[noinst-level]) +ACX_FEATURE([with],[degrees]) +ACX_FEATURE([enable],[perfdata]) +ACX_FEATURE([enable],[extendedinfo]) +ACX_FEATURE([enable],[hwinfo]) diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am new file mode 100644 index 00000000..d37b7354 --- /dev/null +++ b/plugins-scripts/Makefile.am @@ -0,0 +1,55 @@ +## Process this file with automake to produce Makefile.in + +SED=/bin/sed +GREP=/bin/grep +CAT=/bin/cat +ECHO=/bin/echo + +SUFFIXES = .pl .pm .sh + +VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t + +libexec_SCRIPTS=check_nwc_health +MY_MODULES= +EXTRA_MODULES=\ + Nagios/MiniPlugin.pm \ + NWC/Cisco/Component/CpuSubsystem.pm \ + NWC/Cisco/Component/MemSubsystem.pm \ + NWC/Cisco/Component/EnvironmentalSubsystem.pm \ + NWC/Cisco/Component/TemperatureSubsystem.pm \ + NWC/Cisco/Component/SupplySubsystem.pm \ + NWC/Cisco/Component/VoltageSubsystem.pm \ + NWC/Cisco/Component/FanSubsystem.pm \ + NWC/Cisco.pm \ + NWC/MIBII/Component/InterfaceSubsystem.pm \ + NWC/MIBII.pm \ + NWC/Device.pm +EXTRA_DIST=check_nwc_health.pl $(EXTRA_MODULES) + +CLEANFILES=$(libexec_SCRIPTS) + +AM_INSTALL_PROGRAM_FLAGS=@INSTALL_OPTS@ + +.pm : + $(AWK) -f ./subst $< > $@ + chmod +x $@ + +.pl : + $(AWK) -f ./subst $< > $@ + chmod +x $@ + +.sh : + $(AWK) -f ./subst $< > $@ + chmod +x $@ + +$(libexec_SCRIPTS) : $(EXTRA_DIST) + $(ECHO) "#! #PERL# -w" | $(AWK) -f ./subst > $@ + $(ECHO) >> $@ + for m in ${EXTRA_MODULES}; do \ + $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "use Nagios::Plugin" >> $@; \ + done + $(ECHO) "package main;" >> $@ + $(CAT) check_nwc_health.pl | $(AWK) -f ./subst >> $@ + chmod +x $@ +#| $(GREP) -v "use Nagios" >> $@; + diff --git a/plugins-scripts/NWC/Cisco.pm b/plugins-scripts/NWC/Cisco.pm new file mode 100644 index 00000000..79db63ba --- /dev/null +++ b/plugins-scripts/NWC/Cisco.pm @@ -0,0 +1,97 @@ +package NWC::Cisco; + +use strict; + +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +our @ISA = qw(NWC::Device); + +sub init { + my $self = shift; + $self->{components} = { + powersupply_subsystem => undef, + fan_subsystem => undef, + temperature_subsystem => undef, + cpu_subsystem => undef, + memory_subsystem => undef, + disk_subsystem => undef, + environmental_subsystem => undef, + }; + $self->{serial} = 'unknown'; + $self->{product} = 'unknown'; + $self->{romversion} = 'unknown'; + #$self->collect(); + if (! $self->check_messages()) { + ##$self->set_serial(); + if ($self->mode =~ /device::hardware::health/) { + $self->analyze_environmental_subsystem(); + #$self->auto_blacklist(); + $self->check_environmental_subsystem(); + } elsif ($self->mode =~ /device::hardware::load/) { + $self->analyze_cpu_subsystem(); + #$self->auto_blacklist(); + $self->check_cpu_subsystem(); + } elsif ($self->mode =~ /device::hardware::memory/) { + $self->analyze_mem_subsystem(); + #$self->auto_blacklist(); + $self->check_mem_subsystem(); + } elsif ($self->mode =~ /device::interfaces/) { + $self->analyze_interface_subsystem(); + $self->check_interface_subsystem(); + } + } +} + +sub analyze_environmental_subsystem { + my $self = shift; + $self->{components}->{environmental_subsystem} = + NWC::Cisco::Component::EnvironmentalSubsystem->new(); +} + +sub analyze_interface_subsystem { + my $self = shift; + $self->{components}->{interface_subsystem} = + NWC::MIBII::Component::InterfaceSubsystem->new(); +} + +sub analyze_cpu_subsystem { + my $self = shift; + $self->{components}->{cpu_subsystem} = + NWC::Cisco::Component::CpuSubsystem->new(); +} + +sub analyze_mem_subsystem { + my $self = shift; + $self->{components}->{mem_subsystem} = + NWC::Cisco::Component::MemSubsystem->new(); +} + +sub check_environmental_subsystem { + my $self = shift; + $self->{components}->{environmental_subsystem}->check(); + $self->{components}->{environmental_subsystem}->dump() + if $self->opts->verbose >= 2; +} + +sub check_interface_subsystem { + my $self = shift; + $self->{components}->{interface_subsystem}->check(); + $self->{components}->{interface_subsystem}->dump() + if $self->opts->verbose >= 2; +} + +sub check_cpu_subsystem { + my $self = shift; + $self->{components}->{cpu_subsystem}->check(); + $self->{components}->{cpu_subsystem}->dump() + if $self->opts->verbose >= 2; +} + +sub check_mem_subsystem { + my $self = shift; + $self->{components}->{mem_subsystem}->check(); + $self->{components}->{mem_subsystem}->dump() + if $self->opts->verbose >= 2; +} + + diff --git a/plugins-scripts/NWC/Cisco/Component/CpuSubsystem.pm b/plugins-scripts/NWC/Cisco/Component/CpuSubsystem.pm new file mode 100644 index 00000000..f57090e2 --- /dev/null +++ b/plugins-scripts/NWC/Cisco/Component/CpuSubsystem.pm @@ -0,0 +1,136 @@ +package NWC::Cisco::Component::CpuSubsystem; +our @ISA = qw(NWC::Cisco); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + cpus => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + # ciscoEnvMonCpuStatusTable + my $oids = { + cpmCPUTotalTable => '1.3.6.1.4.1.9.9.109.1.1.1', + cpmCPUTotalEntry => '1.3.6.1.4.1.9.9.109.1.1.1.1', + cpmCPUTotalIndex => '1.3.6.1.4.1.9.9.109.1.1.1.1.1', + cpmCPUTotalPhysicalIndex => '1.3.6.1.4.1.9.9.109.1.1.1.1.2', + cpmCPUTotal5sec => '1.3.6.1.4.1.9.9.109.1.1.1.1.3', + cpmCPUTotal1min => '1.3.6.1.4.1.9.9.109.1.1.1.1.4', + cpmCPUTotal5min => '1.3.6.1.4.1.9.9.109.1.1.1.1.5', + cpmCPUTotal5secRev => '1.3.6.1.4.1.9.9.109.1.1.1.1.6', + cpmCPUTotal1minRev => '1.3.6.1.4.1.9.9.109.1.1.1.1.7', + cpmCPUTotal5minRev => '1.3.6.1.4.1.9.9.109.1.1.1.1.8', + cpmCPUMonInterval => '1.3.6.1.4.1.9.9.109.1.1.1.1.9', + cpmCPUTotalMonIntervalValue => '1.3.6.1.4.1.9.9.109.1.1.1.1.10', + cpmCPUInterruptMonIntervalValue => '1.3.6.1.4.1.9.9.109.1.1.1.1.11', + }; + # INDEX { ciscoCpuoryPoolType } + my $type = 0; + foreach ($self->get_entries($oids, 'cpmCPUTotalEntry')) { + $_->{cpmCPUTotalIndex} ||= $type++; + push(@{$self->{cpus}}, + NWC::Cisco::Component::CpuSubsystem::Cpu->new(%{$_})); + } +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->add_info('checking cpus'); + $self->blacklist('ff', ''); + if (scalar (@{$self->{cpus}}) == 0) { + } else { + foreach (@{$self->{cpus}}) { + $_->check(); + } + } +} + + +sub dump { + my $self = shift; + foreach (@{$self->{cpus}}) { + $_->dump(); + } +} + + +package NWC::Cisco::Component::CpuSubsystem::Cpu; +our @ISA = qw(NWC::Cisco::Component::CpuSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + cpmCPUTotalIndex => $params{cpmCPUTotalIndex}, + cpmCPUTotalPhysicalIndex => $params{cpmCPUTotalPhysicalIndex}, + cpmCPUTotal5sec => $params{cpmCPUTotal5sec}, + cpmCPUTotal1min => $params{cpmCPUTotal1min}, + cpmCPUTotal5min => $params{cpmCPUTotal5min}, + cpmCPUTotal5secRev => $params{cpmCPUTotal5secRev}, + cpmCPUTotal1minRev => $params{cpmCPUTotal1minRev}, + cpmCPUTotal5minRev => $params{cpmCPUTotal5minRev}, + cpmCPUMonInterval => $params{cpmCPUMonInterval}, + cpmCPUTotalMonIntervalValue => $params{cpmCPUTotalMonIntervalValue}, + cpmCPUInterruptMonIntervalValue => $params{cpmCPUInterruptMonIntervalValue}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->{usage} = $params{cpmCPUTotal5minRev}; + if ($self->{cpmCPUTotalPhysicalIndex}) { + my $entPhysicalName = '1.3.6.1.2.1.47.1.1.1.1.7'; + $self->{entPhysicalName} = $self->get_request( + -varbindlist => [$entPhysicalName.'.'.$self->{cpmCPUTotalPhysicalIndex}] + ); + $self->{entPhysicalName} = $self->{entPhysicalName}->{$entPhysicalName.'.'.$self->{cpmCPUTotalPhysicalIndex}}; + } else { + $self->{entPhysicalName} = $self->{cpmCPUTotalIndex}; + } + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('c', $self->{cpmCPUTotalPhysicalIndex}); + my $info = sprintf 'cpu %s usage (5 min avg.) is %.2f%%', + $self->{entPhysicalName}, $self->{usage}; + $self->add_info($info); + $self->set_thresholds(warning => 80, critical => 90); + $self->add_message($self->check_thresholds($self->{usage}), $info); + $self->add_perfdata( + label => $self->{entPhysicalName}.'_usage', + value => $self->{usage}, + uom => '%', + warning => $self->{warning}, + critical => $self->{critical}, + ); +} + +sub dump { + my $self = shift; + printf "[CPU_%s]\n", $self->{cpmCPUTotalPhysicalIndex}; + foreach (qw(cpmCPUTotalIndex cpmCPUTotalPhysicalIndex cpmCPUTotal5sec cpmCPUTotal1min cpmCPUTotal5min cpmCPUTotal5secRev cpmCPUTotal1minRev cpmCPUTotal5minRev cpmCPUMonInterval cpmCPUTotalMonIntervalValue cpmCPUInterruptMonIntervalValue)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + diff --git a/plugins-scripts/NWC/Cisco/Component/EnvironmentalSubsystem.pm b/plugins-scripts/NWC/Cisco/Component/EnvironmentalSubsystem.pm new file mode 100644 index 00000000..de46bcc4 --- /dev/null +++ b/plugins-scripts/NWC/Cisco/Component/EnvironmentalSubsystem.pm @@ -0,0 +1,62 @@ +package NWC::Cisco::Component::EnvironmentalSubsystem; +our @ISA = qw(NWC::Cisco); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + method => $params{method}, + condition => $params{condition}, + status => $params{status}, + fan_subsystem => undef, + temperature_subsystem => undef, + powersupply_subsystem => undef, + voltage_subsystem => undef, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + # + # 1.3.6.1.4.1.9.9.13.1.1.0 ciscoEnvMonPresent (irgendein typ of envmon) + # + $self->{fan_subsystem} = + NWC::Cisco::Component::FanSubsystem->new(%params); + $self->{temperature_subsystem} = + NWC::Cisco::Component::TemperatureSubsystem->new(%params); + $self->{powersupply_subsystem} = + NWC::Cisco::Component::SupplySubsystem->new(%params); + $self->{voltage_subsystem} = + NWC::Cisco::Component::VoltageSubsystem->new(%params); +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->{fan_subsystem}->check(); + $self->{temperature_subsystem}->check(); + $self->{voltage_subsystem}->check(); + $self->{powersupply_subsystem}->check(); +} + +sub dump { + my $self = shift; + $self->{fan_subsystem}->dump(); + $self->{temperature_subsystem}->dump(); + $self->{voltage_subsystem}->dump(); + $self->{powersupply_subsystem}->dump(); +} + +1; diff --git a/plugins-scripts/NWC/Cisco/Component/FanSubsystem.pm b/plugins-scripts/NWC/Cisco/Component/FanSubsystem.pm new file mode 100644 index 00000000..58a6f9e6 --- /dev/null +++ b/plugins-scripts/NWC/Cisco/Component/FanSubsystem.pm @@ -0,0 +1,114 @@ +package NWC::Cisco::Component::FanSubsystem; +our @ISA = qw(NWC::Cisco::Component::EnvironmentalSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + fans => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + my $snmpwalk = $params{rawdata}; + my $ignore_redundancy = $params{ignore_redundancy}; + # ciscoEnvMonFanStatusTable + my $oids = { + ciscoEnvMonFanStatusEntry => '1.3.6.1.4.1.9.9.13.1.4.1', + ciscoEnvMonFanStatusIndex => '1.3.6.1.4.1.9.9.13.1.4.1.1', + ciscoEnvMonFanStatusDescr => '1.3.6.1.4.1.9.9.13.1.4.1.2', + ciscoEnvMonFanState => '1.3.6.1.4.1.9.9.13.1.4.1.3', + ciscoEnvMonFanStateValue => { + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', + 4 => 'shutdown', + 5 => 'notPresent', + 6 => 'notFunctioning', + }, + }; + # INDEX { ciscoEnvMonFanStatusIndex } + foreach ($self->get_entries($oids, 'ciscoEnvMonFanStatusEntry')) { + #next if ! $_->{cpqHeThermalFanPresent}; + push(@{$self->{fans}}, + NWC::Cisco::Component::FanSubsystem::Fan->new(%{$_})); + } +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->add_info('checking fans'); + $self->blacklist('ff', ''); + if (scalar (@{$self->{fans}}) == 0) { + } else { + foreach (@{$self->{fans}}) { + $_->check(); + } + } +} + + +sub dump { + my $self = shift; + foreach (@{$self->{fans}}) { + $_->dump(); + } +} + + +package NWC::Cisco::Component::FanSubsystem::Fan; +our @ISA = qw(NWC::Cisco::Component::FanSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + ciscoEnvMonFanStatusIndex => $params{ciscoEnvMonFanStatusIndex} || 0, + ciscoEnvMonFanStatusDescr => $params{ciscoEnvMonFanStatusDescr}, + ciscoEnvMonFanState => $params{ciscoEnvMonFanState}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('f', $self->{ciscoEnvMonFanStatusIndex}); + $self->add_info(sprintf 'fan %d (%s) is %s', + $self->{ciscoEnvMonFanStatusIndex}, + $self->{ciscoEnvMonFanStatusDescr}, + $self->{ciscoEnvMonFanState}); +} + +sub dump { + my $self = shift; + printf "[FAN_%s]\n", $self->{ciscoEnvMonFanStatusIndex}; + foreach (qw(ciscoEnvMonFanStatusIndex ciscoEnvMonFanStatusDescr + ciscoEnvMonFanState)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + diff --git a/plugins-scripts/NWC/Cisco/Component/MemSubsystem.pm b/plugins-scripts/NWC/Cisco/Component/MemSubsystem.pm new file mode 100644 index 00000000..9d7808fb --- /dev/null +++ b/plugins-scripts/NWC/Cisco/Component/MemSubsystem.pm @@ -0,0 +1,128 @@ +package NWC::Cisco::Component::MemSubsystem; +our @ISA = qw(NWC::Cisco); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + mems => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + my $snmpwalk = $params{rawdata}; + my $ignore_redundancy = $params{ignore_redundancy}; + # ciscoEnvMonMemStatusTable + my $oids = { + ciscoMemoryPoolTable => '1.3.6.1.4.1.9.9.48.1.1', + ciscoMemoryPoolEntry => '1.3.6.1.4.1.9.9.48.1.1.1', + ciscoMemoryPoolType => '1.3.6.1.4.1.9.9.48.1.1.1.1', + ciscoMemoryPoolName => '1.3.6.1.4.1.9.9.48.1.1.1.2', + ciscoMemoryPoolAlternate => '1.3.6.1.4.1.9.9.48.1.1.1.3', + ciscoMemoryPoolValid => '1.3.6.1.4.1.9.9.48.1.1.1.4', + ciscoMemoryPoolUsed => '1.3.6.1.4.1.9.9.48.1.1.1.5', + ciscoMemoryPoolFree => '1.3.6.1.4.1.9.9.48.1.1.1.6', + ciscoMemoryPoolLargestFree => '1.3.6.1.4.1.9.9.48.1.1.1.7', + }; + # INDEX { ciscoMemoryPoolType } + my $type = 0; + foreach ($self->get_entries($oids, 'ciscoMemoryPoolEntry')) { + $_->{ciscoMemoryPoolType} ||= $type++; + push(@{$self->{mems}}, + NWC::Cisco::Component::MemSubsystem::Mem->new(%{$_})); + } +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->add_info('checking mems'); + $self->blacklist('ff', ''); + if (scalar (@{$self->{mems}}) == 0) { + } else { + foreach (@{$self->{mems}}) { + $_->check(); + } + } +} + + +sub dump { + my $self = shift; + foreach (@{$self->{mems}}) { + $_->dump(); + } +} + + +package NWC::Cisco::Component::MemSubsystem::Mem; +our @ISA = qw(NWC::Cisco::Component::MemSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + ciscoMemoryPoolTable => $params{ciscoMemoryPoolTable}, + ciscoMemoryPoolEntry => $params{ciscoMemoryPoolEntry}, + ciscoMemoryPoolType => $params{ciscoMemoryPoolType}, + ciscoMemoryPoolName => $params{ciscoMemoryPoolName}, + ciscoMemoryPoolAlternate => $params{ciscoMemoryPoolAlternate}, + ciscoMemoryPoolValid => $params{ciscoMemoryPoolValid}, + ciscoMemoryPoolUsed => $params{ciscoMemoryPoolUsed}, + ciscoMemoryPoolFree => $params{ciscoMemoryPoolFree}, + ciscoMemoryPoolLargestFree => $params{ciscoMemoryPoolLargestFree}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->{usage} = 100 * $params{ciscoMemoryPoolUsed} / + ($params{ciscoMemoryPoolFree} + $params{ciscoMemoryPoolUsed}); + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('m', $self->{ciscoMemoryPoolType}); + my $info = sprintf 'mempool %s usage is %.2f%%', + $self->{ciscoMemoryPoolName}, $self->{usage}; + $self->add_info($info); + $self->set_thresholds(warning => 80, critical => 90); + $self->add_message($self->check_thresholds($self->{usage}), $info); + + $self->add_perfdata( + label => $self->{ciscoMemoryPoolName}.'_usage', + value => $self->{usage}, + uom => '%', + warning => $self->{warningthreshold}, + critical => $self->{criticalthreshold} + ); +} + +sub dump { + my $self = shift; + printf "[MEMPOOL_%s]\n", $self->{ciscoMemoryPoolType}; + foreach (qw(ciscoMemoryPoolType ciscoMemoryPoolName ciscoMemoryPoolAlternate ciscoMemoryPoolValid ciscoMemoryPoolUsed ciscoMemoryPoolFree ciscoMemoryPoolLargestFree)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + diff --git a/plugins-scripts/NWC/Cisco/Component/SupplySubsystem.pm b/plugins-scripts/NWC/Cisco/Component/SupplySubsystem.pm new file mode 100644 index 00000000..6537f7ed --- /dev/null +++ b/plugins-scripts/NWC/Cisco/Component/SupplySubsystem.pm @@ -0,0 +1,120 @@ +package NWC::Cisco::Component::SupplySubsystem; +our @ISA = qw(NWC::Cisco::Component::EnvironmentalSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + supplies => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + my $snmpwalk = $params{rawdata}; + my $ignore_redundancy = $params{ignore_redundancy}; + # ciscoEnvMonSupplyStatusTable + my $oids = { + ciscoEnvMonSupplyStatusTable => '1.3.6.1.4.1.9.9.13.1.5', + ciscoEnvMonSupplyStatusEntry => '1.3.6.1.4.1.9.9.13.1.5.1', + ciscoEnvMonSupplyStatusIndex => '1.3.6.1.4.1.9.9.13.1.5.1.1', + ciscoEnvMonSupplyStatusDescr => '1.3.6.1.4.1.9.9.13.1.5.1.2', + ciscoEnvMonSupplyState => '1.3.6.1.4.1.9.9.13.1.5.1.3', + ciscoEnvMonSupplySource => '1.3.6.1.4.1.9.9.13.1.5.1.4', + ciscoEnvMonSupplyStateValue => { + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', + 4 => 'shutdown', + 5 => 'notPresent', + 6 => 'notFunctioning', + }, + }; + # INDEX { ciscoEnvMonSupplyStatusIndex } + foreach ($self->get_entries($oids, 'ciscoEnvMonSupplyStatusEntry')) { + #next if ! $_->{cpqHeThermalSupplyPresent}; + push(@{$self->{supplies}}, + NWC::Cisco::Component::SupplySubsystem::Supply->new(%{$_})); + } +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->add_info('checking supplies'); + $self->blacklist('ps', ''); + if (scalar (@{$self->{supplies}}) == 0) { + } else { + foreach (@{$self->{supplies}}) { + $_->check(); + } + } +} + + +sub dump { + my $self = shift; + foreach (@{$self->{supplies}}) { + $_->dump(); + } +} + + +package NWC::Cisco::Component::SupplySubsystem::Supply; +our @ISA = qw(NWC::Cisco::Component::SupplySubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + ciscoEnvMonSupplyStatusIndex => $params{ciscoEnvMonSupplyStatusIndex} || 0, + ciscoEnvMonSupplyStatusDescr => $params{ciscoEnvMonSupplyStatusDescr}, + ciscoEnvMonSupplyState => $params{ciscoEnvMonSupplyState}, + ciscoEnvMonSupplySource => $params{ciscoEnvMonSupplySource}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('f', $self->{ciscoEnvMonSupplyStatusIndex}); + $self->add_info(sprintf 'powersupply %d (%s) is %s', + $self->{ciscoEnvMonSupplyStatusIndex}, + $self->{ciscoEnvMonSupplyStatusDescr}, + $self->{ciscoEnvMonSupplyState}); + if ($self->{ciscoEnvMonSupplyState} eq 'notPresent') { + } elsif ($self->{ciscoEnvMonSupplyState} ne 'normal') { + $self->add_message(CRITICAL, $self->{info}); + } +} + +sub dump { + my $self = shift; + printf "[PS_%s]\n", $self->{ciscoEnvMonSupplyStatusIndex}; + foreach (qw(ciscoEnvMonSupplyStatusIndex ciscoEnvMonSupplyStatusDescr ciscoEnvMonSupplyState ciscoEnvMonSupplySource)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + diff --git a/plugins-scripts/NWC/Cisco/Component/TemperatureSubsystem.pm b/plugins-scripts/NWC/Cisco/Component/TemperatureSubsystem.pm new file mode 100644 index 00000000..311dbb64 --- /dev/null +++ b/plugins-scripts/NWC/Cisco/Component/TemperatureSubsystem.pm @@ -0,0 +1,197 @@ +package NWC::Cisco::Component::TemperatureSubsystem; +our @ISA = qw(NWC::Cisco::Component::EnvironmentalSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + temperatures => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + my $snmpwalk = $params{rawdata}; + my $ignore_redundancy = $params{ignore_redundancy}; + # ciscoEnvMonTemperatureStatusTable + my $oids = { + ciscoEnvMonTemperatureStatusTable => '1.3.6.1.4.1.9.9.13.1.3', + ciscoEnvMonTemperatureStatusEntry => '1.3.6.1.4.1.9.9.13.1.3.1', + ciscoEnvMonTemperatureStatusIndex => '1.3.6.1.4.1.9.9.13.1.3.1.1', + ciscoEnvMonTemperatureStatusDescr => '1.3.6.1.4.1.9.9.13.1.3.1.2', + ciscoEnvMonTemperatureStatusValue => '1.3.6.1.4.1.9.9.13.1.3.1.3', + ciscoEnvMonTemperatureThreshold => '1.3.6.1.4.1.9.9.13.1.3.1.4', + ciscoEnvMonTemperatureLastShutdown => '1.3.6.1.4.1.9.9.13.1.3.1.5', + ciscoEnvMonTemperatureState => '1.3.6.1.4.1.9.9.13.1.3.1.6', + ciscoEnvMonTemperatureStateValue => { + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', + 4 => 'shutdown', + 5 => 'notPresent', + 6 => 'notFunctioning', + }, + }; + # INDEX { ciscoEnvMonTemperatureStatusIndex } + foreach ($self->get_entries($oids, 'ciscoEnvMonTemperatureStatusEntry')) { + #next if ! $_->{cpqHeThermalTemperaturePresent}; + push(@{$self->{temperatures}}, + NWC::Cisco::Component::TemperatureSubsystem::Temperature->new(%{$_})); + } +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->add_info('checking temperatures'); + $self->blacklist('t', ''); + if (scalar (@{$self->{temperatures}}) == 0) { + } else { + foreach (@{$self->{temperatures}}) { + $_->check(); + } + } +} + + +sub dump { + my $self = shift; + foreach (@{$self->{temperatures}}) { + $_->dump(); + } +} + + +package NWC::Cisco::Component::TemperatureSubsystem::Temperature; +our @ISA = qw(NWC::Cisco::Component::TemperatureSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + ciscoEnvMonTemperatureStatusIndex => $params{ciscoEnvMonTemperatureStatusIndex} || 0, + ciscoEnvMonTemperatureStatusDescr => $params{ciscoEnvMonTemperatureStatusDescr}, + ciscoEnvMonTemperatureStatusValue => $params{ciscoEnvMonTemperatureStatusValue}, + ciscoEnvMonTemperatureThreshold => $params{ciscoEnvMonTemperatureThreshold}, + ciscoEnvMonTemperatureLastShutdown => $params{ciscoEnvMonTemperatureLastShutdown}, + ciscoEnvMonTemperatureState => $params{ciscoEnvMonTemperatureState}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + if ($self->{ciscoEnvMonTemperatureStatusValue}) { + bless $self, $class; + } else { + bless $self, $class.'::Simple'; + } + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('t', $self->{ciscoEnvMonTemperatureStatusIndex}); + if ($self->{ciscoEnvMonTemperatureStatusValue} > + $self->{ciscoEnvMonTemperatureThreshold}) { + $self->add_info(sprintf 'temperature %d %s is too high (%d of %d max = %s)', + $self->{ciscoEnvMonTemperatureStatusIndex}, + $self->{ciscoEnvMonTemperatureStatusDescr}, + $self->{ciscoEnvMonTemperatureStatusValue}, + $self->{ciscoEnvMonTemperatureThreshold}, + $self->{ciscoEnvMonTemperatureState}); + if ($self->{ciscoEnvMonTemperatureState} eq 'warning') { + $self->add_message(WARNING, $self->{info}); + } elsif ($self->{ciscoEnvMonTemperatureState} eq 'critical') { + $self->add_message(CRITICAL, $self->{info}); + } + } else { + $self->add_info(sprintf 'temperature %d %s is %d (of %d max = normal)', + $self->{ciscoEnvMonTemperatureStatusIndex}, + $self->{ciscoEnvMonTemperatureStatusDescr}, + $self->{ciscoEnvMonTemperatureStatusValue}, + $self->{ciscoEnvMonTemperatureThreshold}, + $self->{ciscoEnvMonTemperatureState}); + } + $self->add_perfdata( + label => sprintf('temp_%s', $self->{ciscoEnvMonTemperatureStatusIndex}), + value => $self->{ciscoEnvMonTemperatureStatusValue}, + warning => $self->{ciscoEnvMonTemperatureThreshold}, + critical => undef, + ); +} + +sub dump { + my $self = shift; + printf "[TEMP_%s]\n", $self->{ciscoEnvMonTemperatureStatusIndex}; + foreach (qw(ciscoEnvMonTemperatureStatusIndex ciscoEnvMonTemperatureStatusDescr ciscoEnvMonTemperatureStatusValue ciscoEnvMonTemperatureThreshold ciscoEnvMonTemperatureLastShutdown ciscoEnvMonTemperatureState)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + +package NWC::Cisco::Component::TemperatureSubsystem::Temperature::Simple; +our @ISA = qw(NWC::Cisco::Component::TemperatureSubsystem::Temperature); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + ciscoEnvMonTemperatureStatusIndex => $params{ciscoEnvMonTemperatureStatusIndex} || 0, + ciscoEnvMonTemperatureStatusDescr => $params{ciscoEnvMonTemperatureStatusDescr}, + ciscoEnvMonTemperatureState => $params{ciscoEnvMonTemperatureState}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('t', $self->{ciscoEnvMonTemperatureStatusIndex}); + $self->add_info(sprintf 'temperature %d %s is %s', + $self->{ciscoEnvMonTemperatureStatusIndex}, + $self->{ciscoEnvMonTemperatureStatusDescr}, + $self->{ciscoEnvMonTemperatureState}); + if ($self->{ciscoEnvMonTemperatureState} ne 'normal') { + if ($self->{ciscoEnvMonTemperatureState} eq 'warning') { + $self->add_message(WARNING, $self->{info}); + } elsif ($self->{ciscoEnvMonTemperatureState} eq 'critical') { + $self->add_message(CRITICAL, $self->{info}); + } + } else { + } +} + +sub dump { + my $self = shift; + printf "[TEMP_%s]\n", $self->{ciscoEnvMonTemperatureStatusIndex}; + foreach (qw(ciscoEnvMonTemperatureStatusIndex ciscoEnvMonTemperatureStatusDescr ciscoEnvMonTemperatureState)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + + diff --git a/plugins-scripts/NWC/Cisco/Component/VoltageSubsystem.pm b/plugins-scripts/NWC/Cisco/Component/VoltageSubsystem.pm new file mode 100644 index 00000000..9f3ace0e --- /dev/null +++ b/plugins-scripts/NWC/Cisco/Component/VoltageSubsystem.pm @@ -0,0 +1,124 @@ +package NWC::Cisco::Component::VoltageSubsystem; +our @ISA = qw(NWC::Cisco::Component::EnvironmentalSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + voltages => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + my $snmpwalk = $params{rawdata}; + my $ignore_redundancy = $params{ignore_redundancy}; + # ciscoEnvMonVoltageStatusTable + my $oids = { + ciscoEnvMonVoltageStatusTable => '1.3.6.1.4.1.9.9.13.1.2', + ciscoEnvMonVoltageStatusEntry => '1.3.6.1.4.1.9.9.13.1.2.1', + ciscoEnvMonVoltageStatusIndex => '1.3.6.1.4.1.9.9.13.1.2.1.1', + ciscoEnvMonVoltageStatusDescr => '1.3.6.1.4.1.9.9.13.1.2.1.2', + ciscoEnvMonVoltageStatusValue => '1.3.6.1.4.1.9.9.13.1.2.1.3', + ciscoEnvMonVoltageThresholdLow => '1.3.6.1.4.1.9.9.13.1.2.1.4', + ciscoEnvMonVoltageThresholdHigh => '1.3.6.1.4.1.9.9.13.1.2.1.5', + ciscoEnvMonVoltageLastShutdown => '1.3.6.1.4.1.9.9.13.1.2.1.6', + ciscoEnvMonVoltageState => '1.3.6.1.4.1.9.9.13.1.2.1.7', + ciscoEnvMonVoltageStateValue => { + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', + 4 => 'shutdown', + 5 => 'notPresent', + 6 => 'notFunctioning', + }, + }; + # INDEX { ciscoEnvMonVoltageStatusIndex } + foreach ($self->get_entries($oids, 'ciscoEnvMonVoltageStatusEntry')) { + #next if ! $_->{cpqHeThermalVoltagePresent}; + push(@{$self->{voltages}}, + NWC::Cisco::Component::VoltageSubsystem::Voltage->new(%{$_})); + } +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->add_info('checking voltages'); + $self->blacklist('ff', ''); + if (scalar (@{$self->{voltages}}) == 0) { + } else { + foreach (@{$self->{voltages}}) { + $_->check(); + } + } +} + + +sub dump { + my $self = shift; + foreach (@{$self->{voltages}}) { + $_->dump(); + } +} + + +package NWC::Cisco::Component::VoltageSubsystem::Voltage; +our @ISA = qw(NWC::Cisco::Component::VoltageSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + ciscoEnvMonVoltageStatusTable => $params{ciscoEnvMonVoltageStatusTable}, + ciscoEnvMonVoltageStatusEntry => $params{ciscoEnvMonVoltageStatusEntry}, + ciscoEnvMonVoltageStatusIndex => $params{ciscoEnvMonVoltageStatusIndex}, + ciscoEnvMonVoltageStatusDescr => $params{ciscoEnvMonVoltageStatusDescr}, + ciscoEnvMonVoltageStatusValue => $params{ciscoEnvMonVoltageStatusValue}, + ciscoEnvMonVoltageThresholdLow => $params{ciscoEnvMonVoltageThresholdLow}, + ciscoEnvMonVoltageThresholdHigh => $params{ciscoEnvMonVoltageThresholdHigh}, + ciscoEnvMonVoltageLastShutdown => $params{ciscoEnvMonVoltageLastShutdown}, + ciscoEnvMonVoltageState => $params{ciscoEnvMonVoltageState}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('f', $self->{ciscoEnvMonVoltageStatusIndex}); + $self->add_info(sprintf 'fan %d (%s) is %s', + $self->{ciscoEnvMonVoltageStatusIndex}, + $self->{ciscoEnvMonVoltageStatusDescr}, + $self->{ciscoEnvMonVoltageState}); +} + +sub dump { + my $self = shift; + printf "[FAN_%s]\n", $self->{ciscoEnvMonVoltageStatusIndex}; + foreach (qw(ciscoEnvMonVoltageStatusTable ciscoEnvMonVoltageStatusEntry ciscoEnvMonVoltageStatusIndex ciscoEnvMonVoltageStatusDescr ciscoEnvMonVoltageStatusValue ciscoEnvMonVoltageThresholdLow ciscoEnvMonVoltageThresholdHigh ciscoEnvMonVoltageLastShutdown ciscoEnvMonVoltageState)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + diff --git a/plugins-scripts/NWC/Component/SNMP.pm b/plugins-scripts/NWC/Component/SNMP.pm new file mode 100644 index 00000000..1d0a06aa --- /dev/null +++ b/plugins-scripts/NWC/Component/SNMP.pm @@ -0,0 +1,86 @@ +package NWC::Component::SNMP; + +sub get_entries { + my $self = shift; + my $oids = shift; + my $entry = shift; + my $snmpwalk = $self->{rawdata}; + my @params = (); + my @indices = SNMP::Utils::get_indices($snmpwalk, $oids->{$entry}); + foreach (@indices) { + my @idx = @{$_}; + my %params = ( + runtime => $self->{runtime}, + ); + my $maxdimension = scalar(@idx) - 1; + foreach my $idxnr (1..scalar(@idx)) { + $params{'index'.$idxnr} = $_->[$idxnr - 1]; + } + foreach my $oid (keys %{$oids}) { + next if $oid =~ /Table$/; + next if $oid =~ /Entry$/; + # there may be scalar oids ciscoEnvMonTemperatureStatusValue = curr. temp. + next if ($oid =~ /Value$/ && ref ($oids->{$oid}) eq 'HASH'); + if (exists $oids->{$oid.'Value'}) { + $params{$oid} = SNMP::Utils::get_object_value( + $snmpwalk, $oids->{$oid}, $oids->{$oid.'Value'}, @idx); + if (! defined $params{$oid}) { + my $numerical_value = SNMP::Utils::get_object( + $snmpwalk, $oids->{$oid}, @idx); + if (! defined $numerical_value) { + # maschine liefert schrott + $params{$oid} = 'value_unknown'; + } else { + $params{$oid} = 'value_'.SNMP::Utils::get_object( + $snmpwalk, $oids->{$oid}, @idx); + } + } + } else { + $params{$oid} = SNMP::Utils::get_object( + $snmpwalk, $oids->{$oid}, @idx); + } + } + push(@params, \%params); + } + if (scalar(@params) == 0) { + if ($self->{runtime}->{snmpsession}) { + + my $table = $entry; + $table =~ s/(.*)\.\d+$/$1/; + my $result = $self->{runtime}->{snmpsession}->get_table( + -baseoid => $oids->{$table} + ); + if ($result) { + foreach my $key (%{$result}) { + $self->{rawdata}->{$key} = $result->{$key}; + } + @params = $self->get_entries($oids, $entry); + } +#printf "%s\n", Data::Dumper::Dumper($result); + } + } + return @params; +} + +sub mib { + my $self = shift; + my $mib = shift; + my $condition = { + 0 => 'other', + 1 => 'ok', + 2 => 'degraded', + 3 => 'failed', + }; + my $MibRevMajor = $mib.'.1.0'; + my $MibRevMinor = $mib.'.2.0'; + my $MibRevCondition = $mib.'.3.0'; + return ( + $self->SNMP::Utils::get_object($self->{rawdata}, + $MibRevMajor), + $self->SNMP::Utils::get_object($self->{rawdata}, + $MibRevMinor), + $self->SNMP::Utils::get_object_value($self->{rawdata}, + $MibRevCondition, $condition)); +}; + +1; diff --git a/plugins-scripts/NWC/Device.pm b/plugins-scripts/NWC/Device.pm new file mode 100644 index 00000000..7fd967c6 --- /dev/null +++ b/plugins-scripts/NWC/Device.pm @@ -0,0 +1,724 @@ +package NWC::Device; + +use strict; +use IO::File; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +{ + our $mode = undef; + our $plugin = undef; + our $blacklist = undef; + our $session = undef; + our $rawdata = {}; + our $info = []; + our $extendedinfo = []; + our $summary = []; + our $statefilesdir = '/var/tmp/check_nwc_health'; +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + productname => 'unknown', + }; + bless $self, $class; + if (! ($self->opts->hostname || $self->opts->snmpwalk)) { + die "wie jetzt??!?!"; + } else { + $self->check_snmp_and_model(); + if ($self->opts->servertype) { + $self->{productname} = 'cisco' if $self->opts->servertype eq 'cisco'; + $self->{productname} = 'huawei' if $self->opts->servertype eq 'huawei'; + $self->{productname} = 'hp' if $self->opts->servertype eq 'hp'; + } + if (! $NWC::Device::plugin->check_messages()) { + if ($self->{productname} =~ /Cisco/i) { + bless $self, 'NWC::Cisco'; + $self->trace(3, 'using NWC::Cisco'); + } else { + $self->add_message(CRITICAL, + sprintf('unknown device%s', $self->{productname} eq 'unknown' ? + '' : '('.$self->{productname}.')')); + } + $self->{method} = 'snmp'; + } + } + if ($self->opts->blacklist && + -f $self->opts->blacklist) { + $self->opts->blacklist = do { + local (@ARGV, $/) = $self->opts->blacklist; <> }; + } + return $self; +} + +sub check_snmp_and_model { +# uptime pruefen +# dann whoami + my $self = shift; + if ($self->opts->snmpwalk) { + my $response = {}; + if (! -f $self->opts->snmpwalk) { + $self->add_message(CRITICAL, + sprintf 'file %s not found', + $self->opts->snmpwalk); + } elsif (-x $self->opts->snmpwalk) { + my $cmd = sprintf "%s -On -v%s -c%s %s 1.3.6.1.4.1.232 2>&1", + $self->opts->snmpwalk, + $self->opts->protocol, + $self->opts->community, + $self->opts->hostname; + open(WALK, "$cmd |"); + while () { + if (/^.*?\.(232\.[\d\.]+) = .*?: (\-*\d+)/) { + $response->{'1.3.6.1.4.1.'.$1} = $2; + } elsif (/^.*?\.(232\.[\d\.]+) = .*?: "(.*?)"/) { + $response->{'1.3.6.1.4.1.'.$1} = $2; + $response->{'1.3.6.1.4.1.'.$1} =~ s/\s+$//; + } + } + close WALK; + } else { + open(MESS, $self->opts->snmpwalk); + while() { + # SNMPv2-SMI::enterprises.232.6.2.6.7.1.3.1.4 = INTEGER: 6 + if (/^([\d\.]+) = .*?: (\-*\d+)/) { + $response->{$1} = $2; + } elsif (/^([\d\.]+) = .*?: "(.*?)"/) { + $response->{$1} = $2; + $response->{$1} =~ s/\s+$//; + } elsif (/^([\d\.]+) = .*?: (.*)/) { + $response->{$1} = $2; + $response->{$1} =~ s/\s+$//; + } elsif (/^([\d\.]+) = (\-*\d+)/) { + $response->{$1} = $2; + } elsif (/^([\d\.]+) = "(.*?)"/) { + $response->{$1} = $2; + $response->{$1} =~ s/\s+$//; + } + } + close MESS; + } + foreach my $oid (keys %$response) { + if ($oid =~ /^\./) { + my $nodot = $oid; + $nodot =~ s/^\.//g; + $response->{$nodot} = $response->{$oid}; + delete $response->{$oid}; + } + } + map { $response->{$_} =~ s/^\s+//; $response->{$_} =~ s/\s+$//; } + keys %$response; + $self->set_rawdata($response); + $self->whoami(); + } else { + if (eval "require Net::SNMP") { + my %params = (); + my $net_snmp_version = Net::SNMP->VERSION(); # 5.002000 or 6.000000 + #$params{'-translate'} = [ + # -all => 0x0 + #]; + $params{'-hostname'} = $self->opts->hostname; + $params{'-version'} = $self->opts->protocol; + if ($self->opts->port) { + $params{'-port'} = $self->opts->port; + } + if ($self->opts->protocol eq '3') { + $params{'-username'} = $self->opts->username; + if ($self->opts->authpassword) { + $params{'-authpassword'} = $self->opts->authpassword; + } + if ($self->opts->authprotocol) { + $params{'-authprotocol'} = $self->opts->authprotocol; + } + if ($self->opts->privpassword) { + $params{'-privpassword'} = $self->opts->privpassword; + } + if ($self->opts->privprotocol) { + $params{'-privprotocol'} = $self->opts->privprotocol; + } + } else { + $params{'-community'} = $self->opts->community; + } + my ($session, $error) = Net::SNMP->session(%params); + if (! defined $session) { + $self->add_message(CRITICAL, 'cannot create session object'); + $self->trace(1, Data::Dumper::Dumper(\%params)); + } else { + $NWC::Device::session = $session; + my $sysUpTime = '1.3.6.1.2.1.1.3.0'; + my $result = $self->get_request( + -varbindlist => [$sysUpTime] + ); + if (!defined($result)) { + $self->add_message(CRITICAL, + 'could not contact snmp agent'); + $session->close; + } else { + $self->trace(3, 'snmp agent answered'); + $self->whoami(); + } + } + } else { + $self->add_message(CRITICAL, + 'could not find Net::SNMP module'); + } + } +} + +sub whoami { + my $self = shift; + my $productname = undef; + if ($self->opts->snmpwalk) { + my $sysDescr = '1.3.6.1.2.1.1.1.0'; +$self->{rawdata}->{$sysDescr} = "bla cisco"; + if ($productname = $self->rawdata->{$sysDescr}) { + if (! $productname) { + $self->{productname} = 'Cisco'; + } else { + $self->{productname} = $self->rawdata->{$sysDescr}; + } + } else { + $self->add_message(CRITICAL, + 'snmpwalk returns no product name (cpqsinfo-mib)'); + } + } else { + my $sysDescr = '1.3.6.1.2.1.1.1.0'; + my $dummy = '1.3.6.1.2.1.1.5.0'; + if ($productname = $self->valid_response($sysDescr)) { + if ($productname eq '') { + $self->{productname} = 'Cisco'; + } else { + $self->{productname} = $productname; + } + } else { + $self->add_message(CRITICAL, + 'snmpwalk returns no product name (cpqsinfo-mib)'); + $self->{session}->close; + } + $self->trace(3, 'whoami: '.$self->{productname}); + } +} + +sub valid_response { + my $self = shift; + my $oid = shift; + my $result = $NWC::Device::session->get_request( + -varbindlist => [$oid] + ); + if (!defined($result) || + ! defined $result->{$oid} || + $result->{$oid} eq 'noSuchInstance' || + $result->{$oid} eq 'noSuchObject' || + $result->{$oid} eq 'endOfMibView') { + return undef; + } else { + $self->add_rawdata($oid, $result->{$oid}); + return $result->{$oid}; + } +} + +sub debug { + my $self = shift; + my $msg = shift; +# printf "%s %s\n", $msg, ref($self); +} + +sub trace { + my $self = shift; + my $format = shift; +return; + $self->{trace} = -f "/tmp/check_nwc_health.trace" ? 1 : 0; + if ($self->opts->verbose) { + printf("%s: ", scalar localtime); + printf($format, @_); + printf "\n"; + } + if ($self->{trace}) { + my $logfh = new IO::File; + $logfh->autoflush(1); + if ($logfh->open("/tmp/check_nwc_health.trace", "a")) { + $logfh->printf("%s: ", scalar localtime); + $logfh->printf($format, @_); + $logfh->printf("\n"); + $logfh->close(); + } + } +} + +sub blacklist { + my $self = shift; + my $type = shift; + my $name = shift; + $self->{blacklisted} = $self->is_blacklisted($type, $name); +} + +sub add_blacklist { + my $self = shift; + my $list = shift; + $NWC::Device::blacklist = join('/', + (split('/', $self->opts->blacklist), $list)); +} + +sub is_blacklisted { + my $self = shift; + my $type = shift; + my $name = shift; + my $blacklisted = 0; +# $name =~ s/\:/-/g; + foreach my $bl_items (split(/\//, $self->opts->blacklist)) { + if ($bl_items =~ /^(\w+):([\:\d\-,]+)$/) { + my $bl_type = $1; + my $bl_names = $2; + foreach my $bl_name (split(/,/, $bl_names)) { + if ($bl_type eq $type && $bl_name eq $name) { + $blacklisted = 1; + } + } + } elsif ($bl_items =~ /^(\w+)$/) { + my $bl_type = $1; + if ($bl_type eq $type) { + $blacklisted = 1; + } + } + } + return $blacklisted; +} + +sub mode { + my $self = shift; + return $NWC::Device::mode; +} + +sub add_message { + my $self = shift; + my $level = shift; + my $message = shift; + $NWC::Device::plugin->add_message($level, $message) + unless $self->{blacklisted}; + if (exists $self->{failed}) { + if ($level == UNKNOWN && $self->{failed} == OK) { + $self->{failed} = $level; + } elsif ($level > $self->{failed}) { + $self->{failed} = $level; + } + } +} + +sub check_messages { + my $self = shift; + return $NWC::Device::plugin->check_messages(@_); +} + +sub add_perfdata { + my $self = shift; + $NWC::Device::plugin->add_perfdata(@_); +} + +sub set_thresholds { + my $self = shift; + $NWC::Device::plugin->set_thresholds(@_); +} + +sub check_thresholds { + my $self = shift; + ($self->{warning}, $self->{critical}) = + $NWC::Device::plugin->get_thresholds(@_); + return $NWC::Device::plugin->check_thresholds(@_); +} + +sub get_thresholds { + my $self = shift; + my @thresholds = $NWC::Device::plugin->get_thresholds(@_); + my($warning, $critical) = $NWC::Device::plugin->get_thresholds(@_); + $self->{warning} = $thresholds[0]; + $self->{critical} = $thresholds[1]; + return @thresholds; +} + +sub has_failed { + my $self = shift; + return $self->{failed}; +} + +sub add_info { + my $self = shift; + my $info = shift; + $info = $self->{blacklisted} ? $info.' (blacklisted)' : $info; + $self->{info} = $info; + push(@{$NWC::Device::info}, $info); +} + +sub annotate_info { + my $self = shift; + my $annotation = shift; + my $lastinfo = pop(@{$NWC::Device::info}); + $lastinfo .= sprintf ' (%s)', $annotation; + push(@{$NWC::Device::info}, $lastinfo); +} + +sub add_extendedinfo { + my $self = shift; + my $info = shift; + $self->{extendedinfo} = $info; + return if ! $self->opts->extendedinfo; + push(@{$NWC::Device::extendedinfo}, $info); +} + +sub get_extendedinfo { + my $self = shift; + return join(' ', @{$NWC::Device::extendedinfo}); +} + +sub add_summary { + my $self = shift; + my $summary = shift; + push(@{$NWC::Device::summary}, $summary); +} + +sub get_summary { + my $self = shift; + return join(', ', @{$NWC::Device::summary}); +} + +sub opts { + my $self = shift; + return $NWC::Device::plugin->opts(); +} + +sub set_rawdata { + my $self = shift; + $NWC::Device::rawdata = shift; +} + +sub add_rawdata { + my $self = shift; + my $oid = shift; + my $value = shift; + $NWC::Device::rawdata->{$oid} = $value; +} + +sub rawdata { + my $self = shift; + return $NWC::Device::rawdata; +} + +sub get_request { + my $self = shift; + my %params = @_; + my @notcached = (); + if (exists $params{'-varbindlist'}) { + foreach my $oid (@{$params{'-varbindlist'}}) { + if (! exists NWC::Device::rawdata->{$oid}) { + my $result = $NWC::Device::session->get_request( + -varbindlist => $oid + ); + foreach my $key (%{$result}) { + $self->add_rawdata($key, $result->{$key}); + } + } + } + my $result = {}; + map { $result->{$_} = $NWC::Device::rawdata->{$_} } + @{$params{'-varbindlist'}}; + return $result; + } + return {}; +} + +sub get_table { + my $self = shift; + return $NWC::Device::session->get_table(@_); +} + +sub valdiff { + my $self = shift; + my $pparams = shift; + my %params = %{$pparams}; + my @keys = @_; + my $now = time; + my $last_values = $self->load_state(%params) || eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = 0; + } + $empty_events->{timestamp} = 0; + if ($self->opts->lookback) { + $empty_events->{lookback_history} = {}; + } + $empty_events; + }; + foreach (@keys) { + if ($self->opts->can('lookback')) { + # find a last_value in the history which fits lookback best + # and overwrite $last_values->{$_} with historic data + if (exists $last_values->{lookback_history}->{$_}) { + foreach my $date (sort {$a <=> $b} keys %{$last_values->{lookback_history}->{$_}}) { + if ($date >= ($now - $self->opts->lookback)) { + $last_values->{$_} = $last_values->{lookback_history}->{$_}->{$date}; + $last_values->{timestamp} = $date; + last; + } else { + delete $last_values->{lookback_history}->{$_}->{$date}; + } + } + } + } + $last_values->{$_} = 0 if ! exists $last_values->{$_}; + if ($self->{$_} >= $last_values->{$_}) { + $self->{'delta_'.$_} = $self->{$_} - $last_values->{$_}; + } else { + # vermutlich db restart und zaehler alle auf null + $self->{'delta_'.$_} = $self->{$_}; + } + $self->debug(sprintf "delta_%s %f", $_, $self->{'delta_'.$_}); + } + $self->{'delta_timestamp'} = $now - $last_values->{timestamp}; + $params{save} = eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = $self->{$_}; + } + $empty_events->{timestamp} = $now; + if ($self->opts->can('lookback')) { + $empty_events->{lookback_history} = $last_values->{lookback_history}; + foreach (@keys) { + $empty_events->{lookback_history}->{$_}->{$now} = $self->{$_}; + } + } + $empty_events; + }; + $self->save_state(%params); +} + +sub save_state { + my $self = shift; + my %params = @_; + my $extension = ""; + mkdir $NWC::Device::statefilesdir unless -d $NWC::Device::statefilesdir; + my $statefile = sprintf "%s/%s_%s", + $NWC::Device::statefilesdir, $self->opts->hostname, $self->opts->mode; + #$extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{name} ? '_'.$params{name} : ''; + $extension =~ s/\//_/g; + $extension =~ s/\(/_/g; + $extension =~ s/\)/_/g; + $extension =~ s/\*/_/g; + $extension =~ s/\s/_/g; + $statefile .= $extension; + $statefile = lc $statefile; + open(STATE, ">$statefile"); + if ((ref($params{save}) eq "HASH") && exists $params{save}->{timestamp}) { + $params{save}->{localtime} = scalar localtime $params{save}->{timestamp}; + } + printf STATE Data::Dumper::Dumper($params{save}); + close STATE; + $self->debug(sprintf "saved %s to %s", + Data::Dumper::Dumper($params{save}), $statefile); +} + +sub load_state { + my $self = shift; + my %params = @_; + my $extension = ""; + mkdir $NWC::Device::statefilesdir unless -d $NWC::Device::statefilesdir; + my $statefile = sprintf "%s/%s_%s", + $NWC::Device::statefilesdir, $self->opts->hostname, $self->opts->mode; + #$extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{name} ? '_'.$params{name} : ''; + $extension =~ s/\//_/g; + $extension =~ s/\(/_/g; + $extension =~ s/\)/_/g; + $extension =~ s/\*/_/g; + $extension =~ s/\s/_/g; + $statefile .= $extension; + $statefile = lc $statefile; + if ( -f $statefile) { + our $VAR1; + eval { + require $statefile; + }; + if($@) { + printf "rumms\n"; + } + $self->debug(sprintf "load %s", Data::Dumper::Dumper($VAR1)); + return $VAR1; + } else { + return undef; + } +} + + +sub dumper { + my $self = shift; + my $object = shift; + my $run = $object->{runtime}; + delete $object->{runtime}; + printf STDERR "%s\n", Data::Dumper::Dumper($object); + $object->{runtime} = $run; +} + + +sub get_entries { + my $self = shift; + my $oids = shift; + my $entry = shift; + my $fallback = shift; + my @params = (); + my @indices = $self->get_indices($oids->{$entry}); + foreach (@indices) { + my @idx = @{$_}; + my %params = (); + my $maxdimension = scalar(@idx) - 1; + foreach my $idxnr (1..scalar(@idx)) { + $params{'index'.$idxnr} = $_->[$idxnr - 1]; + } + foreach my $oid (keys %{$oids}) { + next if $oid =~ /Table$/; + next if $oid =~ /Entry$/; + # there may be scalar oids ciscoEnvMonTemperatureStatusValue = curr. temp. + next if ($oid =~ /Value$/ && ref ($oids->{$oid}) eq 'HASH'); + if (exists $oids->{$oid.'Value'}) { + $params{$oid} = $self->get_object_value( + $oids->{$oid}, $oids->{$oid.'Value'}, @idx); + } else { + $params{$oid} = $self->get_object($oids->{$oid}, @idx); + } + } + push(@params, \%params); + } + if (! $fallback && scalar(@params) == 0) { + if ($NWC::Device::session) { + my $table = $entry; + $table =~ s/(.*)\.\d+$/$1/; + my $result = $self->get_table( + -baseoid => $oids->{$table} + ); + if ($result) { + foreach my $key (keys %{$result}) { + $self->add_rawdata($key, $result->{$key}); + } + @params = $self->get_entries($oids, $entry, 1); + } + #printf "%s\n", Data::Dumper::Dumper($result); + } + } + return @params; +} + +sub get_indices { + my $self = shift; + my $entry = shift; + my $numindices = shift; + # find all oids beginning with $entry + # then skip one field for the sequence + # then read the next numindices fields + my $entrypat = $entry; + $entrypat =~ s/\./\\\./g; + my @indices = map { + /^$entrypat\.\d+\.(.*)/ && $1; + } grep { + /^$entrypat/ + } keys %{$NWC::Device::rawdata}; + my %seen = (); + my @o = map {[split /\./]} sort grep !$seen{$_}++, @indices; + return @o; +} + +sub get_size { + my $self = shift; + my $entry = shift; + my $entrypat = $entry; + $entrypat =~ s/\./\\\./g; + my @entries = grep { + /^$entrypat/ + } keys %{$NWC::Device::rawdata}; + return scalar(@entries); +} + +sub get_object { + my $self = shift; + my $object = shift; + my @indices = @_; + #my $oid = $object.'.'.join('.', @indices); + my $oid = $object; + $oid .= '.'.join('.', @indices) if (@indices); + return $NWC::Device::rawdata->{$oid}; +} + +sub get_object_value { + my $self = shift; + my $object = shift; + my $values = shift; + my @indices = @_; + my $key = $self->get_object($object, @indices); + if (defined $key) { + return $values->{$key}; + } else { + return undef; + } +} + +#SNMP::Utils::counter([$idxs1, $idxs2], $idx1, $idx2), +# this flattens a n-dimensional array and returns the absolute position +# of the element at position idx1,idx2,...,idxn +# element 1,2 in table 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2 is at pos 6 +sub get_number { + my $self = shift; + my $indexlists = shift; #, zeiger auf array aus [1, 2] + my @element = @_; + my $dimensions = scalar(@{$indexlists->[0]}); + my @sorted = (); + my $number = 0; + if ($dimensions == 1) { + @sorted = + sort { $a->[0] <=> $b->[0] } @{$indexlists}; + } elsif ($dimensions == 2) { + @sorted = + sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } @{$indexlists}; + } elsif ($dimensions == 3) { + @sorted = + sort { $a->[0] <=> $b->[0] || + $a->[1] <=> $b->[1] || + $a->[2] <=> $b->[2] } @{$indexlists}; + } + foreach (@sorted) { + if ($dimensions == 1) { + if ($_->[0] == $element[0]) { + last; + } + } elsif ($dimensions == 2) { + if ($_->[0] == $element[0] && $_->[1] == $element[1]) { + last; + } + } elsif ($dimensions == 3) { + if ($_->[0] == $element[0] && + $_->[1] == $element[1] && + $_->[2] == $element[2]) { + last; + } + } + $number++; + } + return ++$number; +} + +sub mib { + my $self = shift; + my $mib = shift; + my $condition = { + 0 => 'other', + 1 => 'ok', + 2 => 'degraded', + 3 => 'failed', + }; + my $MibRevMajor = $mib.'.1.0'; + my $MibRevMinor = $mib.'.2.0'; + my $MibRevCondition = $mib.'.3.0'; + return ( + $self->SNMP::Utils::get_object($MibRevMajor), + $self->SNMP::Utils::get_object($MibRevMinor), + $self->SNMP::Utils::get_object_value($MibRevCondition, $condition)); +}; + +1; diff --git a/plugins-scripts/NWC/MIBII.pm b/plugins-scripts/NWC/MIBII.pm new file mode 100644 index 00000000..343bc255 --- /dev/null +++ b/plugins-scripts/NWC/MIBII.pm @@ -0,0 +1,8 @@ +package NWC::MIBII; + +use strict; + +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +our @ISA = qw(NWC::Device); + diff --git a/plugins-scripts/NWC/MIBII/Component/InterfaceSubsystem.pm b/plugins-scripts/NWC/MIBII/Component/InterfaceSubsystem.pm new file mode 100644 index 00000000..01fbdf61 --- /dev/null +++ b/plugins-scripts/NWC/MIBII/Component/InterfaceSubsystem.pm @@ -0,0 +1,309 @@ +package NWC::MIBII::Component::InterfaceSubsystem; +our @ISA = qw(NWC::MIBII); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + interface_indices => [], + interfaces => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + my $snmpwalk = $params{rawdata}; + my $oids = { + ifTable => '1.3.6.1.2.1.2.2', + ifEntry => '1.3.6.1.2.1.2.2.1', + ifIndex => '1.3.6.1.2.1.2.2.1.1', + ifDescr => '1.3.6.1.2.1.2.2.1.2', + ifType => '1.3.6.1.2.1.2.2.1.3', + ifMtu => '1.3.6.1.2.1.2.2.1.4', + ifSpeed => '1.3.6.1.2.1.2.2.1.5', + ifPhysAddress => '1.3.6.1.2.1.2.2.1.6', + ifAdminStatus => '1.3.6.1.2.1.2.2.1.7', + ifOperStatus => '1.3.6.1.2.1.2.2.1.8', + ifLastChange => '1.3.6.1.2.1.2.2.1.9', + ifInOctets => '1.3.6.1.2.1.2.2.1.10', + ifInUcastPkts => '1.3.6.1.2.1.2.2.1.11', + ifInNUcastPkts => '1.3.6.1.2.1.2.2.1.12', + ifInDiscards => '1.3.6.1.2.1.2.2.1.13', + ifInErrors => '1.3.6.1.2.1.2.2.1.14', + ifInUnknownProtos => '1.3.6.1.2.1.2.2.1.15', + ifOutOctets => '1.3.6.1.2.1.2.2.1.16', + ifOutUcastPkts => '1.3.6.1.2.1.2.2.1.17', + ifOutNUcastPkts => '1.3.6.1.2.1.2.2.1.18', + ifOutDiscards => '1.3.6.1.2.1.2.2.1.19', + ifOutErrors => '1.3.6.1.2.1.2.2.1.20', + ifOutQLen => '1.3.6.1.2.1.2.2.1.21', + ifSpecific => '1.3.6.1.2.1.2.2.1.22', + ifAdminStatusValue => { + 1 => 'up', + 2 => 'down', + 3 => 'testing', + }, + ifOperStatusValue => { + 1 => 'up', + 2 => 'down', + 3 => 'testing', + 4 => 'unknown', + 5 => 'dormant', + 6 => 'notPresent', + 7 => 'lowerLayerDown', + }, + }; + # INDEX { ifIndex } + my $index_cache = {}; + foreach ($self->get_entries($oids, 'ifEntry')) { + next if $self->opts->can('name') && $self->opts->name && + $self->opts->name ne $_->{ifDescr}; + push(@{$self->{interfaces}}, + NWC::MIBII::Component::InterfaceSubsystem::Interface->new(%{$_})); + $index_cache->{$_->{ifIndex}} = $_->{ifDescr}; + } +} + +sub check { + my $self = shift; + my $errorfound = 0; + $self->add_info('checking interfaces'); + $self->blacklist('ff', ''); + if (scalar (@{$self->{interfaces}}) == 0) { + } else { + foreach (@{$self->{interfaces}}) { + $_->check(); + } + } +} + + +sub dump { + my $self = shift; + foreach (@{$self->{interfaces}}) { + $_->dump(); + } +} + + +package NWC::MIBII::Component::InterfaceSubsystem::Interface; +our @ISA = qw(NWC::MIBII::Component::InterfaceSubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + ifTable => $params{ifTable}, + ifEntry => $params{ifEntry}, + ifIndex => $params{ifIndex}, + ifDescr => $params{ifDescr}, + ifType => $params{ifType}, + ifMtu => $params{ifMtu}, + ifSpeed => $params{ifSpeed}, + ifPhysAddress => $params{ifPhysAddress}, + ifAdminStatus => $params{ifAdminStatus}, + ifOperStatus => $params{ifOperStatus}, + ifLastChange => $params{ifLastChange}, + ifInOctets => $params{ifInOctets}, + ifInUcastPkts => $params{ifInUcastPkts}, + ifInNUcastPkts => $params{ifInNUcastPkts}, + ifInDiscards => $params{ifInDiscards}, + ifInErrors => $params{ifInErrors}, + ifInUnknownProtos => $params{ifInUnknownProtos}, + ifOutOctets => $params{ifOutOctets}, + ifOutUcastPkts => $params{ifOutUcastPkts}, + ifOutNUcastPkts => $params{ifOutNUcastPkts}, + ifOutDiscards => $params{ifOutDiscards}, + ifOutErrors => $params{ifOutErrors}, + ifOutQLen => $params{ifOutQLen}, + ifSpecific => $params{ifSpecific}, + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + if ($self->mode =~ /device::interfaces::traffic/) { + $self->valdiff({name => $self->{ifDescr}}, qw(ifInOctets ifInUcastPkts ifInNUcastPkts ifInDiscards ifInErrors ifInUnknownProtos ifOutOctets ifOutUcastPkts ifOutNUcastPkts ifOutDiscards ifOutErrors)); + } elsif ($self->mode =~ /device::interfaces::usage/) { + $self->valdiff({name => $self->{ifDescr}}, qw(ifInOctets ifOutOctets)); + $self->{inputUtilization} = $self->{delta_ifInOctets} * 8 * 100 / + ($self->{delta_timestamp} * $self->{ifSpeed}); + $self->{outputUtilization} = $self->{delta_ifOutOctets} * 8 * 100 / + ($self->{delta_timestamp} * $self->{ifSpeed}); + $self->{inputRate} = $self->{delta_ifInOctets} / $self->{delta_timestamp}; + $self->{outputRate} = $self->{delta_ifOutOctets} / $self->{delta_timestamp}; + my $factor = 1/8; # default Bits + if ($self->opts->units) { + if ($self->opts->units eq "GB") { + $factor = 1024 * 1024 * 1024; + } elsif ($self->opts->units eq "MB") { + $factor = 1024 * 1024; + } elsif ($self->opts->units eq "KB") { + $factor = 1024; + } elsif ($self->opts->units eq "B") { + $factor = 1; + } elsif ($self->opts->units eq "Bit") { + $factor = 1/8; + } + } + $self->{inputRate} /= $factor; + $self->{outputRate} /= $factor; + } elsif ($self->mode =~ /device::interfaces::errors/) { + $self->valdiff({name => $self->{ifDescr}}, qw(ifInErrors ifOutErrors ifInDiscards ifOutDiscards)); + $self->{inputErrorRate} = $self->{delta_ifInErrors} + / $self->{delta_timestamp}; + $self->{outputErrorRate} = $self->{delta_ifOutErrors} + / $self->{delta_timestamp}; + $self->{inputDiscardRate} = $self->{delta_ifInDiscards} + / $self->{delta_timestamp}; + $self->{outputDiscardRate} = $self->{delta_ifOutDiscards} + / $self->{delta_timestamp}; + $self->{inputRate} = ($self->{delta_ifInErrors} + $self->{delta_ifInDiscards}) + / $self->{delta_timestamp}; + $self->{outputRate} = ($self->{delta_ifOutErrors} + $self->{delta_ifOutDiscards}) + / $self->{delta_timestamp}; + } elsif ($self->mode =~ /device::interfaces::operstatus/) { + } + return $self; +} + +sub check { + my $self = shift; + $self->blacklist('if', $self->{ifIndex}); + if ($self->mode =~ /device::interfaces::traffic/) { + } elsif ($self->mode =~ /device::interfaces::usage/) { + my $info = sprintf 'interface %s usage is in:%.2f%% (%s) out:%.2f%% (%s)', + $self->{ifDescr}, + $self->{inputUtilization}, + sprintf("%.2f%s/s", $self->{inputRate}, + ($self->opts->units ? $self->opts->units : 'Bits')), + $self->{outputUtilization}, + sprintf("%.2f%s/s", $self->{outputRate}, + ($self->opts->units ? $self->opts->units : 'Bits')); + $self->add_info($info); + $self->set_thresholds(warning => 80, critical => 90); + my $in = $self->check_thresholds($self->{inputUtilization}); + my $out = $self->check_thresholds($self->{outputUtilization}); + my $level = ($in > $out) ? $in : ($out > $in) ? $out : $in; + $self->add_message($level, $info); + $self->add_perfdata( + label => $self->{ifDescr}.'_usage_in', + value => $self->{inputUtilization}, + uom => '%', + warning => $self->{warning}, + critical => $self->{critical}, + ); + $self->add_perfdata( + label => $self->{ifDescr}.'_usage_out', + value => $self->{outputUtilization}, + uom => '%', + warning => $self->{warning}, + critical => $self->{critical}, + ); + $self->add_perfdata( + label => $self->{ifDescr}.'_traffic_in', + value => $self->{inputRate}, + uom => $self->opts->units, + ); + $self->add_perfdata( + label => $self->{ifDescr}.'_traffic_out', + value => $self->{outputRate}, + uom => $self->opts->units, + ); + } elsif ($self->mode =~ /device::interfaces::errors/) { + my $info = sprintf 'interface %s errors in:%.2f/s out:%.2f/s '. + 'discards in:%.2f/s out:%.2f/s', + $self->{ifDescr}, + $self->{inputErrorRate} , $self->{outputErrorRate}, + $self->{inputDiscardRate} , $self->{outputDiscardRate}; + $self->add_info($info); + $self->set_thresholds(warning => 1, critical => 10); + my $in = $self->check_thresholds($self->{inputRate}); + my $out = $self->check_thresholds($self->{outputRate}); + my $level = ($in > $out) ? $in : ($out > $in) ? $out : $in; + $self->add_message($level, $info); + $self->add_perfdata( + label => $self->{ifDescr}.'_errors_in', + value => $self->{inputErrorRate}, + uom => '%', + warning => $self->{warning}, + critical => $self->{critical}, + ); + $self->add_perfdata( + label => $self->{ifDescr}.'_errors_out', + value => $self->{outputErrorRate}, + uom => '%', + warning => $self->{warning}, + critical => $self->{critical}, + ); + $self->add_perfdata( + label => $self->{ifDescr}.'_discards_in', + value => $self->{inputDiscardRate}, + uom => $self->opts->units, + warning => $self->{warning}, + critical => $self->{critical}, + ); + $self->add_perfdata( + label => $self->{ifDescr}.'_discards_out', + value => $self->{outputDiscardRate}, + uom => $self->opts->units, + warning => $self->{warning}, + critical => $self->{critical}, + ); + } elsif ($self->mode =~ /device::interfaces::operstatus/) { + #rfc2863 + #(1) if ifAdminStatus is not down and ifOperStatus is down then a + # fault condition is presumed to exist on the interface. + #(2) if ifAdminStatus is down, then ifOperStatus will normally also + # be down (or notPresent) i.e., there is not (necessarily) a + # fault condition on the interface. + # --warning onu,anu + # Admin: admindown,admin + # Admin: --warning + # --critical admindown +# if ($self->opts->critical) { +# if ($self->opts->critical =~ /^u/) { +# } elsif ($self->opts->critical =~ /^u/) { +# } +# } +# if ($self->{ifOperStatus} ne 'up') { +# } +# } + my $info = sprintf '%s is %s/%s', + $self->{ifDescr}, $self->{ifOperStatus}, $self->{ifAdminStatus}; + $self->add_info($info); + $self->add_message(OK, $info); + if ($self->{ifOperStatus} eq 'down' && $self->{ifAdminStatus} ne 'down') { + $self->add_message(CRITICAL, + sprintf 'fault condition is presumed to exist on %s', + $self->{ifDescr}); + } + } +} + +sub dump { + my $self = shift; + printf "[IF_%s]\n", $self->{ifIndex}; + foreach (qw(ifIndex ifDescr ifType ifMtu ifSpeed ifPhysAddress ifAdminStatus ifOperStatus ifLastChange ifInOctets ifInUcastPkts ifInNUcastPkts ifInDiscards ifInErrors ifInUnknownProtos ifOutOctets ifOutUcastPkts ifOutNUcastPkts ifOutDiscards ifOutErrors ifOutQLen ifSpecific)) { + printf "%s: %s\n", $_, $self->{$_}; + } + printf "info: %s\n", $self->{info}; + printf "\n"; +} + diff --git a/plugins-scripts/Nagios/MiniPlugin.pm b/plugins-scripts/Nagios/MiniPlugin.pm new file mode 100644 index 00000000..802816d1 --- /dev/null +++ b/plugins-scripts/Nagios/MiniPlugin.pm @@ -0,0 +1,396 @@ +package Nagios::MiniPlugin; + +use strict; +use Getopt::Long qw(:config no_ignore_case bundling); + +our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); + +require Exporter; +our @ISA = qw(Exporter); +our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); +our @EXPORT_OK = qw(%ERRORS); + +use constant OK => 0; +use constant WARNING => 1; +use constant CRITICAL => 2; +use constant UNKNOWN => 3; +use constant DEPENDENT => 4; + +our %ERRORS = ( + 'OK' => OK, + 'WARNING' => WARNING, + 'CRITICAL' => CRITICAL, + 'UNKNOWN' => UNKNOWN, + 'DEPENDENT' => DEPENDENT, +); + +our %STATUS_TEXT = reverse %ERRORS; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + perfdata => [], + messages => { + ok => [], + warning => [], + critical => [], + unknown => [], + }, + args => [], + opts => Nagios::MiniPlugin::Getopt->new(%params), + }; + foreach (qw(shortname usage version url plugin blurb extra + license timeout)) { + $self->{$_} = $params{$_}; + } + bless $self, $class; +} + +sub add_arg { + my $self = shift; + $self->{opts}->add_arg(@_); +} + +sub getopts { + my $self = shift; + $self->{opts}->getopts(); +} + +sub override_opt { + my $self = shift; + $self->{opts}->override_opt(@_); +} + +sub opts { + my $self = shift; + return $self->{opts}; +} + +sub add_message { + my $self = shift; + my ($code, @messages) = @_; + $code = (qw(ok warning critical unknown))[$code] if $code =~ /^\d+$/; + $code = lc $code; + push @{$self->{messages}->{$code}}, @messages; +} + +sub add_perfdata { + my ($self, %args) = @_; + #if ($args{label} =~ /\s/) { + $args{label} = '\''.$args{label}.'\''; + #} + if (! exists $args{places}) { + $args{places} = 2; + } + my $format = '%d'; + if ($args{value} =~ /\./) { + $format = '%.'.$args{places}.'f'; + } + my $str = $args{label}.'='.sprintf $format, $args{value}; + if ($args{uom}) { + $str .= $args{uom}; + } + if ($args{warning}) { + $str .= ';'.$args{warning}; + } + if ($args{critical}) { + $str .= ';'.$args{critical}; + } + push @{$self->{perfdata}}, $str; +} + + +sub check_messages { + my $self = shift; + my %args = @_; + + # Add object messages to any passed in as args + for my $code (qw(critical warning unknown ok)) { + my $messages = $self->{messages}->{$code} || []; + if ($args{$code}) { + unless (ref $args{$code} eq 'ARRAY') { + if ($code eq 'ok') { + $args{$code} = [ $args{$code} ]; + } + } + push @{$args{$code}}, @$messages; + } else { + $args{$code} = $messages; + } + } + my %arg = %args; + $arg{join} = ' ' unless defined $arg{join}; + + # Decide $code + my $code = OK; + $code ||= CRITICAL if @{$arg{critical}}; + $code ||= WARNING if @{$arg{warning}}; + $code ||= UNKNOWN if @{$arg{unknown}}; + return $code unless wantarray; + + # Compose message + my $message = ''; + if ($arg{join_all}) { + $message = join( $arg{join_all}, + map { @$_ ? join( $arg{'join'}, @$_) : () } + $arg{critical}, + $arg{warning}, + $arg{unknown}, + $arg{ok} ? (ref $arg{ok} ? $arg{ok} : [ $arg{ok} ]) : [] + ); + } + + else { + $message ||= join( $arg{'join'}, @{$arg{critical}} ) + if $code == CRITICAL; + $message ||= join( $arg{'join'}, @{$arg{warning}} ) + if $code == WARNING; + $message ||= join( $arg{'join'}, @{$arg{unknown}} ) + if $code == UNKNOWN; + $message ||= ref $arg{ok} ? join( $arg{'join'}, @{$arg{ok}} ) : $arg{ok} + if $arg{ok}; + } + + return ($code, $message); +} + +sub nagios_exit { + my $self = shift; + my ($code, $message, $arg) = @_; + $code = $ERRORS{$code} if defined $code && exists $ERRORS{$code}; + $code = UNKNOWN unless defined $code && exists $STATUS_TEXT{$code}; + $message = '' unless defined $message; + if (ref $message && ref $message eq 'ARRAY') { + $message = join(' ', map { chomp; $_ } @$message); + } else { + chomp $message; + } + my $output = "$STATUS_TEXT{$code}"; + $output .= " - $message" if defined $message && $message ne ''; + if (scalar (@{$self->{perfdata}})) { + $output .= " | ".join(" ", @{$self->{perfdata}}); + } + $output .= "\n"; + print $output; + exit $code; +} + +sub set_thresholds { + my $self = shift; + my %params = @_; + $self->{mywarning} = $self->opts->warning || $params{warning} || 0; + $self->{mycritical} = $self->opts->critical || $params{critical} || 0; +} + +sub get_thresholds { + my $self = shift; + return ($self->{mywarning}, $self->{mycritical}); +} + +sub check_thresholds { + my $self = shift; + my $value; + my $level = $ERRORS{OK}; + my $warningrange; + my $criticalrange; + if (scalar(@_) > 1) { + my %params = @_; + $value = $params{check}; + $warningrange = (defined $params{warning}) ? + $params{warning} : $self->{mywarning}; + $criticalrange = (defined $params{critical}) ? + $params{critical} : $self->{mycritical}; + } else { + $value = $_; + $warningrange = $self->{mywarning}; + $criticalrange = $self->{mycritical}; + } + if ($warningrange !~ /:/ && $criticalrange !~ /:/) { + # warning = 10, critical = 20, warn if > 10, crit if > 20 + $level = $ERRORS{WARNING} if $value > $warningrange; + $level = $ERRORS{CRITICAL} if $value > $criticalrange; + } elsif ($warningrange =~ /(\d+):/ && + $criticalrange =~ /(\d+):/) { + # warning = 98:, critical = 95:, warn if < 98, crit if < 95 + $warningrange =~ /(\d+):/; + $level = $ERRORS{WARNING} if $value < $1; + $criticalrange =~ /(\d+):/; + $level = $ERRORS{CRITICAL} if $value < $1; + } + return $level; + # + # syntax error must be reported with returncode -1 + # +} + + +package Nagios::MiniPlugin::Getopt; + +use strict; +use File::Basename; +use Data::Dumper; +use Getopt::Long qw(:config no_ignore_case bundling); + +# Standard defaults +my %DEFAULT = ( + timeout => 15, + verbose => 0, + license => +"This nagios plugin is free software, and comes with ABSOLUTELY NO WARRANTY. +It may be used, redistributed and/or modified under the terms of the GNU +General Public Licence (see http://www.fsf.org/licensing/licenses/gpl.txt).", +); +# Standard arguments +my @ARGS = ({ + spec => 'usage|?', + help => "-?, --usage\n Print usage information", + }, { + spec => 'help|h', + help => "-h, --help\n Print detailed help screen", + }, { + spec => 'version|V', + help => "-V, --version\n Print version information", + }, { + #spec => 'extra-opts:s@', + #help => "--extra-opts=[
[@]]\n Section and/or config_file from which to load extra options (may repeat)", + }, { + spec => 'timeout|t=i', + help => "-t, --timeout=INTEGER\n Seconds before plugin times out (default: %s)", + default => $DEFAULT{timeout}, + }, { + spec => 'verbose|v+', + help => "-v, --verbose\n Show details for command-line debugging (can repeat up to 3 times)", + default => $DEFAULT{verbose}, + }, +); +# Standard arguments we traditionally display last in the help output +my %DEFER_ARGS = map { $_ => 1 } qw(timeout verbose); + +sub _init +{ + my $self = shift; + my %params = @_; + # Check params + my $plugin = basename($ENV{NAGIOS_PLUGIN} || $0); + #my %attr = validate( @_, { + my %attr = ( + usage => 1, + version => 0, + url => 0, + plugin => { default => $plugin }, + blurb => 0, + extra => 0, + 'extra-opts' => 0, + license => { default => $DEFAULT{license} }, + timeout => { default => $DEFAULT{timeout} }, + ); + + # Add attr to private _attr hash (except timeout) + $self->{timeout} = delete $attr{timeout}; + $self->{_attr} = { %attr }; + foreach (keys %{$self->{_attr}}) { + if (exists $params{$_}) { + $self->{_attr}->{$_} = $params{$_}; + } else { + $self->{_attr}->{$_} = $self->{_attr}->{$_}->{default} + if ref ($self->{_attr}->{$_}) eq 'HASH' && + exists $self->{_attr}->{$_}->{default}; + } + } + # Chomp _attr values + chomp foreach values %{$self->{_attr}}; + + # Setup initial args list + $self->{_args} = [ grep { exists $_->{spec} } @ARGS ]; + + $self +} + +sub new +{ + my $class = shift; + my $self = bless {}, $class; + $self->_init(@_); +} + +sub add_arg { + my $self = shift; + my %arg = @_; + push (@{$self->{_args}}, \%arg); +} + +sub getopts { + my $self = shift; + my %commandline = (); + my @params = map { $_->{spec} } @{$self->{_args}}; + if (! GetOptions(\%commandline, @params)) { + $self->print_help(); + exit 0; + } else { + no strict 'refs'; + do { $self->print_help(); exit 0; } if $commandline{help}; + do { $self->print_version(); exit 0 } if $commandline{version}; + do { $self->print_usage(); exit 0 } if $commandline{usage}; + foreach (map { $_->{spec} =~ /^([\w\-]+)/; $1; } @{$self->{_args}}) { + my $field = $_; + *{"$field"} = sub { + return $self->{opts}->{$field}; + }; + } + foreach (grep { exists $_->{default} } @{$self->{_args}}) { + $_->{spec} =~ /^([\w\-]+)/; + my $spec = $1; + $self->{opts}->{$spec} = $_->{default}; + } + foreach (keys %commandline) { + $self->{opts}->{$_} = $commandline{$_}; + } + } +} + +sub override_opt { + my $self = shift; + my $key = shift; + my $value = shift; + $self->{opts}->{$key} = $value; +} + +sub get { + my $self = shift; + my $opt = shift; + return $self->{opts}->{$opt}; +} + +sub print_help { + my $self = shift; + $self->print_version(); + printf "\n%s\n", $self->{_attr}->{license}; + printf "\n%s\n\n", $self->{_attr}->{blurb}; + $self->print_usage(); + foreach (@{$self->{_args}}) { + printf " %s\n", $_->{help}; + } + exit 0; +} + +sub print_usage { + my $self = shift; + printf $self->{_attr}->{usage}, $self->{_attr}->{plugin}; + print "\n"; +} + +sub print_version { + my $self = shift; + printf "%s %s", $self->{_attr}->{plugin}, $self->{_attr}->{version}; + printf " [%s]", $self->{_attr}->{url} if $self->{_attr}->{url}; + print "\n"; +} + +sub print_license { + my $self = shift; + printf "%s\n", $self->{_attr}->{license}; + print "\n"; +} + +1; diff --git a/plugins-scripts/check_nwc_health.pl b/plugins-scripts/check_nwc_health.pl new file mode 100644 index 00000000..8ea88a57 --- /dev/null +++ b/plugins-scripts/check_nwc_health.pl @@ -0,0 +1,275 @@ +#! /usr/bin/perl + +use strict; + +my $CELSIUS = 1; +my $PERFDATA = 1; +my $EXTENDEDINFO = 1; +my $HWINFO = 1; +my $NOINSTLEVEL = 'unknown'; + +use constant OK => 0; +use constant WARNING => 1; +use constant CRITICAL => 2; +use constant UNKNOWN => 3; +use constant DEPENDENT => 4; + +my @modes = ( + ['device::hardware::health', + 'hardware-health', undef, + 'Check the status of environmental equipment (fans, temperatures, power)' ], + ['device::hardware::load', + 'cpu-load', undef, + 'Check the CPU load of the device' ], + ['device::hardware::memory', + 'memory-usage', undef, + 'Check the memory usage of the device' ], +# ['device::interfaces::traffic', +# 'interface-traffic', undef, +# 'Check the in- and outgoing traffic on interfaces' ], + ['device::interfaces::usage', + 'interface-usage', undef, + 'Check the utilization of interfaces' ], + ['device::interfaces::errors', + 'interface-errors', undef, + 'Check the error-rate of interfaces (errors+discards per sec)' ], + ['device::interfaces::operstatus', + 'interface-status', undef, + 'Check the status of interfaces' ], +); +my $modestring = ""; +my $longest = length ((reverse sort {length $a <=> length $b} map { $_->[1] } @modes)[0]); +my $format = " %-". + (length ((reverse sort {length $a <=> length $b} map { $_->[1] } @modes)[0])). + "s\t(%s)\n"; +foreach (@modes) { + $modestring .= sprintf $format, $_->[1], $_->[3]; +} +$modestring .= sprintf "\n"; + + +my $plugin = Nagios::MiniPlugin->new( + shortname => '', + usage => 'Usage: %s [ -v|--verbose ] [ -t ] '. + '--hostname --community '. + ' ...]', + version => '4.0', + blurb => 'This plugin checks various parameters of cisco network components ', + url => 'http://labs.consol.de/nagios/check_nwc_health', + timeout => 60, + shortname => '', +); +$plugin->add_arg( + spec => 'blacklist|b=s', + help => '--blacklist + Blacklist some (missing/failed) components', + required => 0, + default => '', +); +$plugin->add_arg( + spec => 'customthresholds|c=s', + help => '--customthresholds + Use custom thresholds for certain temperatures', + required => 0, +); +$plugin->add_arg( + spec => 'perfdata=s', + help => '--perfdata=[short] + Output performance data. If your performance data string becomes + too long and is truncated by Nagios, then you can use --perfdata=short + instead. This will output temperature tags without location information', + required => 0, +); +$plugin->add_arg( + spec => 'hostname|H=s', + help => '--hostname + Hostname or IP-address of the server (SNMP mode only)', + required => 0, +); +$plugin->add_arg( + spec => 'port=i', + help => '--port + The SNMP port to use (default: 161)', + required => 0, + default => 161, +); +$plugin->add_arg( + spec => 'protocol|P=s', + help => '--protocol + The SNMP protocol to use (default: 2c, other possibilities: 1,3)', + required => 0, + default => '2c', +); +$plugin->add_arg( + spec => 'community|C=s', + help => '--community + SNMP community of the server (SNMP v1/2 only)', + required => 0, + default => 'public', +); +$plugin->add_arg( + spec => 'username=s', + help => '--username + The securityName for the USM security model (SNMPv3 only)', + required => 0, +); +$plugin->add_arg( + spec => 'authpassword=s', + help => '--authpassword + The authentication password for SNMPv3', + required => 0, +); +$plugin->add_arg( + spec => 'authprotocol=s', + help => '--authprotocol + The authentication protocol for SNMPv3 (md5|sha)', + required => 0, +); +$plugin->add_arg( + spec => 'privpassword=s', + help => '--privpassword + The password for authPriv security level', + required => 0, +); +$plugin->add_arg( + spec => 'privprotocol=s', + help => '--privprotocol + The private protocol for SNMPv3 (des|aes|aes128|3des|3desde)', + required => 0, +); +$plugin->add_arg( + spec => 'snmpwalk=s', + help => '--snmpwalk + A file with the output of snmpwalk 1.3.6.1.4.1.232', + required => 0, +); +$plugin->add_arg( + spec => 'warning=s', + help => '--warning + The warning threshold', + required => 0, +); +$plugin->add_arg( + spec => 'mode=s', + help => "--mode + A keyword which tells the plugin what to do +$modestring", + required => 1, +); +$plugin->add_arg( + spec => 'name=s', + help => "--name + The name of an interface", + required => 0, +); +$plugin->add_arg( + spec => 'units=s', + help => "--units + One of %, KB, MB, GB", + required => 0, +); +$plugin->add_arg( + spec => 'critical=s', + help => '--warning + The critical threshold', + required => 0, +); +$plugin->add_arg( + spec => 'servertype=s', + help => '--servertype + The type of the server: proliant (default) or bladesystem', + required => 0, +); + +$plugin->getopts(); +if ($plugin->opts->community) { + if ($plugin->opts->community =~ /^snmpv3(.)(.+)/) { + my $separator = $1; + my ($authprotocol, $authpassword, $privprotocol, $privpassword, $username) = + split(/$separator/, $2); + $plugin->override_opt('authprotocol', $authprotocol) + if defined($authprotocol) && $authprotocol; + $plugin->override_opt('authpassword', $authpassword) + if defined($authpassword) && $authpassword; + $plugin->override_opt('privprotocol', $privprotocol) + if defined($privprotocol) && $privprotocol; + $plugin->override_opt('privpassword', $privpassword) + if defined($privpassword) && $privpassword; + $plugin->override_opt('username', $username) + if defined($username) && $username; + $plugin->override_opt('protocol', '3') ; + } +} +if (! $PERFDATA && $plugin->opts->get('perfdata')) { + $PERFDATA = 1; +} +if ($PERFDATA && $plugin->opts->get('perfdata') && + ($plugin->opts->get('perfdata') eq 'short')) { + $PERFDATA = 2; +} +$plugin->{messages}->{unknown} = []; # wg. add_message(UNKNOWN,...) + +$plugin->{info} = []; # gefrickel + +if ($plugin->opts->get('mode') =~ /^my-([^\-.]+)/) { + my $param = $plugin->opts->get('mode'); + $param =~ s/\-/::/g; + push(@modes, [$param, $plugin->opts->get('mode'), undef, 'my extension']); +} elsif ((! grep { $plugin->opts->get('mode') eq $_ } map { $_->[1] } @modes) && + (! grep { $plugin->opts->get('mode') eq $_ } map { defined $_->[2] ? @{$_->[2]} : () } @modes)) { + printf "UNKNOWN - mode %s\n", $plugin->opts->get('mode'); + $plugin->opts->print_help(); + exit 3; +} + +$SIG{'ALRM'} = sub { + printf "UNKNOWN - check_nwc_health timed out after %d seconds\n", + $plugin->opts->get('timeout'); + exit $ERRORS{UNKNOWN}; +}; +alarm($plugin->opts->get('timeout')); + +$NWC::Device::plugin = $plugin; +$NWC::Device::mode = ( + map { $_->[0] } + grep { + ($plugin->opts->get('mode') eq $_->[1]) || + ( defined $_->[2] && grep { $plugin->opts->get('mode') eq $_ } @{$_->[2]}) + } @modes +)[0]; +my $server = NWC::Device->new( runtime => { + + plugin => $plugin, + options => { + servertype => $plugin->opts->get('servertype'), + verbose => $plugin->opts->get('verbose'), + scrapiron => 0, + customthresholds => $plugin->opts->get('customthresholds'), + blacklist => $plugin->opts->get('blacklist'), + celsius => $CELSIUS, + perfdata => $PERFDATA, + extendedinfo => $EXTENDEDINFO, + hwinfo => $HWINFO, + noinstlevel => $NOINSTLEVEL, + }, +},); +#$server->dumper(); +if (! $plugin->check_messages()) { + $server->init(); + #$plugin->add_message(OK, $server->identify()) if $HWINFO; + if (! $plugin->check_messages()) { + $plugin->add_message(OK, 'hardware working fine'); + $plugin->add_message(OK, $server->get_summary()) + if $server->get_summary(); + $plugin->add_message(OK, $server->get_extendedinfo()) + if $server->get_extendedinfo(); + } +} else { + $plugin->add_message(CRITICAL, 'wrong device'); +} +my ($code, $message) = $plugin->check_messages(join => ', ', join_all => ', '); +$message .= sprintf "\n%s\n", join("\n", @{$NWC::Device::info}) + if $plugin->opts->get('verbose') >= 1; +#printf "%s\n", Data::Dumper::Dumper($plugin->{info}); +$plugin->nagios_exit($code, $message); + diff --git a/plugins-scripts/subst.in b/plugins-scripts/subst.in new file mode 100644 index 00000000..7ddb10cb --- /dev/null +++ b/plugins-scripts/subst.in @@ -0,0 +1,64 @@ +#!/usr/bin/awk + +function which(c,path) { + cmd = "test -x " c; + + if (system(cmd)==0) { + return c; + } + + sub(/\/.*\//,"",c); + for (dir in path) { + cmd = "test -x " path[dir] "/" c; + if (system(cmd)==0) { + return path[dir] "/" c; + } + } + + + return c; +} + +# used to replace "use lib utils.pm" with "use lib @libexecdir" +# +function led() { + led1 = "@libexecdir@"; + led2 = "@exec_prefix@"; + led3 = "@prefix@"; + if ( match(led1, /^\$\{exec_prefix\}/ ) != 0 ) { + return "\"" led3 "/libexec\" " ; + + } + return "\"" led1 "\"" ; +} + +BEGIN { + split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/); + +} + +# scripting language (first line) + +/^#! ?\/.*\/python/ {sub(/^#! ?\/.*\/python/,"#! @PYTHON@");} +/^#! ?\/.*\/perl/ {sub(/^#! ?\/.*\/perl/,"#! @PERL@");} +/^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! @AWK@");} +/^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! @SHELL@");} + +# add to libexecdir to INC for perl utils.pm +/^use/ { if (/lib/) { if (/utils.pm|"."/ ) {sub(/utils.pm|"."/,led() )} } } + + +# Replace the placeholders with the values from configure +/#PERL#/ {sub(/#PERL#/,"@PERL@");} +/my \$NOINSTLEVEL = 'unknown'/ {sub(/unknown/,"@NOINSTLEVEL@");} +/my \$CELSIUS = 1;/ {sub(/1/,"@CELSIUS@");} +/my \$PERFDATA = 1;/ {sub(/1/,"@PERFDATA@");} +/my \$EXTENDEDINFO = 1;/ {sub(/1/,"@EXTENDEDINFO@");} +/my \$HWINFO = 1;/ {sub(/1/,"@HWINFO@");} +/my \$HPACUCLI = 1;/ {sub(/1/,"@HPACUCLI@");} +/version => '.*',/ {sub(/'.*'/,"'@PACKAGE_VERSION@'");} + +{ + print; +} +