From 14365be2de14ce1bd3dc22e8ab556d872a13c733 Mon Sep 17 00:00:00 2001 From: Pall Sigurdsson Date: Tue, 27 Sep 2011 14:40:29 +0000 Subject: [PATCH] check_mssql health added --- check_mssql_health/LICENSE | 674 +++ check_mssql_health/README | 8 + check_mssql_health/check_mssql_dbsize | 95 + check_mssql_health/check_mssql_health | 3156 ++++++++++++++ check_mssql_health/nagios-okplugin-mssql.spec | 43 + .../src/check_mssql_health-1.5.8.2/AUTHORS | 1 + .../src/check_mssql_health-1.5.8.2/COPYING | 340 ++ .../src/check_mssql_health-1.5.8.2/ChangeLog | 67 + .../src/check_mssql_health-1.5.8.2/INSTALL | 229 ++ .../src/check_mssql_health-1.5.8.2/Makefile | 575 +++ .../check_mssql_health-1.5.8.2/Makefile.am | 13 + .../check_mssql_health-1.5.8.2/Makefile.in | 575 +++ .../src/check_mssql_health-1.5.8.2/NEWS | 0 .../src/check_mssql_health-1.5.8.2/README | 179 + .../src/check_mssql_health-1.5.8.2/TODO | 1 + .../check_mssql_health-1.5.8.2/acinclude.m4 | 78 + .../src/check_mssql_health-1.5.8.2/aclocal.m4 | 559 +++ .../check_mssql_health-1.5.8.2/config.guess | 1432 +++++++ .../src/check_mssql_health-1.5.8.2/config.log | 244 ++ .../check_mssql_health-1.5.8.2/config.status | 753 ++++ .../src/check_mssql_health-1.5.8.2/config.sub | 1534 +++++++ .../src/check_mssql_health-1.5.8.2/configure | 3296 +++++++++++++++ .../check_mssql_health-1.5.8.2/configure.in | 101 + .../contrib/README.formula | 73 + .../contrib/check_mssql_health.php | 526 +++ .../contrib/create_user.sql | 68 + .../contrib/delete_user.sql | 30 + .../src/check_mssql_health-1.5.8.2/install-sh | 295 ++ .../src/check_mssql_health-1.5.8.2/missing | 360 ++ .../plugins-scripts/Makefile | 358 ++ .../plugins-scripts/Makefile.am | 51 + .../plugins-scripts/Makefile.in | 358 ++ .../Nagios/DBD/MSSQL/Server.pm | 2056 +++++++++ .../Nagios/DBD/MSSQL/Server/Database.pm | 471 +++ .../DBD/MSSQL/Server/Database/Datafile.pm | 202 + .../Nagios/DBD/MSSQL/Server/Memorypool.pm | 333 ++ .../plugins-scripts/Nagios/Extraopts.pm | 103 + .../plugins-scripts/check_mssql_health | 3664 +++++++++++++++++ .../plugins-scripts/check_mssql_health.pl | 527 +++ .../plugins-scripts/subst | 61 + .../plugins-scripts/subst.in | 61 + .../src/check_mssql_health-1.5.8.2/t/Makefile | 297 ++ .../check_mssql_health-1.5.8.2/t/Makefile.am | 21 + .../check_mssql_health-1.5.8.2/t/Makefile.in | 297 ++ .../t/check_mssql_health.t | 485 +++ 45 files changed, 24650 insertions(+) create mode 100644 check_mssql_health/LICENSE create mode 100644 check_mssql_health/README create mode 100644 check_mssql_health/check_mssql_dbsize create mode 100644 check_mssql_health/check_mssql_health create mode 100644 check_mssql_health/nagios-okplugin-mssql.spec create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/AUTHORS create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/COPYING create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/ChangeLog create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/INSTALL create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.am create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.in create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/NEWS create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/README create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/TODO create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/acinclude.m4 create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/aclocal.m4 create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/config.guess create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/config.log create mode 100755 check_mssql_health/src/check_mssql_health-1.5.8.2/config.status create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/config.sub create mode 100755 check_mssql_health/src/check_mssql_health-1.5.8.2/configure create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/configure.in create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/README.formula create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/check_mssql_health.php create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/create_user.sql create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/delete_user.sql create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/missing create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.am create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.in create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server.pm create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database.pm create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database/Datafile.pm create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Memorypool.pm create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/Extraopts.pm create mode 100755 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health.pl create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst.in create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.am create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.in create mode 100644 check_mssql_health/src/check_mssql_health-1.5.8.2/t/check_mssql_health.t diff --git a/check_mssql_health/LICENSE b/check_mssql_health/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/check_mssql_health/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. 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 +them 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 prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. 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. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey 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; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + 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. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +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. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + 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 +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 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, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program 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, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/check_mssql_health/README b/check_mssql_health/README new file mode 100644 index 0000000..9202eeb --- /dev/null +++ b/check_mssql_health/README @@ -0,0 +1,8 @@ +check_mssql_dbsize + +Returns the total number of databases and perfdata pertaining size + +check_mssql_health + +checks a bunch of variables and can execute custom queries into MS-SQL +databases. diff --git a/check_mssql_health/check_mssql_dbsize b/check_mssql_health/check_mssql_dbsize new file mode 100644 index 0000000..8fbe478 --- /dev/null +++ b/check_mssql_health/check_mssql_dbsize @@ -0,0 +1,95 @@ +#!/usr/bin/perl -w +# +# check_mssql_dbsize 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 3 of the License, or +# (at your option) any later version. +# +# check_mssql_dbsize 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, see . +# +# +# This script will check MSSQL Database size via check_nrpe and NSclient. returns performance data in Nagios format +# Author Pall Sigurdsson +# + +use strict; +use Nagios::Plugin; + + +my $np = Nagios::Plugin->new( + usage => "Usage: %s " ); + +$np->add_arg( + spec => 'debug|d=i', + help => '-d, --debug=INTEGER', +); + +$np->getopts; + +my $NRPECMD = "/usr/lib/nagios/plugins/check_nrpe"; + +if (@ARGV < 1) { + usage(); + exit 3; +} + +my $HOSTNAME=$ARGV[0]; + + +my $databases = nrpeexec("-H $HOSTNAME -t 60 -c listCounterInstances -a 'SQLServer:Databases'"); +my @array1 = split(/\,/, $databases); + + +my $num_databases = 0; +foreach my $database (@array1) +{ + # Strip whitespace + $database =~ s/^\s*(.*?)\s*$/$1/; + + # Call check_nrpe + my $dbSize = nrpeexec("-H $HOSTNAME -t 60 -c CheckCounter -a 'Counter:$database=\\SQLServer:Databases($database)\\Data File(s) Size (KB)'"); + + # Strip everything but the performance data + $dbSize =~ s/^.*\|(.*?)$/$1/; + chomp($dbSize); + $np->add_perfdata($dbSize); + $num_databases = $num_databases + 1; +} + +$np->nagios_exit( OK, "$num_databases databases found in $HOSTNAME"); + + + +sub usage { + print <<" EOUSAGE"; +Usage $0 + EOUSAGE +} + + + +# Execute NRPE with some error handling +sub nrpeexec { + my @args = @_; + + my $output = ''; + if (open NRPE, "$NRPECMD " . join(' ',@args) . ' 2>&1 |') { + $output .= $_ while(); + close NRPE; + } + my $ret = $? >> 8; + # No such file or directory + if ($ret == 127) { + $np->nagios_die("Cannot execute $NRPECMD command missing"); + # Some other error + } elsif ($ret != 0) { + $np->nagios_die("Cannot execute $NRPECMD: $!"); + } + return $output; +} diff --git a/check_mssql_health/check_mssql_health b/check_mssql_health/check_mssql_health new file mode 100644 index 0000000..8edcc11 --- /dev/null +++ b/check_mssql_health/check_mssql_health @@ -0,0 +1,3156 @@ +#! /usr/bin/perl -w + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); +package DBD::MSSQL::Server::Memorypool; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + buffercache => undef, + procedurecache => undef, + locks => [], + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::buffercache/) { + $self->{buffercache} = DBD::MSSQL::Server::Memorypool::BufferCache->new( + %params); + } elsif ($params{mode} =~ /server::memorypool::procedurecache/) { + $self->{procedurecache} = DBD::MSSQL::Server::Memorypool::ProcedureCache->new( + %params); + } elsif ($params{mode} =~ /server::memorypool::lock/) { + DBD::MSSQL::Server::Memorypool::Lock::init_locks(%params); + if (my @locks = DBD::MSSQL::Server::Memorypool::Lock::return_locks()) { + $self->{locks} = \@locks; + } else { + $self->add_nagios_critical("unable to aquire lock info"); + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if ($params{mode} =~ /server::memorypool::buffercache/) { + $self->{buffercache}->nagios(%params); + $self->merge_nagios($self->{buffercache}); + } elsif ($params{mode} =~ /^server::memorypool::lock::listlocks/) { + foreach (sort { $a->{name} cmp $b->{name}; } @{$self->{locks}}) { + printf "%s\n", $_->{name}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::memorypool::lock/) { + foreach (@{$self->{locks}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } +} + + +package DBD::MSSQL::Server::Memorypool::BufferCache; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server::Memorypool); + + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + hitratio => undef, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::buffercache::hitratio/) { + # -- (a.cntr_value * 1.0 / b.cntr_value) * 100.0 [BufferCacheHitRatio] + $self->{cnt_hitratio} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Buffer cache hit ratio"); + $self->{cnt_hitratio_base} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Buffer cache hit ratio base"); + if (! defined $self->{cnt_hitratio}) { + $self->add_nagios_unknown("unable to aquire buffer cache data"); + } else { + # das kracht weil teilweise negativ + #$self->valdiff(\%params, qw(cnt_hitratio cnt_hitratio_base)); + $self->{hitratio} = ($self->{cnt_hitratio_base} == 0) ? + 100 : $self->{cnt_hitratio} / $self->{cnt_hitratio_base} * 100.0; + # soll vorkommen..... + $self->{hitratio} = 100 if ($self->{hitratio} > 100); + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::lazywrites/) { + $self->{lazy_writes_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Lazy writes/sec"); + if (! defined $self->{lazy_writes_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(lazy_writes_s)); + $self->{lazy_writes_per_sec} = $self->{delta_lazy_writes_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::pagelifeexpectancy/) { + $self->{pagelifeexpectancy} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Page life expectancy"); + if (! defined $self->{pagelifeexpectancy}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::freeliststalls/) { + $self->{freeliststalls_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Free list stalls/sec"); + if (! defined $self->{freeliststalls_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(freeliststalls_s)); + $self->{freeliststalls_per_sec} = $self->{delta_freeliststalls_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::checkpointpages/) { + $self->{checkpointpages_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Checkpoint pages/sec"); + if (! defined $self->{checkpointpages_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(checkpointpages_s)); + $self->{checkpointpages_per_sec} = $self->{delta_checkpointpages_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::memorypool::buffercache::hitratio/) { + $self->add_nagios( + $self->check_thresholds($self->{hitratio}, '90:', '80:'), + sprintf "buffer cache hit ratio is %.2f%%", $self->{hitratio}); + $self->add_perfdata(sprintf "buffer_cache_hit_ratio=%.2f%%;%s;%s", + $self->{hitratio}, + $self->{warningrange}, $self->{criticalrange}); + #$self->add_perfdata(sprintf "buffer_cache_hit_ratio_now=%.2f%%", + # $self->{hitratio_now}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::lazywrites/) { + $self->add_nagios( + $self->check_thresholds($self->{lazy_writes_per_sec}, '20', '40'), + sprintf "%.2f lazy writes per second", $self->{lazy_writes_per_sec}); + $self->add_perfdata(sprintf "lazy_writes_per_sec=%.2f;%s;%s", + $self->{lazy_writes_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::pagelifeexpectancy/) { + $self->add_nagios( + $self->check_thresholds($self->{pagelifeexpectancy}, '300:', '180:'), + sprintf "page life expectancy is %d seconds", $self->{pagelifeexpectancy}); + $self->add_perfdata(sprintf "page_life_expectancy=%d;%s;%s", + $self->{pagelifeexpectancy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::freeliststalls/) { + $self->add_nagios( + $self->check_thresholds($self->{freeliststalls_per_sec}, '4', '10'), + sprintf "%.2f free list stalls per second", $self->{freeliststalls_per_sec}); + $self->add_perfdata(sprintf "free_list_stalls_per_sec=%.2f;%s;%s", + $self->{freeliststalls_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::checkpointpages/) { + $self->add_nagios( + $self->check_thresholds($self->{checkpointpages_per_sec}, '100', '500'), + sprintf "%.2f pages flushed per second", $self->{checkpointpages_per_sec}); + $self->add_perfdata(sprintf "checkpoint_pages_per_sec=%.2f;%s;%s", + $self->{checkpointpages_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + + + + + +package DBD::MSSQL::Server::Memorypool::Lock; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server::Memorypool); + + +{ + my @locks = (); + my $initerrors = undef; + + sub add_lock { + push(@locks, shift); + } + + sub return_locks { + return reverse + sort { $a->{name} cmp $b->{name} } @locks; + } + + sub init_locks { + my %params = @_; + my $num_locks = 0; + if (($params{mode} =~ /server::memorypool::lock::listlocks/) || + ($params{mode} =~ /server::memorypool::lock::waits/) || + ($params{mode} =~ /server::memorypool::lock::deadlocks/) || + ($params{mode} =~ /server::memorypool::lock::timeouts/)) { + my @lockresult = $params{handle}->get_instance_names( + 'SQLServer:Locks'); + foreach (@lockresult) { + my ($name) = @{$_}; + $name =~ s/\s*$//; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + my $lock = DBD::MSSQL::Server::Memorypool::Lock->new( + %thisparams); + add_lock($lock); + $num_locks++; + } + if (! $num_locks) { + $initerrors = 1; + return undef; + } + } + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + name => $params{name}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::lock::listlocks/) { + # name reicht + } elsif ($params{mode} =~ /server::memorypool::lock::waits/) { + $self->{lock_waits_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Lock Waits/sec", $self->{name}); + if (! defined $self->{lock_waits_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_waits_s)); + $self->{lock_waits_per_sec} = $self->{delta_lock_waits_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::memorypool::lock::timeouts/) { + $self->{lock_timeouts_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Lock Timeouts/sec", $self->{name}); + if (! defined $self->{lock_timeouts_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_timeouts_s)); + $self->{lock_timeouts_per_sec} = $self->{delta_lock_timeouts_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::memorypool::lock::deadlocks/) { + $self->{lock_deadlocks_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Number of Deadlocks/sec", $self->{name}); + if (! defined $self->{lock_deadlocks_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_deadlocks_s)); + $self->{lock_deadlocks_per_sec} = $self->{delta_lock_deadlocks_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::memorypool::lock::waits/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_waits_per_sec}, 100, 500), + sprintf "%.4f lock waits / sec for %s", + $self->{lock_waits_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_lock_waits_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_waits_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::memorypool::lock::timeouts/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_timeouts_per_sec}, 1, 5), + sprintf "%.4f lock timeouts / sec for %s", + $self->{lock_timeouts_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_lock_timeouts_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_timeouts_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::memorypool::lock::deadlocks/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_deadlocks_per_sec}, 1, 5), + sprintf "%.4f deadlocks / sec for %s", + $self->{lock_deadlocks_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_deadlocks_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_deadlocks_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + + +package DBD::MSSQL::Server::Memorypool::SystemLevelDataStructures::LockTable; +package DBD::MSSQL::Server::Memorypool::ProcedureCache; +package DBD::MSSQL::Server::Memorypool::LogCache; +package DBD::MSSQL::Server::Memorypool::SystemLevelDataStructures; +package DBD::MSSQL::Server::Database::Datafile; + +use strict; +use File::Basename; + +our @ISA = qw(DBD::MSSQL::Server::Database); + + +{ + my @datafiles = (); + my $initerrors = undef; + + sub add_datafile { + push(@datafiles, shift); + } + + sub return_datafiles { + return reverse + sort { $a->{logicalfilename} cmp $b->{logicalfilename} } @datafiles; + } + + sub clear_datafiles { + @datafiles = (); + } + + sub init_datafiles { + my %params = @_; + my $num_datafiles = 0; + if ($params{mode} =~ /server::database::datafile::listdatafiles/) { + my @datafileresults = $params{handle}->fetchall_array(q{ +DECLARE @DBInfo TABLE +( ServerName VARCHAR(100), +DatabaseName VARCHAR(100), +FileSizeMB INT, +LogicalFileName sysname, +PhysicalFileName NVARCHAR(520), +Status sysname, +Updateability sysname, +RecoveryMode sysname, +FreeSpaceMB INT, +FreeSpacePct VARCHAR(7), +FreeSpacePages INT, +PollDate datetime) + +DECLARE @command VARCHAR(5000) + +SELECT @command = 'Use [' + '?' + '] SELECT +@@servername as ServerName, +' + '''' + '?' + '''' + ' AS DatabaseName, +CAST(sysfiles.size/128.0 AS int) AS FileSize, +sysfiles.name AS LogicalFileName, sysfiles.filename AS PhysicalFileName, +CONVERT(sysname,DatabasePropertyEx(''?'',''Status'')) AS Status, +CONVERT(sysname,DatabasePropertyEx(''?'',''Updateability'')) AS Updateability, +CONVERT(sysname,DatabasePropertyEx(''?'',''Recovery'')) AS RecoveryMode, +CAST(sysfiles.size/128.0 - CAST(FILEPROPERTY(sysfiles.name, ' + '''' + + 'SpaceUsed' + '''' + ' ) AS int)/128.0 AS int) AS FreeSpaceMB, +CAST(100 * (CAST (((sysfiles.size/128.0 -CAST(FILEPROPERTY(sysfiles.name, +' + '''' + 'SpaceUsed' + '''' + ' ) AS int)/128.0)/(sysfiles.size/128.0)) +AS decimal(4,2))) AS varchar(8)) + ' + '''' + '%' + '''' + ' AS FreeSpacePct, +GETDATE() as PollDate FROM dbo.sysfiles' +INSERT INTO @DBInfo + (ServerName, + DatabaseName, + FileSizeMB, + LogicalFileName, + PhysicalFileName, + Status, + Updateability, + RecoveryMode, + FreeSpaceMB, + FreeSpacePct, + PollDate) +EXEC sp_MSForEachDB @command + +SELECT + ServerName, + DatabaseName, + FileSizeMB, + LogicalFileName, + PhysicalFileName, + Status, + Updateability, + RecoveryMode, + FreeSpaceMB, + FreeSpacePct, + PollDate +FROM @DBInfo +ORDER BY + ServerName, + DatabaseName + }); + if (DBD::MSSQL::Server::return_first_server()->windows_server()) { + fileparse_set_fstype("MSWin32"); + } + foreach (@datafileresults) { + my ($servername, $databasename, $filesizemb, $logicalfilename, + $physicalfilename, $status, $updateability, $recoverymode, + $freespacemb, $freespacepct, $polldate) = @{$_}; + next if $databasename ne $params{database}; + if ($params{regexp}) { + #next if $params{selectname} && + # (($name !~ /$params{selectname}/) && + # (basename($name) !~ /$params{selectname}/)); + next if $params{selectname} && + ($logicalfilename !~ /$params{selectname}/); + } else { + #next if $params{selectname} && + # ((lc $params{selectname} ne lc $name) && + # (lc $params{selectname} ne lc basename($name))); + next if $params{selectname} && + (lc $params{selectname} ne lc $logicalfilename); + } + my %thisparams = %params; + $thisparams{servername} = $servername; + $thisparams{databasename} = $databasename; + $thisparams{filesizemb} = $filesizemb; + $thisparams{logicalfilename} = $logicalfilename; + $thisparams{servername} = $servername; + $thisparams{status} = $status; + $thisparams{updateability} = $updateability; + $thisparams{recoverymode} = $recoverymode; + $thisparams{freespacemb} = $freespacemb; + $thisparams{freespacepct} = $freespacepct; + $thisparams{polldate} = $polldate; + my $datafile = + DBD::MSSQL::Server::Database::Datafile->new( + %thisparams); + add_datafile($datafile); + $num_datafiles++; + } + } + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + databasename => $params{databasename}, + filesizemb => $params{filesizemb}, + logicalfilename => $params{logicalfilename}, + physicalfilename => $params{physicalfilename}, + status => $params{status}, + updateability => $params{updateability}, + recoverymode => $params{recoverymode}, + freespacemb => $params{freespacemb}, + freespacepct => $params{freespacepct}, + freespacepages => $params{freespacepages}, + polldate => $params{polldate}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::database::iobalance/) { + if (! defined $self->{phyrds}) { + $self->add_nagios_critical(sprintf "unable to read datafile io %s", $@); + } else { + $params{differenciator} = $self->{path}; + $self->valdiff(\%params, qw(phyrds phywrts)); + $self->{io_total} = $self->{delta_phyrds} + $self->{delta_phywrts}; + } + } elsif ($params{mode} =~ /server::database::datafile::iotraffic/) { + if (! defined $self->{phyrds}) { + $self->add_nagios_critical(sprintf "unable to read datafile io %s", $@); + } else { + $params{differenciator} = $self->{path}; + $self->valdiff(\%params, qw(phyrds phywrts)); + $self->{io_total_per_sec} = ($self->{delta_phyrds} + $self->{delta_phywrts}) / + $self->{delta_timestamp}; + } + } +} + + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::database::datafile::iotraffic/) { + $self->add_nagios( + $self->check_thresholds($self->{io_total_per_sec}, "1000", "5000"), + sprintf ("%s: %.2f IO Operations per Second", + $self->{name}, $self->{io_total_per_sec})); + $self->add_perfdata(sprintf "'dbf_%s_io_total_per_sec'=%.2f;%d;%d", + $self->{name}, $self->{io_total_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + +package DBD::MSSQL::Server::Database; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + + +{ + my @databases = (); + my $initerrors = undef; + + sub add_database { + push(@databases, shift); + } + + sub return_databases { + return reverse + sort { $a->{name} cmp $b->{name} } @databases; + } + + sub init_databases { + my %params = @_; + my $num_databases = 0; + if (($params{mode} =~ /server::database::listdatabases/) || + ($params{mode} =~ /server::database::databasefree/) || + ($params{mode} =~ /server::database::lastbackup/) || + ($params{mode} =~ /server::database::transactions/) || + ($params{mode} =~ /server::database::datafile/)) { + my @databaseresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT name, database_id FROM master.sys.databases + }); + } else { + #@databaseresult = map { + # [ $_->[0], $_->[3] ] # only name, dbid + #} $params{handle}->fetchall_array(q{exec sp_helpdb}); + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT name, dbid FROM master.dbo.sysdatabases + }); + } + if ($params{mode} =~ /server::database::transactions/) { + push(@databaseresult, [ '_Total', 0 ]); + } + foreach (@databaseresult) { + my ($name, $id) = @{$_}; + next if $params{database} && $name ne $params{database}; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + $thisparams{id} = $id; + my $database = DBD::MSSQL::Server::Database->new( + %thisparams); + add_database($database); + $num_databases++; + } + if (! $num_databases) { + $initerrors = 1; + return undef; + } + } elsif ($params{mode} =~ /server::database::backupage/) { + my @databaseresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT + a.name, + DATEDIFF(HH, MAX(b.backup_finish_date), GETDATE()), + DATEDIFF(MI, MAX(b.backup_start_date), MAX(b.backup_finish_date)) + FROM sys.sysdatabases a LEFT OUTER JOIN msdb.dbo.backupset b + ON b.database_name = a.name + GROUP BY a.name + ORDER BY a.name + }); + } else { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT + a.name, + DATEDIFF(HH, MAX(b.backup_finish_date), GETDATE()), + DATEDIFF(MI, MAX(b.backup_start_date), MAX(b.backup_finish_date)) + FROM master.dbo.sysdatabases a LEFT OUTER JOIN msdb.dbo.backupset b + ON b.database_name = a.name + GROUP BY a.name + ORDER BY a.name + }); + } + foreach (sort { + if (! defined $b->[1]) { + return 1; + } elsif (! defined $a->[1]) { + return -1; + } else { + return $a->[1] <=> $b->[1]; + } + } @databaseresult) { + my ($name, $age, $duration) = @{$_}; + next if $params{database} && $name ne $params{database}; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + $thisparams{backup_age} = $age; + $thisparams{backup_duration} = $duration; + my $database = DBD::MSSQL::Server::Database->new( + %thisparams); + add_database($database); + $num_databases++; + } + } + + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + name => $params{name}, + id => $params{id}, + datafiles => [], + backup_age => $params{backup_age}, + backup_duration => $params{backup_duration}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::database::datafile/) { + $params{database} = $self->{name}; + DBD::MSSQL::Server::Database::Datafile::init_datafiles(%params); + if (my @datafiles = + DBD::MSSQL::Server::Database::Datafile::return_datafiles()) { + $self->{datafiles} = \@datafiles; + } else { + $self->add_nagios_critical("unable to aquire datafile info"); + } + } elsif ($params{mode} =~ /server::database::databasefree/) { + ################################################################################### + # fuer's museum + # 1> sp_spaceused + # 2> go + # database_name database_size unallocated space + # master 4.50 MB 1.32 MB + # reserved data index_size unused + # 2744 KB 1056 KB 1064 KB 624 KB + # (return status = 0) + #my($database_name, $database_size, $unallocated_space, + # $reserved, $data, $index_size, $unused) = + # $params{handle}->fetchrow_array( + # "USE ".$self->{name}."\nEXEC SP_SPACEUSED" + #); + # server mgmt studio sp_spaceused + # Currently Allocated Space database_size 641.94MB + # Available Free Space unallocated space 457.09MB + #$database_size =~ s/MB//g; + #$unallocated_space =~ s/MB//g; + #$self->{size} = $database_size * 1024 * 1024; + #$self->{free} = $unallocated_space * 1024 * 1024; + #$self->{percent_free} = $unallocated_space / $database_size * 100; + #$self->{used} = $self->{size} - $self->{free}; + #$self->{maxsize} = "99999999999999999"; + ################################################################################### + my $calc = {}; + $self->{handle}->execute(q{ + if object_id('tempdb..#FreeSpace') is null + create table #FreeSpace( + Drive varchar(10), + MB_Free bigint + ) + }); + $self->{handle}->execute(q{ + DELETE FROM #FreeSpace + }); + $self->{handle}->execute(q{ + INSERT INTO #FreeSpace exec master.dbo.xp_fixeddrives + }); + foreach($self->{handle}->fetchall_array(q{ + SELECT * FROM #FreeSpace + })) { + $calc->{drive_mb}->{lc $_->[0]} = $_->[1]; + } + #$self->{handle}->execute(q{ + # DROP TABLE #FreeSpace + #}); + # Page = 8KB + # sysfiles ist sv2000, noch als kompatibilitaetsview vorhanden + # dbo.sysfiles kann 2008 durch sys.database_files ersetzt werden? + # omeiomeiomei in 2005 ist ein sys.sysindexes compatibility view + # fuer 2000.dbo.sysindexes + # besser ist sys.allocation_units + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + my $sql = q{ + SELECT + SUM(CAST(used AS BIGINT)) / 128 + FROM + [?].sys.sysindexes + WHERE + indid IN (0,1,255) + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + $self->{used_mb} = $self->{handle}->fetchrow_array($sql); + } else { + my $sql = q{ + SELECT + SUM(CAST(used AS BIGINT)) / 128 + FROM + [?].dbo.sysindexes + WHERE + indid IN (0,1,255) + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + $self->{used_mb} = $self->{handle}->fetchrow_array($sql); + } + my @fileresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + my $sql = q{ + SELECT + RTRIM(a.name), RTRIM(a.filename), CAST(a.size AS BIGINT), + CAST(a.maxsize AS BIGINT), a.growth + FROM + [?].sys.sysfiles a + JOIN + [?].sys.sysfilegroups b + ON + a.groupid = b.groupid + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + @fileresult = $self->{handle}->fetchall_array($sql); + } else { + my $sql = q{ + SELECT + RTRIM(a.name), RTRIM(a.filename), CAST(a.size AS BIGINT), + CAST(a.maxsize AS BIGINT), a.growth + FROM + [?].dbo.sysfiles a + JOIN + [?].dbo.sysfilegroups b + ON + a.groupid = b.groupid + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + @fileresult = $self->{handle}->fetchall_array($sql); + } + foreach(@fileresult) { + my($name, $filename, $size, $maxsize, $growth) = @{$_}; + my $drive = lc substr($filename, 0, 1); + $calc->{datafile}->{$name}->{allocsize} = $size / 128; + if ($growth == 0) { + $calc->{datafile}->{$name}->{maxsize} = $size / 128; + } else { + if ($maxsize == -1) { + $calc->{datafile}->{$name}->{maxsize} = + exists $calc->{drive_mb}->{$drive} ? + ($calc->{datafile}->{$name}->{allocsize} + + $calc->{drive_mb}->{$drive}) : 4 * 1024; + # falls die platte nicht gefunden wurde, dann nimm halt 4GB + } else { + $calc->{datafile}->{$name}->{maxsize} = $maxsize / 128; + } + } + $self->{allocated_mb} += $calc->{datafile}->{$name}->{allocsize}; + $self->{max_mb} += $calc->{datafile}->{$name}->{maxsize}; + } + $self->{allocated_mb} = $self->{allocated_mb}; + if ($self->{used_mb} > $self->{allocated_mb}) { + # obige used-berechnung liefert manchmal (wenns knapp hergeht) mehr als + # den maximal verfuegbaren platz. vermutlich muessen dann + # zwecks ermittlung des tatsaechlichen platzverbrauchs + # irgendwelche dbcc updateusage laufen. + # egal, wird schon irgendwie stimmen. + $self->{used_mb} = $self->{allocated_mb}; + $self->{estimated} = 1; + } else { + $self->{estimated} = 0; + } + $self->{free_mb} = $self->{max_mb} - $self->{used_mb}; + $self->{free_percent} = 100 * $self->{free_mb} / $self->{max_mb}; + $self->{allocated_percent} = 100 * $self->{allocated_mb} / $self->{max_mb}; + } elsif ($params{mode} =~ /^server::database::transactions/) { + $self->{transactions_s} = $self->{handle}->get_perf_counter_instance( + 'SQLServer:Databases', 'Transactions/sec', $self->{name}); + if (! defined $self->{transactions_s}) { + $self->add_nagios_unknown("unable to aquire counter data for $self->{name}"); + } else { + $self->valdiff(\%params, qw(transactions_s)); + $self->{transactions_per_sec} = $self->{delta_transactions_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::database::datafile::listdatafiles/) { + foreach (sort { $a->{logicalfilename} cmp $b->{logicalfilename}; } @{$self->{datafiles}}) { + printf "%s\n", $_->{logicalfilename}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::database::transactions/) { + $self->add_nagios( + $self->check_thresholds($self->{transactions_per_sec}, 10000, 50000), + sprintf "\n%s has %.4f transactions / sec", + $self->{name}, $self->{transactions_per_sec}); + $self->add_perfdata(sprintf "%s_transactions_per_sec=%.4f;%s;%s", + $self->{name}, $self->{transactions_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::database::databasefree/) { + # ->percent_free + # ->free + # + # ausgabe + # perfdata db__free_pct + # perfdata db__free (real_bytes_max - bytes) + bytes_free (with units) + # perfdata db__alloc_free bytes_free (with units) + # + # umrechnen der thresholds + # ()/% + # MB + # GB + # KB + if (($self->{warningrange} && $self->{warningrange} !~ /^\d+[\.\d]*:/) || + ($self->{criticalrange} && $self->{criticalrange} !~ /^\d+[\.\d]*:/)) { + $self->add_nagios_unknown("you want an alert if free space is _above_ a threshold????"); + return; + } + if (! $params{units}) { + $params{units} = "%"; + } + $self->{warning_bytes} = 0; + $self->{critical_bytes} = 0; + if ($params{units} eq "%") { + $self->add_nagios( + $self->check_thresholds($self->{free_percent}, "5:", "2:"), + sprintf("database %s has %.2f%% free space left", + $self->{name}, $self->{free_percent}, + ($self->{estimated} ? " (estim.)" : "")) + ); + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->add_perfdata(sprintf "\'db_%s_free_pct\'=%.2f%%;%d:;%d:", + lc $self->{name}, + $self->{free_percent}, + $self->{warningrange}, $self->{criticalrange}); + $self->add_perfdata(sprintf "\'db_%s_free\'=%dMB;%.2f:;%.2f:;0;%.2f", + lc $self->{name}, + $self->{free_mb}, + $self->{warningrange} * $self->{max_mb} / 100, + $self->{criticalrange} * $self->{max_mb} / 100, + $self->{max_mb}); + $self->add_perfdata(sprintf "\'db_%s_allocated_pct\'=%.2f%%", + lc $self->{name}, + $self->{allocated_percent}); + } else { + my $factor = 1; # default MB + if ($params{units} eq "GB") { + $factor = 1024; + } elsif ($params{units} eq "MB") { + $factor = 1; + } elsif ($params{units} eq "KB") { + $factor = 1 / 1024; + } + $self->{warningrange} ||= "5:"; + $self->{criticalrange} ||= "2:"; + my $saved_warningrange = $self->{warningrange}; + my $saved_criticalrange = $self->{criticalrange}; + # : entfernen weil gerechnet werden muss + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->{warningrange} = $self->{warningrange} ? + $self->{warningrange} * $factor : 5 * $factor; + $self->{criticalrange} = $self->{criticalrange} ? + $self->{criticalrange} * $factor : 2 * $factor; + $self->{percent_warning} = 100 * $self->{warningrange} / $self->{max_mb}; + $self->{percent_critical} = 100 * $self->{criticalrange} / $self->{max_mb}; + $self->{warningrange} .= ':'; + $self->{criticalrange} .= ':'; + $self->add_nagios( + $self->check_thresholds($self->{free_mb}, "5242880:", "1048576:"), + sprintf("database %s has %.2f%s free space left", $self->{name}, + $self->{free_mb} / $factor, $params{units}) + ); + $self->{warningrange} = $saved_warningrange; + $self->{criticalrange} = $saved_criticalrange; + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->add_perfdata(sprintf "\'db_%s_free_pct\'=%.2f%%;%.2f:;%.2f:", + lc $self->{name}, + $self->{free_percent}, $self->{percent_warning}, + $self->{percent_critical}); + $self->add_perfdata(sprintf "\'db_%s_free\'=%.2f%s;%.2f:;%.2f:;0;%.2f", + lc $self->{name}, + $self->{free_mb} / $factor, $params{units}, + $self->{warningrange}, + $self->{criticalrange}, + $self->{max_mb} / $factor); + $self->add_perfdata(sprintf "\'db_%s_allocated_pct\'=%.2f%%", + lc $self->{name}, + $self->{allocated_percent}); + } + } elsif ($params{mode} =~ /server::database::backupage/) { + if (! defined $self->{backup_age}) { + $self->add_nagios_critical(sprintf "%s was never backupped", + $self->{name}); + $self->{backup_age} = 0; + $self->{backup_duration} = 0; + $self->check_thresholds($self->{backup_age}, 48, 72); # init wg perfdata + } else { + $self->add_nagios( + $self->check_thresholds($self->{backup_age}, 48, 72), + sprintf "\n%s backupped %dh ago", $self->{name}, $self->{backup_age}); + } + $self->add_perfdata(sprintf "'%s_bck_age'=%d;%s;%s", + $self->{name}, $self->{backup_age}, + $self->{warningrange}, $self->{criticalrange}); + $self->add_perfdata(sprintf "'%s_bck_time'=%d", + $self->{name}, $self->{backup_duration}); + } + } +} + + + +package DBD::MSSQL::Server; + +use strict; +use Time::HiRes; +use IO::File; +use File::Copy 'cp'; +use Data::Dumper; + + +{ + our $verbose = 0; + our $scream = 0; # scream if something is not implemented + our $my_modules_dyn_dir = ""; # where we look for self-written extensions + + my @servers = (); + my $initerrors = undef; + + sub add_server { + push(@servers, shift); + } + + sub return_servers { + return @servers; + } + + sub return_first_server() { + return $servers[0]; + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + method => $params{method} || "dbi", + hostname => $params{hostname}, + username => $params{username}, + password => $params{password}, + port => $params{port} || 1433, + server => $params{server}, + timeout => $params{timeout}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + version => 'unknown', + os => 'unknown', + servicename => 'unknown', + instance => undef, + memorypool => undef, + databases => [], + handle => undef, + }; + bless $self, $class; + $self->init_nagios(); + if ($self->dbconnect(%params)) { + #$self->{version} = $self->{handle}->fetchrow_array( + # q{ SELECT SERVERPROPERTY('productversion') }); + map { + $self->{os} = $1 if /Windows (.*)/; + $self->{version} = $1 if /SQL Server.*\-\s*([\d\.]+)/; + } $self->{handle}->fetchrow_array( + q{ SELECT @@VERSION }); + $self->{dbuser} = $self->{handle}->fetchrow_array( + q{ SELECT SYSTEM_USER }); # maybe SELECT SUSER_SNAME() + $self->{servicename} = $self->{handle}->fetchrow_array( + q{ SELECT @@SERVICENAME }); + if (lc $self->{servicename} ne 'mssqlserver') { + # braucht man fuer abfragen von dm_os_performance_counters + # object_name ist entweder "SQLServer:Buffer Node" oder z.b. "MSSQL$OASH: Buffer Node" + $self->{servicename} = 'MSSQL$'.$self->{servicename}; + } else { + $self->{servicename} = 'SQLServer'; + } + DBD::MSSQL::Server::add_server($self); + $self->init(%params); + } + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $params{handle} = $self->{handle}; + if ($params{mode} =~ /^server::memorypool/) { + $self->{memorypool} = DBD::MSSQL::Server::Memorypool->new(%params); + } elsif ($params{mode} =~ /^server::database/) { + DBD::MSSQL::Server::Database::init_databases(%params); + if (my @databases = + DBD::MSSQL::Server::Database::return_databases()) { + $self->{databases} = \@databases; + } else { + $self->add_nagios_critical("unable to aquire database info"); + } + } elsif ($params{mode} =~ /^server::connectiontime/) { + $self->{connection_time} = $self->{tac} - $self->{tic}; + } elsif ($params{mode} =~ /^server::cpubusy/) { + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + ($self->{secs_busy}) = $self->{handle}->fetchrow_array(q{ + SELECT ((@@CPU_BUSY * CAST(@@TIMETICKS AS FLOAT)) / + (SELECT (CAST(CPU_COUNT AS FLOAT) / CAST(HYPERTHREAD_RATIO AS FLOAT)) FROM sys.dm_os_sys_info) / + 1000000) + }); + $self->valdiff(\%params, qw(secs_busy)); + if (defined $self->{secs_busy}) { + $self->{cpu_busy} = 100 * + $self->{delta_secs_busy} / $self->{delta_timestamp}; + } else { + $self->add_nagios_critical("got no cputime from dm_os_sys_info"); + } + } else { + #$self->requires_version('9'); + my @monitor = $params{handle}->exec_sp_1hash(q{exec sp_monitor}); + foreach (@monitor) { + if ($_->[0] eq 'cpu_busy') { + if ($_->[1] =~ /(\d+)%/) { + $self->{cpu_busy} = $1; + } + } + } + self->requires_version('9') unless defined $self->{cpu_busy}; + } + } elsif ($params{mode} =~ /^server::iobusy/) { + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + ($self->{secs_busy}) = $self->{handle}->fetchrow_array(q{ + SELECT ((@@IO_BUSY * CAST(@@TIMETICKS AS FLOAT)) / + (SELECT (CAST(CPU_COUNT AS FLOAT) / CAST(HYPERTHREAD_RATIO AS FLOAT)) FROM sys.dm_os_sys_info) / + 1000000) + }); + $self->valdiff(\%params, qw(secs_busy)); + if (defined $self->{secs_busy}) { + $self->{io_busy} = 100 * + $self->{delta_secs_busy} / $self->{delta_timestamp}; + } else { + $self->add_nagios_critical("got no iotime from dm_os_sys_info"); + } + } else { + #$self->requires_version('9'); + my @monitor = $params{handle}->exec_sp_1hash(q{exec sp_monitor}); + foreach (@monitor) { + if ($_->[0] eq 'io_busy') { + if ($_->[1] =~ /(\d+)%/) { + $self->{io_busy} = $1; + } + } + } + self->requires_version('9') unless defined $self->{io_busy}; + } + } elsif ($params{mode} =~ /^server::fullscans/) { + $self->{cnt_full_scans_s} = $self->{handle}->get_perf_counter( + 'SQLServer:Access Methods', 'Full Scans/sec'); + if (! defined $self->{cnt_full_scans_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(cnt_full_scans_s)); + $self->{full_scans_per_sec} = $self->{delta_cnt_full_scans_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::latch::waittime/) { + $self->{latch_wait_time} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Average Latch Wait Time (ms)"); + $self->{latch_wait_time_base} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Average Latch Wait Time Base"); + if (! defined $self->{latch_wait_time}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } + $self->{latch_wait_time} = $self->{latch_wait_time} / $self->{latch_wait_time_base}; + } elsif ($params{mode} =~ /^server::latch::waits/) { + $self->{latch_waits_s} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Latch Waits/sec"); + if (! defined $self->{latch_waits_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(latch_waits_s)); + $self->{latch_waits_per_sec} = $self->{delta_latch_waits_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::sql::.*compilations/) { + $self->{recompilations_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "SQL Re-Compilations/sec"); + $self->{compilations_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "SQL Compilations/sec"); + if (! defined $self->{recompilations_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(recompilations_s compilations_s)); + # http://www.sqlmag.com/Articles/ArticleID/40925/pg/3/3.html + # http://www.grumpyolddba.co.uk/monitoring/Performance%20Counter%20Guidance%20-%20SQL%20Server.htm + $self->{delta_initial_compilations_s} = $self->{delta_compilations_s} - + $self->{delta_recompilations_s}; + $self->{initial_compilations_per_sec} = + $self->{delta_initial_compilations_s} / $self->{delta_timestamp}; + $self->{recompilations_per_sec} = + $self->{delta_recompilations_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::batchrequests/) { + $self->{batch_requests_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "Batch requests/sec"); + if (! defined $self->{batch_requests_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(batch_requests_s)); + $self->{batch_requests_per_sec} = $self->{delta_batch_requests_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::totalmemory/) { + $self->{total_memory} = $self->{handle}->get_perf_counter( + "SQLServer:Memory Manager", "Total Server Memory (KB)"); + if (! defined $self->{total_memory}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } + } elsif ($params{mode} =~ /^server::connectedusers/) { + $self->{connectedusers} = $self->{handle}->fetchrow_array(q{ + SELECT + COUNT(*) + FROM + master..sysprocesses + WHERE + spid > ? + }, 51); + if (! defined $self->{connectedusers}) { + $self->add_nagios_unknown("unable to count connected users"); + } + } elsif ($params{mode} =~ /^server::sql/) { + @{$self->{genericsql}} = + $self->{handle}->fetchrow_array($params{selectname}); + if ((scalar(@{$self->{genericsql}}) == 0) || + (! (defined $self->{genericsql} && + (scalar(grep { /^\s*\d+\.{0,1}\d*\s*$/ } @{$self->{genericsql}})) == + scalar(@{$self->{genericsql}})))) { + $self->add_nagios_unknown(sprintf "got no valid response for %s", + $params{selectname}); + } else { + # name2 in array + # units in array + } + } elsif ($params{mode} =~ /^my::([^:.]+)/) { + my $class = $1; + my $loaderror = undef; + substr($class, 0, 1) = uc substr($class, 0, 1); + foreach my $libpath (split(":", $DBD::MSSQL::Server::my_modules_dyn_dir)) { + foreach my $extmod (glob $libpath."/CheckMSSQLHealth*.pm") { + eval { + $self->trace(sprintf "loading module %s", $extmod); + require $extmod; + }; + if ($@) { + $loaderror = $extmod; + $self->trace(sprintf "failed loading module %s: %s", $extmod, $@); + } + } + } + my $obj = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $obj, "My$class"; + $self->{my} = $obj; + if ($self->{my}->isa("DBD::MSSQL::Server")) { + my $dos_init = $self->can("init"); + my $dos_nagios = $self->can("nagios"); + my $my_init = $self->{my}->can("init"); + my $my_nagios = $self->{my}->can("nagios"); + if ($my_init == $dos_init) { + $self->add_nagios_unknown( + sprintf "Class %s needs an init() method", ref($self->{my})); + } elsif ($my_nagios == $dos_nagios) { + $self->add_nagios_unknown( + sprintf "Class %s needs a nagios() method", ref($self->{my})); + } else { + $self->{my}->init_nagios(%params); + $self->{my}->init(%params); + } + } else { + $self->add_nagios_unknown( + sprintf "Class %s is not a subclass of DBD::MSSQL::Server%s", + ref($self->{my}), + $loaderror ? sprintf " (syntax error in %s?)", $loaderror : "" ); + } + } else { + printf "broken mode %s\n", $params{mode}; + } +} + +sub dump { + my $self = shift; + my $message = shift || ""; + printf "%s %s\n", $message, Data::Dumper::Dumper($self); +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /^server::instance/) { + $self->{instance}->nagios(%params); + $self->merge_nagios($self->{instance}); + } elsif ($params{mode} =~ /server::database::listdatabases/) { + foreach (sort { $a->{name} cmp $b->{name}; } @{$self->{databases}}) { + printf "%s\n", $_->{name}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::database/) { + foreach (@{$self->{databases}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } elsif ($params{mode} =~ /^server::database/) { + } elsif ($params{mode} =~ /^server::lock/) { + foreach (@{$self->{locks}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } elsif ($params{mode} =~ /^server::memorypool/) { + $self->{memorypool}->nagios(%params); + $self->merge_nagios($self->{memorypool}); + } elsif ($params{mode} =~ /^server::connectiontime/) { + $self->add_nagios( + $self->check_thresholds($self->{connection_time}, 1, 5), + sprintf "%.2f seconds to connect as %s", + $self->{connection_time}, $self->{dbuser}); + $self->add_perfdata(sprintf "connection_time=%.2f;%d;%d", + $self->{connection_time}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::cpubusy/) { + $self->add_nagios( + $self->check_thresholds($self->{cpu_busy}, 80, 90), + sprintf "CPU busy %.2f%%", $self->{cpu_busy}); + $self->add_perfdata(sprintf "cpu_busy=%.2f;%s;%s", + $self->{cpu_busy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::iobusy/) { + $self->add_nagios( + $self->check_thresholds($self->{io_busy}, 80, 90), + sprintf "IO busy %.2f%%", $self->{io_busy}); + $self->add_perfdata(sprintf "io_busy=%.2f;%s;%s", + $self->{io_busy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::fullscans/) { + $self->add_nagios( + $self->check_thresholds($self->{full_scans_per_sec}, 100, 500), + sprintf "%.2f full table scans / sec", $self->{full_scans_per_sec}); + $self->add_perfdata(sprintf "full_scans_per_sec=%.2f;%s;%s", + $self->{full_scans_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::latch::waits/) { + $self->add_nagios( + $self->check_thresholds($self->{latch_waits_per_sec}, 10, 50), + sprintf "%.2f latches / sec have to wait", $self->{latch_waits_per_sec}); + $self->add_perfdata(sprintf "latch_waits_per_sec=%.2f;%s;%s", + $self->{latch_waits_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::latch::waittime/) { + $self->add_nagios( + $self->check_thresholds($self->{latch_wait_time}, 1, 5), + sprintf "latches have to wait %.2f ms avg", $self->{latch_wait_time}); + $self->add_perfdata(sprintf "latch_avg_wait_time=%.2fms;%s;%s", + $self->{latch_wait_time}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql::recompilations/) { + $self->add_nagios( + $self->check_thresholds($self->{recompilations_per_sec}, 1, 10), + sprintf "%.2f SQL recompilations / sec", $self->{recompilations_per_sec}); + $self->add_perfdata(sprintf "sql_recompilations_per_sec=%.2f;%s;%s", + $self->{recompilations_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql::initcompilations/) { + $self->add_nagios( + $self->check_thresholds($self->{initial_compilations_per_sec}, 100, 200), + sprintf "%.2f initial compilations / sec", $self->{initial_compilations_per_sec}); + $self->add_perfdata(sprintf "sql_initcompilations_per_sec=%.2f;%s;%s", + $self->{initial_compilations_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::batchrequests/) { + $self->add_nagios( + $self->check_thresholds($self->{batch_requests_per_sec}, 100, 200), + sprintf "%.2f batch requests / sec", $self->{batch_requests_per_sec}); + $self->add_perfdata(sprintf "batch_requests_per_sec=%.2f;%s;%s", + $self->{batch_requests_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::totalmemory/) { + $self->add_nagios( + $self->check_thresholds($self->{total_memory}, 1000, 5000), + sprintf "total server memory %ld", $self->{total_memory}); + $self->add_perfdata(sprintf "total_server_memory=%ld;%s;%s", + $self->{total_memory}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::connectedusers/) { + $self->add_nagios( + $self->check_thresholds($self->{connectedusers}, 50, 80), + sprintf "%d connected users", $self->{connectedusers}); + $self->add_perfdata(sprintf "connected_users=%d;%s;%s", + $self->{connectedusers}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql/) { + $self->add_nagios( + # the first item in the list will trigger the threshold values + $self->check_thresholds($self->{genericsql}[0], 1, 5), + sprintf "%s: %s%s", + $params{name2} ? lc $params{name2} : lc $params{selectname}, + # float as float, integers as integers + join(" ", map { + (sprintf("%d", $_) eq $_) ? $_ : sprintf("%f", $_) + } @{$self->{genericsql}}), + $params{units} ? $params{units} : ""); + my $i = 0; + # workaround... getting the column names from the database would be nicer + my @names2_arr = split(/\s+/, $params{name2}); + foreach my $t (@{$self->{genericsql}}) { + $self->add_perfdata(sprintf "\'%s\'=%s%s;%s;%s", + $names2_arr[$i] ? lc $names2_arr[$i] : lc $params{selectname}, + # float as float, integers as integers + (sprintf("%d", $t) eq $t) ? $t : sprintf("%f", $t), + $params{units} ? $params{units} : "", + ($i == 0) ? $self->{warningrange} : "", + ($i == 0) ? $self->{criticalrange} : "" + ); + $i++; + } + } elsif ($params{mode} =~ /^my::([^:.]+)/) { + $self->{my}->nagios(%params); + $self->merge_nagios($self->{my}); + } + } +} + + +sub init_nagios { + my $self = shift; + no strict 'refs'; + if (! ref($self)) { + my $nagiosvar = $self."::nagios"; + my $nagioslevelvar = $self."::nagios_level"; + $$nagiosvar = { + messages => { + 0 => [], + 1 => [], + 2 => [], + 3 => [], + }, + perfdata => [], + }; + $$nagioslevelvar = $ERRORS{OK}, + } else { + $self->{nagios} = { + messages => { + 0 => [], + 1 => [], + 2 => [], + 3 => [], + }, + perfdata => [], + }; + $self->{nagios_level} = $ERRORS{OK}, + } +} + +sub check_thresholds { + my $self = shift; + my $value = shift; + my $defaultwarningrange = shift; + my $defaultcriticalrange = shift; + my $level = $ERRORS{OK}; + $self->{warningrange} = defined $self->{warningrange} ? + $self->{warningrange} : $defaultwarningrange; + $self->{criticalrange} = defined $self->{criticalrange} ? + $self->{criticalrange} : $defaultcriticalrange; + if ($self->{warningrange} !~ /:/ && $self->{criticalrange} !~ /:/) { + # warning = 10, critical = 20, warn if > 10, crit if > 20 + $level = $ERRORS{WARNING} if $value > $self->{warningrange}; + $level = $ERRORS{CRITICAL} if $value > $self->{criticalrange}; + } elsif ($self->{warningrange} =~ /(\d+):/ && + $self->{criticalrange} =~ /(\d+):/) { + # warning = 98:, critical = 95:, warn if < 98, crit if < 95 + $self->{warningrange} =~ /(\d+):/; + $level = $ERRORS{WARNING} if $value < $1; + $self->{criticalrange} =~ /(\d+):/; + $level = $ERRORS{CRITICAL} if $value < $1; + } + return $level; + # + # syntax error must be reported with returncode -1 + # +} + +sub add_nagios { + my $self = shift; + my $level = shift; + my $message = shift; + push(@{$self->{nagios}->{messages}->{$level}}, $message); + # recalc current level + foreach my $llevel qw(CRITICAL WARNING UNKNOWN OK) { + if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$llevel}}})) { + $self->{nagios_level} = $ERRORS{$llevel}; + } + } +} + +sub add_nagios_ok { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{OK}, $message); +} + +sub add_nagios_warning { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{WARNING}, $message); +} + +sub add_nagios_critical { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{CRITICAL}, $message); +} + +sub add_nagios_unknown { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{UNKNOWN}, $message); +} + +sub add_perfdata { + my $self = shift; + my $data = shift; + push(@{$self->{nagios}->{perfdata}}, $data); +} + +sub merge_nagios { + my $self = shift; + my $child = shift; + foreach my $level (0..3) { + foreach (@{$child->{nagios}->{messages}->{$level}}) { + $self->add_nagios($level, $_); + } + #push(@{$self->{nagios}->{messages}->{$level}}, + # @{$child->{nagios}->{messages}->{$level}}); + } + push(@{$self->{nagios}->{perfdata}}, @{$child->{nagios}->{perfdata}}); +} + + +sub calculate_result { + my $self = shift; + if ($ENV{NRPE_MULTILINESUPPORT} && + length join(" ", @{$self->{nagios}->{perfdata}}) > 200) { + foreach my $level ("CRITICAL", "WARNING", "UNKNOWN", "OK") { + # first the bad news + if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$level}}})) { + $self->{nagios_message} .= + "\n".join("\n", @{$self->{nagios}->{messages}->{$ERRORS{$level}}}); + } + } + $self->{nagios_message} =~ s/^\n//g; + $self->{perfdata} = join("\n", @{$self->{nagios}->{perfdata}}); + } else { + foreach my $level ("CRITICAL", "WARNING", "UNKNOWN", "OK") { + # first the bad news + if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$level}}})) { + $self->{nagios_message} .= + join(", ", @{$self->{nagios}->{messages}->{$ERRORS{$level}}}).", "; + } + } + $self->{nagios_message} =~ s/, $//g; + $self->{perfdata} = join(" ", @{$self->{nagios}->{perfdata}}); + } + foreach my $level ("OK", "UNKNOWN", "WARNING", "CRITICAL") { + if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$level}}})) { + $self->{nagios_level} = $ERRORS{$level}; + } + } +} + +sub debug { + my $self = shift; + my $msg = shift; + if ($DBD::MSSQL::Server::verbose) { + printf "%s %s\n", $msg, ref($self); + } +} + +sub dbconnect { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{tic} = Time::HiRes::time(); + $self->{handle} = DBD::MSSQL::Server::Connection->new(%params); + if ($self->{handle}->{errstr}) { + if ($self->{handle}->{errstr} eq "alarm\n") { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "connection could not be established within %d seconds", + $self->{timeout}); + } else { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "cannot connect to %s. %s", + ($self->{server} ? $self->{server} : + ($self->{hostname} ? $self->{hostname} : "unknown host")), + $self->{handle}->{errstr}); + $retval = undef; + } + } else { + $retval = $self->{handle}; + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub trace { + my $self = shift; + my $format = shift; + if (! @_) { + # falls im sql-statement % vorkommen. sonst krachts im printf + $format =~ s/%/%%/g; + } + $self->{trace} = -f "/tmp/check_mssql_health.trace" ? 1 : 0; + if ($DBD::MSSQL::Server::verbose) { + printf("%s: ", scalar localtime); + printf($format, @_); + } + if ($self->{trace}) { + my $logfh = new IO::File; + $logfh->autoflush(1); + if ($logfh->open("/tmp/check_mssql_health.trace", "a")) { + $logfh->printf("%s: ", scalar localtime); + $logfh->printf($format, @_); + $logfh->printf("\n"); + $logfh->close(); + } + } +} + +sub DESTROY { + my $self = shift; + my $handle1 = "null"; + my $handle2 = "null"; + if (defined $self->{handle}) { + $handle1 = ref($self->{handle}); + if (defined $self->{handle}->{handle}) { + $handle2 = ref($self->{handle}->{handle}); + } + } + $self->trace(sprintf "DESTROY %s with handle %s %s", ref($self), $handle1, $handle2); + if (ref($self) eq "DBD::MSSQL::Server") { + } + $self->trace(sprintf "DESTROY %s exit with handle %s %s", ref($self), $handle1, $handle2); + if (ref($self) eq "DBD::MSSQL::Server") { + #printf "humpftata\n"; + } +} + +sub save_state { + my $self = shift; + my %params = @_; + my $extension = ""; + mkdir $params{statefilesdir} unless -d $params{statefilesdir}; + my $statefile = sprintf "%s/%s_%s", + $params{statefilesdir}, ($params{hostname} || $params{server}), $params{mode}; + $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{port} ? "_".$params{port} : ""; + $extension .= $params{database} ? "_".$params{database} : ""; + $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 = ""; + my $statefile = sprintf "%s/%s_%s", + $params{statefilesdir}, ($params{hostname} || $params{server}), $params{mode}; + $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{port} ? "_".$params{port} : ""; + $extension .= $params{database} ? "_".$params{database} : ""; + $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 valdiff { + my $self = shift; + my $pparams = shift; + my %params = %{$pparams}; + my @keys = @_; + my $last_values = $self->load_state(%params) || eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = 0; + } + $empty_events->{timestamp} = 0; + $empty_events; + }; + foreach (@keys) { + $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'} = time - $last_values->{timestamp}; + $params{save} = eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = $self->{$_}; + } + $empty_events->{timestamp} = time; + $empty_events; + }; + $self->save_state(%params); +} + +sub requires_version { + my $self = shift; + my $version = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + my $instversion = $instances[0]->{version}; + if (! $self->version_is_minimum($version)) { + $self->add_nagios($ERRORS{UNKNOWN}, + sprintf "not implemented/possible for MSSQL release %s", $instversion); + } +} + +sub version_is_minimum { + # the current version is newer or equal + my $self = shift; + my $version = shift; + my $newer = 1; + my @instances = DBD::MSSQL::Server::return_servers(); + my @v1 = map { $_ eq "x" ? 0 : $_ } split(/\./, $version); + my @v2 = split(/\./, $instances[0]->{version}); + if (scalar(@v1) > scalar(@v2)) { + push(@v2, (0) x (scalar(@v1) - scalar(@v2))); + } elsif (scalar(@v2) > scalar(@v1)) { + push(@v1, (0) x (scalar(@v2) - scalar(@v1))); + } + foreach my $pos (0..$#v1) { + if ($v2[$pos] > $v1[$pos]) { + $newer = 1; + last; + } elsif ($v2[$pos] < $v1[$pos]) { + $newer = 0; + last; + } + } + #printf STDERR "check if %s os minimum %s\n", join(".", @v2), join(".", @v1); + return $newer; +} + +sub instance_rac { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + return (lc $instances[0]->{parallel} eq "yes") ? 1 : 0; +} + +sub instance_thread { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + return $instances[0]->{thread}; +} + +sub windows_server { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + if ($instances[0]->{os} =~ /Win/i) { + return 1; + } else { + return 0; + } +} + +sub system_vartmpdir { + my $self = shift; + if ($^O =~ /MSWin/) { + return $self->system_tmpdir(); + } else { + return "/var/tmp/check_mssql_health"; + } +} + +sub system_oldvartmpdir { + my $self = shift; + return "/tmp"; +} + +sub system_tmpdir { + my $self = shift; + if ($^O =~ /MSWin/) { + return $ENV{TEMP} if defined $ENV{TEMP}; + return $ENV{TMP} if defined $ENV{TMP}; + return File::Spec->catfile($ENV{windir}, 'Temp') + if defined $ENV{windir}; + return 'C:\Temp'; + } else { + return "/tmp"; + } +} + + +package DBD::MSSQL::Server::Connection; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + + +sub new { + my $class = shift; + my %params = @_; + my $self = { + mode => $params{mode}, + timeout => $params{timeout}, + method => $params{method} || "dbi", + hostname => $params{hostname}, + username => $params{username}, + password => $params{password}, + port => $params{port} || 1433, + server => $params{server}, + handle => undef, + }; + bless $self, $class; + if ($params{method} eq "dbi") { + bless $self, "DBD::MSSQL::Server::Connection::Dbi"; + } elsif ($params{method} eq "tsql") { + bless $self, "DBD::MSSQL::Server::Connection::Tsql"; + } elsif ($params{method} eq "sqlrelay") { + bless $self, "DBD::MSSQL::Server::Connection::Sqlrelay"; + } + $self->init(%params); + return $self; +} + +sub get_instance_names { + my $self = shift; + my $object_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchall_array(q{ + SELECT + DISTINCT instance_name + FROM + sys.dm_os_performance_counters + WHERE + object_name = ? + }, $object_name); + } else { + return $self->fetchall_array(q{ + SELECT + DISTINCT instance_name + FROM + master.dbo.sysperfinfo + WHERE + object_name = ? + }, $object_name); + } +} + +sub get_perf_counter { + my $self = shift; + my $object_name = shift; + my $counter_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + sys.dm_os_performance_counters + WHERE + counter_name = ? AND + object_name = ? + }, $counter_name, $object_name); + } else { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + master.dbo.sysperfinfo + WHERE + counter_name = ? AND + object_name = ? + }, $counter_name, $object_name); + } +} + +sub get_perf_counter_instance { + my $self = shift; + my $object_name = shift; + my $counter_name = shift; + my $instance_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + sys.dm_os_performance_counters + WHERE + counter_name = ? AND + object_name = ? AND + instance_name = ? + }, $counter_name, $object_name, $instance_name); + } else { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + master.dbo.sysperfinfo + WHERE + counter_name = ? AND + object_name = ? AND + instance_name = ? + }, $counter_name, $object_name, $instance_name); + } +} + +package DBD::MSSQL::Server::Connection::Dbi; + +use strict; +use Net::Ping; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + if ($self->{mode} =~ /^server::tnsping/) { + # erstmal reserviert fuer irgendeinen tcp-connect + if (! $self->{connect}) { + $self->{errstr} = "Please specify a database"; + } else { + $self->{sid} = $self->{connect}; + $self->{username} ||= time; # prefer an existing user + $self->{password} = time; + } + } else { + if ((! $self->{hostname} && ! $self->{server}) || + ! $self->{username} || ! $self->{password}) { + $self->{errstr} = "Please specify hostname or server, username and password"; + return undef; + } + $self->{dsn} = "DBI:Sybase:"; + if ($self->{hostname}) { + $self->{dsn} .= sprintf ";host=%s", $self->{hostname}; + $self->{dsn} .= sprintf ";port=%s", $self->{port}; + } else { + $self->{dsn} .= sprintf ";server=%s", $self->{server}; + } + } + if (! exists $self->{errstr}) { + eval { + require DBI; + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "alarm\n"; + }; + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + if ($self->{handle} = DBI->connect( + $self->{dsn}, + $self->{username}, + $self->{password}, + { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { + $retval = $self; + } else { + # doesnt seem to work $self->{errstr} = DBI::errstr(); + $self->{errstr} = "connect failed"; + return undef; + } + }; + if ($@) { + $self->{errstr} = $@; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments) || die DBI::errstr(); + } else { + $sth->execute() || die DBI::errstr(); + } + if (lc $sql =~ /^(exec |sp_)/) { + # flatten the result sets + do { + while (my $aref = $sth->fetchrow_arrayref()) { + push(@row, @{$aref}); + } + } while ($sth->{syb_more_results}); + } else { + @row = $sth->fetchrow_array(); + } + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper(\@row)); + }; + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @row = split(/\s+/, (split(/\n/, $simulation))[0]); + } + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + $rows = $sth->fetchall_arrayref(); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @{$rows} = map { [ split(/\s+/, $_) ] } split(/\n/, $simulation); + } + return @{$rows}; +} + +sub exec_sp_1hash { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + do { + while (my $href = $sth->fetchrow_hashref()) { + foreach (keys %{$href}) { + push(@{$rows}, [ $_, $href->{$_} ]); + } + } + } while ($sth->{syb_more_results}); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + return @{$rows}; +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace(sprintf "disconnecting DBD %s", + $self->{handle} ? "with handle" : "without handle"); + $self->{handle}->disconnect() if $self->{handle}; +} + +package DBD::MSSQL::Server::Connection::Tsql; + +use strict; +use File::Temp qw/tempfile/; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{loginstring} = "traditional"; + ($self->{sql_commandfile_handle}, $self->{sql_commandfile}) = + tempfile($self->{mode}."XXXXX", SUFFIX => ".sql", + DIR => $self->system_tmpdir() ); + close $self->{sql_commandfile_handle}; + ($self->{sql_resultfile_handle}, $self->{sql_resultfile}) = + tempfile($self->{mode}."XXXXX", SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_resultfile_handle}; + if ($self->{mode} =~ /^server::tnsping/) { + if (! $self->{connect}) { + $self->{errstr} = "Please specify a database"; + } else { + $self->{sid} = $self->{connect}; + $self->{user} ||= time; # prefer an existing user + $self->{password} = time; + } + } else { + if ($self->{connect} && ! $self->{user} && ! $self->{password} && + $self->{connect} =~ /(\w+)\/(\w+)@(\w+)/) { + # --connect nagios/oradbmon@bba + $self->{connect} = $3; + $self->{user} = $1; + $self->{password} = $2; + $self->{sid} = $self->{connect}; + if ($self->{user} eq "sys") { + delete $ENV{TWO_TASK}; + $self->{loginstring} = "sys"; + } else { + $self->{loginstring} = "traditional"; + } + } elsif ($self->{connect} && ! $self->{user} && ! $self->{password} && + $self->{connect} =~ /sysdba@(\w+)/) { + # --connect sysdba@bba + $self->{connect} = $1; + $self->{user} = "/"; + $self->{sid} = $self->{connect}; + $self->{loginstring} = "sysdba"; + } elsif ($self->{connect} && ! $self->{user} && ! $self->{password} && + $self->{connect} =~ /(\w+)/) { + # --connect bba + $self->{connect} = $1; + # maybe this is a os authenticated user + delete $ENV{TWO_TASK}; + $self->{sid} = $self->{connect}; + if ($^O ne "hpux") { #hpux && 1.21 only accepts "DBI:MSSQL:SID" + $self->{connect} = ""; #linux 1.20 only accepts "DBI:MSSQL:" + MSSQL_SID + } + $self->{user} = '/'; + $self->{password} = ""; + $self->{loginstring} = "extauth"; + } elsif ($self->{user} && + $self->{user} =~ /^\/@(\w+)/) { + # --user /@ubba1 + $self->{user} = $1; + $self->{sid} = $self->{connect}; + $self->{loginstring} = "passwordstore"; + } elsif ($self->{connect} && $self->{user} && ! $self->{password} && + $self->{user} eq "sysdba") { + # --connect bba --user sysdba + $self->{connect} = $1; + $self->{user} = "/"; + $self->{sid} = $self->{connect}; + $self->{loginstring} = "sysdba"; + } elsif ($self->{connect} && $self->{user} && $self->{password}) { + # --connect bba --user nagios --password oradbmon + $self->{sid} = $self->{connect}; + $self->{loginstring} = "traditional"; + } else { + $self->{errstr} = "Please specify database, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + eval { + $ENV{MSSQL_SID} = $self->{sid}; + $ENV{PATH} = $ENV{MSSQL_HOME}."/bin". + (defined $ENV{PATH} ? + ":".$ENV{PATH} : ""); + $ENV{LD_LIBRARY_PATH} = $ENV{MSSQL_HOME}."/lib". + (defined $ENV{LD_LIBRARY_PATH} ? + ":".$ENV{LD_LIBRARY_PATH} : ""); + # am 30.9.2008 hat perl das /bin/sqlplus in $ENV{MSSQL_HOME}.'/bin/sqlplus' + # eiskalt evaluiert und + # /u00/app/mssql/product/11.1.0/db_1/u00/app/mssql/product/11.1.0/db_1/bin/sqlplus + # draus gemacht. Leider nicht in Mini-Scripts reproduzierbar, sondern nur hier. + # Das ist der Grund fuer die vielen ' und . + my $sqlplus = $ENV{MSSQL_HOME}.'/'.'bin'.'/'.'sqlplus'; + if ((-x $ENV{MSSQL_HOME}.'/'.'sqlplus') && ( -f $ENV{MSSQL_HOME}.'/'.'sqlplus')) { + $sqlplus = $ENV{MSSQL_HOME}.'/'.'sqlplus'; + } + my $tnsping = $ENV{MSSQL_HOME}.'/'.'bin'.'/'.'tnsping'; + if (! -x $sqlplus) { + die "nosqlplus\n"; + } + if ($self->{mode} =~ /^server::tnsping/) { + if ($self->{loginstring} eq "traditional") { + $self->{sqlplus} = sprintf "%s -S %s/%s@%s < /dev/null", + $sqlplus, + $self->{user}, $self->{password}, $self->{sid}; + } elsif ($self->{loginstring} eq "extauth") { + $self->{sqlplus} = sprintf "%s -S / < /dev/null", + $sqlplus; + } elsif ($self->{loginstring} eq "passwordstore") { + $self->{sqlplus} = sprintf "%s -S /@%s < /dev/null", + $sqlplus, + $self->{user}; + } elsif ($self->{loginstring} eq "sysdba") { + $self->{sqlplus} = sprintf "%s -S / as sysdba < /dev/null", + $sqlplus; + } elsif ($self->{loginstring} eq "sys") { + $self->{sqlplus} = sprintf "%s -S %s/%s@%s as sysdba < /dev/null", + $sqlplus, + $self->{user}, $self->{password}, $self->{sid}; + } + } else { + if ($self->{loginstring} eq "traditional") { + $self->{sqlplus} = sprintf "%s -S %s/%s@%s < %s > %s", + $sqlplus, + $self->{user}, $self->{password}, $self->{sid}, + $self->{sql_commandfile}, $self->{sql_resultfile}; + } elsif ($self->{loginstring} eq "extauth") { + $self->{sqlplus} = sprintf "%s -S / < %s > %s", + $sqlplus, + $self->{sql_commandfile}, $self->{sql_resultfile}; + } elsif ($self->{loginstring} eq "passwordstore") { + $self->{sqlplus} = sprintf "%s -S /@%s < %s > %s", + $sqlplus, + $self->{user}, + $self->{sql_commandfile}, $self->{sql_resultfile}; + } elsif ($self->{loginstring} eq "sysdba") { + $self->{sqlplus} = sprintf "%s -S / as sysdba < %s > %s", + $sqlplus, + $self->{sql_commandfile}, $self->{sql_resultfile}; + } elsif ($self->{loginstring} eq "sys") { + $self->{sqlplus} = sprintf "%s -S %s/%s@%s as sysdba < %s > %s", + $sqlplus, + $self->{user}, $self->{password}, $self->{sid}, + $self->{sql_commandfile}, $self->{sql_resultfile}; + } + } + + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "alarm\n"; + }; + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + + if ($self->{mode} =~ /^server::tnsping/) { + if (-x $tnsping) { + my $exit_output = `$tnsping $self->{sid}`; + if ($?) { + # printf STDERR "tnsping exit bumm \n"; + # immer 1 bei misserfolg + } + if ($exit_output =~ /^OK \(\d+/m) { + die "ORA-01017"; # fake a successful connect with wrong password + } elsif ($exit_output =~ /^(TNS\-\d+)/m) { + die $1; + } else { + die "TNS-03505"; + } + } else { + my $exit_output = `$self->{sqlplus}`; + if ($?) { + printf STDERR "ping exit bumm \n"; + } + $exit_output =~ s/\n//g; + $exit_output =~ s/at $0//g; + chomp $exit_output; + die $exit_output; + } + } else { + my $answer = $self->fetchrow_array( + q{ SELECT 42 FROM dual}); + die unless defined $answer and $answer == 42; + } + $retval = $self; + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at $0 .*//g; + chomp $self->{errstr}; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->create_commandfile($sql); + my $exit_output = `$self->{sqlplus}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm \n"; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + @row = map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } # strip leading space from numbers + map { s/\s+$//g; $_ } # strip trailing space + split(/\|/, (split(/\n/, $output))[0]); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + + $self->create_commandfile($sql); + my $exit_output = `$self->{sqlplus}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm %s\n", $exit_output; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @rows = map { [ + map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } + map { s/\s+$//g; $_ } + split /\|/ + ] } grep { ! /^\d+ rows selected/ } + grep { ! /^Elapsed: / } + grep { ! /^\s*$/ } split(/\n/, $output); + $rows = \@rows; + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return @{$rows}; +} + +sub func { + my $self = shift; + my $function = shift; + $self->{handle}->func(@_); +} + +sub convert { + my $n = shift; + # mostly used to convert numbers in scientific notation + if ($n =~ /^\s*\d+\s*$/) { + return $n; + } elsif ($n =~ /^\s*([-+]?)(\d*[\.,]*\d*)[eE]{1}([-+]?)(\d+)\s*$/) { + my ($vor, $num, $sign, $exp) = ($1, $2, $3, $4); + $n =~ s/E/e/g; + $n =~ s/,/\./g; + $num =~ s/,/\./g; + my $sig = $sign eq '-' ? "." . ($exp - 1 + length $num) : ''; + my $dec = sprintf "%${sig}f", $n; + $dec =~ s/\.[0]+$//g; + return $dec; + } elsif ($n =~ /^\s*([-+]?)(\d+)[\.,]*(\d*)\s*$/) { + return $1.$2.".".$3; + } elsif ($n =~ /^\s*(.*?)\s*$/) { + return $1; + } else { + return $n; + } +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace("try to clean up command and result files"); + unlink $self->{sql_commandfile} if -f $self->{sql_commandfile}; + unlink $self->{sql_resultfile} if -f $self->{sql_resultfile}; +} + +sub create_commandfile { + my $self = shift; + my $sql = shift; + open CMDCMD, "> $self->{sql_commandfile}"; + printf CMDCMD "SET HEADING OFF\n"; + printf CMDCMD "SET PAGESIZE 0\n"; + printf CMDCMD "SET LINESIZE 32767\n"; + printf CMDCMD "SET COLSEP '|'\n"; + printf CMDCMD "SET TAB OFF\n"; + printf CMDCMD "SET TRIMSPOOL ON\n"; + printf CMDCMD "SET NUMFORMAT 9.999999EEEE\n"; + printf CMDCMD "SPOOL %s\n", $self->{sql_resultfile}; +# printf CMDCMD "ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,';\n/\n"; + printf CMDCMD "%s\n/\n", $sql; + printf CMDCMD "EXIT\n"; + close CMDCMD; +} + +package DBD::MSSQL::Server::Connection::Sqlrelay; + +use strict; +use Net::Ping; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + if ($self->{mode} =~ /^server::tnsping/) { + } else { + if (! $self->{hostname} || ! $self->{username} || ! $self->{password} || ! $self->{port}) { + $self->{errstr} = "Please specify database, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + eval { + require DBI; + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "alarm\n"; + }; + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + if ($self->{handle} = DBI->connect( + #sprintf("DBI:SQLRelay:host=%s;port=%d;socket=%s", + sprintf("DBI:SQLRelay:host=%s;port=%d;", + $self->{hostname}, $self->{port}), + $self->{username}, + $self->{password}, + { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { + } else { + $self->{errstr} = DBI::errstr(); + } + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at [\w\/\.]+ line \d+.*//g; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + my $new_dbh = $self->{handle}->clone(); + $self->trace(sprintf "fetchrow_array: %s", $sql); + # + # does not work with bind variables + # + while ($sql =~ /\?/) { + my $param = shift @arguments; + if ($param !~ /^\d+$/) { + $param = $self->{handle}->quote($param); + } + $sql =~ s/\?/$param/; + } + $sql =~ s/^\s*//g; + $sql =~ s/\s*$//g; + eval { + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + @row = $sth->fetchrow_array(); + $sth->finish(); + }; + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + # without this trick, there are error messages like + # "No server-side cursors were available to process the query" + # and the results are messed up. + $self->{handle}->disconnect(); + $self->{handle} = $new_dbh; + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @row = split(/\s+/, (split(/\n/, $simulation))[0]); + } + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + my $new_dbh = $self->{handle}->clone(); + $self->trace(sprintf "fetchall_array: %s", $sql); + while ($sql =~ /\?/) { + my $param = shift @arguments; + if ($param !~ /^\d+$/) { + $param = $self->{handle}->quote($param); + } + $sql =~ s/\?/$param/; + } + eval { + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + $rows = $sth->fetchall_arrayref(); + my $asrows = $sth->fetchall_arrayref(); + $sth->finish(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + $self->{handle}->disconnect(); + $self->{handle} = $new_dbh; + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @{$rows} = map { [ split(/\s+/, $_) ] } split(/\n/, $simulation); + } + return @{$rows}; +} + +sub func { + my $self = shift; + $self->{handle}->func(@_); +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + #$self->trace(sprintf "disconnecting DBD %s", + # $self->{handle} ? "with handle" : "without handle"); + #$self->{handle}->disconnect() if $self->{handle}; +} + + + + + + +package main; + +use strict; +use Getopt::Long qw(:config no_ignore_case); +use File::Basename; +use lib dirname($0); + + + +use vars qw ($PROGNAME $REVISION $CONTACT $TIMEOUT $STATEFILESDIR $needs_restart %commandline); + +$PROGNAME = "check_mssql_health"; +$REVISION = '$Revision: 1.5.3 $'; +$CONTACT = 'gerhard.lausser@consol.de'; +$TIMEOUT = 60; +$STATEFILESDIR = '/var/tmp/check_mssql_health'; +$needs_restart = 0; + +my @modes = ( + ['server::connectiontime', + 'connection-time', undef, + 'Time to connect to the server' ], + ['server::cpubusy', + 'cpu-busy', undef, + 'Cpu busy in percent' ], + ['server::iobusy', + 'io-busy', undef, + 'IO busy in percent' ], + ['server::fullscans', + 'full-scans', undef, + 'Full table scans per second' ], + ['server::connectedusers', + 'connected-users', undef, + 'Number of currently connected users' ], + ['server::database::transactions', + 'transactions', undef, + 'Transactions per second (per database)' ], + ['server::batchrequests', + 'batch-requests', undef, + 'Batch requests per second' ], + ['server::latch::waits', + 'latches-waits', undef, + 'Number of latch requests that could not be granted immediately' ], + ['server::latch::waittime', + 'latches-wait-time', undef, + 'Average time for a latch to wait before the request is met' ], + ['server::memorypool::lock::waits', + 'locks-waits', undef, + 'The number of locks per second that had to wait' ], + ['server::memorypool::lock::timeouts', + 'locks-timeouts', undef, + 'The number of locks per second that timed out' ], + ['server::memorypool::lock::deadlocks', + 'locks-deadlocks', undef, + 'The number of deadlocks per second' ], + ['server::sql::recompilations', + 'sql-recompilations', undef, + 'Re-Compilations per second' ], + ['server::sql::initcompilations', + 'sql-initcompilations', undef, + 'Initial compilations per second' ], + ['server::totalmemory', + 'total-server-memory', undef, + 'The amount of memory that SQL Server has allocated to it' ], + ['server::memorypool::buffercache::hitratio', + 'mem-pool-data-buffer-hit-ratio', ['buffer-cache-hit-ratio'], + 'Data Buffer Cache Hit Ratio' ], + ['server::memorypool::buffercache::hitratio', + 'mem-pool-data-buffer-hit-ratio', ['buffer-cache-hit-ratio'], + 'Data Buffer Cache Hit Ratio' ], + + + ['server::memorypool::buffercache::lazywrites', + 'lazy-writes', undef, + 'Lazy writes per second' ], + ['server::memorypool::buffercache::pagelifeexpectancy', + 'page-life-expectancy', undef, + 'Seconds a page is kept in memory before being flushed' ], + ['server::memorypool::buffercache::freeliststalls', + 'free-list-stalls', undef, + 'Requests per second that had to wait for a free page' ], + ['server::memorypool::buffercache::checkpointpages', + 'checkpoint-pages', undef, + 'Dirty pages flushed to disk per second. (usually by a checkpoint)' ], + + + ['server::database::databasefree', + 'database-free', undef, + 'Free space in database' ], + ['server::database::backupage', + 'backup-age', undef, + 'Elapsed time (in hours) since a database was last backupped' ], + ['server::sql', + 'sql', undef, + 'any sql command returning a single number' ], + ['server::database::listdatabases', + 'list-databases', undef, + 'convenience function which lists all databases' ], + ['server::database::datafile::listdatafiles', + 'list-datafiles', undef, + 'convenience function which lists all datafiles' ], + ['server::memorypool::lock::listlocks', + 'list-locks', undef, + 'convenience function which lists all locks' ], +); + +sub print_usage () { + print <] --hostname= + --username= --password= [--port ] + --mode= + $PROGNAME [-h | --help] + $PROGNAME [-V | --version] + + Options: + --hostname + the database server + --username + the mssql user + --password + the mssql user's password + --warning + the warning range + --critical + the critical range + --mode + the mode of the plugin. select one of the following keywords: +EOUS + 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) { + printf $format, $_->[1], $_->[3]; + } + printf "\n"; + print <; + chomp $input; + $input =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; + printf "%s\n", $input; + exit $ERRORS{OK}; +} + +if (!exists $commandline{queryfile} || !$commandline{queryfile}) { + $commandline{queryfile} = "/etc/nagios/check_mssql_health-queries"; +} + + +if (exists $commandline{3}) { + $ENV{NRPE_MULTILINESUPPORT} = 1; +} + +if (exists $commandline{timeout}) { + $TIMEOUT = $commandline{timeout}; +} + +if (exists $commandline{verbose}) { + $DBD::MSSQL::Server::verbose = exists $commandline{verbose}; +} + +if (exists $commandline{scream}) { +# $DBD::MSSQL::Server::hysterical = exists $commandline{scream}; +} + +$DBD::MSSQL::Server::my_modules_dyn_dir = '/usr/local/nagios/libexec'; + +if (exists $commandline{environment}) { + # if the desired environment variable values are different from + # the environment of this running script, then a restart is necessary. + # because setting $ENV does _not_ change the environment of the running script. + foreach (keys %{$commandline{environment}}) { + if ((! $ENV{$_}) || ($ENV{$_} ne $commandline{environment}->{$_})) { + $needs_restart = 1; + $ENV{$_} = $commandline{environment}->{$_}; + printf STDERR "new %s=%s forces restart\n", $_, $ENV{$_} + if $DBD::MSSQL::Server::verbose; + } + } + # e.g. called with --runas dbnagio. shlib_path environment variable is stripped + # during the sudo. + # so the perl interpreter starts without a shlib_path. but --runas cares for + # a --environment shlib_path=... + # so setting the environment variable in the code above and restarting the + # perl interpreter will help it find shared libs +} + +if (exists $commandline{runas}) { + # remove the runas parameter + # exec sudo $0 ... the remaining parameters + $needs_restart = 1; + # if the calling script has a path for shared libs and there is no --environment + # parameter then the called script surely needs the variable too. + foreach my $important_env qw(LD_LIBRARY_PATH SHLIB_PATH + MSSQL_HOME TNS_ADMIN ORA_NLS ORA_NLS33 ORA_NLS10) { + if ($ENV{$important_env} && ! scalar(grep { /^$important_env=/ } + keys %{$commandline{environment}})) { + $commandline{environment}->{$important_env} = $ENV{$important_env}; + printf STDERR "add important --environment %s=%s\n", + $important_env, $ENV{$important_env} if $DBD::MSSQL::Server::verbose; + } + } +} + +if (exists $commandline{namefromfile}) { + if (!open QF, "<$commandline{queryfile}") { + print "Unable to open queryfile $commandline{queryfile} param --queryfile\n"; + print_help(); + exit $ERRORS{OK}; + } + + my $sql = ''; + while (my $l = ) { + # Double chomp if needed + chomp($l) for (0..1); + + $l =~ s/#.*$//g; + + my ($k, $sql_line) = split(/\s*=\s*/, $l, 2); + #printf("l: %s\nk: %s sql: %s\n", $l, $k, $sql_line); + + if ($k eq $commandline{namefromfile}) { + $sql = $sql_line; + last; + } + } + close QF; + + if (!$sql) { + print "Unable to find namefromfile key $commandline{namefromfile} in file $commandline{queryfile}\n"; + exit $ERRORS{OK}; + } + $commandline{name}=$sql; +} + +if ($needs_restart) { + my @newargv = (); + my $runas = undef; + if (exists $commandline{runas}) { + $runas = $commandline{runas}; + delete $commandline{runas}; + } + foreach my $option (keys %commandline) { + if (grep { /^$option/ && /=/ } @params) { + if (ref ($commandline{$option}) eq "HASH") { + foreach (keys %{$commandline{$option}}) { + push(@newargv, sprintf "--%s", $option); + push(@newargv, sprintf "%s=%s", $_, $commandline{$option}->{$_}); + } + } else { + push(@newargv, sprintf "--%s", $option); + push(@newargv, sprintf "%s", $commandline{$option}); + } + } else { + push(@newargv, sprintf "--%s", $option); + } + } + if ($runas && ($> == 0)) { + # this was not my idea. some people connect as root to their nagios clients. + exec "su", "-c", sprintf("%s %s", $0, join(" ", @newargv)), "-", $runas; + } elsif ($runas) { + exec "sudo", "-S", "-u", $runas, $0, @newargv; + } else { + exec $0, @newargv; + # this makes sure that even a SHLIB or LD_LIBRARY_PATH are set correctly + # when the perl interpreter starts. Setting them during runtime does not + # help loading e.g. libclntsh.so + } + exit; +} + +if (exists $commandline{shell}) { + # forget what you see here. + system("/bin/sh"); +} + +if (exists $commandline{name}) { + # objects can be encoded like an url + # with s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; + if (($commandline{mode} ne "sql") || + (($commandline{mode} eq "sql") && + ($commandline{name} =~ /select%20/i))) { # protect ... like '%cac%' ... from decoding + $commandline{name} =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; + } + if ($commandline{name} =~ /^0$/) { + # without this, $params{selectname} would be treated like undef + $commandline{name} = "00"; + } +} + +$SIG{'ALRM'} = sub { + printf "UNKNOWN - %s timed out after %d seconds\n", $PROGNAME, $TIMEOUT; + exit $ERRORS{UNKNOWN}; +}; +alarm($TIMEOUT); + +my $nagios_level = $ERRORS{UNKNOWN}; +my $nagios_message = ""; +my $perfdata = ""; +my $racmode = 0; +if ($commandline{mode} =~ /^rac-([^\-.]+)/) { + $racmode = 1; + $commandline{mode} =~ s/^rac\-//g; +} +if ($commandline{mode} =~ /^my-([^\-.]+)/) { + my $param = $commandline{mode}; + $param =~ s/\-/::/g; + push(@modes, [$param, $commandline{mode}, undef, 'my extension']); +} elsif ((! grep { $commandline{mode} eq $_ } map { $_->[1] } @modes) && + (! grep { $commandline{mode} eq $_ } map { defined $_->[2] ? @{$_->[2]} : () } @modes)) { + printf "UNKNOWN - mode %s\n", $commandline{mode}; + print_usage(); + exit 3; +} + +my %params = ( + timeout => $TIMEOUT, + mode => ( + map { $_->[0] } + grep { + ($commandline{mode} eq $_->[1]) || + ( defined $_->[2] && grep { $commandline{mode} eq $_ } @{$_->[2]}) + } @modes + )[0], + racmode => $racmode, + method => $commandline{method} || + $ENV{NAGIOS__SERVICEMSSQL_METH} || + $ENV{NAGIOS__HOSTMSSQL_METH} || 'dbi', + hostname => $commandline{hostname} || + $ENV{NAGIOS__SERVICEMSSQL_HOST} || + $ENV{NAGIOS__HOSTMSSQL_HOST}, + username => $commandline{username} || + $ENV{NAGIOS__SERVICEMSSQL_USER} || + $ENV{NAGIOS__HOSTMSSQL_USER}, + password => $commandline{password} || + $ENV{NAGIOS__SERVICEMSSQL_PASS} || + $ENV{NAGIOS__HOSTMSSQL_PASS}, + port => $commandline{port} || + $ENV{NAGIOS__SERVICEMSSQL_PORT} || + $ENV{NAGIOS__HOSTMSSQL_PORT}, + server => $commandline{server} || + $ENV{NAGIOS__SERVICEMSSQL_SERVER} || + $ENV{NAGIOS__HOSTMSSQL_SERVER}, + warningrange => $commandline{warning}, + criticalrange => $commandline{critical}, + absolute => $commandline{absolute}, + lookback => $commandline{lookback}, + tablespace => $commandline{tablespace}, + database => $commandline{database}, + datafile => $commandline{datafile}, + basis => $commandline{basis}, + selectname => $commandline{name} || $commandline{tablespace} || $commandline{datafile}, + regexp => $commandline{regexp}, + name => $commandline{name}, + name2 => $commandline{name2} || $commandline{name}, + units => $commandline{units}, + eyecandy => $commandline{eyecandy}, + statefilesdir => $STATEFILESDIR, +); + +my $server = undef; + +$server = DBD::MSSQL::Server->new(%params); +$server->nagios(%params); +$server->calculate_result(); +$nagios_message = $server->{nagios_message}; +$nagios_level = $server->{nagios_level}; +$perfdata = $server->{perfdata}; + +printf "%s - %s", $ERRORCODES{$nagios_level}, $nagios_message; +printf " | %s", $perfdata if $perfdata; +printf "\n"; +exit $nagios_level; diff --git a/check_mssql_health/nagios-okplugin-mssql.spec b/check_mssql_health/nagios-okplugin-mssql.spec new file mode 100644 index 0000000..62671cb --- /dev/null +++ b/check_mssql_health/nagios-okplugin-mssql.spec @@ -0,0 +1,43 @@ +%define debug_package %{nil} + +Summary: Nagios plugins to check the status of MS-SQL Servers +Name: nagios-okplugin-mssql +Version: 0.0.3 +Release: 2%{?dist} +License: GPLv2+ +Group: Applications/System +URL: http://opensource.is/trac/wiki/nagios-MSSQL +Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_mssql/releases/nagios-okplugin-mssql-%{version}.tar.gz +Requires: perl-Nagios-Plugin +Requires: perl-DBD-Sybase +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +Packager: Tomas Edwardsson + + +%description +MS-SQL checks for health and size of MSSQL servers + +%prep +%setup -q +perl -pi -e "s|/usr/lib|%{_libdir}|g" check_mssql_dbsize +perl -pi -e "s|/usr/lib|%{_libdir}|g" check_mssql_health + +%build + + +%install +rm -rf %{buildroot} +install -D -p -m 0755 check_mssql_dbsize %{buildroot}%{_libdir}/nagios/plugins/check_mssql_dbsize +install -D -p -m 0755 check_mssql_health %{buildroot}%{_libdir}/nagios/plugins/check_mssql_health + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%doc README LICENSE +%{_libdir}/nagios/plugins/* + +%changelog +* Sun Nov 21 2010 Tomas Edwardsson 0.0.3-1 +- Initial packaging diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/AUTHORS b/check_mssql_health/src/check_mssql_health-1.5.8.2/AUTHORS new file mode 100644 index 0000000..6206f02 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/AUTHORS @@ -0,0 +1 @@ +Gerhard Lausser diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/COPYING b/check_mssql_health/src/check_mssql_health-1.5.8.2/COPYING new file mode 100644 index 0000000..60549be --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/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/check_mssql_health/src/check_mssql_health-1.5.8.2/ChangeLog b/check_mssql_health/src/check_mssql_health-1.5.8.2/ChangeLog new file mode 100644 index 0000000..027832c --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/ChangeLog @@ -0,0 +1,67 @@ +############################################### +# Changelog of the check_mssql_health plugin # +############################################### + +1.5.8.2 2011-01-19 +- output a nicer error message if a sqlrelay connection fails + +1.5.8.1 2011-01-03 +- bugfix in --mode sql (numeric vs. regexp result) + +1.5.8 2010-12-20 +- mode sql can now have a non-numerical output which is compared to a string/regexp +- new parameter --dbthresholds +- new mode report can be used to output only the bad news (short,long,html) + +1.5.7 2010-09-10 +- fixed a bug in database-free (too much free space was calculated when more than one datafile of a database was on the same filesystem). (Thanks Juergen Essberger) +- new parameter extra-opts + +1.5.6 2010-08-12 +- new parameter --dbthresholds. thresholds can now also be deposited in the table check_mssql_health_thresholds +- added --currentdb so that the plugin can connect to a non-default database +- --with-mymodules-dyn-dir on the commandline overrides the configure-option of the same name + +1.5.5 +- backup-age is now an alias for the "official" database-backup-age +- catch the "can't change context to database" error +- --mode sqlcmd + +1.5.3 2009-11-02 +- fixed a bug in mode database-free (results are more accurate now) +- added new mode backup-age which checks the age (in hours) of the last backup + +1.5.2 +- fixed a bug where database names with special characters showed errors. (Thanks Hugh Ranalli) + +1.5.1 2009-05-26 +- added --server which can be used instead of --hostname/port (Thanks Mark Monaghan) +- lots of fixes. sql server 2000 should now be fully supported. (Thanks Mereghetti Stefano) +- --warning/--critical were ignored for memory-pool-related modes (Thanks Mereghetti Stefano) + +1.5.0.2 2009-05-05 +- fixed a bug which led to error messages when using the plugin with sql server 2000 (Thanks Christian Mies) +- fixed a bug so sql server 2000 can list-databases (Thanks Mereghetti Stefano) + +1.5.0.1 2009-04-29 +- added a security advice to the README (Thanks Mathieu Barret) +- fixed a bug in database-free (Thanks Michael Luebben) +- fixed a typo (Thanks Bernd Staudacher) + +1.5 - 2009-03-20 +- rewrote database-free so that unrestricted growth is taken into account (limit is disk) +- added support for SQLRelay + +1.2 - 2009-03-19 +- added support for object_name <> SQLServer:... (this caused "unable to aquire"-errors sometimes) +- fixed a bug in the PNP template + +1.1 - 2009-03-11 +- added modes: transactions, latches-wait-time, locks-waits, locks-timeouts, + locks-deadlocks, sql-recompilations, total-server-memory +- beautified the PNP template +- fixed counter rollovers after database restart + +1.0 - 2009-03-10 +---------------- +- Initial release diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/INSTALL b/check_mssql_health/src/check_mssql_health-1.5.8.2/INSTALL new file mode 100644 index 0000000..08dbade --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/INSTALL @@ -0,0 +1,229 @@ +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2008 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/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile b/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile new file mode 100644 index 0000000..1fb2570 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile @@ -0,0 +1,575 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +# find . \( -type d -and -name .svn -and -prune \) -or -type f -exec fromdos -v {} \; +srcdir = . +top_srcdir = . + +pkgdatadir = $(datadir)/check_mssql_health +pkglibdir = $(libdir)/check_mssql_health +pkgincludedir = $(includedir)/check_mssql_health +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ + ChangeLog INSTALL NEWS TODO config.guess config.sub install-sh \ + missing +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +INSTALL = /usr/bin/install -c +ACLOCAL = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run aclocal-1.9 +AMTAR = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run tar +AUTOCONF = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoconf +AUTOHEADER = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoheader +AUTOMAKE = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run automake-1.9 +AWK = /usr/bin/gawk +CAT = /bin/cat +CYGPATH_W = echo +DEFS = -DPACKAGE_NAME=\"check_mssql_health\" -DPACKAGE_TARNAME=\"check_mssql_health\" -DPACKAGE_VERSION=\"1.5.8.2\" -DPACKAGE_STRING=\"check_mssql_health\ 1.5.8.2\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"check_mssql_health\" -DVERSION=\"1.5.8.2\" +ECHO = /bin/echo +ECHO_C = +ECHO_N = -n +ECHO_T = +GREP = /bin/grep +GZIP = /bin/gzip +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_OPTS = -o nagios -g nagios +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s +LIBOBJS = +LIBS = +LTLIBOBJS = +MAKEINFO = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run makeinfo +MYMODULES_DIR = /usr/local/nagios/libexec +MYMODULES_DYN_DIR = /usr/local/nagios/libexec +PACKAGE = check_mssql_health +PACKAGE_BUGREPORT = +PACKAGE_NAME = check_mssql_health +PACKAGE_STRING = check_mssql_health 1.5.8.2 +PACKAGE_TARNAME = check_mssql_health +PACKAGE_VERSION = 1.5.8.2 +PATH_SEPARATOR = : +PERL = /usr/bin/perl +RELEASE = 1 +SED = /bin/sed +SET_MAKE = +SH = /bin/sh +SHELL = /bin/bash +STATEFILES_DIR = /var/tmp/check_mssql_health +STRIP = +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 +VERSION = 1.5.8.2 +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_ct_STRIP = +am__leading_dot = . +am__tar = tar --format=posix -chf - "$$tardir" +am__untar = tar -xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +datadir = ${prefix}/share +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +includedir = ${prefix}/include +infodir = ${prefix}/info +install_sh = /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localstatedir = ${prefix}/var +mandir = ${prefix}/man +mkdir_p = mkdir -p -- +oldincludedir = /usr/include +prefix = /usr/local/nagios +program_transform_name = s,x,x, +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +sysconfdir = ${prefix}/etc +target_alias = +with_nagios_group = nagios +with_nagios_user = nagios +SUBDIRS = plugins-scripts t +EXTRA_DIST = contrib +all: all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkdir_p) $(distdir)/plugins-scripts + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -find $(distdir) -type d ! -perm -755 -exec chmod a+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ + check-am clean clean-generic clean-recursive ctags \ + ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \ + dist-shar dist-tarZ dist-zip distcheck distclean \ + distclean-generic distclean-recursive distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-generic mostlyclean-recursive pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-info-am + + +dist-hook: + rm -f t/var/tmp/* + rm -f t/var/adm/* + find $(distdir) -depth -name .svn -exec rm -rf {} \; + find $(distdir) -type f -exec fromdos -v {} \; + make +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.am b/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.am new file mode 100644 index 0000000..a40a4a5 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.am @@ -0,0 +1,13 @@ +## Process this file with automake to produce Makefile.in + +# find . \( -type d -and -name .svn -and -prune \) -or -type f -exec fromdos -v {} \; + +SUBDIRS = plugins-scripts t +EXTRA_DIST = contrib + +dist-hook: + rm -f t/var/tmp/* + rm -f t/var/adm/* + find $(distdir) -depth -name .svn -exec rm -rf {} \; + find $(distdir) -type f -exec fromdos -v {} \; + make diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.in b/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.in new file mode 100644 index 0000000..36bf46d --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/Makefile.in @@ -0,0 +1,575 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# find . \( -type d -and -name .svn -and -prune \) -or -type f -exec fromdos -v {} \; +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ + ChangeLog INSTALL NEWS TODO config.guess config.sub install-sh \ + missing +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +INSTALL = @INSTALL@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CAT = @CAT@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +GREP = @GREP@ +GZIP = @GZIP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_OPTS = @INSTALL_OPTS@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MYMODULES_DIR = @MYMODULES_DIR@ +MYMODULES_DYN_DIR = @MYMODULES_DYN_DIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +RELEASE = @RELEASE@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SH = @SH@ +SHELL = @SHELL@ +STATEFILES_DIR = @STATEFILES_DIR@ +STRIP = @STRIP@ +SUPPORT = @SUPPORT@ +VERSION = @VERSION@ +WARRANTY = @WARRANTY@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +with_nagios_group = @with_nagios_group@ +with_nagios_user = @with_nagios_user@ +SUBDIRS = plugins-scripts t +EXTRA_DIST = contrib +all: all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkdir_p) $(distdir)/plugins-scripts + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -find $(distdir) -type d ! -perm -755 -exec chmod a+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ + check-am clean clean-generic clean-recursive ctags \ + ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \ + dist-shar dist-tarZ dist-zip distcheck distclean \ + distclean-generic distclean-recursive distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-generic mostlyclean-recursive pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-info-am + + +dist-hook: + rm -f t/var/tmp/* + rm -f t/var/adm/* + find $(distdir) -depth -name .svn -exec rm -rf {} \; + find $(distdir) -type f -exec fromdos -v {} \; + make +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/NEWS b/check_mssql_health/src/check_mssql_health-1.5.8.2/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/README b/check_mssql_health/src/check_mssql_health-1.5.8.2/README new file mode 100644 index 0000000..4f9fd8e --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/README @@ -0,0 +1,179 @@ +check_mssql_health Nagios Plugin README +--------------------- + +This plugin is used to monitor a variety of MS SQL Server database metrics. + +* 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 plugin 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.com/opensource/nagios/check-mssql-health + +The documentation in this README covers only the most common features. +To view the full documentation and examples, go to + http://www.consol.com/opensource/nagios/check-mssql-health or + http://www.consol.de/opensource/nagios/check-mssql-health + +Send mail to gerhard.lausser@consol.de for assistance. +Please include the OS type/version and the Perl DBI/DBD version +that you are using. +Also, run the plugin with the '-vvv' option and provide the resulting +version information. Of course, there may be additional diagnostic information +required as well. Use good judgment. + +For patch submissions and bug reports, please send me a mail. You can also find +me at http://www.nagios-portal.de + +Requirements +-------------------------------------------------------- +You need to install the Perl module DBD::Sybase first. +It is very important to set the protocol version in /etc/freetds.conf to 8.0 +Otherwise your database password will be visible on the network. + +[global] + # TDS protocol version + tds version = 8.0 + + + +How to "compile" the check_mssql_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-statefiles-dir=STATE_PATH + + 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 STATE_PATH with the directory where you want the script to + write state files which transport information from one run to the next. + (default is /tmp) + + Simply running ./configure will be sufficient to create a check_mssql_health + script which you can customize later. + + +2) "Compile" the plugin with the following command: + + make + + This will produce a "check_mssql_health" script. You will also find + a "check_mssql_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. + + +Command line parameters +----------------------- + +--hostname= + This is the hostname or the ip-address. + +--port= + This is the port where an instance listens. Default: 1433 + +--server= + This can be used instead of a hostname/port combination. + The servername given here is used for a lookup in /etc/freetds.conf + +--user= + This is the user which reads the system tables. + +--password= + This is the user's password. + +--mode= + This parameter tells the plugin what it should check. + The list of known modes may grow frequently. Please look at + http://www.consol.com/opensource/nagios/check-mssql-health for a list + of features. + +--database= + Database-related modes check all databases in one run by default. + If only a single database should be checked, use this parameter. + +--warning= + If the metric is out of this range, the plugin returns a warning. + +--critical= + If the metric is out of this range, the plugin returns a critical. + + +Connecting +---------- + + +You can call the plugin with "--hostname [--port ]" +This bypasses the freetds.conf file and directly connects you to +whatever is listening on port 1433 or +This will surely be the default instance. If you have different (named) instances +listening on the same port, you need to edit /etc/freetds.conf + +[dbsrv1instance01] + host = 192.168.1.1 + port = 1433 + instance = instance01 + +[dbsrv1instance02] + host = 192.168.1.1 + port = 1433 + instance = instance02 + +.... + +Then you call the plugin with "--server dbsrv1instance02" for example. + +Testing the connection +---------------------- + +use DBI; +use strict; + +my $username = "xxxxx"; +my $password = "xxxxx"; +my $dsn = "DBI:Sybase:;host=127.0.1.1;port=1433"; +#my $dsn = "DBI:Sybase:;server=dbsrv_in_freetds_conf"; +if (my $dbh = DBI->connect( + $dsn, $username, $password, + { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { + printf "connection succeeded\n"; +} else { + printf "connection failed\n"; +} + + + + +-------------------------------------- +That's it. If you have any problems or questions, feel free to send mail +to gerhard.lausser@consol.de diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/TODO b/check_mssql_health/src/check_mssql_health-1.5.8.2/TODO new file mode 100644 index 0000000..869edca --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/TODO @@ -0,0 +1 @@ +--database is important diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/acinclude.m4 b/check_mssql_health/src/check_mssql_health-1.5.8.2/acinclude.m4 new file mode 100644 index 0000000..788d68e --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/acinclude.m4 @@ -0,0 +1,78 @@ +dnl @synopsis ACX_WHICH_GETHOSTBYNAME_R +dnl +dnl Provides a test to determine the correct way to call gethostbyname_r +dnl +dnl defines HAVE_GETHOSTBYNAME_R to the number of arguments required +dnl +dnl e.g. 6 arguments (linux) +dnl e.g. 5 arguments (solaris) +dnl e.g. 3 arguments (osf/1) +dnl +dnl @version $Id: acinclude.m4,v 1.5 2004/02/18 14:56:34 kdebisschop Exp $ +dnl @author Brian Stafford +dnl +dnl based on version by Caolan McNamara +dnl based on David Arnold's autoconf suggestion in the threads faq +dnl +AC_DEFUN([ACX_WHICH_GETHOSTBYNAME_R], +[AC_CACHE_CHECK(number of arguments to gethostbyname_r, + acx_which_gethostbyname_r, [ + AC_TRY_COMPILE([ +# include + ], [ + + char *name; + struct hostent *he; + struct hostent_data data; + (void) gethostbyname_r(name, he, &data); + + ],acx_which_gethostbyname_r=3, + [ +dnl acx_which_gethostbyname_r=0 + AC_TRY_COMPILE([ +# include + ], [ + char *name; + struct hostent *he, *res; + char *buffer = NULL; + int buflen = 2048; + int h_errnop; + (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) + ],acx_which_gethostbyname_r=6, + + [ +dnl acx_which_gethostbyname_r=0 + AC_TRY_COMPILE([ +# include + ], [ + char *name; + struct hostent *he; + char *buffer = NULL; + int buflen = 2048; + int h_errnop; + (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) + ],acx_which_gethostbyname_r=5,acx_which_gethostbyname_r=0) + + ] + + ) + ] + ) + ]) + +if test $acx_which_gethostbyname_r -gt 0 ; then + AC_DEFINE_UNQUOTED([HAVE_GETHOSTBYNAME_R], $acx_which_gethostbyname_r, + [Number of parameters to gethostbyname_r or 0 if not available]) +fi + +]) + +dnl @synopsis ACX_HELP_STRING(OPTION,DESCRIPTION) +AC_DEFUN([ACX_HELP_STRING], + [ $1 builtin([substr],[ ],len($1))[$2]]) + + +dnl @synopsis ACX_FEATURE(ENABLE_OR_WITH,NAME[,VALUE]) +AC_DEFUN([ACX_FEATURE], + [echo "builtin([substr],[ ],len(--$1-$2))--$1-$2: ifelse($3,,[$]translit($1-$2,-,_),$3)"]) + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/aclocal.m4 b/check_mssql_health/src/check_mssql_health-1.5.8.2/aclocal.m4 new file mode 100644 index 0000000..59f88ef --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/aclocal.m4 @@ -0,0 +1,559 @@ +# generated automatically by aclocal 1.9.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.6])]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 12 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. +# +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([acinclude.m4]) diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/config.guess b/check_mssql_health/src/check_mssql_health-1.5.8.2/config.guess new file mode 100644 index 0000000..61f2e4c --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/config.guess @@ -0,0 +1,1432 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +timestamp='2003-10-20' + +# This file 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pegasos:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha*:OpenVMS:*:*) + echo alpha-hp-vms + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + # GNU/KFreeBSD systems have a "k" prefix to indicate we are using + # FreeBSD's kernel, but not the complete OS. + case ${LIBC} in gnu) kernel_only='k' ;; esac + echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit 0 ;; + *:DRAGONFLY:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE} + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/config.log b/check_mssql_health/src/check_mssql_health-1.5.8.2/config.log new file mode 100644 index 0000000..99a7472 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/config.log @@ -0,0 +1,244 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by check_mssql_health configure 1.5.8.2, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ ./configure + +## --------- ## +## Platform. ## +## --------- ## + +hostname = darkstar +uname -m = x86_64 +uname -r = 2.6.38-8-generic +uname -s = Linux +uname -v = #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 + +/usr/bin/uname -p = unknown +/bin/uname -X = unknown + +/bin/arch = unknown +/usr/bin/arch -k = unknown +/usr/convex/getsysinfo = unknown +hostinfo = unknown +/bin/machine = unknown +/usr/bin/oslevel = unknown +/bin/universe = unknown + +PATH: /usr/local/sbin +PATH: /usr/local/bin +PATH: /usr/sbin +PATH: /usr/bin +PATH: /sbin +PATH: /bin +PATH: /usr/games + + +## ----------- ## +## Core tests. ## +## ----------- ## + +configure:1289: checking for a BSD-compatible install +configure:1344: result: /usr/bin/install -c +configure:1355: checking whether build environment is sane +configure:1398: result: yes +configure:1463: checking for gawk +configure:1479: found /usr/bin/gawk +configure:1489: result: gawk +configure:1499: checking whether make sets $(MAKE) +configure:1519: result: yes +configure:1682: checking how to create a pax tar archive +configure:1695: tar --version +tar (GNU tar) 1.25 +Copyright (C) 2010 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later . +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. + +Written by John Gilmore and Jay Fenlason. +configure:1698: $? = 0 +configure:1738: tardir=conftest.dir && eval tar --format=posix -chf - "$tardir" >conftest.tar +configure:1741: $? = 0 +configure:1745: tar -xf - /dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by check_mssql_health $as_me 1.5.8.2, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +config_files=" Makefile plugins-scripts/Makefile plugins-scripts/subst t/Makefile" + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." +ac_cs_version="\ +check_mssql_health config.status 1.5.8.2 +configured by ./configure, generated by GNU Autoconf 2.59, + with options \"\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=. +INSTALL="/usr/bin/install -c" +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +if $ac_cs_recheck; then + echo "running /bin/bash ./configure " $ac_configure_extra_args " --no-create --no-recursion" >&6 + exec /bin/bash ./configure $ac_configure_extra_args --no-create --no-recursion +fi + +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "plugins-scripts/Makefile" ) CONFIG_FILES="$CONFIG_FILES plugins-scripts/Makefile" ;; + "plugins-scripts/subst" ) CONFIG_FILES="$CONFIG_FILES plugins-scripts/subst" ;; + "t/Makefile" ) CONFIG_FILES="$CONFIG_FILES t/Makefile" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t$/@;t t/; /@;t t$/s/[\\&,]/\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t$/,;t t/' >$tmp/subs.sed <<\CEOF +s,@SHELL@,/bin/bash,;t t +s,@PATH_SEPARATOR@,:,;t t +s,@PACKAGE_NAME@,check_mssql_health,;t t +s,@PACKAGE_TARNAME@,check_mssql_health,;t t +s,@PACKAGE_VERSION@,1.5.8.2,;t t +s,@PACKAGE_STRING@,check_mssql_health 1.5.8.2,;t t +s,@PACKAGE_BUGREPORT@,,;t t +s,@exec_prefix@,${prefix},;t t +s,@prefix@,/usr/local/nagios,;t t +s,@program_transform_name@,s,x,x,,;t t +s,@bindir@,${exec_prefix}/bin,;t t +s,@sbindir@,${exec_prefix}/sbin,;t t +s,@libexecdir@,${exec_prefix}/libexec,;t t +s,@datadir@,${prefix}/share,;t t +s,@sysconfdir@,${prefix}/etc,;t t +s,@sharedstatedir@,${prefix}/com,;t t +s,@localstatedir@,${prefix}/var,;t t +s,@libdir@,${exec_prefix}/lib,;t t +s,@includedir@,${prefix}/include,;t t +s,@oldincludedir@,/usr/include,;t t +s,@infodir@,${prefix}/info,;t t +s,@mandir@,${prefix}/man,;t t +s,@build_alias@,,;t t +s,@host_alias@,,;t t +s,@target_alias@,,;t t +s,@DEFS@,-DPACKAGE_NAME=\"check_mssql_health\" -DPACKAGE_TARNAME=\"check_mssql_health\" -DPACKAGE_VERSION=\"1.5.8.2\" -DPACKAGE_STRING=\"check_mssql_health\ 1.5.8.2\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"check_mssql_health\" -DVERSION=\"1.5.8.2\" ,;t t +s,@ECHO_C@,,;t t +s,@ECHO_N@,-n,;t t +s,@ECHO_T@,,;t t +s,@LIBS@,,;t t +s,@INSTALL_PROGRAM@,${INSTALL},;t t +s,@INSTALL_SCRIPT@,${INSTALL},;t t +s,@INSTALL_DATA@,${INSTALL} -m 644,;t t +s,@CYGPATH_W@,echo,;t t +s,@PACKAGE@,check_mssql_health,;t t +s,@VERSION@,1.5.8.2,;t t +s,@ACLOCAL@,${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run aclocal-1.9,;t t +s,@AUTOCONF@,${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoconf,;t t +s,@AUTOMAKE@,${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run automake-1.9,;t t +s,@AUTOHEADER@,${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoheader,;t t +s,@MAKEINFO@,${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run makeinfo,;t t +s,@install_sh@,/home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh,;t t +s,@STRIP@,,;t t +s,@ac_ct_STRIP@,,;t t +s,@INSTALL_STRIP_PROGRAM@,${SHELL} $(install_sh) -c -s,;t t +s,@mkdir_p@,mkdir -p --,;t t +s,@AWK@,/usr/bin/gawk,;t t +s,@SET_MAKE@,,;t t +s,@am__leading_dot@,.,;t t +s,@AMTAR@,${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run tar,;t t +s,@am__tar@,tar --format=posix -chf - "$$tardir",;t t +s,@am__untar@,tar -xf -,;t t +s,@build@,x86_64-unknown-linux-gnu,;t t +s,@build_cpu@,x86_64,;t t +s,@build_vendor@,unknown,;t t +s,@build_os@,linux-gnu,;t t +s,@host@,x86_64-unknown-linux-gnu,;t t +s,@host_cpu@,x86_64,;t t +s,@host_vendor@,unknown,;t t +s,@host_os@,linux-gnu,;t t +s,@RELEASE@,1,;t t +s,@INSTALL@,/usr/bin/install -c,;t t +s,@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,;t t +s,@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,;t t +s,@with_nagios_user@,nagios,;t t +s,@with_nagios_group@,nagios,;t t +s,@INSTALL_OPTS@,-o nagios -g nagios,;t t +s,@STATEFILES_DIR@,/var/tmp/check_mssql_health,;t t +s,@MYMODULES_DIR@,/usr/local/nagios/libexec,;t t +s,@MYMODULES_DYN_DIR@,/usr/local/nagios/libexec,;t t +s,@SH@,/bin/sh,;t t +s,@PERL@,/usr/bin/perl,;t t +s,@GZIP@,/bin/gzip,;t t +s,@GREP@,/bin/grep,;t t +s,@ECHO@,/bin/echo,;t t +s,@SED@,/bin/sed,;t t +s,@CAT@,/bin/cat,;t t +s,@LIBOBJS@,,;t t +s,@LTLIBOBJS@,,;t t +CEOF + + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + sed "/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +} + +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done + +{ (exit 0); exit 0; } diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/config.sub b/check_mssql_health/src/check_mssql_health-1.5.8.2/config.sub new file mode 100644 index 0000000..fac5195 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/config.sub @@ -0,0 +1,1534 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +timestamp='2003-11-20' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | msp430 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/configure b/check_mssql_health/src/check_mssql_health-1.5.8.2/configure new file mode 100755 index 0000000..160e445 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/configure @@ -0,0 +1,3296 @@ +#! /bin/sh +# From configure.in . +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59 for check_mssql_health 1.5.8.2. +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME='check_mssql_health' +PACKAGE_TARNAME='check_mssql_health' +PACKAGE_VERSION='1.5.8.2' +PACKAGE_STRING='check_mssql_health 1.5.8.2' +PACKAGE_BUGREPORT='' + +ac_default_prefix=/usr/local/nagios +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os RELEASE INSTALL WARRANTY SUPPORT with_nagios_user with_nagios_group INSTALL_OPTS STATEFILES_DIR MYMODULES_DIR MYMODULES_DYN_DIR SH PERL GZIP GREP ECHO SED CAT LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures check_mssql_health 1.5.8.2 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of check_mssql_health 1.5.8.2:";; + esac + cat <<\_ACEOF + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-nagios-user=USER set user name to run nagios + --with-nagios-group=GROUP set group name to run nagios + --with-statefiles-dir=PATH sets directory for the state files (default=/var/tmp/check_mssql_health) + --with-mymodules-dir=PATH sets directory for own extensions which will be included during the build process (default=/usr/local/nagios/libexec) + --with-mymodules-dyn-dir=PATH sets directory for own extensions which will be included at runtime (default=/usr/local/nagios/libexec) + --with-perl=PATH sets path to perl executable + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF +check_mssql_health configure 1.5.8.2 +generated by GNU Autoconf 2.59 + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by check_mssql_health $as_me 1.5.8.2, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + + + + + + + + + +am__api_version="1.9" +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='check_mssql_health' + VERSION='1.5.8.2' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + + +echo "$as_me:$LINENO: checking how to create a pax tar archive" >&5 +echo $ECHO_N "checking how to create a pax tar archive... $ECHO_C" >&6 +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' +_am_tools=${am_cv_prog_tar_pax-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + { echo "$as_me:$LINENO: $_am_tar --version" >&5 + ($_am_tar --version) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && break + done + am__tar="$_am_tar --format=posix -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=posix -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x pax -w "$$tardir"' + am__tar_='pax -L -x pax -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H pax -L' + am__tar_='find "$tardir" -print | cpio -o -H pax -L' + am__untar='cpio -i -H pax -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_pax}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 + (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + rm -rf conftest.dir + if test -s conftest.tar; then + { echo "$as_me:$LINENO: $am__untar &5 + ($am__untar &5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + grep GrepMe conftest.dir/file >/dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +if test "${am_cv_prog_tar_pax+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + am_cv_prog_tar_pax=$_am_tool +fi + +echo "$as_me:$LINENO: result: $am_cv_prog_tar_pax" >&5 +echo "${ECHO_T}$am_cv_prog_tar_pax" >&6 + + + + + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + + +RELEASE=1 + + + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + + + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + +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" + + +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" + + + +# Check whether --with-nagios_user or --without-nagios_user was given. +if test "${with_nagios_user+set}" = set; then + withval="$with_nagios_user" + with_nagios_user=$withval +else + with_nagios_user=nagios +fi; + +# Check whether --with-nagios_group or --without-nagios_group was given. +if test "${with_nagios_group+set}" = set; then + withval="$with_nagios_group" + with_nagios_group=$withval +else + with_nagios_group=nagios +fi; + + +INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group" + + + +# Check whether --with-statefiles_dir or --without-statefiles_dir was given. +if test "${with_statefiles_dir+set}" = set; then + withval="$with_statefiles_dir" + with_statefiles_dir=$withval +else + with_statefiles_dir=/var/tmp/check_mssql_health +fi; +STATEFILES_DIR=$with_statefiles_dir + +echo variable with_statefiles_dir is $with_statefiles_dir + + +# Check whether --with-mymodules_dir or --without-mymodules_dir was given. +if test "${with_mymodules_dir+set}" = set; then + withval="$with_mymodules_dir" + with_mymodules_dir=$withval +else + with_mymodules_dir=/usr/local/nagios/libexec +fi; +MYMODULES_DIR=$with_mymodules_dir + +echo variable with_mymodules_dir is $with_mymodules_dir + + +# Check whether --with-mymodules_dyn_dir or --without-mymodules_dyn_dir was given. +if test "${with_mymodules_dyn_dir+set}" = set; then + withval="$with_mymodules_dyn_dir" + with_mymodules_dyn_dir=$withval +else + with_mymodules_dyn_dir=/usr/local/nagios/libexec +fi; +MYMODULES_DYN_DIR=$with_mymodules_dyn_dir + +echo variable with_mymodules_dyn_dir is $with_mymodules_dyn_dir + +EXTRAS= + +# Extract the first word of "sh", so it can be a program name with args. +set dummy sh; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_SH+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $SH in + [\\/]* | ?:[\\/]*) + ac_cv_path_SH="$SH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_SH="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +SH=$ac_cv_path_SH + +if test -n "$SH"; then + echo "$as_me:$LINENO: result: $SH" >&5 +echo "${ECHO_T}$SH" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_PERL+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $PERL in + [\\/]* | ?:[\\/]*) + ac_cv_path_PERL="$PERL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +PERL=$ac_cv_path_PERL + +if test -n "$PERL"; then + echo "$as_me:$LINENO: result: $PERL" >&5 +echo "${ECHO_T}$PERL" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "gzip", so it can be a program name with args. +set dummy gzip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GZIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +GZIP=$ac_cv_path_GZIP + +if test -n "$GZIP"; then + echo "$as_me:$LINENO: result: $GZIP" >&5 +echo "${ECHO_T}$GZIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +for ac_prog in gawk nawk /usr/xpg4/bin/awk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AWK in + [\\/]* | ?:[\\/]*) + ac_cv_path_AWK="$AWK" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AWK="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +AWK=$ac_cv_path_AWK + +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +# Extract the first word of "grep", so it can be a program name with args. +set dummy grep; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GREP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GREP="$GREP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GREP="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +GREP=$ac_cv_path_GREP + +if test -n "$GREP"; then + echo "$as_me:$LINENO: result: $GREP" >&5 +echo "${ECHO_T}$GREP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "echo", so it can be a program name with args. +set dummy echo; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_ECHO+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $ECHO in + [\\/]* | ?:[\\/]*) + ac_cv_path_ECHO="$ECHO" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ECHO="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +ECHO=$ac_cv_path_ECHO + +if test -n "$ECHO"; then + echo "$as_me:$LINENO: result: $ECHO" >&5 +echo "${ECHO_T}$ECHO" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "sed", so it can be a program name with args. +set dummy sed; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_SED+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $SED in + [\\/]* | ?:[\\/]*) + ac_cv_path_SED="$SED" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_SED="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +SED=$ac_cv_path_SED + +if test -n "$SED"; then + echo "$as_me:$LINENO: result: $SED" >&5 +echo "${ECHO_T}$SED" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "cat", so it can be a program name with args. +set dummy cat; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_CAT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $CAT in + [\\/]* | ?:[\\/]*) + ac_cv_path_CAT="$CAT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CAT="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +CAT=$ac_cv_path_CAT + +if test -n "$CAT"; then + echo "$as_me:$LINENO: result: $CAT" >&5 +echo "${ECHO_T}$CAT" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + + +# Check whether --with-perl or --without-perl was given. +if test "${with_perl+set}" = set; then + withval="$with_perl" + with_perl=$withval +else + with_perl=$PERL +fi; +PERL=$with_perl + + + ac_config_files="$ac_config_files Makefile plugins-scripts/Makefile plugins-scripts/subst t/Makefile" +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by check_mssql_health $as_me 1.5.8.2, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +check_mssql_health config.status 1.5.8.2 +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "plugins-scripts/Makefile" ) CONFIG_FILES="$CONFIG_FILES plugins-scripts/Makefile" ;; + "plugins-scripts/subst" ) CONFIG_FILES="$CONFIG_FILES plugins-scripts/subst" ;; + "t/Makefile" ) CONFIG_FILES="$CONFIG_FILES t/Makefile" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CYGPATH_W@,$CYGPATH_W,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@mkdir_p@,$mkdir_p,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@am__leading_dot@,$am__leading_dot,;t t +s,@AMTAR@,$AMTAR,;t t +s,@am__tar@,$am__tar,;t t +s,@am__untar@,$am__untar,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@RELEASE@,$RELEASE,;t t +s,@INSTALL@,$INSTALL,;t t +s,@WARRANTY@,$WARRANTY,;t t +s,@SUPPORT@,$SUPPORT,;t t +s,@with_nagios_user@,$with_nagios_user,;t t +s,@with_nagios_group@,$with_nagios_group,;t t +s,@INSTALL_OPTS@,$INSTALL_OPTS,;t t +s,@STATEFILES_DIR@,$STATEFILES_DIR,;t t +s,@MYMODULES_DIR@,$MYMODULES_DIR,;t t +s,@MYMODULES_DYN_DIR@,$MYMODULES_DYN_DIR,;t t +s,@SH@,$SH,;t t +s,@PERL@,$PERL,;t t +s,@GZIP@,$GZIP,;t t +s,@GREP@,$GREP,;t t +s,@ECHO@,$ECHO,;t t +s,@SED@,$SED,;t t +s,@CAT@,$CAT,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + + +echo " --with-perl: $with_perl" +echo " --with-statefiles-dir: $with_statefiles_dir" +echo " --with-nagios-user: $with_nagios_user" +echo " --with-nagios-group: $with_nagios_group" +echo " --with-mymodules-dir: $with_mymodules_dir" +echo " --with-mymodules-dyn-dir: $with_mymodules_dyn_dir" diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/configure.in b/check_mssql_health/src/check_mssql_health-1.5.8.2/configure.in new file mode 100644 index 0000000..ac7a982 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/configure.in @@ -0,0 +1,101 @@ +dnl Process this file with autoconf to produce a configure script. +AC_REVISION ($Revision: 1.150 $) +AC_PREREQ(2.58) +AC_INIT(check_mssql_health,1.5.8.2) +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) + +dnl AC_PROG_CC +dnl AC_PROG_CPP +dnl AC_PROG_GCC_TRADITIONAL +dnl AC_PROG_RANLIB + +AC_PROG_MAKE_SET + +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(statefiles_dir, + ACX_HELP_STRING([--with-statefiles-dir=PATH], + [sets directory for the state files (default=/var/tmp/check_mssql_health)]), + with_statefiles_dir=$withval, + with_statefiles_dir=/var/tmp/check_mssql_health) +AC_SUBST(STATEFILES_DIR, $with_statefiles_dir) +echo variable with_statefiles_dir is $with_statefiles_dir + +AC_ARG_WITH(mymodules_dir, + ACX_HELP_STRING([--with-mymodules-dir=PATH], + [sets directory for own extensions which will be included during the build process (default=/usr/local/nagios/libexec)]), + with_mymodules_dir=$withval, + with_mymodules_dir=/usr/local/nagios/libexec) +AC_SUBST(MYMODULES_DIR, $with_mymodules_dir) +echo variable with_mymodules_dir is $with_mymodules_dir + +AC_ARG_WITH(mymodules_dyn_dir, + ACX_HELP_STRING([--with-mymodules-dyn-dir=PATH], + [sets directory for own extensions which will be included at runtime (default=/usr/local/nagios/libexec)]), + with_mymodules_dyn_dir=$withval, + with_mymodules_dyn_dir=/usr/local/nagios/libexec) +AC_SUBST(MYMODULES_DYN_DIR, $with_mymodules_dyn_dir) +echo variable with_mymodules_dyn_dir is $with_mymodules_dyn_dir + +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) +AC_PATH_PROG(GZIP,gzip) +AC_PATH_PROGS(AWK,gawk nawk /usr/xpg4/bin/awk awk) +AC_PATH_PROG(GREP,grep) +AC_PATH_PROG(ECHO,echo) +AC_PATH_PROG(SED,sed) +AC_PATH_PROG(CAT,cat) + +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 + t/Makefile +) + +ACX_FEATURE([with],[perl]) +ACX_FEATURE([with],[statefiles-dir]) +ACX_FEATURE([with],[nagios-user]) +ACX_FEATURE([with],[nagios-group]) +ACX_FEATURE([with],[mymodules-dir]) +ACX_FEATURE([with],[mymodules-dyn-dir]) diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/README.formula b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/README.formula new file mode 100644 index 0000000..7115d40 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/README.formula @@ -0,0 +1,73 @@ +========================================================================================== +http://www.sqlservercentral.com/Forums/Topic261080-5-1.aspx#bm261128 + +MachineName InstanceName DbName FileGroupName AllocatedMb UsedMb FreeMb FreePercent AutoGrowMb AutoGrowMaxSize +WIN2K3R2EE Default master PRIMARY 4 2 1 49 0.4 2147483647 +WIN2K3R2EE Default tempdb PRIMARY 8 1 6 86 0.8 2147483647 +WIN2K3R2EE Default model PRIMARY 1 0 0 17 1 2147483647 +WIN2K3R2EE Default msdb PRIMARY 4 3 0 15 0.25 2147483647 +WIN2K3R2EE Default ReportServer PRIMARY 3 1 1 38 1 2147483647 +WIN2K3R2EE Default ReportServerTempDB PRIMARY 2 1 1 53 1 2147483647 +WIN2K3R2EE Default AdventureWorksDW PRIMARY 68 60 8 12 16 2147483647 +WIN2K3R2EE Default AdventureWorks PRIMARY 163 153 10 6 16 2147483647 + + +set nocount on +create table #DBSpace +(DbName sysname +,FileGroupName sysname +,AllocatedMb integer +,UsedMb integer +,FreeMb integer +,FreePercent integer +,AutoGrowMb decimal(12,2) +,AutoGrowMaxSize integer +) +exec master.dbo.sp_MSForEachDb @command1 = +'dbcc updateusage([?]) with no_infomsgs +insert into #DBSpace +select ''?'' +, sysFileGroups.groupname +, F.AllocatedPages / 128 as AllocatedMb +, U.UsedPages / 128 as UsedMb +, (F.AllocatedPages - U.UsedPages) / 128 as FreeMb +, (F.AllocatedPages - U.UsedPages) * 100 + / F.AllocatedPages as FreePercent +, CAST(F.GrowthPages / 128.0 as decimal(12,2) ) as AutoGrowMb +, F.MaxSize as AutoGrowMaxSize +FROM (select GroupId + , sum( cast( used as bigint) ) + from [?].dbo.sysindexes + where indid in (0,1,255) + group by GroupId + ) as U ( GroupId , UsedPages) +join (select GroupId + , sum(cast( size as bigint) ) + , Max(growth) + , MAX(case status & 0x100000 + WHEN 0x100000 then Growth * Size / 100 -- Increase in Percentage + else Growth -- Increase in Pages + end) + , MAX( case maxsize when -1 then 2147483647 else maxsize end) + from [?].dbo.sysfiles + where (status & 64 = 0) + group by GroupId + ) as F (GroupId , AllocatedPages, Growth, GrowthPages, maxsize) + on F.GroupId = U.groupid +join sysFileGroups + on sysFileGroups.GroupId = U.groupId +' + + +select CAST( SERVERPROPERTY ('MachineName') as nvarchar(128) ) AS MachineName +, COALESCE ( CAST( SERVERPROPERTY ('InstanceName') as nvarchar(128) ) , 'Default') AS InstanceName +, DbName +, FileGroupName +, AllocatedMb +, UsedMb +, FreeMb +, FreePercent +, AutoGrowMb +, AutoGrowMaxSize +from #DBSpace + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/check_mssql_health.php b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/check_mssql_health.php new file mode 100644 index 0000000..6d0d02f --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/check_mssql_health.php @@ -0,0 +1,526 @@ + 0 -> next + if(isset($dbs)) continue; # da muss rein, dass $servicedesc schon gezeichnet wurde. + # hash bauen mit database als key + $dbs = array(); + $dsnr = array(); + $units = array(); + $numds = 1; + $colors = array("#ff0000","#00ffff","#0000ff","#00ff00"); #.....fuer singlegraph + $multigraph = 0; + foreach ($DS as $t) { + if(preg_match('/^(.*)_transactions_per_sec/', $NAME[$t], $match)) { + $dbs[] = $match[1]; + } + $dsnr[] = $DS[$t]; + $units[] = $UNIT[$t]; + $warn[] = $WARN[$t]; + $crit[] = $CRIT[$t]; + } + foreach ($dbs as $key => $db) { + $ds_transactions = $dsnr[$key * $numds]; + $units_transactions = $units[$key * $numds]; + $warn_transactions = $warn[$key * $numds]; + $crit_transactions = $crit[$key * $numds]; + # eine zweite ds wuerde so aussehen + # $ds_used = $dsnr[$key * $numds + 1]; + # aber transactions hat nur 1 ds + $ds_name[$defcnt] = "Transactions / sec of DB $db"; + $opt[$defcnt] = "--vertical-label \"Transactions/s\" -l0 --title \"Database $db transactions / sec\" "; + $def[$defcnt] = "DEF:trans=$rrdfile:".$ds_transactions.":AVERAGE " ; + if ($multigraph) { + $def[$defcnt] .= "CDEF:ag=trans,$WARN[$i],LE,trans,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,trans,0,IF "; + $def[$defcnt] .= "CDEF:ay=trans,$CRIT[$i],LE,trans,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,trans,0,IF "; + $def[$defcnt] .= "CDEF:ar=trans,100,LE,trans,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,trans,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:trans#000000:\"$db\" " ; + } else { + $def[$defcnt] = "DEF:trans=$rrdfile:".$ds_transactions.":AVERAGE " ; + $def[$defcnt] .= "AREA:trans#F2F2F2:\"\" " ; + $def[$defcnt] .= "LINE1:trans$colors[$multigraph]:\"$db\" " ; + } + $def[$defcnt] .= "GPRINT:trans:LAST:\"%3.2lf/s LAST \" "; + $def[$defcnt] .= "GPRINT:trans:MAX:\"%3.2lf/s MAX \" "; + $def[$defcnt] .= "GPRINT:trans:AVERAGE:\"%3.2lf/s AVERAGE \\n\" "; + if ($multigraph) { + $defcnt++; + } + } + } + if(preg_match('/^latch_waits_per_sec$/', $NAME[$i])) { + $ds_name[$defcnt] = "Latch Waits / Sec"; + $opt[$defcnt] = "--vertical-label \"waits / sec\" --title \"Latch waits / sec on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:waits=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=waits,$WARN[$i],LE,waits,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,waits,0,IF "; + $def[$defcnt] .= "CDEF:ay=waits,$CRIT[$i],LE,waits,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,waits,0,IF "; + $def[$defcnt] .= "CDEF:ar=waits,INF,LE,waits,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,waits,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:waits#000000:\" \" "; + $def[$defcnt] .= "VDEF:vwaits=waits,LAST " ; + $def[$defcnt] .= "GPRINT:vwaits:\"%3.2lf waits / sec\\n\" " ; + $defcnt++; + } + if(preg_match('/^latch_avg_wait_time$/', $NAME[$i])) { + $ds_name[$defcnt] = "Latch Wait Time"; + $opt[$defcnt] = "--vertical-label \"msec\" --title \"Latch avg wait time on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:waittime=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=waittime,$WARN[$i],LE,waittime,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,waittime,0,IF "; + $def[$defcnt] .= "CDEF:ay=waittime,$CRIT[$i],LE,waittime,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,waittime,0,IF "; + $def[$defcnt] .= "CDEF:ar=waittime,INF,LE,waittime,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,waittime,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:waittime#000000:\" \" "; + $def[$defcnt] .= "VDEF:vwaittime=waittime,LAST " ; + $def[$defcnt] .= "GPRINT:vwaittime:\"%3.2lf waittime (milliseconds)\\n\" " ; + $defcnt++; + } + if(preg_match('/^sql_initcompilations_per_sec$/', $NAME[$i])) { + $ds_name[$defcnt] = "Initial Compilations"; + $opt[$defcnt] = "--vertical-label \"initcomps/s\" --title \"Initial compilations / sec on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:comps=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=comps,$WARN[$i],LE,comps,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,comps,0,IF "; + $def[$defcnt] .= "CDEF:ay=comps,$CRIT[$i],LE,comps,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,comps,0,IF "; + $def[$defcnt] .= "CDEF:ar=comps,INF,LE,comps,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,comps,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:comps#000000:\" \" "; + $def[$defcnt] .= "VDEF:vcomps=comps,LAST " ; + $def[$defcnt] .= "GPRINT:vcomps:\"%3.2lf initial compilations / sec\\n\" " ; + $defcnt++; + } + if(preg_match('/^sql_recompilations_per_sec$/', $NAME[$i])) { + $ds_name[$defcnt] = "Re-Compilations"; + $opt[$defcnt] = "--vertical-label \"re-comps/s\" --title \"Re-Compilations / sec on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:comps=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=comps,$WARN[$i],LE,comps,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,comps,0,IF "; + $def[$defcnt] .= "CDEF:ay=comps,$CRIT[$i],LE,comps,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,comps,0,IF "; + $def[$defcnt] .= "CDEF:ar=comps,INF,LE,comps,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,comps,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:comps#000000:\" \" "; + $def[$defcnt] .= "VDEF:vcomps=comps,LAST " ; + $def[$defcnt] .= "GPRINT:vcomps:\"%3.2lf re-compilations / sec\\n\" " ; + $defcnt++; + } + if(preg_match('/^batch_requests_per_sec$/', $NAME[$i])) { + $ds_name[$defcnt] = "Batch Requests"; + $opt[$defcnt] = "--vertical-label \"batchreqs/s\" --title \"Batch requests / sec on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:breqs=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=breqs,$WARN[$i],LE,breqs,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,breqs,0,IF "; + $def[$defcnt] .= "CDEF:ay=breqs,$CRIT[$i],LE,breqs,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,breqs,0,IF "; + $def[$defcnt] .= "CDEF:ar=breqs,INF,LE,breqs,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,breqs,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:breqs#000000:\" \" "; + $def[$defcnt] .= "VDEF:lvbreqs=breqs,LAST " ; + $def[$defcnt] .= "VDEF:avbreqs=breqs,AVERAGE " ; + $def[$defcnt] .= "VDEF:mvbreqs=breqs,MAXIMUM " ; + $def[$defcnt] .= "GPRINT:lvbreqs:\"%3.2lf batch requests / sec \" " ; + $def[$defcnt] .= "GPRINT:avbreqs:\"(AVERAGE\: %3.2lf\" " ; + $def[$defcnt] .= "GPRINT:mvbreqs:\"MAX %3.2lf)\\n\" " ; + $defcnt++; + } + if(preg_match('/^checkpoint_pages_per_sec$/', $NAME[$i])) { + $ds_name[$defcnt] = "Checpoint Pages"; + $opt[$defcnt] = "--vertical-label \"pages/s\" --title \"Flushed pages / sec on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:pages=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=pages,$WARN[$i],LE,pages,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,pages,0,IF "; + $def[$defcnt] .= "CDEF:ay=pages,$CRIT[$i],LE,pages,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,pages,0,IF "; + $def[$defcnt] .= "CDEF:ar=pages,INF,LE,pages,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,pages,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:pages#000000:\" \" "; + $def[$defcnt] .= "VDEF:lvpages=pages,LAST " ; + $def[$defcnt] .= "VDEF:avpages=pages,AVERAGE " ; + $def[$defcnt] .= "VDEF:mvpages=pages,MAXIMUM " ; + $def[$defcnt] .= "GPRINT:lvpages:\"%3.2lf pages flushed / sec \" " ; + $def[$defcnt] .= "GPRINT:avpages:\"(AVERAGE\: %3.2lf\" " ; + $def[$defcnt] .= "GPRINT:mvpages:\"MAX %3.2lf)\\n\" " ; + $defcnt++; + } + if(preg_match('/^free_list_stalls_per_sec$/', $NAME[$i])) { + $ds_name[$defcnt] = "Free List Stalls"; + $opt[$defcnt] = "--vertical-label \"stalls/s\" --title \"Free list stalls / sec on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:stalls=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=stalls,$WARN[$i],LE,stalls,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,stalls,0,IF "; + $def[$defcnt] .= "CDEF:ay=stalls,$CRIT[$i],LE,stalls,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,stalls,0,IF "; + $def[$defcnt] .= "CDEF:ar=stalls,INF,LE,stalls,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,stalls,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:stalls#000000:\" \" "; + $def[$defcnt] .= "VDEF:lvstalls=stalls,LAST " ; + $def[$defcnt] .= "VDEF:avstalls=stalls,AVERAGE " ; + $def[$defcnt] .= "VDEF:mvstalls=stalls,MAXIMUM " ; + $def[$defcnt] .= "GPRINT:lvstalls:\"%3.2lf free list stalls / sec \" " ; + $def[$defcnt] .= "GPRINT:avstalls:\"(AVERAGE\: %3.2lf\" " ; + $def[$defcnt] .= "GPRINT:mvstalls:\"MAX %3.2lf)\\n\" " ; + $defcnt++; + } + if(preg_match('/^lazy_writes_per_sec$/', $NAME[$i])) { + $ds_name[$defcnt] = "Lazy Writes"; + $opt[$defcnt] = "--vertical-label \"lazyw/s\" --title \"Lazy writes / sec on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:lazyw=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=lazyw,$WARN[$i],LE,lazyw,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,lazyw,0,IF "; + $def[$defcnt] .= "CDEF:ay=lazyw,$CRIT[$i],LE,lazyw,$WARN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,lazyw,0,IF "; + $def[$defcnt] .= "CDEF:ar=lazyw,INF,LE,lazyw,$CRIT[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,lazyw,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:lazyw#000000:\" \" "; + $def[$defcnt] .= "VDEF:lvlazyw=lazyw,LAST " ; + $def[$defcnt] .= "VDEF:avlazyw=lazyw,AVERAGE " ; + $def[$defcnt] .= "VDEF:mvlazyw=lazyw,MAXIMUM " ; + $def[$defcnt] .= "GPRINT:lvlazyw:\"%3.2lf lazy writes / sec \" " ; + $def[$defcnt] .= "GPRINT:avlazyw:\"(AVERAGE\: %3.2lf\" " ; + $def[$defcnt] .= "GPRINT:mvlazyw:\"MAX %3.2lf)\\n\" " ; + $defcnt++; + } + if(preg_match('/^page_life_expectancy$/', $NAME[$i])) { + $ds_name[$defcnt] = "Page Life Expectancy"; + $opt[$defcnt] = "--vertical-label \"s\" --title \"Page life expectancy on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:lifeexp=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ar=lifeexp,$CRIT_MIN[$i],LE,lifeexp,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,lifeexp,0,IF "; + $def[$defcnt] .= "CDEF:ay=lifeexp,$WARN_MIN[$i],LE,lifeexp,$CRIT_MIN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,lifeexp,0,IF "; + $def[$defcnt] .= "CDEF:ag=lifeexp,INF,LE,lifeexp,$WARN_MIN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,lifeexp,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:lifeexp#000000:\" \" "; + $def[$defcnt] .= "VDEF:lvlifeexp=lifeexp,LAST " ; + $def[$defcnt] .= "VDEF:avlifeexp=lifeexp,AVERAGE " ; + $def[$defcnt] .= "VDEF:mvlifeexp=lifeexp,MINIMUM " ; + $def[$defcnt] .= "GPRINT:lvlifeexp:\"Page life expectancy is %3.2lf seconds \" " ; + $def[$defcnt] .= "GPRINT:avlifeexp:\"(AVERAGE\: %3.2lf\" " ; + $def[$defcnt] .= "GPRINT:mvlifeexp:\"MIN %3.2lf)\\n\" " ; + $defcnt++; + } + if(preg_match('/^total_server_memory$/', $NAME[$i])) { + $ds_name[$defcnt] = "Total Server memory"; + $opt[$defcnt] = "--vertical-label \"Bytes\" --title \"Total sql server memory on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:threads=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "AREA:threads#111111 "; + $def[$defcnt] .= "VDEF:vthreads=threads,LAST " ; + $def[$defcnt] .= "GPRINT:vthreads:\"%.0lf Bytes \" " ; + $defcnt++; + } + if(preg_match('/^buffer_cache_hit_ratio$/', $NAME[$i])) { + $ds_name[$defcnt] = "Buffer Cache Hit Ratio"; + $opt[$defcnt] = "--vertical-label \"%\" --title \"Buffer cache hit ratio on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:bufcahitrat=$rrdfile:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ar=bufcahitrat,$CRIT_MIN[$i],LE,bufcahitrat,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,bufcahitrat,0,IF "; + $def[$defcnt] .= "CDEF:ay=bufcahitrat,$WARN_MIN[$i],LE,bufcahitrat,$CRIT_MIN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,bufcahitrat,0,IF "; + $def[$defcnt] .= "CDEF:ag=bufcahitrat,100,LE,bufcahitrat,$WARN_MIN[$i],GT,INF,UNKN,IF,UNKN,IF,ISINF,bufcahitrat,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:bufcahitrat#000000:\" \" "; + $def[$defcnt] .= "VDEF:vbufcahitrat=bufcahitrat,LAST " ; + $def[$defcnt] .= "GPRINT:vbufcahitrat:\"Hit ratio is %3.2lf percent\\n\" " ; + $defcnt++; + } + if(preg_match('/^.*_lock_timeouts_per_sec/', $NAME[$i])) { + # if exists array locks && > 0 -> next + if(isset($locks)) continue; + # hash bauen mit tablespace als key + $locks = array(); + $dsnr = array(); + $units = array(); + $numds = 2; + foreach ($DS as $t) { + if(preg_match('/^(.*)_lock_timeouts_per_sec/', $NAME[$t], $match)) { + $locks[] = $match[1]; + } + $dsnr[] = $DS[$t]; + $units[] = $UNIT[$t]; + $warn[] = $WARN[$t]; + $crit[] = $CRIT[$t]; + $warn_min[] = $WARN_MIN[$t]; + $crit_min[] = $CRIT_MIN[$t]; + } + foreach ($locks as $key => $lock) { + $lock_timeouts_per_sec = $dsnr[$key * $numds]; + $unit_lock_timeouts_per_sec = $units[$key * $numds]; + $warn= $warn[$key * $numds]; + $crit= $crit[$key * $numds]; + + $ds_name[$defcnt] = "Lock Timeouts Per Second"; + $opt[$defcnt] = "--vertical-label \"timeouts / sec\" -l0 --title \"Timeouts / sec for lock $lock on $hostname \" "; + $def[$defcnt] = "DEF:timeouts=$rrdfile:".$lock_timeouts_per_sec.":AVERAGE " ; + $def[$defcnt] .= "CDEF:ag=timeouts,$warn,LE,timeouts,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,timeouts,0,IF "; + $def[$defcnt] .= "CDEF:ay=timeouts,$crit,LE,timeouts,$warn,GT,INF,UNKN,IF,UNKN,IF,ISINF,timeouts,0,IF "; + $def[$defcnt] .= "CDEF:ar=timeouts,INF,LE,timeouts,$crit,GT,INF,UNKN,IF,UNKN,IF,ISINF,timeouts,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:timeouts#000000:\" \" "; + $def[$defcnt] .= "VDEF:vtimeouts=timeouts,LAST " ; + $def[$defcnt] .= "GPRINT:vtimeouts:\"%8.3lf timeouts / sec\" "; + $defcnt++; + } + } + if(preg_match('/^.*_lock_waits_per_sec/', $NAME[$i])) { + # if exists array locks && > 0 -> next + if(isset($locks)) continue; + # hash bauen mit tablespace als key + $locks = array(); + $dsnr = array(); + $units = array(); + $numds = 2; + foreach ($DS as $t) { + if(preg_match('/^(.*)_lock_waits_per_sec/', $NAME[$t], $match)) { + $locks[] = $match[1]; + } + $dsnr[] = $DS[$t]; + $units[] = $UNIT[$t]; + $warn[] = $WARN[$t]; + $crit[] = $CRIT[$t]; + $warn_min[] = $WARN_MIN[$t]; + $crit_min[] = $CRIT_MIN[$t]; + } + foreach ($locks as $key => $lock) { + $lock_waits_per_sec = $dsnr[$key * $numds]; + $unit_lock_waits_per_sec = $units[$key * $numds]; + $warn= $warn[$key * $numds]; + $crit= $crit[$key * $numds]; + + $ds_name[$defcnt] = "Lock waits Per Second"; + $opt[$defcnt] = "--vertical-label \"waits / sec\" -l0 --title \"Waits / sec for lock $lock on $hostname \" "; + $def[$defcnt] = "DEF:waits=$rrdfile:".$lock_waits_per_sec.":AVERAGE " ; + $def[$defcnt] .= "CDEF:ag=waits,$crit,LE,waits,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,waits,0,IF "; + $def[$defcnt] .= "CDEF:ay=waits,$warn,LE,waits,$crit,GT,INF,UNKN,IF,UNKN,IF,ISINF,waits,0,IF "; + $def[$defcnt] .= "CDEF:ar=waits,100,LE,waits,$warn,GT,INF,UNKN,IF,UNKN,IF,ISINF,waits,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:waits#000000:\" \" "; + $defcnt++; + } + } + if(preg_match('/^.*_deadlocks_per_sec/', $NAME[$i])) { + # if exists array locks && > 0 -> next + if(isset($locks)) continue; + # hash bauen mit tablespace als key + $locks = array(); + $dsnr = array(); + $units = array(); + $numds = 2; + foreach ($DS as $t) { + if(preg_match('/^(.*)_deadlocks_per_sec/', $NAME[$t], $match)) { + $locks[] = $match[1]; + } + $dsnr[] = $DS[$t]; + $units[] = $UNIT[$t]; + $warn[] = $WARN[$t]; + $crit[] = $CRIT[$t]; + $warn_min[] = $WARN_MIN[$t]; + $crit_min[] = $CRIT_MIN[$t]; + } + foreach ($locks as $key => $lock) { + $lock_deadlocks_per_sec = $dsnr[$key * $numds]; + $unit_lock_deadlocks_per_sec = $units[$key * $numds]; + $warn= $warn[$key * $numds]; + $crit= $crit[$key * $numds]; + + $ds_name[$defcnt] = "Deadlocks Per Second"; + $opt[$defcnt] = "--vertical-label \"deadlocks / sec\" -l0 --title \"Deadlocks / sec for lock $lock on $hostname \" "; + $def[$defcnt] = "DEF:deadlocks=$rrdfile:".$lock_deadlocks_per_sec.":AVERAGE " ; + $def[$defcnt] .= "CDEF:ag=deadlocks,$crit,LE,deadlocks,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,deadlocks,0,IF "; + $def[$defcnt] .= "CDEF:ay=deadlocks,$warn,LE,deadlocks,$crit,GT,INF,UNKN,IF,UNKN,IF,ISINF,deadlocks,0,IF "; + $def[$defcnt] .= "CDEF:ar=deadlocks,100,LE,deadlocks,$warn,GT,INF,UNKN,IF,UNKN,IF,ISINF,deadlocks,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $defcnt++; + } + } + if(preg_match('/^db_.*_free_pct/', $NAME[$i])) { + # if exists array dbs && > 0 -> next + if(isset($dbs)) continue; + # hash bauen mit tablespace als key + $dbs = array(); + $dsnr = array(); + $units = array(); + $numds = 3; + $colors = array("#000000","#00ffff","#0000ff"); + foreach ($DS as $t) { + if(preg_match('/^db_(.*)_free_pct/', $NAME[$t], $match)) { + $dbs[] = $match[1]; + } + $dsnr[] = $DS[$t]; + $act[] = $ACT[$t]; + $units[] = $UNIT[$t]; + $warn[] = $WARN[$t]; + $crit[] = $CRIT[$t]; + $warn_min[] = $WARN_MIN[$t]; + $crit_min[] = $CRIT_MIN[$t]; + $max[] = $MAX[$t]; + $min[] = $MIN[$t]; + } + foreach ($dbs as $key => $db) { + $db_free_pct = $dsnr[$key * $numds]; + $db_free_mb = $dsnr[$key * $numds + 1]; + $db_free_mb_val = $act[$key * $numds + 1]; + $max_free_mb = $max[$key * $numds + 1]; + $db_alloc_pct = $dsnr[$key * $numds + 2]; + $unit_free_pct = $units[$key * $numds]; + $unit_free_mb = $units[$key * $numds + 1]; + $warn_free_pct = $warn_min[$key * $numds]; + $crit_free_pct = $crit_min[$key * $numds]; + + $ds_name[$defcnt] = "DB free space %"; + $opt[$defcnt] = "--vertical-label \"DB free space %\" -u102 -l0 --title \"Database $db free space \" "; + $def[$defcnt] = "DEF:free=$rrdfile:".$db_free_pct.":AVERAGE " ; + $def[$defcnt] .= "DEF:allocated=$rrdfile:".$db_alloc_pct.":AVERAGE " ; + $def[$defcnt] .= "DEF:freemb=$rrdfile:".$db_free_mb.":AVERAGE " ; + $def[$defcnt] .= "CDEF:ar=free,$crit_free_pct,LE,free,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,free,0,IF "; + $def[$defcnt] .= "CDEF:ay=free,$warn_free_pct,LE,free,$crit_free_pct,GT,INF,UNKN,IF,UNKN,IF,ISINF,free,0,IF "; + $def[$defcnt] .= "CDEF:ag=free,100,LE,free,$warn_free_pct,GT,INF,UNKN,IF,UNKN,IF,ISINF,free,0,IF "; + $def[$defcnt] .= "CDEF:used=100,free,- "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE0.6:free#000000:\" \" "; + $def[$defcnt] .= "AREA:used#00000030::STACK " ; + $def[$defcnt] .= "VDEF:lvfree=free,LAST " ; + $def[$defcnt] .= "VDEF:lvfreemb=freemb,LAST " ; + $def[$defcnt] .= "GPRINT:lvfree:\"Database $db has %.2lf%% free space left \" "; + $def[$defcnt] .= "COMMENT:\"($db_free_mb_val of $max_free_mb$unit_free_mb)\\n\" "; + $def[$defcnt] .= "COMMENT:\"($warn_free_pct $crit_free_pct\" "; + $def[$defcnt] .= "LINE1:allocated#FFFFFF:\" \" "; + $def[$defcnt] .= "VDEF:lvallocated=allocated,LAST " ; + $def[$defcnt] .= "GPRINT:lvallocated:\"Database $db has %.2lf%% allocated\\n\" "; + $defcnt++; + } + } +} +if(isset($dbs)) unset($dbs); +if(isset($locks)) unset($locks); +if(isset($warn)) unset($warn); +if(isset($crit)) unset($crit); +?> + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/create_user.sql b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/create_user.sql new file mode 100644 index 0000000..f57db49 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/create_user.sql @@ -0,0 +1,68 @@ +declare @dbname varchar(255) +declare @check_mssql_health_USER varchar(255) +declare @check_mssql_health_PASS varchar(255) +declare @check_mssql_health_ROLE varchar(255) +declare @source varchar(255) +declare @options varchar(255) +declare @backslash int + +/*******************************************************************/ +SET @check_mssql_health_USER = '"[Servername|Domainname]\Username"' +SET @check_mssql_health_PASS = 'Password' +SET @check_mssql_health_ROLE = 'Rolename' +/******************************************************************* + +PLEASE CHANGE THE ABOVE VALUES ACCORDING TO YOUR REQUIREMENTS + +- Example for Windows authentication: + SET @check_mssql_health_USER = '"[Servername|Domainname]\Username"' + SET @check_mssql_health_ROLE = 'Rolename' + +- Example for SQL Server authentication: + SET @check_mssql_health_USER = 'Username' + SET @check_mssql_health_PASS = 'Password' + SET @check_mssql_health_ROLE = 'Rolename' + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +It is strongly recommended to use Windows authentication. Otherwise +you will get no reliable results for database usage. +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +*********** NO NEED TO CHANGE ANYTHING BELOW THIS LINE *************/ + +SET @options = 'DEFAULT_DATABASE=MASTER, DEFAULT_LANGUAGE=English' +SET @backslash = (SELECT CHARINDEX('\', @check_mssql_health_USER)) +IF @backslash > 0 + BEGIN + SET @source = ' FROM WINDOWS' + SET @options = ' WITH ' + @options + END +ELSE + BEGIN + SET @source = '' + SET @options = ' WITH PASSWORD=''' + @check_mssql_health_PASS + ''',' + @options + END + +PRINT 'create Nagios plugin user ' + @check_mssql_health_USER +EXEC ('CREATE LOGIN ' + @check_mssql_health_USER + @source + @options) +EXEC ('USE MASTER GRANT VIEW SERVER STATE TO ' + @check_mssql_health_USER) +PRINT 'User ' + @check_mssql_health_USER + ' created.' +PRINT '' + +declare dblist cursor for + select name from sysdatabases WHERE name NOT IN ('master', 'tempdb', 'msdb') open dblist + fetch next from dblist into @dbname + while @@fetch_status = 0 begin + EXEC ('USE ' + @dbname + ' print ''Grant permissions in the db '' + ''"'' + DB_NAME() + ''"''') + EXEC ('USE ' + @dbname + ' CREATE ROLE ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' GRANT EXECUTE TO ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' GRANT VIEW DATABASE STATE TO ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' GRANT VIEW DEFINITION TO ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' CREATE USER ' + @check_mssql_health_USER + ' FOR LOGIN ' + @check_mssql_health_USER) + EXEC ('USE ' + @dbname + ' EXEC sp_addrolemember ' + @check_mssql_health_ROLE + ' , ' + @check_mssql_health_USER) + EXEC ('USE ' + @dbname + ' print ''Permissions in the db '' + ''"'' + DB_NAME() + ''" granted.''') + fetch next from dblist into @dbname + end +close dblist +deallocate dblist + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/delete_user.sql b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/delete_user.sql new file mode 100644 index 0000000..4b8b7d4 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/contrib/delete_user.sql @@ -0,0 +1,30 @@ +declare @dbname varchar(255) +declare @check_mssql_health_USER varchar(255) +declare @check_mssql_health_ROLE varchar(255) + +SET @check_mssql_health_USER = '"[Servername|Domainname]\Username"' +SET @check_mssql_health_ROLE = 'Rolename' + +declare dblist cursor for + select name from sysdatabases WHERE name NOT IN ('master', 'tempdb', 'msdb') open dblist + fetch next from dblist into @dbname + while @@fetch_status = 0 begin + EXEC ('USE ' + @dbname + ' print ''Revoke permissions in the db '' + ''"'' + DB_NAME() + ''"''') + EXEC ('USE ' + @dbname + ' EXEC sp_droprolemember ' + @check_mssql_health_ROLE + ' , ' + @check_mssql_health_USER) + EXEC ('USE ' + @dbname + ' DROP USER ' + @check_mssql_health_USER) + EXEC ('USE ' + @dbname + ' REVOKE VIEW DEFINITION TO ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' REVOKE VIEW DATABASE STATE TO ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' REVOKE EXECUTE TO ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' DROP ROLE ' + @check_mssql_health_ROLE) + EXEC ('USE ' + @dbname + ' print ''Permissions in the db '' + ''"'' + DB_NAME() + ''" revoked.''') + fetch next from dblist into @dbname + end +close dblist +deallocate dblist + +PRINT '' +PRINT 'drop Nagios plugin user ' + @check_mssql_health_USER +EXEC ('USE MASTER REVOKE VIEW SERVER STATE TO ' + @check_mssql_health_USER) +EXEC ('DROP LOGIN ' + @check_mssql_health_USER) +PRINT 'User ' + @check_mssql_health_USER + ' dropped.' + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh b/check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh new file mode 100644 index 0000000..f5061e7 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh @@ -0,0 +1,295 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2003-09-24.23 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename= +transform_arg= +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= + +usage="Usage: $0 [OPTION]... SRCFILE DSTFILE + or: $0 -d DIR1 DIR2... + +In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default. +In the second, create the directory path DIR. + +Options: +-b=TRANSFORMBASENAME +-c copy source (using $cpprog) instead of moving (using $mvprog). +-d create directories instead of installing files. +-g GROUP $chgrp installed files to GROUP. +-m MODE $chmod installed files to MODE. +-o USER $chown installed files to USER. +-s strip installed files (using $stripprog). +-t=TRANSFORM +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + -c) instcmd=$cpprog + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit 0;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + --version) echo "$0 $scriptversion"; exit 0;; + + *) if test -z "$src"; then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if test -z "$src"; then + echo "$0: no input file specified." >&2 + exit 1 +fi + +# Protect names starting with `-'. +case $src in + -*) src=./$src ;; +esac + +if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + instcmd=: + chmodcmd= + else + instcmd=$mkdirprog + fi +else + # Waiting for this to be detected by the "$instcmd $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + dst=$dst/`basename "$src"` + fi +fi + +# This sed command emulates the dirname command. +dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. + +# Skip lots of stat calls in the usual case. +if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + test -d "$pathcomp" || $mkdirprog "$pathcomp" + pathcomp=$pathcomp/ + done +fi + +if test -n "$dir_arg"; then + $doit $instcmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + +else + # If we're going to rename the final executable, determine the name now. + if test -z "$transformarg"; then + dstfile=`basename "$dst"` + else + dstfile=`basename "$dst" $transformbasename \ + | sed $transformarg`$transformbasename + fi + + # don't allow the sed command to completely eliminate the filename. + test -z "$dstfile" && dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Move or copy the file name to the temp name + $doit $instcmd "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $instcmd $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now remove or move aside any old file at destination location. We + # try this two ways since rm can't unlink itself on some systems and + # the destination file might be busy for other reasons. In this case, + # the final cleanup might fail but the new file should still install + # successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" +fi && + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/missing b/check_mssql_health/src/check_mssql_health-1.5.8.2/missing new file mode 100644 index 0000000..e7ef83a --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/missing @@ -0,0 +1,360 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2003-09-02.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# 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, 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile new file mode 100644 index 0000000..21d99f7 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile @@ -0,0 +1,358 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# plugins-scripts/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +srcdir = . +top_srcdir = .. +pkgdatadir = $(datadir)/check_mssql_health +pkglibdir = $(libdir)/check_mssql_health +pkgincludedir = $(includedir)/check_mssql_health +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +subdir = plugins-scripts +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/subst.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = subst +am__installdirs = "$(DESTDIR)$(libexecdir)" +libexecSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(libexec_SCRIPTS) +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +VPATH = $(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t +INSTALL = /usr/bin/install -c +ACLOCAL = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run aclocal-1.9 +AMTAR = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run tar +AUTOCONF = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoconf +AUTOHEADER = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoheader +AUTOMAKE = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run automake-1.9 +AWK = /usr/bin/gawk +CAT = /bin/cat +CYGPATH_W = echo +DEFS = -DPACKAGE_NAME=\"check_mssql_health\" -DPACKAGE_TARNAME=\"check_mssql_health\" -DPACKAGE_VERSION=\"1.5.8.2\" -DPACKAGE_STRING=\"check_mssql_health\ 1.5.8.2\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"check_mssql_health\" -DVERSION=\"1.5.8.2\" +ECHO = /bin/echo +ECHO_C = +ECHO_N = -n +ECHO_T = +GREP = /bin/grep +GZIP = /bin/gzip +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_OPTS = -o nagios -g nagios +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s +LIBOBJS = +LIBS = +LTLIBOBJS = +MAKEINFO = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run makeinfo +MYMODULES_DIR = /usr/local/nagios/libexec +MYMODULES_DYN_DIR = /usr/local/nagios/libexec +PACKAGE = check_mssql_health +PACKAGE_BUGREPORT = +PACKAGE_NAME = check_mssql_health +PACKAGE_STRING = check_mssql_health 1.5.8.2 +PACKAGE_TARNAME = check_mssql_health +PACKAGE_VERSION = 1.5.8.2 +PATH_SEPARATOR = : +PERL = /usr/bin/perl +RELEASE = 1 +SED = /bin/sed +SET_MAKE = +SH = /bin/sh +SHELL = /bin/bash +STATEFILES_DIR = /var/tmp/check_mssql_health +STRIP = +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 +VERSION = 1.5.8.2 +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_ct_STRIP = +am__leading_dot = . +am__tar = tar --format=posix -chf - "$$tardir" +am__untar = tar -xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +datadir = ${prefix}/share +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +includedir = ${prefix}/include +infodir = ${prefix}/info +install_sh = /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localstatedir = ${prefix}/var +mandir = ${prefix}/man +mkdir_p = mkdir -p -- +oldincludedir = /usr/include +prefix = /usr/local/nagios +program_transform_name = s,x,x, +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +sysconfdir = ${prefix}/etc +target_alias = +with_nagios_group = nagios +with_nagios_user = nagios +SUFFIXES = .pl .pm .sh +libexec_SCRIPTS = check_mssql_health +MY_MODULES = +EXTRA_MODULES = \ + Nagios/DBD/MSSQL/Server/Memorypool.pm \ + Nagios/DBD/MSSQL/Server/Database/Datafile.pm \ + Nagios/DBD/MSSQL/Server/Database.pm \ + Nagios/DBD/MSSQL/Server.pm \ + Nagios/Extraopts.pm + +EXTRA_DIST = check_mssql_health.pl $(EXTRA_MODULES) +CLEANFILES = $(libexec_SCRIPTS) +AM_INSTALL_PROGRAM_FLAGS = -o nagios -g nagios +all: all-am + +.SUFFIXES: +.SUFFIXES: .pl .pm .sh +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins-scripts/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu plugins-scripts/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +subst: $(top_builddir)/config.status $(srcdir)/subst.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-libexecSCRIPTS: $(libexec_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(libexecdir)" || $(mkdir_p) "$(DESTDIR)$(libexecdir)" + @list='$(libexec_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(libexecSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(libexecdir)/$$f'"; \ + $(libexecSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(libexecdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libexecSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f '$(DESTDIR)$(libexecdir)/$$f'"; \ + rm -f "$(DESTDIR)$(libexecdir)/$$f"; \ + done +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/Nagios $(distdir)/Nagios/DBD/MSSQL $(distdir)/Nagios/DBD/MSSQL/Server $(distdir)/Nagios/DBD/MSSQL/Server/Database + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) +installdirs: + for dir in "$(DESTDIR)$(libexecdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-libexecSCRIPTS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-libexecSCRIPTS + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am \ + install-libexecSCRIPTS install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-info-am \ + uninstall-libexecSCRIPTS + + +.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 > $@ +#since 1.5.1 $(ECHO) "# nagios: -epn" >> $@ + $(ECHO) >> $@ + $(ECHO) "my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 );" >> $@ + $(ECHO) "my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' );" >> $@ + for m in ${EXTRA_MODULES}; do \ + $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "my %ERROR" >> $@; \ + done + if [ -d "${MYMODULES_DIR}" ]; then \ + for m in ${MYMODULES_DIR}/CheckMSSQLHealthExt*.pm; do \ + if [ -f $$m ]; then \ + $(ECHO) found $$m; \ + $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "my %ERROR" >> $@; \ + fi \ + done \ + fi + $(CAT) check_mssql_health.pl | $(GREP) -v "^use Nagios" | $(GREP) -v "^my %ERROR" | $(AWK) -f ./subst >> $@ + chmod +x $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.am b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.am new file mode 100644 index 0000000..b450dd0 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.am @@ -0,0 +1,51 @@ +## Process this file with automake to produce Makefile.in + +SUFFIXES = .pl .pm .sh + +VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t + +libexec_SCRIPTS=check_mssql_health +MY_MODULES= +EXTRA_MODULES=\ + Nagios/DBD/MSSQL/Server/Memorypool.pm \ + Nagios/DBD/MSSQL/Server/Database/Datafile.pm \ + Nagios/DBD/MSSQL/Server/Database.pm \ + Nagios/DBD/MSSQL/Server.pm \ + Nagios/Extraopts.pm +EXTRA_DIST=check_mssql_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 > $@ +#since 1.5.1 $(ECHO) "# nagios: -epn" >> $@ + $(ECHO) >> $@ + $(ECHO) "my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 );" >> $@ + $(ECHO) "my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' );" >> $@ + for m in ${EXTRA_MODULES}; do \ + $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "my %ERROR" >> $@; \ + done + if [ -d "${MYMODULES_DIR}" ]; then \ + for m in ${MYMODULES_DIR}/CheckMSSQLHealthExt*.pm; do \ + if [ -f $$m ]; then \ + $(ECHO) found $$m; \ + $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "my %ERROR" >> $@; \ + fi \ + done \ + fi + $(CAT) check_mssql_health.pl | $(GREP) -v "^use Nagios" | $(GREP) -v "^my %ERROR" | $(AWK) -f ./subst >> $@ + chmod +x $@ diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.in b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.in new file mode 100644 index 0000000..c25869e --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Makefile.in @@ -0,0 +1,358 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = plugins-scripts +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/subst.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = subst +am__installdirs = "$(DESTDIR)$(libexecdir)" +libexecSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(libexec_SCRIPTS) +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +VPATH = $(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t +INSTALL = @INSTALL@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CAT = @CAT@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +GREP = @GREP@ +GZIP = @GZIP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_OPTS = @INSTALL_OPTS@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MYMODULES_DIR = @MYMODULES_DIR@ +MYMODULES_DYN_DIR = @MYMODULES_DYN_DIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +RELEASE = @RELEASE@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SH = @SH@ +SHELL = @SHELL@ +STATEFILES_DIR = @STATEFILES_DIR@ +STRIP = @STRIP@ +SUPPORT = @SUPPORT@ +VERSION = @VERSION@ +WARRANTY = @WARRANTY@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +with_nagios_group = @with_nagios_group@ +with_nagios_user = @with_nagios_user@ +SUFFIXES = .pl .pm .sh +libexec_SCRIPTS = check_mssql_health +MY_MODULES = +EXTRA_MODULES = \ + Nagios/DBD/MSSQL/Server/Memorypool.pm \ + Nagios/DBD/MSSQL/Server/Database/Datafile.pm \ + Nagios/DBD/MSSQL/Server/Database.pm \ + Nagios/DBD/MSSQL/Server.pm \ + Nagios/Extraopts.pm + +EXTRA_DIST = check_mssql_health.pl $(EXTRA_MODULES) +CLEANFILES = $(libexec_SCRIPTS) +AM_INSTALL_PROGRAM_FLAGS = @INSTALL_OPTS@ +all: all-am + +.SUFFIXES: +.SUFFIXES: .pl .pm .sh +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins-scripts/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu plugins-scripts/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +subst: $(top_builddir)/config.status $(srcdir)/subst.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-libexecSCRIPTS: $(libexec_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(libexecdir)" || $(mkdir_p) "$(DESTDIR)$(libexecdir)" + @list='$(libexec_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(libexecSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(libexecdir)/$$f'"; \ + $(libexecSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(libexecdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libexecSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f '$(DESTDIR)$(libexecdir)/$$f'"; \ + rm -f "$(DESTDIR)$(libexecdir)/$$f"; \ + done +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/Nagios $(distdir)/Nagios/DBD/MSSQL $(distdir)/Nagios/DBD/MSSQL/Server $(distdir)/Nagios/DBD/MSSQL/Server/Database + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) +installdirs: + for dir in "$(DESTDIR)$(libexecdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-libexecSCRIPTS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-libexecSCRIPTS + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am \ + install-libexecSCRIPTS install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-info-am \ + uninstall-libexecSCRIPTS + + +.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 > $@ +#since 1.5.1 $(ECHO) "# nagios: -epn" >> $@ + $(ECHO) >> $@ + $(ECHO) "my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 );" >> $@ + $(ECHO) "my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' );" >> $@ + for m in ${EXTRA_MODULES}; do \ + $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "my %ERROR" >> $@; \ + done + if [ -d "${MYMODULES_DIR}" ]; then \ + for m in ${MYMODULES_DIR}/CheckMSSQLHealthExt*.pm; do \ + if [ -f $$m ]; then \ + $(ECHO) found $$m; \ + $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "my %ERROR" >> $@; \ + fi \ + done \ + fi + $(CAT) check_mssql_health.pl | $(GREP) -v "^use Nagios" | $(GREP) -v "^my %ERROR" | $(AWK) -f ./subst >> $@ + chmod +x $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server.pm b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server.pm new file mode 100644 index 0000000..7640acf --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server.pm @@ -0,0 +1,2056 @@ +package DBD::MSSQL::Server; + +use strict; +use Time::HiRes; +use IO::File; +use File::Copy 'cp'; +use Data::Dumper; + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +{ + our $verbose = 0; + our $scream = 0; # scream if something is not implemented + our $my_modules_dyn_dir = ""; # where we look for self-written extensions + + my @servers = (); + my $initerrors = undef; + + sub add_server { + push(@servers, shift); + } + + sub return_servers { + return @servers; + } + + sub return_first_server() { + return $servers[0]; + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + method => $params{method} || "dbi", + hostname => $params{hostname}, + username => $params{username}, + password => $params{password}, + port => $params{port} || 1433, + server => $params{server}, + timeout => $params{timeout}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + verbose => $params{verbose}, + report => $params{report}, + version => 'unknown', + os => 'unknown', + servicename => 'unknown', + instance => undef, + memorypool => undef, + databases => [], + handle => undef, + }; + bless $self, $class; + $self->init_nagios(); + if ($self->dbconnect(%params)) { + #$self->{version} = $self->{handle}->fetchrow_array( + # q{ SELECT SERVERPROPERTY('productversion') }); + map { + $self->{os} = $1 if /Windows (.*)/; + $self->{version} = $1 if /SQL Server.*\-\s*([\d\.]+)/; + } $self->{handle}->fetchrow_array( + q{ SELECT @@VERSION }); + $self->{dbuser} = $self->{handle}->fetchrow_array( + q{ SELECT SYSTEM_USER }); # maybe SELECT SUSER_SNAME() + $self->{servicename} = $self->{handle}->fetchrow_array( + q{ SELECT @@SERVICENAME }); + if (lc $self->{servicename} ne 'mssqlserver') { + # braucht man fuer abfragen von dm_os_performance_counters + # object_name ist entweder "SQLServer:Buffer Node" oder z.b. "MSSQL$OASH: Buffer Node" + $self->{servicename} = 'MSSQL$'.$self->{servicename}; + } else { + $self->{servicename} = 'SQLServer'; + } + DBD::MSSQL::Server::add_server($self); + $self->init(%params); + } + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $params{handle} = $self->{handle}; + $self->set_global_db_thresholds(\%params); + if ($params{mode} =~ /^server::memorypool/) { + $self->{memorypool} = DBD::MSSQL::Server::Memorypool->new(%params); + } elsif ($params{mode} =~ /^server::database/) { + DBD::MSSQL::Server::Database::init_databases(%params); + if (my @databases = + DBD::MSSQL::Server::Database::return_databases()) { + $self->{databases} = \@databases; + } else { + $self->add_nagios_critical("unable to aquire database info"); + } + } elsif ($params{mode} =~ /^server::connectiontime/) { + $self->{connection_time} = $self->{tac} - $self->{tic}; + } elsif ($params{mode} =~ /^server::cpubusy/) { + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + ($self->{secs_busy}) = $self->{handle}->fetchrow_array(q{ + SELECT ((@@CPU_BUSY * CAST(@@TIMETICKS AS FLOAT)) / + (SELECT (CAST(CPU_COUNT AS FLOAT) / CAST(HYPERTHREAD_RATIO AS FLOAT)) FROM sys.dm_os_sys_info) / + 1000000) + }); + $self->valdiff(\%params, qw(secs_busy)); + if (defined $self->{secs_busy}) { + $self->{cpu_busy} = 100 * + $self->{delta_secs_busy} / $self->{delta_timestamp}; + } else { + $self->add_nagios_critical("got no cputime from dm_os_sys_info"); + } + } else { + #$self->requires_version('9'); + my @monitor = $params{handle}->exec_sp_1hash(q{exec sp_monitor}); + foreach (@monitor) { + if ($_->[0] eq 'cpu_busy') { + if ($_->[1] =~ /(\d+)%/) { + $self->{cpu_busy} = $1; + } + } + } + self->requires_version('9') unless defined $self->{cpu_busy}; + } + } elsif ($params{mode} =~ /^server::iobusy/) { + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + ($self->{secs_busy}) = $self->{handle}->fetchrow_array(q{ + SELECT ((@@IO_BUSY * CAST(@@TIMETICKS AS FLOAT)) / + (SELECT (CAST(CPU_COUNT AS FLOAT) / CAST(HYPERTHREAD_RATIO AS FLOAT)) FROM sys.dm_os_sys_info) / + 1000000) + }); + $self->valdiff(\%params, qw(secs_busy)); + if (defined $self->{secs_busy}) { + $self->{io_busy} = 100 * + $self->{delta_secs_busy} / $self->{delta_timestamp}; + } else { + $self->add_nagios_critical("got no iotime from dm_os_sys_info"); + } + } else { + #$self->requires_version('9'); + my @monitor = $params{handle}->exec_sp_1hash(q{exec sp_monitor}); + foreach (@monitor) { + if ($_->[0] eq 'io_busy') { + if ($_->[1] =~ /(\d+)%/) { + $self->{io_busy} = $1; + } + } + } + self->requires_version('9') unless defined $self->{io_busy}; + } + } elsif ($params{mode} =~ /^server::fullscans/) { + $self->{cnt_full_scans_s} = $self->{handle}->get_perf_counter( + 'SQLServer:Access Methods', 'Full Scans/sec'); + if (! defined $self->{cnt_full_scans_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(cnt_full_scans_s)); + $self->{full_scans_per_sec} = $self->{delta_cnt_full_scans_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::latch::waittime/) { + $self->{latch_wait_time} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Average Latch Wait Time (ms)"); + $self->{latch_wait_time_base} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Average Latch Wait Time Base"); + if (! defined $self->{latch_wait_time}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } + $self->{latch_wait_time} = $self->{latch_wait_time} / $self->{latch_wait_time_base}; + } elsif ($params{mode} =~ /^server::latch::waits/) { + $self->{latch_waits_s} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Latch Waits/sec"); + if (! defined $self->{latch_waits_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(latch_waits_s)); + $self->{latch_waits_per_sec} = $self->{delta_latch_waits_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::sql::.*compilations/) { + $self->{recompilations_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "SQL Re-Compilations/sec"); + $self->{compilations_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "SQL Compilations/sec"); + if (! defined $self->{recompilations_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(recompilations_s compilations_s)); + # http://www.sqlmag.com/Articles/ArticleID/40925/pg/3/3.html + # http://www.grumpyolddba.co.uk/monitoring/Performance%20Counter%20Guidance%20-%20SQL%20Server.htm + $self->{delta_initial_compilations_s} = $self->{delta_compilations_s} - + $self->{delta_recompilations_s}; + $self->{initial_compilations_per_sec} = + $self->{delta_initial_compilations_s} / $self->{delta_timestamp}; + $self->{recompilations_per_sec} = + $self->{delta_recompilations_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::batchrequests/) { + $self->{batch_requests_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "Batch requests/sec"); + if (! defined $self->{batch_requests_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(batch_requests_s)); + $self->{batch_requests_per_sec} = $self->{delta_batch_requests_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::totalmemory/) { + $self->{total_memory} = $self->{handle}->get_perf_counter( + "SQLServer:Memory Manager", "Total Server Memory (KB)"); + if (! defined $self->{total_memory}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } + } elsif ($params{mode} =~ /^server::connectedusers/) { + $self->{connectedusers} = $self->{handle}->fetchrow_array(q{ + SELECT + COUNT(*) + FROM + master..sysprocesses + WHERE + spid > ? + }, 51); + if (! defined $self->{connectedusers}) { + $self->add_nagios_unknown("unable to count connected users"); + } + } elsif ($params{mode} =~ /^server::sql/) { + $self->set_local_db_thresholds(%params); + if ($params{regexp}) { + # sql output is treated as text + if ($params{name2} eq $params{name}) { + $self->add_nagios_unknown(sprintf "where's the regexp????"); + } else { + $self->{genericsql} = + $self->{handle}->fetchrow_array($params{selectname}); + if (! defined $self->{genericsql}) { + $self->add_nagios_unknown(sprintf "got no valid response for %s", + $params{selectname}); + } + } + } else { + # sql output must be a number (or array of numbers) + @{$self->{genericsql}} = + $self->{handle}->fetchrow_array($params{selectname}); + if (! (defined $self->{genericsql} && + (scalar(grep { /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/ } @{$self->{genericsql}})) == + scalar(@{$self->{genericsql}}))) { + $self->add_nagios_unknown(sprintf "got no valid response for %s", + $params{selectname}); + } else { + # name2 in array + # units in array + } + } + } elsif ($params{mode} =~ /^my::([^:.]+)/) { + my $class = $1; + my $loaderror = undef; + substr($class, 0, 1) = uc substr($class, 0, 1); + foreach my $libpath (split(":", $DBD::MSSQL::Server::my_modules_dyn_dir)) { + foreach my $extmod (glob $libpath."/CheckMSSQLHealth*.pm") { + eval { + $self->trace(sprintf "loading module %s", $extmod); + require $extmod; + }; + if ($@) { + $loaderror = $extmod; + $self->trace(sprintf "failed loading module %s: %s", $extmod, $@); + } + } + } + my $obj = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $obj, "My$class"; + $self->{my} = $obj; + if ($self->{my}->isa("DBD::MSSQL::Server")) { + my $dos_init = $self->can("init"); + my $dos_nagios = $self->can("nagios"); + my $my_init = $self->{my}->can("init"); + my $my_nagios = $self->{my}->can("nagios"); + if ($my_init == $dos_init) { + $self->add_nagios_unknown( + sprintf "Class %s needs an init() method", ref($self->{my})); + } elsif ($my_nagios == $dos_nagios) { + $self->add_nagios_unknown( + sprintf "Class %s needs a nagios() method", ref($self->{my})); + } else { + $self->{my}->init_nagios(%params); + $self->{my}->init(%params); + } + } else { + $self->add_nagios_unknown( + sprintf "Class %s is not a subclass of DBD::MSSQL::Server%s", + ref($self->{my}), + $loaderror ? sprintf " (syntax error in %s?)", $loaderror : "" ); + } + } else { + printf "broken mode %s\n", $params{mode}; + } +} + +sub dump { + my $self = shift; + my $message = shift || ""; + printf "%s %s\n", $message, Data::Dumper::Dumper($self); +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /^server::instance/) { + $self->{instance}->nagios(%params); + $self->merge_nagios($self->{instance}); + } elsif ($params{mode} =~ /server::database::listdatabases/) { + foreach (sort { $a->{name} cmp $b->{name}; } @{$self->{databases}}) { + printf "%s\n", $_->{name}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::database/) { + foreach (@{$self->{databases}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } elsif ($params{mode} =~ /^server::database/) { + } elsif ($params{mode} =~ /^server::lock/) { + foreach (@{$self->{locks}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } elsif ($params{mode} =~ /^server::memorypool/) { + $self->{memorypool}->nagios(%params); + $self->merge_nagios($self->{memorypool}); + } elsif ($params{mode} =~ /^server::connectiontime/) { + $self->add_nagios( + $self->check_thresholds($self->{connection_time}, 1, 5), + sprintf "%.2f seconds to connect as %s", + $self->{connection_time}, $self->{dbuser}); + $self->add_perfdata(sprintf "connection_time=%.2f;%d;%d", + $self->{connection_time}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::cpubusy/) { + $self->add_nagios( + $self->check_thresholds($self->{cpu_busy}, 80, 90), + sprintf "CPU busy %.2f%%", $self->{cpu_busy}); + $self->add_perfdata(sprintf "cpu_busy=%.2f;%s;%s", + $self->{cpu_busy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::iobusy/) { + $self->add_nagios( + $self->check_thresholds($self->{io_busy}, 80, 90), + sprintf "IO busy %.2f%%", $self->{io_busy}); + $self->add_perfdata(sprintf "io_busy=%.2f;%s;%s", + $self->{io_busy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::fullscans/) { + $self->add_nagios( + $self->check_thresholds($self->{full_scans_per_sec}, 100, 500), + sprintf "%.2f full table scans / sec", $self->{full_scans_per_sec}); + $self->add_perfdata(sprintf "full_scans_per_sec=%.2f;%s;%s", + $self->{full_scans_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::latch::waits/) { + $self->add_nagios( + $self->check_thresholds($self->{latch_waits_per_sec}, 10, 50), + sprintf "%.2f latches / sec have to wait", $self->{latch_waits_per_sec}); + $self->add_perfdata(sprintf "latch_waits_per_sec=%.2f;%s;%s", + $self->{latch_waits_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::latch::waittime/) { + $self->add_nagios( + $self->check_thresholds($self->{latch_wait_time}, 1, 5), + sprintf "latches have to wait %.2f ms avg", $self->{latch_wait_time}); + $self->add_perfdata(sprintf "latch_avg_wait_time=%.2fms;%s;%s", + $self->{latch_wait_time}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql::recompilations/) { + $self->add_nagios( + $self->check_thresholds($self->{recompilations_per_sec}, 1, 10), + sprintf "%.2f SQL recompilations / sec", $self->{recompilations_per_sec}); + $self->add_perfdata(sprintf "sql_recompilations_per_sec=%.2f;%s;%s", + $self->{recompilations_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql::initcompilations/) { + $self->add_nagios( + $self->check_thresholds($self->{initial_compilations_per_sec}, 100, 200), + sprintf "%.2f initial compilations / sec", $self->{initial_compilations_per_sec}); + $self->add_perfdata(sprintf "sql_initcompilations_per_sec=%.2f;%s;%s", + $self->{initial_compilations_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::batchrequests/) { + $self->add_nagios( + $self->check_thresholds($self->{batch_requests_per_sec}, 100, 200), + sprintf "%.2f batch requests / sec", $self->{batch_requests_per_sec}); + $self->add_perfdata(sprintf "batch_requests_per_sec=%.2f;%s;%s", + $self->{batch_requests_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::totalmemory/) { + $self->add_nagios( + $self->check_thresholds($self->{total_memory}, 1000, 5000), + sprintf "total server memory %ld", $self->{total_memory}); + $self->add_perfdata(sprintf "total_server_memory=%ld;%s;%s", + $self->{total_memory}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::connectedusers/) { + $self->add_nagios( + $self->check_thresholds($self->{connectedusers}, 50, 80), + sprintf "%d connected users", $self->{connectedusers}); + $self->add_perfdata(sprintf "connected_users=%d;%s;%s", + $self->{connectedusers}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql/) { + if ($params{regexp}) { + if (substr($params{name2}, 0, 1) eq '!') { + $params{name2} =~ s/^!//; + if ($self->{genericsql} !~ /$params{name2}/) { + $self->add_nagios_ok( + sprintf "output %s does not match pattern %s", + $self->{genericsql}, $params{name2}); + } else { + $self->add_nagios_critical( + sprintf "output %s matches pattern %s", + $self->{genericsql}, $params{name2}); + } + } else { + if ($self->{genericsql} =~ /$params{name2}/) { + $self->add_nagios_ok( + sprintf "output %s matches pattern %s", + $self->{genericsql}, $params{name2}); + } else { + $self->add_nagios_critical( + sprintf "output %s does not match pattern %s", + $self->{genericsql}, $params{name2}); + } + } + } else { + $self->add_nagios( + # the first item in the list will trigger the threshold values + $self->check_thresholds($self->{genericsql}[0], 1, 5), + sprintf "%s: %s%s", + $params{name2} ? lc $params{name2} : lc $params{selectname}, + # float as float, integers as integers + join(" ", map { + (sprintf("%d", $_) eq $_) ? $_ : sprintf("%f", $_) + } @{$self->{genericsql}}), + $params{units} ? $params{units} : ""); + my $i = 0; + # workaround... getting the column names from the database would be nicer + my @names2_arr = split(/\s+/, $params{name2}); + foreach my $t (@{$self->{genericsql}}) { + $self->add_perfdata(sprintf "\'%s\'=%s%s;%s;%s", + $names2_arr[$i] ? lc $names2_arr[$i] : lc $params{selectname}, + # float as float, integers as integers + (sprintf("%d", $t) eq $t) ? $t : sprintf("%f", $t), + $params{units} ? $params{units} : "", + ($i == 0) ? $self->{warningrange} : "", + ($i == 0) ? $self->{criticalrange} : "" + ); + $i++; + } + } + } elsif ($params{mode} =~ /^my::([^:.]+)/) { + $self->{my}->nagios(%params); + $self->merge_nagios($self->{my}); + } + } +} + + +sub init_nagios { + my $self = shift; + no strict 'refs'; + if (! ref($self)) { + my $nagiosvar = $self."::nagios"; + my $nagioslevelvar = $self."::nagios_level"; + $$nagiosvar = { + messages => { + 0 => [], + 1 => [], + 2 => [], + 3 => [], + }, + perfdata => [], + }; + $$nagioslevelvar = $ERRORS{OK}, + } else { + $self->{nagios} = { + messages => { + 0 => [], + 1 => [], + 2 => [], + 3 => [], + }, + perfdata => [], + }; + $self->{nagios_level} = $ERRORS{OK}, + } +} + +sub check_thresholds { + my $self = shift; + my $value = shift; + my $defaultwarningrange = shift; + my $defaultcriticalrange = shift; + my $level = $ERRORS{OK}; + $self->{warningrange} = defined $self->{warningrange} ? + $self->{warningrange} : $defaultwarningrange; + $self->{criticalrange} = defined $self->{criticalrange} ? + $self->{criticalrange} : $defaultcriticalrange; + if ($self->{warningrange} !~ /:/ && $self->{criticalrange} !~ /:/) { + # warning = 10, critical = 20, warn if > 10, crit if > 20 + $level = $ERRORS{WARNING} if $value > $self->{warningrange}; + $level = $ERRORS{CRITICAL} if $value > $self->{criticalrange}; + } elsif ($self->{warningrange} =~ /(\d+):/ && + $self->{criticalrange} =~ /(\d+):/) { + # warning = 98:, critical = 95:, warn if < 98, crit if < 95 + $self->{warningrange} =~ /(\d+):/; + $level = $ERRORS{WARNING} if $value < $1; + $self->{criticalrange} =~ /(\d+):/; + $level = $ERRORS{CRITICAL} if $value < $1; + } + return $level; + # + # syntax error must be reported with returncode -1 + # +} + +sub add_nagios { + my $self = shift; + my $level = shift; + my $message = shift; + push(@{$self->{nagios}->{messages}->{$level}}, $message); + # recalc current level + foreach my $llevel qw(CRITICAL WARNING UNKNOWN OK) { + if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$llevel}}})) { + $self->{nagios_level} = $ERRORS{$llevel}; + } + } +} + +sub add_nagios_ok { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{OK}, $message); +} + +sub add_nagios_warning { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{WARNING}, $message); +} + +sub add_nagios_critical { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{CRITICAL}, $message); +} + +sub add_nagios_unknown { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{UNKNOWN}, $message); +} + +sub add_perfdata { + my $self = shift; + my $data = shift; + push(@{$self->{nagios}->{perfdata}}, $data); +} + +sub merge_nagios { + my $self = shift; + my $child = shift; + foreach my $level (0..3) { + foreach (@{$child->{nagios}->{messages}->{$level}}) { + $self->add_nagios($level, $_); + } + #push(@{$self->{nagios}->{messages}->{$level}}, + # @{$child->{nagios}->{messages}->{$level}}); + } + push(@{$self->{nagios}->{perfdata}}, @{$child->{nagios}->{perfdata}}); +} + +sub calculate_result { + my $self = shift; + my $multiline = 0; + map { + $self->{nagios_level} = $ERRORS{$_} if + (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}})); + } ("OK", "UNKNOWN", "WARNING", "CRITICAL"); + if ($ENV{NRPE_MULTILINESUPPORT} && + length join(" ", @{$self->{nagios}->{perfdata}}) > 200) { + $multiline = 1; + } + if ($multiline) { + my $num_ok = @{$self->{nagios}->{messages}->{ $ERRORS{"OK"} } }; + my $num_crit = @{$self->{nagios}->{messages}->{ $ERRORS{"WARNING"} }}; + my $num_warn = @{$self->{nagios}->{messages}->{ $ERRORS{"CRITICAL"} }}; + my $num_unk = @{$self->{nagios}->{messages}->{ $ERRORS{"UNKNOWN"} }}; + $self->{nagios_message} .= sprintf "%s ok, %s warnings, %s criticals and %s unknown\n", + $num_ok, $num_warn,$num_crit, $num_unk; + } + my $all_messages = join(($multiline ? "\n" : ", "), map { + join(($multiline ? "\n" : ", "), @{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN", "OK")); + my $bad_messages = join(($multiline ? "\n" : ", "), map { + join(($multiline ? "\n" : ", "), @{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN")); + my $all_messages_short = $bad_messages ? $bad_messages : 'no problems'; + my $all_messages_html = "". + join("", map { + my $level = $_; + join("", map { + sprintf "", + $level, $_; + } @{$self->{nagios}->{messages}->{$ERRORS{$_}}}); + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN", "OK")). + "
%s
"; + if (exists $self->{identstring}) { + $self->{nagios_message} .= $self->{identstring}; + } + if ($self->{report} eq "long") { + $self->{nagios_message} .= $all_messages; + } elsif ($self->{report} eq "short") { + $self->{nagios_message} .= $all_messages_short; + } elsif ($self->{report} eq "html") { + $self->{nagios_message} .= $all_messages_short."\n".$all_messages_html; + } + $self->{perfdata} = join(" ", @{$self->{nagios}->{perfdata}}); +} + +sub set_global_db_thresholds { + my $self = shift; + my $params = shift; + my $warning = undef; + my $critical = undef; + return unless defined $params->{dbthresholds}; + $params->{name0} = $params->{dbthresholds}; + # :pluginmode :name :warning :critical + # mode empty + # + eval { + my $find_sql = undef; + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + $find_sql = q{ + SELECT name FROM sys.objects + WHERE name = 'check_mssql_health_thresholds' + }; + } else { + $find_sql = q{ + SELECT name FROM sysobjects + WHERE name = 'check_mssql_health_thresholds' + }; + } + if ($self->{handle}->fetchrow_array($find_sql)) { + my @dbthresholds = $self->{handle}->fetchall_array(q{ + SELECT * FROM check_mssql_health_thresholds + }); + $params->{dbthresholds} = \@dbthresholds; + foreach (@dbthresholds) { + if (($_->[0] eq $params->{cmdlinemode}) && + (! defined $_->[1] || ! $_->[1])) { + ($warning, $critical) = ($_->[2], $_->[3]); + } + } + } + }; + if (! $@) { + if ($warning) { + $params->{warningrange} = $warning; + $self->trace("read warningthreshold %s from database", $warning); + } + if ($critical) { + $params->{criticalrange} = $critical; + $self->trace("read criticalthreshold %s from database", $critical); + } + } +} + +sub set_local_db_thresholds { + my $self = shift; + my %params = @_; + my $warning = undef; + my $critical = undef; + # :pluginmode :name :warning :critical + # mode name0 + # mode name2 + # mode name + # + # first: argument of --dbthresholds, it it exists + # second: --name2 + # third: --name + if (ref($params{dbthresholds}) eq 'ARRAY') { + my $marker; + foreach (@{$params{dbthresholds}}) { + if ($_->[0] eq $params{cmdlinemode}) { + if (defined $_->[1] && $params{name0} && $_->[1] eq $params{name0}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name0}; + last; + } elsif (defined $_->[1] && $params{name2} && $_->[1] eq $params{name2}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name2}; + last; + } elsif (defined $_->[1] && $params{name} && $_->[1] eq $params{name}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name}; + last; + } + } + } + if ($warning) { + $self->{warningrange} = $warning; + $self->trace("read warningthreshold %s for %s from database", + $marker, $warning); + } + if ($critical) { + $self->{criticalrange} = $critical; + $self->trace("read criticalthreshold %s for %s from database", + $marker, $critical); + } + } +} + +sub debug { + my $self = shift; + my $msg = shift; + if ($DBD::MSSQL::Server::verbose) { + printf "%s %s\n", $msg, ref($self); + } +} + +sub dbconnect { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{tic} = Time::HiRes::time(); + $self->{handle} = DBD::MSSQL::Server::Connection->new(%params); + if ($self->{handle}->{errstr}) { + if ($self->{handle}->{errstr} eq "alarm\n") { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "connection could not be established within %d seconds", + $self->{timeout}); + } else { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "cannot connect to %s. %s", + ($self->{server} ? $self->{server} : + ($self->{hostname} ? $self->{hostname} : "unknown host")), + $self->{handle}->{errstr}); + $retval = undef; + } + } else { + $retval = $self->{handle}; + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub trace { + my $self = shift; + my $format = shift; + if (! @_) { + # falls im sql-statement % vorkommen. sonst krachts im printf + $format =~ s/%/%%/g; + } + $self->{trace} = -f "/tmp/check_mssql_health.trace" ? 1 : 0; + if ($DBD::MSSQL::Server::verbose) { + printf("%s: ", scalar localtime); + printf($format, @_); + } + if ($self->{trace}) { + my $logfh = new IO::File; + $logfh->autoflush(1); + if ($logfh->open("/tmp/check_mssql_health.trace", "a")) { + $logfh->printf("%s: ", scalar localtime); + $logfh->printf($format, @_); + $logfh->printf("\n"); + $logfh->close(); + } + } +} + +sub DESTROY { + my $self = shift; + my $handle1 = "null"; + my $handle2 = "null"; + if (defined $self->{handle}) { + $handle1 = ref($self->{handle}); + if (defined $self->{handle}->{handle}) { + $handle2 = ref($self->{handle}->{handle}); + } + } + #$self->trace(sprintf "DESTROY %s with handle %s %s", ref($self), $handle1, $handle2); + if (ref($self) eq "DBD::MSSQL::Server") { + } + #$self->trace(sprintf "DESTROY %s exit with handle %s %s", ref($self), $handle1, $handle2); + if (ref($self) eq "DBD::MSSQL::Server") { + #printf "humpftata\n"; + } +} + +sub save_state { + my $self = shift; + my %params = @_; + my $extension = ""; + my $mode = $params{mode}; + if ($^O =~ /MSWin/) { + $mode =~ s/::/_/g; + $params{statefilesdir} = $self->system_vartmpdir(); + } + mkdir $params{statefilesdir} unless -d $params{statefilesdir}; + my $statefile = sprintf "%s/%s_%s", + $params{statefilesdir}, ($params{hostname} || $params{server}), $mode; + $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{port} ? "_".$params{port} : ""; + $extension .= $params{database} ? "_".$params{database} : ""; + $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 = ""; + my $mode = $params{mode}; + if ($^O =~ /MSWin/) { + $mode =~ s/::/_/g; + $params{statefilesdir} = $self->system_vartmpdir(); + } + my $statefile = sprintf "%s/%s_%s", + $params{statefilesdir}, ($params{hostname} || $params{server}), $mode; + $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{port} ? "_".$params{port} : ""; + $extension .= $params{database} ? "_".$params{database} : ""; + $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 valdiff { + my $self = shift; + my $pparams = shift; + my %params = %{$pparams}; + my @keys = @_; + my $last_values = $self->load_state(%params) || eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = 0; + } + $empty_events->{timestamp} = 0; + $empty_events; + }; + foreach (@keys) { + $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'} = time - $last_values->{timestamp}; + $params{save} = eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = $self->{$_}; + } + $empty_events->{timestamp} = time; + $empty_events; + }; + $self->save_state(%params); +} + +sub requires_version { + my $self = shift; + my $version = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + my $instversion = $instances[0]->{version}; + if (! $self->version_is_minimum($version)) { + $self->add_nagios($ERRORS{UNKNOWN}, + sprintf "not implemented/possible for MSSQL release %s", $instversion); + } +} + +sub version_is_minimum { + # the current version is newer or equal + my $self = shift; + my $version = shift; + my $newer = 1; + my @instances = DBD::MSSQL::Server::return_servers(); + my @v1 = map { $_ eq "x" ? 0 : $_ } split(/\./, $version); + my @v2 = split(/\./, $instances[0]->{version}); + if (scalar(@v1) > scalar(@v2)) { + push(@v2, (0) x (scalar(@v1) - scalar(@v2))); + } elsif (scalar(@v2) > scalar(@v1)) { + push(@v1, (0) x (scalar(@v2) - scalar(@v1))); + } + foreach my $pos (0..$#v1) { + if ($v2[$pos] > $v1[$pos]) { + $newer = 1; + last; + } elsif ($v2[$pos] < $v1[$pos]) { + $newer = 0; + last; + } + } + #printf STDERR "check if %s os minimum %s\n", join(".", @v2), join(".", @v1); + return $newer; +} + +sub instance_rac { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + return (lc $instances[0]->{parallel} eq "yes") ? 1 : 0; +} + +sub instance_thread { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + return $instances[0]->{thread}; +} + +sub windows_server { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + if ($instances[0]->{os} =~ /Win/i) { + return 1; + } else { + return 0; + } +} + +sub system_vartmpdir { + my $self = shift; + if ($^O =~ /MSWin/) { + return $self->system_tmpdir(); + } else { + return "/var/tmp/check_mssql_health"; + } +} + +sub system_oldvartmpdir { + my $self = shift; + return "/tmp"; +} + +sub system_tmpdir { + my $self = shift; + if ($^O =~ /MSWin/) { + return $ENV{TEMP} if defined $ENV{TEMP}; + return $ENV{TMP} if defined $ENV{TMP}; + return File::Spec->catfile($ENV{windir}, 'Temp') + if defined $ENV{windir}; + return 'C:\Temp'; + } else { + return "/tmp"; + } +} + + +package DBD::MSSQL::Server::Connection; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +sub new { + my $class = shift; + my %params = @_; + my $self = { + mode => $params{mode}, + timeout => $params{timeout}, + method => $params{method} || "dbi", + hostname => $params{hostname}, + username => $params{username}, + password => $params{password}, + verbose => $params{verbose}, + port => $params{port} || 1433, + server => $params{server}, + currentdb => $params{currentdb}, + handle => undef, + }; + bless $self, $class; + if ($params{method} eq "dbi") { + bless $self, "DBD::MSSQL::Server::Connection::Dbi"; + } elsif ($params{method} eq "sqsh") { + bless $self, "DBD::MSSQL::Server::Connection::Sqsh"; + } elsif ($params{method} eq "sqlrelay") { + bless $self, "DBD::MSSQL::Server::Connection::Sqlrelay"; + } elsif ($params{method} eq "sqlcmd") { + bless $self, "DBD::MSSQL::Server::Connection::Sqlcmd"; + } + $self->init(%params); + return $self; +} + +sub get_instance_names { + my $self = shift; + my $object_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchall_array(q{ + SELECT + DISTINCT instance_name + FROM + sys.dm_os_performance_counters + WHERE + object_name = ? + }, $object_name); + } else { + return $self->fetchall_array(q{ + SELECT + DISTINCT instance_name + FROM + master.dbo.sysperfinfo + WHERE + object_name = ? + }, $object_name); + } +} + +sub get_perf_counter { + my $self = shift; + my $object_name = shift; + my $counter_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + sys.dm_os_performance_counters + WHERE + counter_name = ? AND + object_name = ? + }, $counter_name, $object_name); + } else { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + master.dbo.sysperfinfo + WHERE + counter_name = ? AND + object_name = ? + }, $counter_name, $object_name); + } +} + +sub get_perf_counter_instance { + my $self = shift; + my $object_name = shift; + my $counter_name = shift; + my $instance_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + sys.dm_os_performance_counters + WHERE + counter_name = ? AND + object_name = ? AND + instance_name = ? + }, $counter_name, $object_name, $instance_name); + } else { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + master.dbo.sysperfinfo + WHERE + counter_name = ? AND + object_name = ? AND + instance_name = ? + }, $counter_name, $object_name, $instance_name); + } +} + +package DBD::MSSQL::Server::Connection::Dbi; + +use strict; +use Net::Ping; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + if ($self->{mode} =~ /^server::tnsping/) { + # erstmal reserviert fuer irgendeinen tcp-connect + if (! $self->{connect}) { + $self->{errstr} = "Please specify a database"; + } else { + $self->{sid} = $self->{connect}; + $self->{username} ||= time; # prefer an existing user + $self->{password} = time; + } + } else { + if ((! $self->{hostname} && ! $self->{server}) || + ! $self->{username} || ! $self->{password}) { + $self->{errstr} = "Please specify hostname or server, username and password"; + return undef; + } + $self->{dsn} = "DBI:Sybase:"; + if ($self->{hostname}) { + $self->{dsn} .= sprintf ";host=%s", $self->{hostname}; + $self->{dsn} .= sprintf ";port=%s", $self->{port}; + } else { + $self->{dsn} .= sprintf ";server=%s", $self->{server}; + } + if ($params{currentdb}) { + $self->{dsn} .= sprintf ";database=%s", $params{currentdb}; + } + } + if (! exists $self->{errstr}) { + my $stderrvar; + eval { + require DBI; + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "alarm\n"; + }; + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + *SAVEERR = *STDERR; + open OUT ,'>',\$stderrvar; + *STDERR = *OUT; + if ($self->{handle} = DBI->connect( + $self->{dsn}, + $self->{username}, + $self->{password}, + { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { + $retval = $self; + } else { + # doesnt seem to work $self->{errstr} = DBI::errstr(); + $self->{errstr} = "connect failed"; + return undef; + } + *STDERR = *SAVEERR; + }; + if ($@) { + $self->{errstr} = $@; + $retval = undef; + } elsif ($stderrvar && $stderrvar =~ /can't change context to database/) { + $self->{errstr} = $stderrvar; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments) || die DBI::errstr(); + } else { + $sth->execute() || die DBI::errstr(); + } + if (lc $sql =~ /^(exec |sp_)/) { + # flatten the result sets + do { + while (my $aref = $sth->fetchrow_arrayref()) { + push(@row, @{$aref}); + } + } while ($sth->{syb_more_results}); + } else { + @row = $sth->fetchrow_array(); + } + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper(\@row)); + }; + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @row = split(/\s+/, (split(/\n/, $simulation))[0]); + } + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + $rows = $sth->fetchall_arrayref(); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @{$rows} = map { [ split(/\s+/, $_) ] } split(/\n/, $simulation); + } + return @{$rows}; +} + +sub exec_sp_1hash { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + do { + while (my $href = $sth->fetchrow_hashref()) { + foreach (keys %{$href}) { + push(@{$rows}, [ $_, $href->{$_} ]); + } + } + } while ($sth->{syb_more_results}); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + return @{$rows}; +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace(sprintf "disconnecting DBD %s", + $self->{handle} ? "with handle" : "without handle"); + $self->{handle}->disconnect() if $self->{handle}; +} + +package DBD::MSSQL::Server::Connection::Sqlcmd; + +use strict; +use File::Temp qw/tempfile/; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{loginstring} = "hostport"; + my $template = $self->{mode}.'XXXXX'; + if ($^O =~ /MSWin/) { + $template =~ s/::/_/g; + } + ($self->{sql_commandfile_handle}, $self->{sql_commandfile}) = + tempfile($template, SUFFIX => ".sql", + DIR => $self->system_tmpdir() ); + close $self->{sql_commandfile_handle}; + ($self->{sql_resultfile_handle}, $self->{sql_resultfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_resultfile_handle}; + ($self->{sql_outfile_handle}, $self->{sql_outfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_outfile_handle}; + + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + # --server xy --username xy --password xy + # --hostname xy --username xy --password xy + # --hostname xy --port --username xy --password xy + if ($self->{server} && $self->{username} && $self->{password}) { + # --server bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + } elsif ($self->{hostname} && $self->{username} && $self->{password}) { + # --hostname bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + $self->{server} = sprintf 'tcp:%s,%s', $self->{hostname}, $self->{port}; + } else { + $self->{errstr} = "Please specify servername, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + eval { + if (! exists $ENV{SQL_HOME}) { + foreach my $path (split(';', $ENV{PATH})) { + $self->trace(sprintf "try to find sqlcmd.exe in %s", $path); + if (-x $path.'/sqlcmd.exe') { + $ENV{SQL_HOME} = $path; + last; + } + } + $ENV{SQL_HOME} |= ''; + } else { + $ENV{PATH} = $ENV{SQL_HOME}. + (defined $ENV{PATH} ? ";".$ENV{PATH} : ""); + } + my $sqlcmd = undef; + if (-x $ENV{SQL_HOME}.'/'.'sqlcmd.exe') { + $sqlcmd = $ENV{SQL_HOME}.'/'.'sqlcmd.exe'; + } + if (! $sqlcmd) { + die "nosqlcmd\n"; + } else { + $self->trace(sprintf "found %s", $sqlcmd); + } + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + if ($self->{loginstring} eq "server") { + $self->{sqlcmd} = sprintf '"%s" -S %s -U "%s" -P "%s" %s -i "%s" -o "%s"', + $sqlcmd, $self->{server}, $self->{username}, $self->{password}, + ($self->{currentdb} ? "-d ".$self->{currentdb} : ""), + $self->{sql_commandfile}, $self->{sql_resultfile}; + $self->{sqlcmd} .= ' -h-1 -s"|" -W'; + } + } + + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "timeout\n"; + }; + if ($^O !~ /MSWin/) { + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + } + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + + my $answer = $self->fetchrow_array( + q{ SELECT 'schnorch' }); + die unless defined $answer and $answer eq 'schnorch'; + $retval = $self; + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at $0 .*//g; + chomp $self->{errstr}; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqlcmd}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm \n"; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + @row = map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } # strip leading space from numbers + map { s/\s+$//g; $_ } # strip trailing space + split(/\|/, (split(/\n/, $output))[0]); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper(\@row)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqlcmd}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm %s\n", $exit_output; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @rows = map { [ + map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } + map { s/\s+$//g; $_ } + split /\|/ + ] } grep { ! /^\(\d+ rows affected\)/ } + grep { ! /^\s*$/ } + grep { ! /^Database name .* ignored, referencing object in/ } split(/\n/, $output); + $rows = \@rows; + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return @{$rows}; +} + +sub func { + my $self = shift; + my $function = shift; + $self->{handle}->func(@_); +} + +sub convert { + my $n = shift; + # mostly used to convert numbers in scientific notation + if ($n =~ /^\s*\d+\s*$/) { + return $n; + } elsif ($n =~ /^\s*([-+]?)(\d*[\.,]*\d*)[eE]{1}([-+]?)(\d+)\s*$/) { + my ($vor, $num, $sign, $exp) = ($1, $2, $3, $4); + $n =~ s/E/e/g; + $n =~ s/,/\./g; + $num =~ s/,/\./g; + my $sig = $sign eq '-' ? "." . ($exp - 1 + length $num) : ''; + my $dec = sprintf "%${sig}f", $n; + $dec =~ s/\.[0]+$//g; + return $dec; + } elsif ($n =~ /^\s*([-+]?)(\d+)[\.,]*(\d*)\s*$/) { + return $1.$2.".".$3; + } elsif ($n =~ /^\s*(.*?)\s*$/) { + return $1; + } else { + return $n; + } +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace("try to clean up command and result files"); + unlink $self->{sql_commandfile} if -f $self->{sql_commandfile}; + unlink $self->{sql_resultfile} if -f $self->{sql_resultfile}; +} + +sub create_commandfile { + my $self = shift; + my $sql = shift; + open CMDCMD, "> $self->{sql_commandfile}"; + printf CMDCMD "%s\n", $sql; + printf CMDCMD "go\n"; + close CMDCMD; +} + +package DBD::MSSQL::Server::Connection::Sqsh; + +use strict; +use File::Temp qw/tempfile/; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{loginstring} = "hostport"; + my $template = $self->{mode}.'XXXXX'; + if ($^O =~ /MSWin/) { + $template =~ s/::/_/g; + } + ($self->{sql_commandfile_handle}, $self->{sql_commandfile}) = + tempfile($template, SUFFIX => ".sql", + DIR => $self->system_tmpdir() ); + close $self->{sql_commandfile_handle}; + ($self->{sql_resultfile_handle}, $self->{sql_resultfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_resultfile_handle}; + ($self->{sql_outfile_handle}, $self->{sql_outfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_outfile_handle}; + + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + # --server xy --username xy --password xy + # --hostname xy --username xy --password xy + # --hostname xy --port --username xy --password xy + if ($self->{server} && $self->{username} && $self->{password}) { + # --server bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + } elsif ($self->{hostname} && $self->{username} && $self->{password}) { + # --hostname bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + $self->{server} = sprintf 'tcp:%s,%s', $self->{hostname}, $self->{port}; + } else { + $self->{errstr} = "Please specify servername, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + eval { + if (! exists $ENV{SQL_HOME}) { + if ($^O =~ /MSWin/) { + foreach my $path (split(';', $ENV{PATH})) { + if (-x $path.'/sqsh.exe') { + $ENV{SQL_HOME} = $path; + last; + } + } + } else { + foreach my $path (split(':', $ENV{PATH})) { + if (-x $path.'/bin/sqsh') { + $ENV{SQL_HOME} = $path; + last; + } + } + } + $ENV{SQL_HOME} |= ''; + } else { + if ($^O =~ /MSWin/) { + $ENV{PATH} = $ENV{SQL_HOME}. + (defined $ENV{PATH} ? ";".$ENV{PATH} : ""); + } else { + $ENV{PATH} = $ENV{SQL_HOME}."/bin". + (defined $ENV{PATH} ? ":".$ENV{PATH} : ""); + $ENV{LD_LIBRARY_PATH} = $ENV{SQL_HOME}."/lib". + (defined $ENV{LD_LIBRARY_PATH} ? ":".$ENV{LD_LIBRARY_PATH} : ""); + } + } + my $sqsh = undef; + my $tnsping = undef; + if (-x $ENV{SQL_HOME}.'/'.'bin'.'/'.'sqsh') { + $sqsh = $ENV{SQL_HOME}.'/'.'bin'.'/'.'sqsh'; + } elsif (-x $ENV{SQL_HOME}.'/'.'sqsh') { + $sqsh = $ENV{SQL_HOME}.'/'.'sqsh'; + } elsif (-x $ENV{SQL_HOME}.'/'.'sqsh.exe') { + $sqsh = $ENV{SQL_HOME}.'/'.'sqsh.exe'; + } elsif (-x '/usr/bin/sqsh') { + $sqsh = '/usr/bin/sqsh'; + } + if (! $sqsh) { + die "nosqsh\n"; + } + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + if ($self->{loginstring} eq "server") { + $self->{sqsh} = sprintf '"%s" -S %s -U "%s" -P "%s" -i "%s" -o "%s"', + $sqsh, $self->{server}, $self->{username}, $self->{password}, + $self->{sql_commandfile}, $self->{sql_resultfile}; + $self->{sqsh} .= ' -h -s"|"'; + } + } + + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "timeout\n"; + }; + if ($^O !~ /MSWin/) { + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + } + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + + my $answer = $self->fetchrow_array( + q{ SELECT 'schnorch' }); + die unless defined $answer and $answer eq 'schnorch'; + $retval = $self; + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at $0 .*//g; + chomp $self->{errstr}; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqsh}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm \n"; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + @row = map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } # strip leading space from numbers + map { s/\s+$//g; $_ } # strip trailing space + split(/\|/, (split(/\n/, $output))[0]); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper(\@row)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqsh}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm %s\n", $exit_output; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @rows = map { [ + map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } + map { s/\s+$//g; $_ } + split /\|/ + ] } grep { ! /^\(\d+ rows affected\)/ } + grep { ! /^\s*$/ } + grep { ! /^Database name .* ignored, referencing object in/ } split(/\n/, $output); + $rows = \@rows; + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return @{$rows}; +} + +sub func { + my $self = shift; + my $function = shift; + $self->{handle}->func(@_); +} + +sub convert { + my $n = shift; + # mostly used to convert numbers in scientific notation + if ($n =~ /^\s*\d+\s*$/) { + return $n; + } elsif ($n =~ /^\s*([-+]?)(\d*[\.,]*\d*)[eE]{1}([-+]?)(\d+)\s*$/) { + my ($vor, $num, $sign, $exp) = ($1, $2, $3, $4); + $n =~ s/E/e/g; + $n =~ s/,/\./g; + $num =~ s/,/\./g; + my $sig = $sign eq '-' ? "." . ($exp - 1 + length $num) : ''; + my $dec = sprintf "%${sig}f", $n; + $dec =~ s/\.[0]+$//g; + return $dec; + } elsif ($n =~ /^\s*([-+]?)(\d+)[\.,]*(\d*)\s*$/) { + return $1.$2.".".$3; + } elsif ($n =~ /^\s*(.*?)\s*$/) { + return $1; + } else { + return $n; + } +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace("try to clean up command and result files"); + unlink $self->{sql_commandfile} if -f $self->{sql_commandfile}; + unlink $self->{sql_resultfile} if -f $self->{sql_resultfile}; +} + +sub create_commandfile { + my $self = shift; + my $sql = shift; + open CMDCMD, "> $self->{sql_commandfile}"; + printf CMDCMD "%s\n", $sql; + printf CMDCMD "go\n"; + close CMDCMD; +} + +package DBD::MSSQL::Server::Connection::Sqlrelay; + +use strict; +use Net::Ping; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + if ($self->{mode} =~ /^server::tnsping/) { + } else { + if (! $self->{hostname} || ! $self->{username} || ! $self->{password} || ! $self->{port}) { + $self->{errstr} = "Please specify database, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + my $stderrvar; + eval { + require DBI; + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "alarm\n"; + }; + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + *SAVEERR = *STDERR; + open OUT ,'>',\$stderrvar; + *STDERR = *OUT; + if ($self->{handle} = DBI->connect( + #sprintf("DBI:SQLRelay:host=%s;port=%d;socket=%s", + sprintf("DBI:SQLRelay:host=%s;port=%d;", + $self->{hostname}, $self->{port}), + $self->{username}, + $self->{password}, + { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { + } else { + $self->{errstr} = DBI::errstr(); + } + my $answer = $self->fetchrow_array( + q{ SELECT 42 }); + die $self->{errstr} unless defined $answer and $answer == 42; + *STDERR = *SAVEERR; + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at [\w\/\.]+ line \d+.*//g; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + my $new_dbh = $self->{handle}->clone(); + $self->trace(sprintf "fetchrow_array: %s", $sql); + # + # does not work with bind variables + # + while ($sql =~ /\?/) { + my $param = shift @arguments; + if ($param !~ /^\d+$/) { + $param = $self->{handle}->quote($param); + } + $sql =~ s/\?/$param/; + } + $sql =~ s/^\s*//g; + $sql =~ s/\s*$//g; + eval { + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + @row = $sth->fetchrow_array(); + $sth->finish(); + }; + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + # without this trick, there are error messages like + # "No server-side cursors were available to process the query" + # and the results are messed up. + $self->{handle}->disconnect(); + $self->{handle} = $new_dbh; + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @row = split(/\s+/, (split(/\n/, $simulation))[0]); + } + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + my $new_dbh = $self->{handle}->clone(); + $self->trace(sprintf "fetchall_array: %s", $sql); + while ($sql =~ /\?/) { + my $param = shift @arguments; + if ($param !~ /^\d+$/) { + $param = $self->{handle}->quote($param); + } + $sql =~ s/\?/$param/; + } + eval { + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + $rows = $sth->fetchall_arrayref(); + my $asrows = $sth->fetchall_arrayref(); + $sth->finish(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + $self->{handle}->disconnect(); + $self->{handle} = $new_dbh; + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @{$rows} = map { [ split(/\s+/, $_) ] } split(/\n/, $simulation); + } + return @{$rows}; +} + +sub func { + my $self = shift; + $self->{handle}->func(@_); +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + #$self->trace(sprintf "disconnecting DBD %s", + # $self->{handle} ? "with handle" : "without handle"); + #$self->{handle}->disconnect() if $self->{handle}; +} + +1; + + + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database.pm b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database.pm new file mode 100644 index 0000000..1861655 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database.pm @@ -0,0 +1,471 @@ +package DBD::MSSQL::Server::Database; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +{ + my @databases = (); + my $initerrors = undef; + + sub add_database { + push(@databases, shift); + } + + sub return_databases { + return reverse + sort { $a->{name} cmp $b->{name} } @databases; + } + + sub init_databases { + my %params = @_; + my $num_databases = 0; + if (($params{mode} =~ /server::database::listdatabases/) || + ($params{mode} =~ /server::database::databasefree/) || + ($params{mode} =~ /server::database::lastbackup/) || + ($params{mode} =~ /server::database::transactions/) || + ($params{mode} =~ /server::database::datafile/)) { + my @databaseresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT name, database_id FROM master.sys.databases + }); + } else { + #@databaseresult = map { + # [ $_->[0], $_->[3] ] # only name, dbid + #} $params{handle}->fetchall_array(q{exec sp_helpdb}); + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT name, dbid FROM master.dbo.sysdatabases + }); + } + if ($params{mode} =~ /server::database::transactions/) { + push(@databaseresult, [ '_Total', 0 ]); + } + foreach (@databaseresult) { + my ($name, $id) = @{$_}; + next if $params{database} && $name ne $params{database}; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + $thisparams{id} = $id; + my $database = DBD::MSSQL::Server::Database->new( + %thisparams); + add_database($database); + $num_databases++; + } + if (! $num_databases) { + $initerrors = 1; + return undef; + } + } elsif ($params{mode} =~ /server::database::backupage/) { + my @databaseresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT + a.name, + DATEDIFF(HH, MAX(b.backup_finish_date), GETDATE()), + DATEDIFF(MI, MAX(b.backup_start_date), MAX(b.backup_finish_date)) + FROM sys.sysdatabases a LEFT OUTER JOIN msdb.dbo.backupset b + ON b.database_name = a.name + GROUP BY a.name + ORDER BY a.name + }); + } else { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT + a.name, + DATEDIFF(HH, MAX(b.backup_finish_date), GETDATE()), + DATEDIFF(MI, MAX(b.backup_start_date), MAX(b.backup_finish_date)) + FROM master.dbo.sysdatabases a LEFT OUTER JOIN msdb.dbo.backupset b + ON b.database_name = a.name + GROUP BY a.name + ORDER BY a.name + }); + } + foreach (sort { + if (! defined $b->[1]) { + return 1; + } elsif (! defined $a->[1]) { + return -1; + } else { + return $a->[1] <=> $b->[1]; + } + } @databaseresult) { + my ($name, $age, $duration) = @{$_}; + next if $params{database} && $name ne $params{database}; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + $thisparams{backup_age} = $age; + $thisparams{backup_duration} = $duration; + my $database = DBD::MSSQL::Server::Database->new( + %thisparams); + add_database($database); + $num_databases++; + } + } + + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + name => $params{name}, + id => $params{id}, + datafiles => [], + backup_age => $params{backup_age}, + backup_duration => $params{backup_duration}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + $self->set_local_db_thresholds(%params); + if ($params{mode} =~ /server::database::datafile/) { + $params{database} = $self->{name}; + DBD::MSSQL::Server::Database::Datafile::init_datafiles(%params); + if (my @datafiles = + DBD::MSSQL::Server::Database::Datafile::return_datafiles()) { + $self->{datafiles} = \@datafiles; + } else { + $self->add_nagios_critical("unable to aquire datafile info"); + } + } elsif ($params{mode} =~ /server::database::databasefree/) { + ################################################################################### + # fuer's museum + # 1> sp_spaceused + # 2> go + # database_name database_size unallocated space + # master 4.50 MB 1.32 MB + # reserved data index_size unused + # 2744 KB 1056 KB 1064 KB 624 KB + # (return status = 0) + #my($database_name, $database_size, $unallocated_space, + # $reserved, $data, $index_size, $unused) = + # $params{handle}->fetchrow_array( + # "USE ".$self->{name}."\nEXEC SP_SPACEUSED" + #); + # server mgmt studio sp_spaceused + # Currently Allocated Space database_size 641.94MB + # Available Free Space unallocated space 457.09MB + #$database_size =~ s/MB//g; + #$unallocated_space =~ s/MB//g; + #$self->{size} = $database_size * 1024 * 1024; + #$self->{free} = $unallocated_space * 1024 * 1024; + #$self->{percent_free} = $unallocated_space / $database_size * 100; + #$self->{used} = $self->{size} - $self->{free}; + #$self->{maxsize} = "99999999999999999"; + ################################################################################### + my $calc = {}; + if ($params{method} eq 'sqlcmd' || $params{method} eq 'sqsh') { + foreach($self->{handle}->fetchall_array(q{ + if object_id('tempdb..#FreeSpace') is null + create table #FreeSpace( + Drive varchar(10), + MB_Free bigint + ) + go + DELETE FROM tempdb..#FreeSpace + INSERT INTO tempdb..#FreeSpace exec master.dbo.xp_fixeddrives + go + SELECT * FROM tempdb..#FreeSpace + })) { + $calc->{drive_mb}->{lc $_->[0]} = $_->[1]; + } + } else { + $self->{handle}->execute(q{ + if object_id('tempdb..#FreeSpace') is null + create table #FreeSpace( + Drive varchar(10), + MB_Free bigint + ) + }); + $self->{handle}->execute(q{ + DELETE FROM #FreeSpace + }); + $self->{handle}->execute(q{ + INSERT INTO #FreeSpace exec master.dbo.xp_fixeddrives + }); + foreach($self->{handle}->fetchall_array(q{ + SELECT * FROM #FreeSpace + })) { + $calc->{drive_mb}->{lc $_->[0]} = $_->[1]; + } + } + #$self->{handle}->execute(q{ + # DROP TABLE #FreeSpace + #}); + # Page = 8KB + # sysfiles ist sv2000, noch als kompatibilitaetsview vorhanden + # dbo.sysfiles kann 2008 durch sys.database_files ersetzt werden? + # omeiomeiomei in 2005 ist ein sys.sysindexes compatibility view + # fuer 2000.dbo.sysindexes + # besser ist sys.allocation_units + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + my $sql = q{ + SELECT + SUM(CAST(used AS BIGINT)) / 128 + FROM + [?].sys.sysindexes + WHERE + indid IN (0,1,255) + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + $self->{used_mb} = $self->{handle}->fetchrow_array($sql); + } else { + my $sql = q{ + SELECT + SUM(CAST(used AS BIGINT)) / 128 + FROM + [?].dbo.sysindexes + WHERE + indid IN (0,1,255) + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + $self->{used_mb} = $self->{handle}->fetchrow_array($sql); + } + my @fileresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + my $sql = q{ + SELECT + RTRIM(a.name), RTRIM(a.filename), CAST(a.size AS BIGINT), + CAST(a.maxsize AS BIGINT), a.growth + FROM + [?].sys.sysfiles a + JOIN + [?].sys.sysfilegroups b + ON + a.groupid = b.groupid + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + @fileresult = $self->{handle}->fetchall_array($sql); + } else { + my $sql = q{ + SELECT + RTRIM(a.name), RTRIM(a.filename), CAST(a.size AS BIGINT), + CAST(a.maxsize AS BIGINT), a.growth + FROM + [?].dbo.sysfiles a + JOIN + [?].dbo.sysfilegroups b + ON + a.groupid = b.groupid + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + @fileresult = $self->{handle}->fetchall_array($sql); + } + foreach(@fileresult) { + my($name, $filename, $size, $maxsize, $growth) = @{$_}; + my $drive = lc substr($filename, 0, 1); + $calc->{datafile}->{$name}->{allocsize} = $size / 128; + if ($growth == 0) { + $calc->{datafile}->{$name}->{maxsize} = $size / 128; + } else { + if ($maxsize == -1) { + $calc->{datafile}->{$name}->{maxsize} = + exists $calc->{drive_mb}->{$drive} ? + ($calc->{datafile}->{$name}->{allocsize} + + $calc->{drive_mb}->{$drive}) : 4 * 1024; + # falls die platte nicht gefunden wurde, dann nimm halt 4GB + if (exists $calc->{drive_mb}->{$drive}) { + # davon kann ausgegangen werden. wenn die drives nicht zur + # vefuegung stehen, stimmt sowieso hinten und vorne nichts. + $calc->{drive_mb}->{$drive} = 0; + # damit ist der platz dieses laufwerks verbraten und in + # max_mb eingeflossen. es darf nicht sein, dass der freie platz + # mehrfach gezaehlt wird, wenn es mehrere datafiles auf diesem + # laufwerk gibt. + } + } else { + $calc->{datafile}->{$name}->{maxsize} = $maxsize / 128; + } + } + $self->{allocated_mb} += $calc->{datafile}->{$name}->{allocsize}; + $self->{max_mb} += $calc->{datafile}->{$name}->{maxsize}; + } + $self->{allocated_mb} = $self->{allocated_mb}; + if ($self->{used_mb} > $self->{allocated_mb}) { + # obige used-berechnung liefert manchmal (wenns knapp hergeht) mehr als + # den maximal verfuegbaren platz. vermutlich muessen dann + # zwecks ermittlung des tatsaechlichen platzverbrauchs + # irgendwelche dbcc updateusage laufen. + # egal, wird schon irgendwie stimmen. + $self->{used_mb} = $self->{allocated_mb}; + $self->{estimated} = 1; + } else { + $self->{estimated} = 0; + } + $self->{free_mb} = $self->{max_mb} - $self->{used_mb}; + $self->{free_percent} = 100 * $self->{free_mb} / $self->{max_mb}; + $self->{allocated_percent} = 100 * $self->{allocated_mb} / $self->{max_mb}; + } elsif ($params{mode} =~ /^server::database::transactions/) { + $self->{transactions_s} = $self->{handle}->get_perf_counter_instance( + 'SQLServer:Databases', 'Transactions/sec', $self->{name}); + if (! defined $self->{transactions_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(transactions_s)); + $self->{transactions_per_sec} = $self->{delta_transactions_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::database::datafile::listdatafiles/) { + foreach (sort { $a->{logicalfilename} cmp $b->{logicalfilename}; } @{$self->{datafiles}}) { + printf "%s\n", $_->{logicalfilename}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::database::transactions/) { + $self->add_nagios( + $self->check_thresholds($self->{transactions_per_sec}, 10000, 50000), + sprintf "%s has %.4f transactions / sec", + $self->{name}, $self->{transactions_per_sec}); + $self->add_perfdata(sprintf "%s_transactions_per_sec=%.4f;%s;%s", + $self->{name}, $self->{transactions_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::database::databasefree/) { + # ->percent_free + # ->free + # + # ausgabe + # perfdata db__free_pct + # perfdata db__free (real_bytes_max - bytes) + bytes_free (with units) + # perfdata db__alloc_free bytes_free (with units) + # + # umrechnen der thresholds + # ()/% + # MB + # GB + # KB + if (($self->{warningrange} && $self->{warningrange} !~ /^\d+[\.\d]*:/) || + ($self->{criticalrange} && $self->{criticalrange} !~ /^\d+[\.\d]*:/)) { + $self->add_nagios_unknown("you want an alert if free space is _above_ a threshold????"); + return; + } + if (! $params{units}) { + $params{units} = "%"; + } + $self->{warning_bytes} = 0; + $self->{critical_bytes} = 0; + if ($params{units} eq "%") { + $self->add_nagios( + $self->check_thresholds($self->{free_percent}, "5:", "2:"), + sprintf("database %s has %.2f%% free space left", + $self->{name}, $self->{free_percent}, + ($self->{estimated} ? " (estim.)" : "")) + ); + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->add_perfdata(sprintf "\'db_%s_free_pct\'=%.2f%%;%d:;%d:", + lc $self->{name}, + $self->{free_percent}, + $self->{warningrange}, $self->{criticalrange}); + $self->add_perfdata(sprintf "\'db_%s_free\'=%dMB;%.2f:;%.2f:;0;%.2f", + lc $self->{name}, + $self->{free_mb}, + $self->{warningrange} * $self->{max_mb} / 100, + $self->{criticalrange} * $self->{max_mb} / 100, + $self->{max_mb}); + $self->add_perfdata(sprintf "\'db_%s_allocated_pct\'=%.2f%%", + lc $self->{name}, + $self->{allocated_percent}); + } else { + my $factor = 1; # default MB + if ($params{units} eq "GB") { + $factor = 1024; + } elsif ($params{units} eq "MB") { + $factor = 1; + } elsif ($params{units} eq "KB") { + $factor = 1 / 1024; + } + $self->{warningrange} ||= "5:"; + $self->{criticalrange} ||= "2:"; + my $saved_warningrange = $self->{warningrange}; + my $saved_criticalrange = $self->{criticalrange}; + # : entfernen weil gerechnet werden muss + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->{warningrange} = $self->{warningrange} ? + $self->{warningrange} * $factor : 5 * $factor; + $self->{criticalrange} = $self->{criticalrange} ? + $self->{criticalrange} * $factor : 2 * $factor; + $self->{percent_warning} = 100 * $self->{warningrange} / $self->{max_mb}; + $self->{percent_critical} = 100 * $self->{criticalrange} / $self->{max_mb}; + $self->{warningrange} .= ':'; + $self->{criticalrange} .= ':'; + $self->add_nagios( + $self->check_thresholds($self->{free_mb}, "5242880:", "1048576:"), + sprintf("database %s has %.2f%s free space left", $self->{name}, + $self->{free_mb} / $factor, $params{units}) + ); + $self->{warningrange} = $saved_warningrange; + $self->{criticalrange} = $saved_criticalrange; + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->add_perfdata(sprintf "\'db_%s_free_pct\'=%.2f%%;%.2f:;%.2f:", + lc $self->{name}, + $self->{free_percent}, $self->{percent_warning}, + $self->{percent_critical}); + $self->add_perfdata(sprintf "\'db_%s_free\'=%.2f%s;%.2f:;%.2f:;0;%.2f", + lc $self->{name}, + $self->{free_mb} / $factor, $params{units}, + $self->{warningrange}, + $self->{criticalrange}, + $self->{max_mb} / $factor); + $self->add_perfdata(sprintf "\'db_%s_allocated_pct\'=%.2f%%", + lc $self->{name}, + $self->{allocated_percent}); + } + } elsif ($params{mode} =~ /server::database::backupage/) { + if (! defined $self->{backup_age}) { + $self->add_nagios_critical(sprintf "%s was never backupped", + $self->{name}); + $self->{backup_age} = 0; + $self->{backup_duration} = 0; + $self->check_thresholds($self->{backup_age}, 48, 72); # init wg perfdata + } else { + $self->add_nagios( + $self->check_thresholds($self->{backup_age}, 48, 72), + sprintf "%s backupped %dh ago", $self->{name}, $self->{backup_age}); + } + $self->add_perfdata(sprintf "'%s_bck_age'=%d;%s;%s", + $self->{name}, $self->{backup_age}, + $self->{warningrange}, $self->{criticalrange}); + $self->add_perfdata(sprintf "'%s_bck_time'=%d", + $self->{name}, $self->{backup_duration}); + } + } +} + + +1; diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database/Datafile.pm b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database/Datafile.pm new file mode 100644 index 0000000..ffae903 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Database/Datafile.pm @@ -0,0 +1,202 @@ +package DBD::MSSQL::Server::Database::Datafile; + +use strict; +use File::Basename; + +our @ISA = qw(DBD::MSSQL::Server::Database); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +{ + my @datafiles = (); + my $initerrors = undef; + + sub add_datafile { + push(@datafiles, shift); + } + + sub return_datafiles { + return reverse + sort { $a->{logicalfilename} cmp $b->{logicalfilename} } @datafiles; + } + + sub clear_datafiles { + @datafiles = (); + } + + sub init_datafiles { + my %params = @_; + my $num_datafiles = 0; + if ($params{mode} =~ /server::database::datafile::listdatafiles/) { + my @datafileresults = $params{handle}->fetchall_array(q{ +DECLARE @DBInfo TABLE +( ServerName VARCHAR(100), +DatabaseName VARCHAR(100), +FileSizeMB INT, +LogicalFileName sysname, +PhysicalFileName NVARCHAR(520), +Status sysname, +Updateability sysname, +RecoveryMode sysname, +FreeSpaceMB INT, +FreeSpacePct VARCHAR(7), +FreeSpacePages INT, +PollDate datetime) + +DECLARE @command VARCHAR(5000) + +SELECT @command = 'Use [' + '?' + '] SELECT +@@servername as ServerName, +' + '''' + '?' + '''' + ' AS DatabaseName, +CAST(sysfiles.size/128.0 AS int) AS FileSize, +sysfiles.name AS LogicalFileName, sysfiles.filename AS PhysicalFileName, +CONVERT(sysname,DatabasePropertyEx(''?'',''Status'')) AS Status, +CONVERT(sysname,DatabasePropertyEx(''?'',''Updateability'')) AS Updateability, +CONVERT(sysname,DatabasePropertyEx(''?'',''Recovery'')) AS RecoveryMode, +CAST(sysfiles.size/128.0 - CAST(FILEPROPERTY(sysfiles.name, ' + '''' + + 'SpaceUsed' + '''' + ' ) AS int)/128.0 AS int) AS FreeSpaceMB, +CAST(100 * (CAST (((sysfiles.size/128.0 -CAST(FILEPROPERTY(sysfiles.name, +' + '''' + 'SpaceUsed' + '''' + ' ) AS int)/128.0)/(sysfiles.size/128.0)) +AS decimal(4,2))) AS varchar(8)) + ' + '''' + '%' + '''' + ' AS FreeSpacePct, +GETDATE() as PollDate FROM dbo.sysfiles' +INSERT INTO @DBInfo + (ServerName, + DatabaseName, + FileSizeMB, + LogicalFileName, + PhysicalFileName, + Status, + Updateability, + RecoveryMode, + FreeSpaceMB, + FreeSpacePct, + PollDate) +EXEC sp_MSForEachDB @command + +SELECT + ServerName, + DatabaseName, + FileSizeMB, + LogicalFileName, + PhysicalFileName, + Status, + Updateability, + RecoveryMode, + FreeSpaceMB, + FreeSpacePct, + PollDate +FROM @DBInfo +ORDER BY + ServerName, + DatabaseName + }); + if (DBD::MSSQL::Server::return_first_server()->windows_server()) { + fileparse_set_fstype("MSWin32"); + } + foreach (@datafileresults) { + my ($servername, $databasename, $filesizemb, $logicalfilename, + $physicalfilename, $status, $updateability, $recoverymode, + $freespacemb, $freespacepct, $polldate) = @{$_}; + next if $databasename ne $params{database}; + if ($params{regexp}) { + #next if $params{selectname} && + # (($name !~ /$params{selectname}/) && + # (basename($name) !~ /$params{selectname}/)); + next if $params{selectname} && + ($logicalfilename !~ /$params{selectname}/); + } else { + #next if $params{selectname} && + # ((lc $params{selectname} ne lc $name) && + # (lc $params{selectname} ne lc basename($name))); + next if $params{selectname} && + (lc $params{selectname} ne lc $logicalfilename); + } + my %thisparams = %params; + $thisparams{servername} = $servername; + $thisparams{databasename} = $databasename; + $thisparams{filesizemb} = $filesizemb; + $thisparams{logicalfilename} = $logicalfilename; + $thisparams{servername} = $servername; + $thisparams{status} = $status; + $thisparams{updateability} = $updateability; + $thisparams{recoverymode} = $recoverymode; + $thisparams{freespacemb} = $freespacemb; + $thisparams{freespacepct} = $freespacepct; + $thisparams{polldate} = $polldate; + my $datafile = + DBD::MSSQL::Server::Database::Datafile->new( + %thisparams); + add_datafile($datafile); + $num_datafiles++; + } + } + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + databasename => $params{databasename}, + filesizemb => $params{filesizemb}, + logicalfilename => $params{logicalfilename}, + physicalfilename => $params{physicalfilename}, + status => $params{status}, + updateability => $params{updateability}, + recoverymode => $params{recoverymode}, + freespacemb => $params{freespacemb}, + freespacepct => $params{freespacepct}, + freespacepages => $params{freespacepages}, + polldate => $params{polldate}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::database::iobalance/) { + if (! defined $self->{phyrds}) { + $self->add_nagios_critical(sprintf "unable to read datafile io %s", $@); + } else { + $params{differenciator} = $self->{path}; + $self->valdiff(\%params, qw(phyrds phywrts)); + $self->{io_total} = $self->{delta_phyrds} + $self->{delta_phywrts}; + } + } elsif ($params{mode} =~ /server::database::datafile::iotraffic/) { + if (! defined $self->{phyrds}) { + $self->add_nagios_critical(sprintf "unable to read datafile io %s", $@); + } else { + $params{differenciator} = $self->{path}; + $self->valdiff(\%params, qw(phyrds phywrts)); + $self->{io_total_per_sec} = ($self->{delta_phyrds} + $self->{delta_phywrts}) / + $self->{delta_timestamp}; + } + } +} + + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::database::datafile::iotraffic/) { + $self->add_nagios( + $self->check_thresholds($self->{io_total_per_sec}, "1000", "5000"), + sprintf ("%s: %.2f IO Operations per Second", + $self->{name}, $self->{io_total_per_sec})); + $self->add_perfdata(sprintf "'dbf_%s_io_total_per_sec'=%.2f;%d;%d", + $self->{name}, $self->{io_total_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Memorypool.pm b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Memorypool.pm new file mode 100644 index 0000000..d364ba6 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/DBD/MSSQL/Server/Memorypool.pm @@ -0,0 +1,333 @@ +package DBD::MSSQL::Server::Memorypool; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + buffercache => undef, + procedurecache => undef, + locks => [], + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::buffercache/) { + $self->{buffercache} = DBD::MSSQL::Server::Memorypool::BufferCache->new( + %params); + } elsif ($params{mode} =~ /server::memorypool::procedurecache/) { + $self->{procedurecache} = DBD::MSSQL::Server::Memorypool::ProcedureCache->new( + %params); + } elsif ($params{mode} =~ /server::memorypool::lock/) { + DBD::MSSQL::Server::Memorypool::Lock::init_locks(%params); + if (my @locks = DBD::MSSQL::Server::Memorypool::Lock::return_locks()) { + $self->{locks} = \@locks; + } else { + $self->add_nagios_critical("unable to aquire lock info"); + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if ($params{mode} =~ /server::memorypool::buffercache/) { + $self->{buffercache}->nagios(%params); + $self->merge_nagios($self->{buffercache}); + } elsif ($params{mode} =~ /^server::memorypool::lock::listlocks/) { + foreach (sort { $a->{name} cmp $b->{name}; } @{$self->{locks}}) { + printf "%s\n", $_->{name}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::memorypool::lock/) { + foreach (@{$self->{locks}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } +} + + +package DBD::MSSQL::Server::Memorypool::BufferCache; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server::Memorypool); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + hitratio => undef, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::buffercache::hitratio/) { + # -- (a.cntr_value * 1.0 / b.cntr_value) * 100.0 [BufferCacheHitRatio] + $self->{cnt_hitratio} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Buffer cache hit ratio"); + $self->{cnt_hitratio_base} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Buffer cache hit ratio base"); + if (! defined $self->{cnt_hitratio}) { + $self->add_nagios_unknown("unable to aquire buffer cache data"); + } else { + # das kracht weil teilweise negativ + #$self->valdiff(\%params, qw(cnt_hitratio cnt_hitratio_base)); + $self->{hitratio} = ($self->{cnt_hitratio_base} == 0) ? + 100 : $self->{cnt_hitratio} / $self->{cnt_hitratio_base} * 100.0; + # soll vorkommen..... + $self->{hitratio} = 100 if ($self->{hitratio} > 100); + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::lazywrites/) { + $self->{lazy_writes_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Lazy writes/sec"); + if (! defined $self->{lazy_writes_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(lazy_writes_s)); + $self->{lazy_writes_per_sec} = $self->{delta_lazy_writes_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::pagelifeexpectancy/) { + $self->{pagelifeexpectancy} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Page life expectancy"); + if (! defined $self->{pagelifeexpectancy}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::freeliststalls/) { + $self->{freeliststalls_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Free list stalls/sec"); + if (! defined $self->{freeliststalls_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(freeliststalls_s)); + $self->{freeliststalls_per_sec} = $self->{delta_freeliststalls_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::checkpointpages/) { + $self->{checkpointpages_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Checkpoint pages/sec"); + if (! defined $self->{checkpointpages_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(checkpointpages_s)); + $self->{checkpointpages_per_sec} = $self->{delta_checkpointpages_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::memorypool::buffercache::hitratio/) { + $self->add_nagios( + $self->check_thresholds($self->{hitratio}, '90:', '80:'), + sprintf "buffer cache hit ratio is %.2f%%", $self->{hitratio}); + $self->add_perfdata(sprintf "buffer_cache_hit_ratio=%.2f%%;%s;%s", + $self->{hitratio}, + $self->{warningrange}, $self->{criticalrange}); + #$self->add_perfdata(sprintf "buffer_cache_hit_ratio_now=%.2f%%", + # $self->{hitratio_now}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::lazywrites/) { + $self->add_nagios( + $self->check_thresholds($self->{lazy_writes_per_sec}, '20', '40'), + sprintf "%.2f lazy writes per second", $self->{lazy_writes_per_sec}); + $self->add_perfdata(sprintf "lazy_writes_per_sec=%.2f;%s;%s", + $self->{lazy_writes_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::pagelifeexpectancy/) { + $self->add_nagios( + $self->check_thresholds($self->{pagelifeexpectancy}, '300:', '180:'), + sprintf "page life expectancy is %d seconds", $self->{pagelifeexpectancy}); + $self->add_perfdata(sprintf "page_life_expectancy=%d;%s;%s", + $self->{pagelifeexpectancy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::freeliststalls/) { + $self->add_nagios( + $self->check_thresholds($self->{freeliststalls_per_sec}, '4', '10'), + sprintf "%.2f free list stalls per second", $self->{freeliststalls_per_sec}); + $self->add_perfdata(sprintf "free_list_stalls_per_sec=%.2f;%s;%s", + $self->{freeliststalls_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::checkpointpages/) { + $self->add_nagios( + $self->check_thresholds($self->{checkpointpages_per_sec}, '100', '500'), + sprintf "%.2f pages flushed per second", $self->{checkpointpages_per_sec}); + $self->add_perfdata(sprintf "checkpoint_pages_per_sec=%.2f;%s;%s", + $self->{checkpointpages_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + + + + + +package DBD::MSSQL::Server::Memorypool::Lock; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server::Memorypool); + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +{ + my @locks = (); + my $initerrors = undef; + + sub add_lock { + push(@locks, shift); + } + + sub return_locks { + return reverse + sort { $a->{name} cmp $b->{name} } @locks; + } + + sub init_locks { + my %params = @_; + my $num_locks = 0; + if (($params{mode} =~ /server::memorypool::lock::listlocks/) || + ($params{mode} =~ /server::memorypool::lock::waits/) || + ($params{mode} =~ /server::memorypool::lock::deadlocks/) || + ($params{mode} =~ /server::memorypool::lock::timeouts/)) { + my @lockresult = $params{handle}->get_instance_names( + 'SQLServer:Locks'); + foreach (@lockresult) { + my ($name) = @{$_}; + $name =~ s/\s*$//; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + my $lock = DBD::MSSQL::Server::Memorypool::Lock->new( + %thisparams); + add_lock($lock); + $num_locks++; + } + if (! $num_locks) { + $initerrors = 1; + return undef; + } + } + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + name => $params{name}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::lock::listlocks/) { + # name reicht + } elsif ($params{mode} =~ /server::memorypool::lock::waits/) { + $self->{lock_waits_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Lock Waits/sec", $self->{name}); + if (! defined $self->{lock_waits_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_waits_s)); + $self->{lock_waits_per_sec} = $self->{delta_lock_waits_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::memorypool::lock::timeouts/) { + $self->{lock_timeouts_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Lock Timeouts/sec", $self->{name}); + if (! defined $self->{lock_timeouts_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_timeouts_s)); + $self->{lock_timeouts_per_sec} = $self->{delta_lock_timeouts_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::memorypool::lock::deadlocks/) { + $self->{lock_deadlocks_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Number of Deadlocks/sec", $self->{name}); + if (! defined $self->{lock_deadlocks_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_deadlocks_s)); + $self->{lock_deadlocks_per_sec} = $self->{delta_lock_deadlocks_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::memorypool::lock::waits/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_waits_per_sec}, 100, 500), + sprintf "%.4f lock waits / sec for %s", + $self->{lock_waits_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_lock_waits_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_waits_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::memorypool::lock::timeouts/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_timeouts_per_sec}, 1, 5), + sprintf "%.4f lock timeouts / sec for %s", + $self->{lock_timeouts_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_lock_timeouts_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_timeouts_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::memorypool::lock::deadlocks/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_deadlocks_per_sec}, 1, 5), + sprintf "%.4f deadlocks / sec for %s", + $self->{lock_deadlocks_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_deadlocks_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_deadlocks_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + + +package DBD::MSSQL::Server::Memorypool::SystemLevelDataStructures::LockTable; +package DBD::MSSQL::Server::Memorypool::ProcedureCache; +package DBD::MSSQL::Server::Memorypool::LogCache; +package DBD::MSSQL::Server::Memorypool::SystemLevelDataStructures; diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/Extraopts.pm b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/Extraopts.pm new file mode 100644 index 0000000..21700c0 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/Nagios/Extraopts.pm @@ -0,0 +1,103 @@ +package Extraopts; + +use strict; +use File::Basename; +use Data::Dumper; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + file => $params{file}, + commandline => $params{commandline}, + config => {}, + section => 'default_no_section', + }; + bless $self, $class; + $self->prepare_file_and_section(); + $self->init(); + return $self; +} + +sub prepare_file_and_section { + my $self = shift; + if (! defined $self->{file}) { + # ./check_stuff --extra-opts + $self->{section} = basename($0); + $self->{file} = $self->get_default_file(); + } elsif ($self->{file} =~ /^[^@]+$/) { + # ./check_stuff --extra-opts=special_opts + $self->{section} = $self->{file}; + $self->{file} = $self->get_default_file(); + } elsif ($self->{file} =~ /^@(.*)/) { + # ./check_stuff --extra-opts=@/etc/myconfig.ini + $self->{section} = basename($0); + $self->{file} = $1; + } elsif ($self->{file} =~ /^(.*?)@(.*)/) { + # ./check_stuff --extra-opts=special_opts@/etc/myconfig.ini + $self->{section} = $1; + $self->{file} = $2; + } +} + +sub get_default_file { + my $self = shift; + foreach my $default (qw(/etc/nagios/plugins.ini + /usr/local/nagios/etc/plugins.ini + /usr/local/etc/nagios/plugins.ini + /etc/opt/nagios/plugins.ini + /etc/nagios-plugins.ini + /usr/local/etc/nagios-plugins.ini + /etc/opt/nagios-plugins.ini)) { + if (-f $default) { + return $default; + } + } + return undef; +} + +sub init { + my $self = shift; + if (! defined $self->{file}) { + $self->{errors} = sprintf 'no extra-opts file specified and no default file found'; + } elsif (! -f $self->{file}) { + $self->{errors} = sprintf 'could not open %s', $self->{file}; + } else { + my $data = do { local (@ARGV, $/) = $self->{file}; <> }; + my $in_section = 'default_no_section'; + foreach my $line (split(/\n/, $data)) { + if ($line =~ /\[(.*)\]/) { + $in_section = $1; + } elsif ($line =~ /(.*)=(.*)/) { + $self->{config}->{$in_section}->{$1} = $2; + } + } + } +} + +sub is_valid { + my $self = shift; + return ! exists $self->{errors}; +} + +sub overwrite { + my $self = shift; + my %commandline = (); + if (scalar(keys %{$self->{config}->{default_no_section}}) > 0) { + foreach (keys %{$self->{config}->{default_no_section}}) { + $commandline{$_} = $self->{config}->{default_no_section}->{$_}; + } + } + if (exists $self->{config}->{$self->{section}}) { + foreach (keys %{$self->{config}->{$self->{section}}}) { + $commandline{$_} = $self->{config}->{$self->{section}}->{$_}; + } + } + foreach (keys %commandline) { + if (! exists $self->{commandline}->{$_}) { + $self->{commandline}->{$_} = $commandline{$_}; + } + } +} + + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health new file mode 100755 index 0000000..a38442e --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health @@ -0,0 +1,3664 @@ +#! /usr/bin/perl -w + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); +package DBD::MSSQL::Server::Memorypool; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + buffercache => undef, + procedurecache => undef, + locks => [], + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::buffercache/) { + $self->{buffercache} = DBD::MSSQL::Server::Memorypool::BufferCache->new( + %params); + } elsif ($params{mode} =~ /server::memorypool::procedurecache/) { + $self->{procedurecache} = DBD::MSSQL::Server::Memorypool::ProcedureCache->new( + %params); + } elsif ($params{mode} =~ /server::memorypool::lock/) { + DBD::MSSQL::Server::Memorypool::Lock::init_locks(%params); + if (my @locks = DBD::MSSQL::Server::Memorypool::Lock::return_locks()) { + $self->{locks} = \@locks; + } else { + $self->add_nagios_critical("unable to aquire lock info"); + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if ($params{mode} =~ /server::memorypool::buffercache/) { + $self->{buffercache}->nagios(%params); + $self->merge_nagios($self->{buffercache}); + } elsif ($params{mode} =~ /^server::memorypool::lock::listlocks/) { + foreach (sort { $a->{name} cmp $b->{name}; } @{$self->{locks}}) { + printf "%s\n", $_->{name}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::memorypool::lock/) { + foreach (@{$self->{locks}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } +} + + +package DBD::MSSQL::Server::Memorypool::BufferCache; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server::Memorypool); + + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + hitratio => undef, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::buffercache::hitratio/) { + # -- (a.cntr_value * 1.0 / b.cntr_value) * 100.0 [BufferCacheHitRatio] + $self->{cnt_hitratio} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Buffer cache hit ratio"); + $self->{cnt_hitratio_base} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Buffer cache hit ratio base"); + if (! defined $self->{cnt_hitratio}) { + $self->add_nagios_unknown("unable to aquire buffer cache data"); + } else { + # das kracht weil teilweise negativ + #$self->valdiff(\%params, qw(cnt_hitratio cnt_hitratio_base)); + $self->{hitratio} = ($self->{cnt_hitratio_base} == 0) ? + 100 : $self->{cnt_hitratio} / $self->{cnt_hitratio_base} * 100.0; + # soll vorkommen..... + $self->{hitratio} = 100 if ($self->{hitratio} > 100); + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::lazywrites/) { + $self->{lazy_writes_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Lazy writes/sec"); + if (! defined $self->{lazy_writes_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(lazy_writes_s)); + $self->{lazy_writes_per_sec} = $self->{delta_lazy_writes_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::pagelifeexpectancy/) { + $self->{pagelifeexpectancy} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Page life expectancy"); + if (! defined $self->{pagelifeexpectancy}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::freeliststalls/) { + $self->{freeliststalls_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Free list stalls/sec"); + if (! defined $self->{freeliststalls_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(freeliststalls_s)); + $self->{freeliststalls_per_sec} = $self->{delta_freeliststalls_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /server::memorypool::buffercache::checkpointpages/) { + $self->{checkpointpages_s} = $self->{handle}->get_perf_counter( + "SQLServer:Buffer Manager", "Checkpoint pages/sec"); + if (! defined $self->{checkpointpages_s}) { + $self->add_nagios_unknown("unable to aquire buffer manager data"); + } else { + $self->valdiff(\%params, qw(checkpointpages_s)); + $self->{checkpointpages_per_sec} = $self->{delta_checkpointpages_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::memorypool::buffercache::hitratio/) { + $self->add_nagios( + $self->check_thresholds($self->{hitratio}, '90:', '80:'), + sprintf "buffer cache hit ratio is %.2f%%", $self->{hitratio}); + $self->add_perfdata(sprintf "buffer_cache_hit_ratio=%.2f%%;%s;%s", + $self->{hitratio}, + $self->{warningrange}, $self->{criticalrange}); + #$self->add_perfdata(sprintf "buffer_cache_hit_ratio_now=%.2f%%", + # $self->{hitratio_now}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::lazywrites/) { + $self->add_nagios( + $self->check_thresholds($self->{lazy_writes_per_sec}, '20', '40'), + sprintf "%.2f lazy writes per second", $self->{lazy_writes_per_sec}); + $self->add_perfdata(sprintf "lazy_writes_per_sec=%.2f;%s;%s", + $self->{lazy_writes_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::pagelifeexpectancy/) { + $self->add_nagios( + $self->check_thresholds($self->{pagelifeexpectancy}, '300:', '180:'), + sprintf "page life expectancy is %d seconds", $self->{pagelifeexpectancy}); + $self->add_perfdata(sprintf "page_life_expectancy=%d;%s;%s", + $self->{pagelifeexpectancy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::freeliststalls/) { + $self->add_nagios( + $self->check_thresholds($self->{freeliststalls_per_sec}, '4', '10'), + sprintf "%.2f free list stalls per second", $self->{freeliststalls_per_sec}); + $self->add_perfdata(sprintf "free_list_stalls_per_sec=%.2f;%s;%s", + $self->{freeliststalls_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::memorypool::buffercache::checkpointpages/) { + $self->add_nagios( + $self->check_thresholds($self->{checkpointpages_per_sec}, '100', '500'), + sprintf "%.2f pages flushed per second", $self->{checkpointpages_per_sec}); + $self->add_perfdata(sprintf "checkpoint_pages_per_sec=%.2f;%s;%s", + $self->{checkpointpages_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + + + + + +package DBD::MSSQL::Server::Memorypool::Lock; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server::Memorypool); + + +{ + my @locks = (); + my $initerrors = undef; + + sub add_lock { + push(@locks, shift); + } + + sub return_locks { + return reverse + sort { $a->{name} cmp $b->{name} } @locks; + } + + sub init_locks { + my %params = @_; + my $num_locks = 0; + if (($params{mode} =~ /server::memorypool::lock::listlocks/) || + ($params{mode} =~ /server::memorypool::lock::waits/) || + ($params{mode} =~ /server::memorypool::lock::deadlocks/) || + ($params{mode} =~ /server::memorypool::lock::timeouts/)) { + my @lockresult = $params{handle}->get_instance_names( + 'SQLServer:Locks'); + foreach (@lockresult) { + my ($name) = @{$_}; + $name =~ s/\s*$//; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + my $lock = DBD::MSSQL::Server::Memorypool::Lock->new( + %thisparams); + add_lock($lock); + $num_locks++; + } + if (! $num_locks) { + $initerrors = 1; + return undef; + } + } + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + name => $params{name}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::memorypool::lock::listlocks/) { + # name reicht + } elsif ($params{mode} =~ /server::memorypool::lock::waits/) { + $self->{lock_waits_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Lock Waits/sec", $self->{name}); + if (! defined $self->{lock_waits_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_waits_s)); + $self->{lock_waits_per_sec} = $self->{delta_lock_waits_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::memorypool::lock::timeouts/) { + $self->{lock_timeouts_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Lock Timeouts/sec", $self->{name}); + if (! defined $self->{lock_timeouts_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_timeouts_s)); + $self->{lock_timeouts_per_sec} = $self->{delta_lock_timeouts_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::memorypool::lock::deadlocks/) { + $self->{lock_deadlocks_s} = $self->{handle}->get_perf_counter_instance( + "SQLServer:Locks", "Number of Deadlocks/sec", $self->{name}); + if (! defined $self->{lock_deadlocks_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(lock_deadlocks_s)); + $self->{lock_deadlocks_per_sec} = $self->{delta_lock_deadlocks_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::memorypool::lock::waits/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_waits_per_sec}, 100, 500), + sprintf "%.4f lock waits / sec for %s", + $self->{lock_waits_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_lock_waits_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_waits_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::memorypool::lock::timeouts/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_timeouts_per_sec}, 1, 5), + sprintf "%.4f lock timeouts / sec for %s", + $self->{lock_timeouts_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_lock_timeouts_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_timeouts_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::memorypool::lock::deadlocks/) { + $self->add_nagios( + $self->check_thresholds($self->{lock_deadlocks_per_sec}, 1, 5), + sprintf "%.4f deadlocks / sec for %s", + $self->{lock_deadlocks_per_sec}, $self->{name}); + $self->add_perfdata(sprintf "%s_deadlocks_per_sec=%.4f;%s;%s", + $self->{name}, $self->{lock_deadlocks_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + + +package DBD::MSSQL::Server::Memorypool::SystemLevelDataStructures::LockTable; +package DBD::MSSQL::Server::Memorypool::ProcedureCache; +package DBD::MSSQL::Server::Memorypool::LogCache; +package DBD::MSSQL::Server::Memorypool::SystemLevelDataStructures; +package DBD::MSSQL::Server::Database::Datafile; + +use strict; +use File::Basename; + +our @ISA = qw(DBD::MSSQL::Server::Database); + + +{ + my @datafiles = (); + my $initerrors = undef; + + sub add_datafile { + push(@datafiles, shift); + } + + sub return_datafiles { + return reverse + sort { $a->{logicalfilename} cmp $b->{logicalfilename} } @datafiles; + } + + sub clear_datafiles { + @datafiles = (); + } + + sub init_datafiles { + my %params = @_; + my $num_datafiles = 0; + if ($params{mode} =~ /server::database::datafile::listdatafiles/) { + my @datafileresults = $params{handle}->fetchall_array(q{ +DECLARE @DBInfo TABLE +( ServerName VARCHAR(100), +DatabaseName VARCHAR(100), +FileSizeMB INT, +LogicalFileName sysname, +PhysicalFileName NVARCHAR(520), +Status sysname, +Updateability sysname, +RecoveryMode sysname, +FreeSpaceMB INT, +FreeSpacePct VARCHAR(7), +FreeSpacePages INT, +PollDate datetime) + +DECLARE @command VARCHAR(5000) + +SELECT @command = 'Use [' + '?' + '] SELECT +@@servername as ServerName, +' + '''' + '?' + '''' + ' AS DatabaseName, +CAST(sysfiles.size/128.0 AS int) AS FileSize, +sysfiles.name AS LogicalFileName, sysfiles.filename AS PhysicalFileName, +CONVERT(sysname,DatabasePropertyEx(''?'',''Status'')) AS Status, +CONVERT(sysname,DatabasePropertyEx(''?'',''Updateability'')) AS Updateability, +CONVERT(sysname,DatabasePropertyEx(''?'',''Recovery'')) AS RecoveryMode, +CAST(sysfiles.size/128.0 - CAST(FILEPROPERTY(sysfiles.name, ' + '''' + + 'SpaceUsed' + '''' + ' ) AS int)/128.0 AS int) AS FreeSpaceMB, +CAST(100 * (CAST (((sysfiles.size/128.0 -CAST(FILEPROPERTY(sysfiles.name, +' + '''' + 'SpaceUsed' + '''' + ' ) AS int)/128.0)/(sysfiles.size/128.0)) +AS decimal(4,2))) AS varchar(8)) + ' + '''' + '%' + '''' + ' AS FreeSpacePct, +GETDATE() as PollDate FROM dbo.sysfiles' +INSERT INTO @DBInfo + (ServerName, + DatabaseName, + FileSizeMB, + LogicalFileName, + PhysicalFileName, + Status, + Updateability, + RecoveryMode, + FreeSpaceMB, + FreeSpacePct, + PollDate) +EXEC sp_MSForEachDB @command + +SELECT + ServerName, + DatabaseName, + FileSizeMB, + LogicalFileName, + PhysicalFileName, + Status, + Updateability, + RecoveryMode, + FreeSpaceMB, + FreeSpacePct, + PollDate +FROM @DBInfo +ORDER BY + ServerName, + DatabaseName + }); + if (DBD::MSSQL::Server::return_first_server()->windows_server()) { + fileparse_set_fstype("MSWin32"); + } + foreach (@datafileresults) { + my ($servername, $databasename, $filesizemb, $logicalfilename, + $physicalfilename, $status, $updateability, $recoverymode, + $freespacemb, $freespacepct, $polldate) = @{$_}; + next if $databasename ne $params{database}; + if ($params{regexp}) { + #next if $params{selectname} && + # (($name !~ /$params{selectname}/) && + # (basename($name) !~ /$params{selectname}/)); + next if $params{selectname} && + ($logicalfilename !~ /$params{selectname}/); + } else { + #next if $params{selectname} && + # ((lc $params{selectname} ne lc $name) && + # (lc $params{selectname} ne lc basename($name))); + next if $params{selectname} && + (lc $params{selectname} ne lc $logicalfilename); + } + my %thisparams = %params; + $thisparams{servername} = $servername; + $thisparams{databasename} = $databasename; + $thisparams{filesizemb} = $filesizemb; + $thisparams{logicalfilename} = $logicalfilename; + $thisparams{servername} = $servername; + $thisparams{status} = $status; + $thisparams{updateability} = $updateability; + $thisparams{recoverymode} = $recoverymode; + $thisparams{freespacemb} = $freespacemb; + $thisparams{freespacepct} = $freespacepct; + $thisparams{polldate} = $polldate; + my $datafile = + DBD::MSSQL::Server::Database::Datafile->new( + %thisparams); + add_datafile($datafile); + $num_datafiles++; + } + } + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + databasename => $params{databasename}, + filesizemb => $params{filesizemb}, + logicalfilename => $params{logicalfilename}, + physicalfilename => $params{physicalfilename}, + status => $params{status}, + updateability => $params{updateability}, + recoverymode => $params{recoverymode}, + freespacemb => $params{freespacemb}, + freespacepct => $params{freespacepct}, + freespacepages => $params{freespacepages}, + polldate => $params{polldate}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + if ($params{mode} =~ /server::database::iobalance/) { + if (! defined $self->{phyrds}) { + $self->add_nagios_critical(sprintf "unable to read datafile io %s", $@); + } else { + $params{differenciator} = $self->{path}; + $self->valdiff(\%params, qw(phyrds phywrts)); + $self->{io_total} = $self->{delta_phyrds} + $self->{delta_phywrts}; + } + } elsif ($params{mode} =~ /server::database::datafile::iotraffic/) { + if (! defined $self->{phyrds}) { + $self->add_nagios_critical(sprintf "unable to read datafile io %s", $@); + } else { + $params{differenciator} = $self->{path}; + $self->valdiff(\%params, qw(phyrds phywrts)); + $self->{io_total_per_sec} = ($self->{delta_phyrds} + $self->{delta_phywrts}) / + $self->{delta_timestamp}; + } + } +} + + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::database::datafile::iotraffic/) { + $self->add_nagios( + $self->check_thresholds($self->{io_total_per_sec}, "1000", "5000"), + sprintf ("%s: %.2f IO Operations per Second", + $self->{name}, $self->{io_total_per_sec})); + $self->add_perfdata(sprintf "'dbf_%s_io_total_per_sec'=%.2f;%d;%d", + $self->{name}, $self->{io_total_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } + } +} + +package DBD::MSSQL::Server::Database; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + + +{ + my @databases = (); + my $initerrors = undef; + + sub add_database { + push(@databases, shift); + } + + sub return_databases { + return reverse + sort { $a->{name} cmp $b->{name} } @databases; + } + + sub init_databases { + my %params = @_; + my $num_databases = 0; + if (($params{mode} =~ /server::database::listdatabases/) || + ($params{mode} =~ /server::database::databasefree/) || + ($params{mode} =~ /server::database::lastbackup/) || + ($params{mode} =~ /server::database::transactions/) || + ($params{mode} =~ /server::database::datafile/)) { + my @databaseresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT name, database_id FROM master.sys.databases + }); + } else { + #@databaseresult = map { + # [ $_->[0], $_->[3] ] # only name, dbid + #} $params{handle}->fetchall_array(q{exec sp_helpdb}); + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT name, dbid FROM master.dbo.sysdatabases + }); + } + if ($params{mode} =~ /server::database::transactions/) { + push(@databaseresult, [ '_Total', 0 ]); + } + foreach (@databaseresult) { + my ($name, $id) = @{$_}; + next if $params{database} && $name ne $params{database}; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + $thisparams{id} = $id; + my $database = DBD::MSSQL::Server::Database->new( + %thisparams); + add_database($database); + $num_databases++; + } + if (! $num_databases) { + $initerrors = 1; + return undef; + } + } elsif ($params{mode} =~ /server::database::backupage/) { + my @databaseresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT + a.name, + DATEDIFF(HH, MAX(b.backup_finish_date), GETDATE()), + DATEDIFF(MI, MAX(b.backup_start_date), MAX(b.backup_finish_date)) + FROM sys.sysdatabases a LEFT OUTER JOIN msdb.dbo.backupset b + ON b.database_name = a.name + GROUP BY a.name + ORDER BY a.name + }); + } else { + @databaseresult = $params{handle}->fetchall_array(q{ + SELECT + a.name, + DATEDIFF(HH, MAX(b.backup_finish_date), GETDATE()), + DATEDIFF(MI, MAX(b.backup_start_date), MAX(b.backup_finish_date)) + FROM master.dbo.sysdatabases a LEFT OUTER JOIN msdb.dbo.backupset b + ON b.database_name = a.name + GROUP BY a.name + ORDER BY a.name + }); + } + foreach (sort { + if (! defined $b->[1]) { + return 1; + } elsif (! defined $a->[1]) { + return -1; + } else { + return $a->[1] <=> $b->[1]; + } + } @databaseresult) { + my ($name, $age, $duration) = @{$_}; + next if $params{database} && $name ne $params{database}; + if ($params{regexp}) { + next if $params{selectname} && $name !~ /$params{selectname}/; + } else { + next if $params{selectname} && lc $params{selectname} ne lc $name; + } + my %thisparams = %params; + $thisparams{name} = $name; + $thisparams{backup_age} = $age; + $thisparams{backup_duration} = $duration; + my $database = DBD::MSSQL::Server::Database->new( + %thisparams); + add_database($database); + $num_databases++; + } + } + + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + name => $params{name}, + id => $params{id}, + datafiles => [], + backup_age => $params{backup_age}, + backup_duration => $params{backup_duration}, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $self->init_nagios(); + $self->set_local_db_thresholds(%params); + if ($params{mode} =~ /server::database::datafile/) { + $params{database} = $self->{name}; + DBD::MSSQL::Server::Database::Datafile::init_datafiles(%params); + if (my @datafiles = + DBD::MSSQL::Server::Database::Datafile::return_datafiles()) { + $self->{datafiles} = \@datafiles; + } else { + $self->add_nagios_critical("unable to aquire datafile info"); + } + } elsif ($params{mode} =~ /server::database::databasefree/) { + ################################################################################### + # fuer's museum + # 1> sp_spaceused + # 2> go + # database_name database_size unallocated space + # master 4.50 MB 1.32 MB + # reserved data index_size unused + # 2744 KB 1056 KB 1064 KB 624 KB + # (return status = 0) + #my($database_name, $database_size, $unallocated_space, + # $reserved, $data, $index_size, $unused) = + # $params{handle}->fetchrow_array( + # "USE ".$self->{name}."\nEXEC SP_SPACEUSED" + #); + # server mgmt studio sp_spaceused + # Currently Allocated Space database_size 641.94MB + # Available Free Space unallocated space 457.09MB + #$database_size =~ s/MB//g; + #$unallocated_space =~ s/MB//g; + #$self->{size} = $database_size * 1024 * 1024; + #$self->{free} = $unallocated_space * 1024 * 1024; + #$self->{percent_free} = $unallocated_space / $database_size * 100; + #$self->{used} = $self->{size} - $self->{free}; + #$self->{maxsize} = "99999999999999999"; + ################################################################################### + my $calc = {}; + if ($params{method} eq 'sqlcmd' || $params{method} eq 'sqsh') { + foreach($self->{handle}->fetchall_array(q{ + if object_id('tempdb..#FreeSpace') is null + create table #FreeSpace( + Drive varchar(10), + MB_Free bigint + ) + go + DELETE FROM tempdb..#FreeSpace + INSERT INTO tempdb..#FreeSpace exec master.dbo.xp_fixeddrives + go + SELECT * FROM tempdb..#FreeSpace + })) { + $calc->{drive_mb}->{lc $_->[0]} = $_->[1]; + } + } else { + $self->{handle}->execute(q{ + if object_id('tempdb..#FreeSpace') is null + create table #FreeSpace( + Drive varchar(10), + MB_Free bigint + ) + }); + $self->{handle}->execute(q{ + DELETE FROM #FreeSpace + }); + $self->{handle}->execute(q{ + INSERT INTO #FreeSpace exec master.dbo.xp_fixeddrives + }); + foreach($self->{handle}->fetchall_array(q{ + SELECT * FROM #FreeSpace + })) { + $calc->{drive_mb}->{lc $_->[0]} = $_->[1]; + } + } + #$self->{handle}->execute(q{ + # DROP TABLE #FreeSpace + #}); + # Page = 8KB + # sysfiles ist sv2000, noch als kompatibilitaetsview vorhanden + # dbo.sysfiles kann 2008 durch sys.database_files ersetzt werden? + # omeiomeiomei in 2005 ist ein sys.sysindexes compatibility view + # fuer 2000.dbo.sysindexes + # besser ist sys.allocation_units + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + my $sql = q{ + SELECT + SUM(CAST(used AS BIGINT)) / 128 + FROM + [?].sys.sysindexes + WHERE + indid IN (0,1,255) + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + $self->{used_mb} = $self->{handle}->fetchrow_array($sql); + } else { + my $sql = q{ + SELECT + SUM(CAST(used AS BIGINT)) / 128 + FROM + [?].dbo.sysindexes + WHERE + indid IN (0,1,255) + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + $self->{used_mb} = $self->{handle}->fetchrow_array($sql); + } + my @fileresult = (); + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + my $sql = q{ + SELECT + RTRIM(a.name), RTRIM(a.filename), CAST(a.size AS BIGINT), + CAST(a.maxsize AS BIGINT), a.growth + FROM + [?].sys.sysfiles a + JOIN + [?].sys.sysfilegroups b + ON + a.groupid = b.groupid + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + @fileresult = $self->{handle}->fetchall_array($sql); + } else { + my $sql = q{ + SELECT + RTRIM(a.name), RTRIM(a.filename), CAST(a.size AS BIGINT), + CAST(a.maxsize AS BIGINT), a.growth + FROM + [?].dbo.sysfiles a + JOIN + [?].dbo.sysfilegroups b + ON + a.groupid = b.groupid + }; + #$sql =~ s/\[\?\]/$self->{name}/g; + $sql =~ s/\?/$self->{name}/g; + @fileresult = $self->{handle}->fetchall_array($sql); + } + foreach(@fileresult) { + my($name, $filename, $size, $maxsize, $growth) = @{$_}; + my $drive = lc substr($filename, 0, 1); + $calc->{datafile}->{$name}->{allocsize} = $size / 128; + if ($growth == 0) { + $calc->{datafile}->{$name}->{maxsize} = $size / 128; + } else { + if ($maxsize == -1) { + $calc->{datafile}->{$name}->{maxsize} = + exists $calc->{drive_mb}->{$drive} ? + ($calc->{datafile}->{$name}->{allocsize} + + $calc->{drive_mb}->{$drive}) : 4 * 1024; + # falls die platte nicht gefunden wurde, dann nimm halt 4GB + if (exists $calc->{drive_mb}->{$drive}) { + # davon kann ausgegangen werden. wenn die drives nicht zur + # vefuegung stehen, stimmt sowieso hinten und vorne nichts. + $calc->{drive_mb}->{$drive} = 0; + # damit ist der platz dieses laufwerks verbraten und in + # max_mb eingeflossen. es darf nicht sein, dass der freie platz + # mehrfach gezaehlt wird, wenn es mehrere datafiles auf diesem + # laufwerk gibt. + } + } else { + $calc->{datafile}->{$name}->{maxsize} = $maxsize / 128; + } + } + $self->{allocated_mb} += $calc->{datafile}->{$name}->{allocsize}; + $self->{max_mb} += $calc->{datafile}->{$name}->{maxsize}; + } + $self->{allocated_mb} = $self->{allocated_mb}; + if ($self->{used_mb} > $self->{allocated_mb}) { + # obige used-berechnung liefert manchmal (wenns knapp hergeht) mehr als + # den maximal verfuegbaren platz. vermutlich muessen dann + # zwecks ermittlung des tatsaechlichen platzverbrauchs + # irgendwelche dbcc updateusage laufen. + # egal, wird schon irgendwie stimmen. + $self->{used_mb} = $self->{allocated_mb}; + $self->{estimated} = 1; + } else { + $self->{estimated} = 0; + } + $self->{free_mb} = $self->{max_mb} - $self->{used_mb}; + $self->{free_percent} = 100 * $self->{free_mb} / $self->{max_mb}; + $self->{allocated_percent} = 100 * $self->{allocated_mb} / $self->{max_mb}; + } elsif ($params{mode} =~ /^server::database::transactions/) { + $self->{transactions_s} = $self->{handle}->get_perf_counter_instance( + 'SQLServer:Databases', 'Transactions/sec', $self->{name}); + if (! defined $self->{transactions_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(transactions_s)); + $self->{transactions_per_sec} = $self->{delta_transactions_s} / $self->{delta_timestamp}; + } + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /server::database::datafile::listdatafiles/) { + foreach (sort { $a->{logicalfilename} cmp $b->{logicalfilename}; } @{$self->{datafiles}}) { + printf "%s\n", $_->{logicalfilename}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::database::transactions/) { + $self->add_nagios( + $self->check_thresholds($self->{transactions_per_sec}, 10000, 50000), + sprintf "%s has %.4f transactions / sec", + $self->{name}, $self->{transactions_per_sec}); + $self->add_perfdata(sprintf "%s_transactions_per_sec=%.4f;%s;%s", + $self->{name}, $self->{transactions_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::database::databasefree/) { + # ->percent_free + # ->free + # + # ausgabe + # perfdata db__free_pct + # perfdata db__free (real_bytes_max - bytes) + bytes_free (with units) + # perfdata db__alloc_free bytes_free (with units) + # + # umrechnen der thresholds + # ()/% + # MB + # GB + # KB + if (($self->{warningrange} && $self->{warningrange} !~ /^\d+[\.\d]*:/) || + ($self->{criticalrange} && $self->{criticalrange} !~ /^\d+[\.\d]*:/)) { + $self->add_nagios_unknown("you want an alert if free space is _above_ a threshold????"); + return; + } + if (! $params{units}) { + $params{units} = "%"; + } + $self->{warning_bytes} = 0; + $self->{critical_bytes} = 0; + if ($params{units} eq "%") { + $self->add_nagios( + $self->check_thresholds($self->{free_percent}, "5:", "2:"), + sprintf("database %s has %.2f%% free space left", + $self->{name}, $self->{free_percent}, + ($self->{estimated} ? " (estim.)" : "")) + ); + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->add_perfdata(sprintf "\'db_%s_free_pct\'=%.2f%%;%d:;%d:", + lc $self->{name}, + $self->{free_percent}, + $self->{warningrange}, $self->{criticalrange}); + $self->add_perfdata(sprintf "\'db_%s_free\'=%dMB;%.2f:;%.2f:;0;%.2f", + lc $self->{name}, + $self->{free_mb}, + $self->{warningrange} * $self->{max_mb} / 100, + $self->{criticalrange} * $self->{max_mb} / 100, + $self->{max_mb}); + $self->add_perfdata(sprintf "\'db_%s_allocated_pct\'=%.2f%%", + lc $self->{name}, + $self->{allocated_percent}); + } else { + my $factor = 1; # default MB + if ($params{units} eq "GB") { + $factor = 1024; + } elsif ($params{units} eq "MB") { + $factor = 1; + } elsif ($params{units} eq "KB") { + $factor = 1 / 1024; + } + $self->{warningrange} ||= "5:"; + $self->{criticalrange} ||= "2:"; + my $saved_warningrange = $self->{warningrange}; + my $saved_criticalrange = $self->{criticalrange}; + # : entfernen weil gerechnet werden muss + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->{warningrange} = $self->{warningrange} ? + $self->{warningrange} * $factor : 5 * $factor; + $self->{criticalrange} = $self->{criticalrange} ? + $self->{criticalrange} * $factor : 2 * $factor; + $self->{percent_warning} = 100 * $self->{warningrange} / $self->{max_mb}; + $self->{percent_critical} = 100 * $self->{criticalrange} / $self->{max_mb}; + $self->{warningrange} .= ':'; + $self->{criticalrange} .= ':'; + $self->add_nagios( + $self->check_thresholds($self->{free_mb}, "5242880:", "1048576:"), + sprintf("database %s has %.2f%s free space left", $self->{name}, + $self->{free_mb} / $factor, $params{units}) + ); + $self->{warningrange} = $saved_warningrange; + $self->{criticalrange} = $saved_criticalrange; + $self->{warningrange} =~ s/://g; + $self->{criticalrange} =~ s/://g; + $self->add_perfdata(sprintf "\'db_%s_free_pct\'=%.2f%%;%.2f:;%.2f:", + lc $self->{name}, + $self->{free_percent}, $self->{percent_warning}, + $self->{percent_critical}); + $self->add_perfdata(sprintf "\'db_%s_free\'=%.2f%s;%.2f:;%.2f:;0;%.2f", + lc $self->{name}, + $self->{free_mb} / $factor, $params{units}, + $self->{warningrange}, + $self->{criticalrange}, + $self->{max_mb} / $factor); + $self->add_perfdata(sprintf "\'db_%s_allocated_pct\'=%.2f%%", + lc $self->{name}, + $self->{allocated_percent}); + } + } elsif ($params{mode} =~ /server::database::backupage/) { + if (! defined $self->{backup_age}) { + $self->add_nagios_critical(sprintf "%s was never backupped", + $self->{name}); + $self->{backup_age} = 0; + $self->{backup_duration} = 0; + $self->check_thresholds($self->{backup_age}, 48, 72); # init wg perfdata + } else { + $self->add_nagios( + $self->check_thresholds($self->{backup_age}, 48, 72), + sprintf "%s backupped %dh ago", $self->{name}, $self->{backup_age}); + } + $self->add_perfdata(sprintf "'%s_bck_age'=%d;%s;%s", + $self->{name}, $self->{backup_age}, + $self->{warningrange}, $self->{criticalrange}); + $self->add_perfdata(sprintf "'%s_bck_time'=%d", + $self->{name}, $self->{backup_duration}); + } + } +} + + + +package DBD::MSSQL::Server; + +use strict; +use Time::HiRes; +use IO::File; +use File::Copy 'cp'; +use Data::Dumper; + + +{ + our $verbose = 0; + our $scream = 0; # scream if something is not implemented + our $my_modules_dyn_dir = ""; # where we look for self-written extensions + + my @servers = (); + my $initerrors = undef; + + sub add_server { + push(@servers, shift); + } + + sub return_servers { + return @servers; + } + + sub return_first_server() { + return $servers[0]; + } + +} + +sub new { + my $class = shift; + my %params = @_; + my $self = { + method => $params{method} || "dbi", + hostname => $params{hostname}, + username => $params{username}, + password => $params{password}, + port => $params{port} || 1433, + server => $params{server}, + timeout => $params{timeout}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + verbose => $params{verbose}, + report => $params{report}, + version => 'unknown', + os => 'unknown', + servicename => 'unknown', + instance => undef, + memorypool => undef, + databases => [], + handle => undef, + }; + bless $self, $class; + $self->init_nagios(); + if ($self->dbconnect(%params)) { + #$self->{version} = $self->{handle}->fetchrow_array( + # q{ SELECT SERVERPROPERTY('productversion') }); + map { + $self->{os} = $1 if /Windows (.*)/; + $self->{version} = $1 if /SQL Server.*\-\s*([\d\.]+)/; + } $self->{handle}->fetchrow_array( + q{ SELECT @@VERSION }); + $self->{dbuser} = $self->{handle}->fetchrow_array( + q{ SELECT SYSTEM_USER }); # maybe SELECT SUSER_SNAME() + $self->{servicename} = $self->{handle}->fetchrow_array( + q{ SELECT @@SERVICENAME }); + if (lc $self->{servicename} ne 'mssqlserver') { + # braucht man fuer abfragen von dm_os_performance_counters + # object_name ist entweder "SQLServer:Buffer Node" oder z.b. "MSSQL$OASH: Buffer Node" + $self->{servicename} = 'MSSQL$'.$self->{servicename}; + } else { + $self->{servicename} = 'SQLServer'; + } + DBD::MSSQL::Server::add_server($self); + $self->init(%params); + } + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + $params{handle} = $self->{handle}; + $self->set_global_db_thresholds(\%params); + if ($params{mode} =~ /^server::memorypool/) { + $self->{memorypool} = DBD::MSSQL::Server::Memorypool->new(%params); + } elsif ($params{mode} =~ /^server::database/) { + DBD::MSSQL::Server::Database::init_databases(%params); + if (my @databases = + DBD::MSSQL::Server::Database::return_databases()) { + $self->{databases} = \@databases; + } else { + $self->add_nagios_critical("unable to aquire database info"); + } + } elsif ($params{mode} =~ /^server::connectiontime/) { + $self->{connection_time} = $self->{tac} - $self->{tic}; + } elsif ($params{mode} =~ /^server::cpubusy/) { + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + ($self->{secs_busy}) = $self->{handle}->fetchrow_array(q{ + SELECT ((@@CPU_BUSY * CAST(@@TIMETICKS AS FLOAT)) / + (SELECT (CAST(CPU_COUNT AS FLOAT) / CAST(HYPERTHREAD_RATIO AS FLOAT)) FROM sys.dm_os_sys_info) / + 1000000) + }); + $self->valdiff(\%params, qw(secs_busy)); + if (defined $self->{secs_busy}) { + $self->{cpu_busy} = 100 * + $self->{delta_secs_busy} / $self->{delta_timestamp}; + } else { + $self->add_nagios_critical("got no cputime from dm_os_sys_info"); + } + } else { + #$self->requires_version('9'); + my @monitor = $params{handle}->exec_sp_1hash(q{exec sp_monitor}); + foreach (@monitor) { + if ($_->[0] eq 'cpu_busy') { + if ($_->[1] =~ /(\d+)%/) { + $self->{cpu_busy} = $1; + } + } + } + self->requires_version('9') unless defined $self->{cpu_busy}; + } + } elsif ($params{mode} =~ /^server::iobusy/) { + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + ($self->{secs_busy}) = $self->{handle}->fetchrow_array(q{ + SELECT ((@@IO_BUSY * CAST(@@TIMETICKS AS FLOAT)) / + (SELECT (CAST(CPU_COUNT AS FLOAT) / CAST(HYPERTHREAD_RATIO AS FLOAT)) FROM sys.dm_os_sys_info) / + 1000000) + }); + $self->valdiff(\%params, qw(secs_busy)); + if (defined $self->{secs_busy}) { + $self->{io_busy} = 100 * + $self->{delta_secs_busy} / $self->{delta_timestamp}; + } else { + $self->add_nagios_critical("got no iotime from dm_os_sys_info"); + } + } else { + #$self->requires_version('9'); + my @monitor = $params{handle}->exec_sp_1hash(q{exec sp_monitor}); + foreach (@monitor) { + if ($_->[0] eq 'io_busy') { + if ($_->[1] =~ /(\d+)%/) { + $self->{io_busy} = $1; + } + } + } + self->requires_version('9') unless defined $self->{io_busy}; + } + } elsif ($params{mode} =~ /^server::fullscans/) { + $self->{cnt_full_scans_s} = $self->{handle}->get_perf_counter( + 'SQLServer:Access Methods', 'Full Scans/sec'); + if (! defined $self->{cnt_full_scans_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(cnt_full_scans_s)); + $self->{full_scans_per_sec} = $self->{delta_cnt_full_scans_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::latch::waittime/) { + $self->{latch_wait_time} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Average Latch Wait Time (ms)"); + $self->{latch_wait_time_base} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Average Latch Wait Time Base"); + if (! defined $self->{latch_wait_time}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } + $self->{latch_wait_time} = $self->{latch_wait_time} / $self->{latch_wait_time_base}; + } elsif ($params{mode} =~ /^server::latch::waits/) { + $self->{latch_waits_s} = $self->{handle}->get_perf_counter( + "SQLServer:Latches", "Latch Waits/sec"); + if (! defined $self->{latch_waits_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(latch_waits_s)); + $self->{latch_waits_per_sec} = $self->{delta_latch_waits_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::sql::.*compilations/) { + $self->{recompilations_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "SQL Re-Compilations/sec"); + $self->{compilations_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "SQL Compilations/sec"); + if (! defined $self->{recompilations_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(recompilations_s compilations_s)); + # http://www.sqlmag.com/Articles/ArticleID/40925/pg/3/3.html + # http://www.grumpyolddba.co.uk/monitoring/Performance%20Counter%20Guidance%20-%20SQL%20Server.htm + $self->{delta_initial_compilations_s} = $self->{delta_compilations_s} - + $self->{delta_recompilations_s}; + $self->{initial_compilations_per_sec} = + $self->{delta_initial_compilations_s} / $self->{delta_timestamp}; + $self->{recompilations_per_sec} = + $self->{delta_recompilations_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::batchrequests/) { + $self->{batch_requests_s} = $self->{handle}->get_perf_counter( + "SQLServer:SQL Statistics", "Batch requests/sec"); + if (! defined $self->{batch_requests_s}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } else { + $self->valdiff(\%params, qw(batch_requests_s)); + $self->{batch_requests_per_sec} = $self->{delta_batch_requests_s} / $self->{delta_timestamp}; + } + } elsif ($params{mode} =~ /^server::totalmemory/) { + $self->{total_memory} = $self->{handle}->get_perf_counter( + "SQLServer:Memory Manager", "Total Server Memory (KB)"); + if (! defined $self->{total_memory}) { + $self->add_nagios_unknown("unable to aquire counter data"); + } + } elsif ($params{mode} =~ /^server::connectedusers/) { + $self->{connectedusers} = $self->{handle}->fetchrow_array(q{ + SELECT + COUNT(*) + FROM + master..sysprocesses + WHERE + spid > ? + }, 51); + if (! defined $self->{connectedusers}) { + $self->add_nagios_unknown("unable to count connected users"); + } + } elsif ($params{mode} =~ /^server::sql/) { + $self->set_local_db_thresholds(%params); + if ($params{regexp}) { + # sql output is treated as text + if ($params{name2} eq $params{name}) { + $self->add_nagios_unknown(sprintf "where's the regexp????"); + } else { + $self->{genericsql} = + $self->{handle}->fetchrow_array($params{selectname}); + if (! defined $self->{genericsql}) { + $self->add_nagios_unknown(sprintf "got no valid response for %s", + $params{selectname}); + } + } + } else { + # sql output must be a number (or array of numbers) + @{$self->{genericsql}} = + $self->{handle}->fetchrow_array($params{selectname}); + if (! (defined $self->{genericsql} && + (scalar(grep { /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/ } @{$self->{genericsql}})) == + scalar(@{$self->{genericsql}}))) { + $self->add_nagios_unknown(sprintf "got no valid response for %s", + $params{selectname}); + } else { + # name2 in array + # units in array + } + } + } elsif ($params{mode} =~ /^my::([^:.]+)/) { + my $class = $1; + my $loaderror = undef; + substr($class, 0, 1) = uc substr($class, 0, 1); + foreach my $libpath (split(":", $DBD::MSSQL::Server::my_modules_dyn_dir)) { + foreach my $extmod (glob $libpath."/CheckMSSQLHealth*.pm") { + eval { + $self->trace(sprintf "loading module %s", $extmod); + require $extmod; + }; + if ($@) { + $loaderror = $extmod; + $self->trace(sprintf "failed loading module %s: %s", $extmod, $@); + } + } + } + my $obj = { + handle => $params{handle}, + warningrange => $params{warningrange}, + criticalrange => $params{criticalrange}, + }; + bless $obj, "My$class"; + $self->{my} = $obj; + if ($self->{my}->isa("DBD::MSSQL::Server")) { + my $dos_init = $self->can("init"); + my $dos_nagios = $self->can("nagios"); + my $my_init = $self->{my}->can("init"); + my $my_nagios = $self->{my}->can("nagios"); + if ($my_init == $dos_init) { + $self->add_nagios_unknown( + sprintf "Class %s needs an init() method", ref($self->{my})); + } elsif ($my_nagios == $dos_nagios) { + $self->add_nagios_unknown( + sprintf "Class %s needs a nagios() method", ref($self->{my})); + } else { + $self->{my}->init_nagios(%params); + $self->{my}->init(%params); + } + } else { + $self->add_nagios_unknown( + sprintf "Class %s is not a subclass of DBD::MSSQL::Server%s", + ref($self->{my}), + $loaderror ? sprintf " (syntax error in %s?)", $loaderror : "" ); + } + } else { + printf "broken mode %s\n", $params{mode}; + } +} + +sub dump { + my $self = shift; + my $message = shift || ""; + printf "%s %s\n", $message, Data::Dumper::Dumper($self); +} + +sub nagios { + my $self = shift; + my %params = @_; + if (! $self->{nagios_level}) { + if ($params{mode} =~ /^server::instance/) { + $self->{instance}->nagios(%params); + $self->merge_nagios($self->{instance}); + } elsif ($params{mode} =~ /server::database::listdatabases/) { + foreach (sort { $a->{name} cmp $b->{name}; } @{$self->{databases}}) { + printf "%s\n", $_->{name}; + } + $self->add_nagios_ok("have fun"); + } elsif ($params{mode} =~ /^server::database/) { + foreach (@{$self->{databases}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } elsif ($params{mode} =~ /^server::database/) { + } elsif ($params{mode} =~ /^server::lock/) { + foreach (@{$self->{locks}}) { + $_->nagios(%params); + $self->merge_nagios($_); + } + } elsif ($params{mode} =~ /^server::memorypool/) { + $self->{memorypool}->nagios(%params); + $self->merge_nagios($self->{memorypool}); + } elsif ($params{mode} =~ /^server::connectiontime/) { + $self->add_nagios( + $self->check_thresholds($self->{connection_time}, 1, 5), + sprintf "%.2f seconds to connect as %s", + $self->{connection_time}, $self->{dbuser}); + $self->add_perfdata(sprintf "connection_time=%.2f;%d;%d", + $self->{connection_time}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::cpubusy/) { + $self->add_nagios( + $self->check_thresholds($self->{cpu_busy}, 80, 90), + sprintf "CPU busy %.2f%%", $self->{cpu_busy}); + $self->add_perfdata(sprintf "cpu_busy=%.2f;%s;%s", + $self->{cpu_busy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::iobusy/) { + $self->add_nagios( + $self->check_thresholds($self->{io_busy}, 80, 90), + sprintf "IO busy %.2f%%", $self->{io_busy}); + $self->add_perfdata(sprintf "io_busy=%.2f;%s;%s", + $self->{io_busy}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::fullscans/) { + $self->add_nagios( + $self->check_thresholds($self->{full_scans_per_sec}, 100, 500), + sprintf "%.2f full table scans / sec", $self->{full_scans_per_sec}); + $self->add_perfdata(sprintf "full_scans_per_sec=%.2f;%s;%s", + $self->{full_scans_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::latch::waits/) { + $self->add_nagios( + $self->check_thresholds($self->{latch_waits_per_sec}, 10, 50), + sprintf "%.2f latches / sec have to wait", $self->{latch_waits_per_sec}); + $self->add_perfdata(sprintf "latch_waits_per_sec=%.2f;%s;%s", + $self->{latch_waits_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::latch::waittime/) { + $self->add_nagios( + $self->check_thresholds($self->{latch_wait_time}, 1, 5), + sprintf "latches have to wait %.2f ms avg", $self->{latch_wait_time}); + $self->add_perfdata(sprintf "latch_avg_wait_time=%.2fms;%s;%s", + $self->{latch_wait_time}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql::recompilations/) { + $self->add_nagios( + $self->check_thresholds($self->{recompilations_per_sec}, 1, 10), + sprintf "%.2f SQL recompilations / sec", $self->{recompilations_per_sec}); + $self->add_perfdata(sprintf "sql_recompilations_per_sec=%.2f;%s;%s", + $self->{recompilations_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql::initcompilations/) { + $self->add_nagios( + $self->check_thresholds($self->{initial_compilations_per_sec}, 100, 200), + sprintf "%.2f initial compilations / sec", $self->{initial_compilations_per_sec}); + $self->add_perfdata(sprintf "sql_initcompilations_per_sec=%.2f;%s;%s", + $self->{initial_compilations_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::batchrequests/) { + $self->add_nagios( + $self->check_thresholds($self->{batch_requests_per_sec}, 100, 200), + sprintf "%.2f batch requests / sec", $self->{batch_requests_per_sec}); + $self->add_perfdata(sprintf "batch_requests_per_sec=%.2f;%s;%s", + $self->{batch_requests_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::totalmemory/) { + $self->add_nagios( + $self->check_thresholds($self->{total_memory}, 1000, 5000), + sprintf "total server memory %ld", $self->{total_memory}); + $self->add_perfdata(sprintf "total_server_memory=%ld;%s;%s", + $self->{total_memory}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::connectedusers/) { + $self->add_nagios( + $self->check_thresholds($self->{connectedusers}, 50, 80), + sprintf "%d connected users", $self->{connectedusers}); + $self->add_perfdata(sprintf "connected_users=%d;%s;%s", + $self->{connectedusers}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /^server::sql/) { + if ($params{regexp}) { + if (substr($params{name2}, 0, 1) eq '!') { + $params{name2} =~ s/^!//; + if ($self->{genericsql} !~ /$params{name2}/) { + $self->add_nagios_ok( + sprintf "output %s does not match pattern %s", + $self->{genericsql}, $params{name2}); + } else { + $self->add_nagios_critical( + sprintf "output %s matches pattern %s", + $self->{genericsql}, $params{name2}); + } + } else { + if ($self->{genericsql} =~ /$params{name2}/) { + $self->add_nagios_ok( + sprintf "output %s matches pattern %s", + $self->{genericsql}, $params{name2}); + } else { + $self->add_nagios_critical( + sprintf "output %s does not match pattern %s", + $self->{genericsql}, $params{name2}); + } + } + } else { + $self->add_nagios( + # the first item in the list will trigger the threshold values + $self->check_thresholds($self->{genericsql}[0], 1, 5), + sprintf "%s: %s%s", + $params{name2} ? lc $params{name2} : lc $params{selectname}, + # float as float, integers as integers + join(" ", map { + (sprintf("%d", $_) eq $_) ? $_ : sprintf("%f", $_) + } @{$self->{genericsql}}), + $params{units} ? $params{units} : ""); + my $i = 0; + # workaround... getting the column names from the database would be nicer + my @names2_arr = split(/\s+/, $params{name2}); + foreach my $t (@{$self->{genericsql}}) { + $self->add_perfdata(sprintf "\'%s\'=%s%s;%s;%s", + $names2_arr[$i] ? lc $names2_arr[$i] : lc $params{selectname}, + # float as float, integers as integers + (sprintf("%d", $t) eq $t) ? $t : sprintf("%f", $t), + $params{units} ? $params{units} : "", + ($i == 0) ? $self->{warningrange} : "", + ($i == 0) ? $self->{criticalrange} : "" + ); + $i++; + } + } + } elsif ($params{mode} =~ /^my::([^:.]+)/) { + $self->{my}->nagios(%params); + $self->merge_nagios($self->{my}); + } + } +} + + +sub init_nagios { + my $self = shift; + no strict 'refs'; + if (! ref($self)) { + my $nagiosvar = $self."::nagios"; + my $nagioslevelvar = $self."::nagios_level"; + $$nagiosvar = { + messages => { + 0 => [], + 1 => [], + 2 => [], + 3 => [], + }, + perfdata => [], + }; + $$nagioslevelvar = $ERRORS{OK}, + } else { + $self->{nagios} = { + messages => { + 0 => [], + 1 => [], + 2 => [], + 3 => [], + }, + perfdata => [], + }; + $self->{nagios_level} = $ERRORS{OK}, + } +} + +sub check_thresholds { + my $self = shift; + my $value = shift; + my $defaultwarningrange = shift; + my $defaultcriticalrange = shift; + my $level = $ERRORS{OK}; + $self->{warningrange} = defined $self->{warningrange} ? + $self->{warningrange} : $defaultwarningrange; + $self->{criticalrange} = defined $self->{criticalrange} ? + $self->{criticalrange} : $defaultcriticalrange; + if ($self->{warningrange} !~ /:/ && $self->{criticalrange} !~ /:/) { + # warning = 10, critical = 20, warn if > 10, crit if > 20 + $level = $ERRORS{WARNING} if $value > $self->{warningrange}; + $level = $ERRORS{CRITICAL} if $value > $self->{criticalrange}; + } elsif ($self->{warningrange} =~ /(\d+):/ && + $self->{criticalrange} =~ /(\d+):/) { + # warning = 98:, critical = 95:, warn if < 98, crit if < 95 + $self->{warningrange} =~ /(\d+):/; + $level = $ERRORS{WARNING} if $value < $1; + $self->{criticalrange} =~ /(\d+):/; + $level = $ERRORS{CRITICAL} if $value < $1; + } + return $level; + # + # syntax error must be reported with returncode -1 + # +} + +sub add_nagios { + my $self = shift; + my $level = shift; + my $message = shift; + push(@{$self->{nagios}->{messages}->{$level}}, $message); + # recalc current level + foreach my $llevel qw(CRITICAL WARNING UNKNOWN OK) { + if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$llevel}}})) { + $self->{nagios_level} = $ERRORS{$llevel}; + } + } +} + +sub add_nagios_ok { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{OK}, $message); +} + +sub add_nagios_warning { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{WARNING}, $message); +} + +sub add_nagios_critical { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{CRITICAL}, $message); +} + +sub add_nagios_unknown { + my $self = shift; + my $message = shift; + $self->add_nagios($ERRORS{UNKNOWN}, $message); +} + +sub add_perfdata { + my $self = shift; + my $data = shift; + push(@{$self->{nagios}->{perfdata}}, $data); +} + +sub merge_nagios { + my $self = shift; + my $child = shift; + foreach my $level (0..3) { + foreach (@{$child->{nagios}->{messages}->{$level}}) { + $self->add_nagios($level, $_); + } + #push(@{$self->{nagios}->{messages}->{$level}}, + # @{$child->{nagios}->{messages}->{$level}}); + } + push(@{$self->{nagios}->{perfdata}}, @{$child->{nagios}->{perfdata}}); +} + +sub calculate_result { + my $self = shift; + my $multiline = 0; + map { + $self->{nagios_level} = $ERRORS{$_} if + (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}})); + } ("OK", "UNKNOWN", "WARNING", "CRITICAL"); + if ($ENV{NRPE_MULTILINESUPPORT} && + length join(" ", @{$self->{nagios}->{perfdata}}) > 200) { + $multiline = 1; + } + if ($multiline) { + my $num_ok = @{$self->{nagios}->{messages}->{ $ERRORS{"OK"} } }; + my $num_crit = @{$self->{nagios}->{messages}->{ $ERRORS{"WARNING"} }}; + my $num_warn = @{$self->{nagios}->{messages}->{ $ERRORS{"CRITICAL"} }}; + my $num_unk = @{$self->{nagios}->{messages}->{ $ERRORS{"UNKNOWN"} }}; + $self->{nagios_message} .= sprintf "%s ok, %s warnings, %s criticals and %s unknown\n", + $num_ok, $num_warn,$num_crit, $num_unk; + } + my $all_messages = join(($multiline ? "\n" : ", "), map { + join(($multiline ? "\n" : ", "), @{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN", "OK")); + my $bad_messages = join(($multiline ? "\n" : ", "), map { + join(($multiline ? "\n" : ", "), @{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN")); + my $all_messages_short = $bad_messages ? $bad_messages : 'no problems'; + my $all_messages_html = "". + join("", map { + my $level = $_; + join("", map { + sprintf "", + $level, $_; + } @{$self->{nagios}->{messages}->{$ERRORS{$_}}}); + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN", "OK")). + "
%s
"; + if (exists $self->{identstring}) { + $self->{nagios_message} .= $self->{identstring}; + } + if ($self->{report} eq "long") { + $self->{nagios_message} .= $all_messages; + } elsif ($self->{report} eq "short") { + $self->{nagios_message} .= $all_messages_short; + } elsif ($self->{report} eq "html") { + $self->{nagios_message} .= $all_messages_short."\n".$all_messages_html; + } + $self->{perfdata} = join(" ", @{$self->{nagios}->{perfdata}}); +} + +sub set_global_db_thresholds { + my $self = shift; + my $params = shift; + my $warning = undef; + my $critical = undef; + return unless defined $params->{dbthresholds}; + $params->{name0} = $params->{dbthresholds}; + # :pluginmode :name :warning :critical + # mode empty + # + eval { + my $find_sql = undef; + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + $find_sql = q{ + SELECT name FROM sys.objects + WHERE name = 'check_mssql_health_thresholds' + }; + } else { + $find_sql = q{ + SELECT name FROM sysobjects + WHERE name = 'check_mssql_health_thresholds' + }; + } + if ($self->{handle}->fetchrow_array($find_sql)) { + my @dbthresholds = $self->{handle}->fetchall_array(q{ + SELECT * FROM check_mssql_health_thresholds + }); + $params->{dbthresholds} = \@dbthresholds; + foreach (@dbthresholds) { + if (($_->[0] eq $params->{cmdlinemode}) && + (! defined $_->[1] || ! $_->[1])) { + ($warning, $critical) = ($_->[2], $_->[3]); + } + } + } + }; + if (! $@) { + if ($warning) { + $params->{warningrange} = $warning; + $self->trace("read warningthreshold %s from database", $warning); + } + if ($critical) { + $params->{criticalrange} = $critical; + $self->trace("read criticalthreshold %s from database", $critical); + } + } +} + +sub set_local_db_thresholds { + my $self = shift; + my %params = @_; + my $warning = undef; + my $critical = undef; + # :pluginmode :name :warning :critical + # mode name0 + # mode name2 + # mode name + # + # first: argument of --dbthresholds, it it exists + # second: --name2 + # third: --name + if (ref($params{dbthresholds}) eq 'ARRAY') { + my $marker; + foreach (@{$params{dbthresholds}}) { + if ($_->[0] eq $params{cmdlinemode}) { + if (defined $_->[1] && $params{name0} && $_->[1] eq $params{name0}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name0}; + last; + } elsif (defined $_->[1] && $params{name2} && $_->[1] eq $params{name2}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name2}; + last; + } elsif (defined $_->[1] && $params{name} && $_->[1] eq $params{name}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name}; + last; + } + } + } + if ($warning) { + $self->{warningrange} = $warning; + $self->trace("read warningthreshold %s for %s from database", + $marker, $warning); + } + if ($critical) { + $self->{criticalrange} = $critical; + $self->trace("read criticalthreshold %s for %s from database", + $marker, $critical); + } + } +} + +sub debug { + my $self = shift; + my $msg = shift; + if ($DBD::MSSQL::Server::verbose) { + printf "%s %s\n", $msg, ref($self); + } +} + +sub dbconnect { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{tic} = Time::HiRes::time(); + $self->{handle} = DBD::MSSQL::Server::Connection->new(%params); + if ($self->{handle}->{errstr}) { + if ($self->{handle}->{errstr} eq "alarm\n") { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "connection could not be established within %d seconds", + $self->{timeout}); + } else { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "cannot connect to %s. %s", + ($self->{server} ? $self->{server} : + ($self->{hostname} ? $self->{hostname} : "unknown host")), + $self->{handle}->{errstr}); + $retval = undef; + } + } else { + $retval = $self->{handle}; + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub trace { + my $self = shift; + my $format = shift; + if (! @_) { + # falls im sql-statement % vorkommen. sonst krachts im printf + $format =~ s/%/%%/g; + } + $self->{trace} = -f "/tmp/check_mssql_health.trace" ? 1 : 0; + if ($DBD::MSSQL::Server::verbose) { + printf("%s: ", scalar localtime); + printf($format, @_); + } + if ($self->{trace}) { + my $logfh = new IO::File; + $logfh->autoflush(1); + if ($logfh->open("/tmp/check_mssql_health.trace", "a")) { + $logfh->printf("%s: ", scalar localtime); + $logfh->printf($format, @_); + $logfh->printf("\n"); + $logfh->close(); + } + } +} + +sub DESTROY { + my $self = shift; + my $handle1 = "null"; + my $handle2 = "null"; + if (defined $self->{handle}) { + $handle1 = ref($self->{handle}); + if (defined $self->{handle}->{handle}) { + $handle2 = ref($self->{handle}->{handle}); + } + } + #$self->trace(sprintf "DESTROY %s with handle %s %s", ref($self), $handle1, $handle2); + if (ref($self) eq "DBD::MSSQL::Server") { + } + #$self->trace(sprintf "DESTROY %s exit with handle %s %s", ref($self), $handle1, $handle2); + if (ref($self) eq "DBD::MSSQL::Server") { + #printf "humpftata\n"; + } +} + +sub save_state { + my $self = shift; + my %params = @_; + my $extension = ""; + my $mode = $params{mode}; + if ($^O =~ /MSWin/) { + $mode =~ s/::/_/g; + $params{statefilesdir} = $self->system_vartmpdir(); + } + mkdir $params{statefilesdir} unless -d $params{statefilesdir}; + my $statefile = sprintf "%s/%s_%s", + $params{statefilesdir}, ($params{hostname} || $params{server}), $mode; + $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{port} ? "_".$params{port} : ""; + $extension .= $params{database} ? "_".$params{database} : ""; + $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 = ""; + my $mode = $params{mode}; + if ($^O =~ /MSWin/) { + $mode =~ s/::/_/g; + $params{statefilesdir} = $self->system_vartmpdir(); + } + my $statefile = sprintf "%s/%s_%s", + $params{statefilesdir}, ($params{hostname} || $params{server}), $mode; + $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; + $extension .= $params{port} ? "_".$params{port} : ""; + $extension .= $params{database} ? "_".$params{database} : ""; + $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 valdiff { + my $self = shift; + my $pparams = shift; + my %params = %{$pparams}; + my @keys = @_; + my $last_values = $self->load_state(%params) || eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = 0; + } + $empty_events->{timestamp} = 0; + $empty_events; + }; + foreach (@keys) { + $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'} = time - $last_values->{timestamp}; + $params{save} = eval { + my $empty_events = {}; + foreach (@keys) { + $empty_events->{$_} = $self->{$_}; + } + $empty_events->{timestamp} = time; + $empty_events; + }; + $self->save_state(%params); +} + +sub requires_version { + my $self = shift; + my $version = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + my $instversion = $instances[0]->{version}; + if (! $self->version_is_minimum($version)) { + $self->add_nagios($ERRORS{UNKNOWN}, + sprintf "not implemented/possible for MSSQL release %s", $instversion); + } +} + +sub version_is_minimum { + # the current version is newer or equal + my $self = shift; + my $version = shift; + my $newer = 1; + my @instances = DBD::MSSQL::Server::return_servers(); + my @v1 = map { $_ eq "x" ? 0 : $_ } split(/\./, $version); + my @v2 = split(/\./, $instances[0]->{version}); + if (scalar(@v1) > scalar(@v2)) { + push(@v2, (0) x (scalar(@v1) - scalar(@v2))); + } elsif (scalar(@v2) > scalar(@v1)) { + push(@v1, (0) x (scalar(@v2) - scalar(@v1))); + } + foreach my $pos (0..$#v1) { + if ($v2[$pos] > $v1[$pos]) { + $newer = 1; + last; + } elsif ($v2[$pos] < $v1[$pos]) { + $newer = 0; + last; + } + } + #printf STDERR "check if %s os minimum %s\n", join(".", @v2), join(".", @v1); + return $newer; +} + +sub instance_rac { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + return (lc $instances[0]->{parallel} eq "yes") ? 1 : 0; +} + +sub instance_thread { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + return $instances[0]->{thread}; +} + +sub windows_server { + my $self = shift; + my @instances = DBD::MSSQL::Server::return_servers(); + if ($instances[0]->{os} =~ /Win/i) { + return 1; + } else { + return 0; + } +} + +sub system_vartmpdir { + my $self = shift; + if ($^O =~ /MSWin/) { + return $self->system_tmpdir(); + } else { + return "/var/tmp/check_mssql_health"; + } +} + +sub system_oldvartmpdir { + my $self = shift; + return "/tmp"; +} + +sub system_tmpdir { + my $self = shift; + if ($^O =~ /MSWin/) { + return $ENV{TEMP} if defined $ENV{TEMP}; + return $ENV{TMP} if defined $ENV{TMP}; + return File::Spec->catfile($ENV{windir}, 'Temp') + if defined $ENV{windir}; + return 'C:\Temp'; + } else { + return "/tmp"; + } +} + + +package DBD::MSSQL::Server::Connection; + +use strict; + +our @ISA = qw(DBD::MSSQL::Server); + + +sub new { + my $class = shift; + my %params = @_; + my $self = { + mode => $params{mode}, + timeout => $params{timeout}, + method => $params{method} || "dbi", + hostname => $params{hostname}, + username => $params{username}, + password => $params{password}, + verbose => $params{verbose}, + port => $params{port} || 1433, + server => $params{server}, + currentdb => $params{currentdb}, + handle => undef, + }; + bless $self, $class; + if ($params{method} eq "dbi") { + bless $self, "DBD::MSSQL::Server::Connection::Dbi"; + } elsif ($params{method} eq "sqsh") { + bless $self, "DBD::MSSQL::Server::Connection::Sqsh"; + } elsif ($params{method} eq "sqlrelay") { + bless $self, "DBD::MSSQL::Server::Connection::Sqlrelay"; + } elsif ($params{method} eq "sqlcmd") { + bless $self, "DBD::MSSQL::Server::Connection::Sqlcmd"; + } + $self->init(%params); + return $self; +} + +sub get_instance_names { + my $self = shift; + my $object_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchall_array(q{ + SELECT + DISTINCT instance_name + FROM + sys.dm_os_performance_counters + WHERE + object_name = ? + }, $object_name); + } else { + return $self->fetchall_array(q{ + SELECT + DISTINCT instance_name + FROM + master.dbo.sysperfinfo + WHERE + object_name = ? + }, $object_name); + } +} + +sub get_perf_counter { + my $self = shift; + my $object_name = shift; + my $counter_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + sys.dm_os_performance_counters + WHERE + counter_name = ? AND + object_name = ? + }, $counter_name, $object_name); + } else { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + master.dbo.sysperfinfo + WHERE + counter_name = ? AND + object_name = ? + }, $counter_name, $object_name); + } +} + +sub get_perf_counter_instance { + my $self = shift; + my $object_name = shift; + my $counter_name = shift; + my $instance_name = shift; + my $servicename = DBD::MSSQL::Server::return_first_server()->{servicename}; + if ($object_name =~ /SQLServer:(.*)/) { + $object_name = $servicename.':'.$1; + } + if (DBD::MSSQL::Server::return_first_server()->version_is_minimum("9.x")) { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + sys.dm_os_performance_counters + WHERE + counter_name = ? AND + object_name = ? AND + instance_name = ? + }, $counter_name, $object_name, $instance_name); + } else { + return $self->fetchrow_array(q{ + SELECT + cntr_value + FROM + master.dbo.sysperfinfo + WHERE + counter_name = ? AND + object_name = ? AND + instance_name = ? + }, $counter_name, $object_name, $instance_name); + } +} + +package DBD::MSSQL::Server::Connection::Dbi; + +use strict; +use Net::Ping; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + if ($self->{mode} =~ /^server::tnsping/) { + # erstmal reserviert fuer irgendeinen tcp-connect + if (! $self->{connect}) { + $self->{errstr} = "Please specify a database"; + } else { + $self->{sid} = $self->{connect}; + $self->{username} ||= time; # prefer an existing user + $self->{password} = time; + } + } else { + if ((! $self->{hostname} && ! $self->{server}) || + ! $self->{username} || ! $self->{password}) { + $self->{errstr} = "Please specify hostname or server, username and password"; + return undef; + } + $self->{dsn} = "DBI:Sybase:"; + if ($self->{hostname}) { + $self->{dsn} .= sprintf ";host=%s", $self->{hostname}; + $self->{dsn} .= sprintf ";port=%s", $self->{port}; + } else { + $self->{dsn} .= sprintf ";server=%s", $self->{server}; + } + if ($params{currentdb}) { + $self->{dsn} .= sprintf ";database=%s", $params{currentdb}; + } + } + if (! exists $self->{errstr}) { + my $stderrvar; + eval { + require DBI; + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "alarm\n"; + }; + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + *SAVEERR = *STDERR; + open OUT ,'>',\$stderrvar; + *STDERR = *OUT; + if ($self->{handle} = DBI->connect( + $self->{dsn}, + $self->{username}, + $self->{password}, + { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { + $retval = $self; + } else { + # doesnt seem to work $self->{errstr} = DBI::errstr(); + $self->{errstr} = "connect failed"; + return undef; + } + *STDERR = *SAVEERR; + }; + if ($@) { + $self->{errstr} = $@; + $retval = undef; + } elsif ($stderrvar && $stderrvar =~ /can't change context to database/) { + $self->{errstr} = $stderrvar; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments) || die DBI::errstr(); + } else { + $sth->execute() || die DBI::errstr(); + } + if (lc $sql =~ /^(exec |sp_)/) { + # flatten the result sets + do { + while (my $aref = $sth->fetchrow_arrayref()) { + push(@row, @{$aref}); + } + } while ($sth->{syb_more_results}); + } else { + @row = $sth->fetchrow_array(); + } + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper(\@row)); + }; + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @row = split(/\s+/, (split(/\n/, $simulation))[0]); + } + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + $rows = $sth->fetchall_arrayref(); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @{$rows} = map { [ split(/\s+/, $_) ] } split(/\n/, $simulation); + } + return @{$rows}; +} + +sub exec_sp_1hash { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + eval { + $self->trace(sprintf "SQL:\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + do { + while (my $href = $sth->fetchrow_hashref()) { + foreach (keys %{$href}) { + push(@{$rows}, [ $_, $href->{$_} ]); + } + } + } while ($sth->{syb_more_results}); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + return @{$rows}; +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace(sprintf "disconnecting DBD %s", + $self->{handle} ? "with handle" : "without handle"); + $self->{handle}->disconnect() if $self->{handle}; +} + +package DBD::MSSQL::Server::Connection::Sqlcmd; + +use strict; +use File::Temp qw/tempfile/; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{loginstring} = "hostport"; + my $template = $self->{mode}.'XXXXX'; + if ($^O =~ /MSWin/) { + $template =~ s/::/_/g; + } + ($self->{sql_commandfile_handle}, $self->{sql_commandfile}) = + tempfile($template, SUFFIX => ".sql", + DIR => $self->system_tmpdir() ); + close $self->{sql_commandfile_handle}; + ($self->{sql_resultfile_handle}, $self->{sql_resultfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_resultfile_handle}; + ($self->{sql_outfile_handle}, $self->{sql_outfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_outfile_handle}; + + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + # --server xy --username xy --password xy + # --hostname xy --username xy --password xy + # --hostname xy --port --username xy --password xy + if ($self->{server} && $self->{username} && $self->{password}) { + # --server bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + } elsif ($self->{hostname} && $self->{username} && $self->{password}) { + # --hostname bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + $self->{server} = sprintf 'tcp:%s,%s', $self->{hostname}, $self->{port}; + } else { + $self->{errstr} = "Please specify servername, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + eval { + if (! exists $ENV{SQL_HOME}) { + foreach my $path (split(';', $ENV{PATH})) { + $self->trace(sprintf "try to find sqlcmd.exe in %s", $path); + if (-x $path.'/sqlcmd.exe') { + $ENV{SQL_HOME} = $path; + last; + } + } + $ENV{SQL_HOME} |= ''; + } else { + $ENV{PATH} = $ENV{SQL_HOME}. + (defined $ENV{PATH} ? ";".$ENV{PATH} : ""); + } + my $sqlcmd = undef; + if (-x $ENV{SQL_HOME}.'/'.'sqlcmd.exe') { + $sqlcmd = $ENV{SQL_HOME}.'/'.'sqlcmd.exe'; + } + if (! $sqlcmd) { + die "nosqlcmd\n"; + } else { + $self->trace(sprintf "found %s", $sqlcmd); + } + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + if ($self->{loginstring} eq "server") { + $self->{sqlcmd} = sprintf '"%s" -S %s -U "%s" -P "%s" %s -i "%s" -o "%s"', + $sqlcmd, $self->{server}, $self->{username}, $self->{password}, + ($self->{currentdb} ? "-d ".$self->{currentdb} : ""), + $self->{sql_commandfile}, $self->{sql_resultfile}; + $self->{sqlcmd} .= ' -h-1 -s"|" -W'; + } + } + + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "timeout\n"; + }; + if ($^O !~ /MSWin/) { + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + } + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + + my $answer = $self->fetchrow_array( + q{ SELECT 'schnorch' }); + die unless defined $answer and $answer eq 'schnorch'; + $retval = $self; + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at $0 .*//g; + chomp $self->{errstr}; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqlcmd}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm \n"; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + @row = map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } # strip leading space from numbers + map { s/\s+$//g; $_ } # strip trailing space + split(/\|/, (split(/\n/, $output))[0]); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper(\@row)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqlcmd}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm %s\n", $exit_output; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @rows = map { [ + map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } + map { s/\s+$//g; $_ } + split /\|/ + ] } grep { ! /^\(\d+ rows affected\)/ } + grep { ! /^\s*$/ } + grep { ! /^Database name .* ignored, referencing object in/ } split(/\n/, $output); + $rows = \@rows; + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return @{$rows}; +} + +sub func { + my $self = shift; + my $function = shift; + $self->{handle}->func(@_); +} + +sub convert { + my $n = shift; + # mostly used to convert numbers in scientific notation + if ($n =~ /^\s*\d+\s*$/) { + return $n; + } elsif ($n =~ /^\s*([-+]?)(\d*[\.,]*\d*)[eE]{1}([-+]?)(\d+)\s*$/) { + my ($vor, $num, $sign, $exp) = ($1, $2, $3, $4); + $n =~ s/E/e/g; + $n =~ s/,/\./g; + $num =~ s/,/\./g; + my $sig = $sign eq '-' ? "." . ($exp - 1 + length $num) : ''; + my $dec = sprintf "%${sig}f", $n; + $dec =~ s/\.[0]+$//g; + return $dec; + } elsif ($n =~ /^\s*([-+]?)(\d+)[\.,]*(\d*)\s*$/) { + return $1.$2.".".$3; + } elsif ($n =~ /^\s*(.*?)\s*$/) { + return $1; + } else { + return $n; + } +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace("try to clean up command and result files"); + unlink $self->{sql_commandfile} if -f $self->{sql_commandfile}; + unlink $self->{sql_resultfile} if -f $self->{sql_resultfile}; +} + +sub create_commandfile { + my $self = shift; + my $sql = shift; + open CMDCMD, "> $self->{sql_commandfile}"; + printf CMDCMD "%s\n", $sql; + printf CMDCMD "go\n"; + close CMDCMD; +} + +package DBD::MSSQL::Server::Connection::Sqsh; + +use strict; +use File::Temp qw/tempfile/; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + $self->{loginstring} = "hostport"; + my $template = $self->{mode}.'XXXXX'; + if ($^O =~ /MSWin/) { + $template =~ s/::/_/g; + } + ($self->{sql_commandfile_handle}, $self->{sql_commandfile}) = + tempfile($template, SUFFIX => ".sql", + DIR => $self->system_tmpdir() ); + close $self->{sql_commandfile_handle}; + ($self->{sql_resultfile_handle}, $self->{sql_resultfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_resultfile_handle}; + ($self->{sql_outfile_handle}, $self->{sql_outfile}) = + tempfile($template, SUFFIX => ".out", + DIR => $self->system_tmpdir() ); + close $self->{sql_outfile_handle}; + + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + # --server xy --username xy --password xy + # --hostname xy --username xy --password xy + # --hostname xy --port --username xy --password xy + if ($self->{server} && $self->{username} && $self->{password}) { + # --server bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + } elsif ($self->{hostname} && $self->{username} && $self->{password}) { + # --hostname bba --user nagios --password oradbmon + $self->{loginstring} = "server"; + $self->{server} = sprintf 'tcp:%s,%s', $self->{hostname}, $self->{port}; + } else { + $self->{errstr} = "Please specify servername, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + eval { + if (! exists $ENV{SQL_HOME}) { + if ($^O =~ /MSWin/) { + foreach my $path (split(';', $ENV{PATH})) { + if (-x $path.'/sqsh.exe') { + $ENV{SQL_HOME} = $path; + last; + } + } + } else { + foreach my $path (split(':', $ENV{PATH})) { + if (-x $path.'/bin/sqsh') { + $ENV{SQL_HOME} = $path; + last; + } + } + } + $ENV{SQL_HOME} |= ''; + } else { + if ($^O =~ /MSWin/) { + $ENV{PATH} = $ENV{SQL_HOME}. + (defined $ENV{PATH} ? ";".$ENV{PATH} : ""); + } else { + $ENV{PATH} = $ENV{SQL_HOME}."/bin". + (defined $ENV{PATH} ? ":".$ENV{PATH} : ""); + $ENV{LD_LIBRARY_PATH} = $ENV{SQL_HOME}."/lib". + (defined $ENV{LD_LIBRARY_PATH} ? ":".$ENV{LD_LIBRARY_PATH} : ""); + } + } + my $sqsh = undef; + my $tnsping = undef; + if (-x $ENV{SQL_HOME}.'/'.'bin'.'/'.'sqsh') { + $sqsh = $ENV{SQL_HOME}.'/'.'bin'.'/'.'sqsh'; + } elsif (-x $ENV{SQL_HOME}.'/'.'sqsh') { + $sqsh = $ENV{SQL_HOME}.'/'.'sqsh'; + } elsif (-x $ENV{SQL_HOME}.'/'.'sqsh.exe') { + $sqsh = $ENV{SQL_HOME}.'/'.'sqsh.exe'; + } elsif (-x '/usr/bin/sqsh') { + $sqsh = '/usr/bin/sqsh'; + } + if (! $sqsh) { + die "nosqsh\n"; + } + if ($self->{mode} =~ /^server::tnsping/) { + die "oracle leftover"; + } else { + if ($self->{loginstring} eq "server") { + $self->{sqsh} = sprintf '"%s" -S %s -U "%s" -P "%s" -i "%s" -o "%s"', + $sqsh, $self->{server}, $self->{username}, $self->{password}, + $self->{sql_commandfile}, $self->{sql_resultfile}; + $self->{sqsh} .= ' -h -s"|"'; + } + } + + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "timeout\n"; + }; + if ($^O !~ /MSWin/) { + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + } + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + + my $answer = $self->fetchrow_array( + q{ SELECT 'schnorch' }); + die unless defined $answer and $answer eq 'schnorch'; + $retval = $self; + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at $0 .*//g; + chomp $self->{errstr}; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqsh}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm \n"; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + @row = map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } # strip leading space from numbers + map { s/\s+$//g; $_ } # strip trailing space + split(/\|/, (split(/\n/, $output))[0]); + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper(\@row)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + foreach (@arguments) { + # replace the ? by the parameters + if (/^\d+$/) { + $sql =~ s/\?/$_/; + } else { + $sql =~ s/\?/'$_'/; + } + } + $self->trace(sprintf "SQL (? resolved):\n%s\nARGS:\n%s\n", + $sql, Data::Dumper::Dumper(\@arguments)); + $self->create_commandfile($sql); + my $exit_output = `$self->{sqsh}`; + if ($?) { + printf STDERR "fetchrow_array exit bumm %s\n", $exit_output; + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @oerrs = map { + /(ORA\-\d+:.*)/ ? $1 : (); + } split(/\n/, $output); + $self->{errstr} = join(" ", @oerrs); + } else { + my $output = do { local (@ARGV, $/) = $self->{sql_resultfile}; <> }; + my @rows = map { [ + map { convert($_) } + map { s/^\s+([\.\d]+)$/$1/g; $_ } + map { s/\s+$//g; $_ } + split /\|/ + ] } grep { ! /^\(\d+ rows affected\)/ } + grep { ! /^\s*$/ } + grep { ! /^Database name .* ignored, referencing object in/ } split(/\n/, $output); + $rows = \@rows; + $self->trace(sprintf "RESULT:\n%s\n", + Data::Dumper::Dumper($rows)); + } + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + unlink $self->{sql_commandfile}; + unlink $self->{sql_resultfile}; + return @{$rows}; +} + +sub func { + my $self = shift; + my $function = shift; + $self->{handle}->func(@_); +} + +sub convert { + my $n = shift; + # mostly used to convert numbers in scientific notation + if ($n =~ /^\s*\d+\s*$/) { + return $n; + } elsif ($n =~ /^\s*([-+]?)(\d*[\.,]*\d*)[eE]{1}([-+]?)(\d+)\s*$/) { + my ($vor, $num, $sign, $exp) = ($1, $2, $3, $4); + $n =~ s/E/e/g; + $n =~ s/,/\./g; + $num =~ s/,/\./g; + my $sig = $sign eq '-' ? "." . ($exp - 1 + length $num) : ''; + my $dec = sprintf "%${sig}f", $n; + $dec =~ s/\.[0]+$//g; + return $dec; + } elsif ($n =~ /^\s*([-+]?)(\d+)[\.,]*(\d*)\s*$/) { + return $1.$2.".".$3; + } elsif ($n =~ /^\s*(.*?)\s*$/) { + return $1; + } else { + return $n; + } +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + $self->trace("try to clean up command and result files"); + unlink $self->{sql_commandfile} if -f $self->{sql_commandfile}; + unlink $self->{sql_resultfile} if -f $self->{sql_resultfile}; +} + +sub create_commandfile { + my $self = shift; + my $sql = shift; + open CMDCMD, "> $self->{sql_commandfile}"; + printf CMDCMD "%s\n", $sql; + printf CMDCMD "go\n"; + close CMDCMD; +} + +package DBD::MSSQL::Server::Connection::Sqlrelay; + +use strict; +use Net::Ping; + +our @ISA = qw(DBD::MSSQL::Server::Connection); + + +sub init { + my $self = shift; + my %params = @_; + my $retval = undef; + if ($self->{mode} =~ /^server::tnsping/) { + } else { + if (! $self->{hostname} || ! $self->{username} || ! $self->{password} || ! $self->{port}) { + $self->{errstr} = "Please specify database, username and password"; + return undef; + } + } + if (! exists $self->{errstr}) { + my $stderrvar; + eval { + require DBI; + use POSIX ':signal_h'; + local $SIG{'ALRM'} = sub { + die "alarm\n"; + }; + my $mask = POSIX::SigSet->new( SIGALRM ); + my $action = POSIX::SigAction->new( + sub { die "alarm\n" ; }, $mask); + my $oldaction = POSIX::SigAction->new(); + sigaction(SIGALRM ,$action ,$oldaction ); + alarm($self->{timeout} - 1); # 1 second before the global unknown timeout + *SAVEERR = *STDERR; + open OUT ,'>',\$stderrvar; + *STDERR = *OUT; + if ($self->{handle} = DBI->connect( + #sprintf("DBI:SQLRelay:host=%s;port=%d;socket=%s", + sprintf("DBI:SQLRelay:host=%s;port=%d;", + $self->{hostname}, $self->{port}), + $self->{username}, + $self->{password}, + { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { + } else { + $self->{errstr} = DBI::errstr(); + } + my $answer = $self->fetchrow_array( + q{ SELECT 42 }); + die $self->{errstr} unless defined $answer and $answer == 42; + *STDERR = *SAVEERR; + }; + if ($@) { + $self->{errstr} = $@; + $self->{errstr} =~ s/at [\w\/\.]+ line \d+.*//g; + $retval = undef; + } + } + $self->{tac} = Time::HiRes::time(); + return $retval; +} + +sub fetchrow_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my @row = (); + my $new_dbh = $self->{handle}->clone(); + $self->trace(sprintf "fetchrow_array: %s", $sql); + # + # does not work with bind variables + # + while ($sql =~ /\?/) { + my $param = shift @arguments; + if ($param !~ /^\d+$/) { + $param = $self->{handle}->quote($param); + } + $sql =~ s/\?/$param/; + } + $sql =~ s/^\s*//g; + $sql =~ s/\s*$//g; + eval { + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + @row = $sth->fetchrow_array(); + $sth->finish(); + }; + if ($@) { + $self->debug(sprintf "bumm %s", $@); + } + # without this trick, there are error messages like + # "No server-side cursors were available to process the query" + # and the results are messed up. + $self->{handle}->disconnect(); + $self->{handle} = $new_dbh; + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @row = split(/\s+/, (split(/\n/, $simulation))[0]); + } + return $row[0] unless wantarray; + return @row; +} + +sub fetchall_array { + my $self = shift; + my $sql = shift; + my @arguments = @_; + my $sth = undef; + my $rows = undef; + my $new_dbh = $self->{handle}->clone(); + $self->trace(sprintf "fetchall_array: %s", $sql); + while ($sql =~ /\?/) { + my $param = shift @arguments; + if ($param !~ /^\d+$/) { + $param = $self->{handle}->quote($param); + } + $sql =~ s/\?/$param/; + } + eval { + $sth = $self->{handle}->prepare($sql); + if (scalar(@arguments)) { + $sth->execute(@arguments); + } else { + $sth->execute(); + } + $rows = $sth->fetchall_arrayref(); + my $asrows = $sth->fetchall_arrayref(); + $sth->finish(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } + $self->{handle}->disconnect(); + $self->{handle} = $new_dbh; + if (-f "/tmp/check_mssql_health_simulation/".$self->{mode}) { + my $simulation = do { local (@ARGV, $/) = + "/tmp/check_mssql_health_simulation/".$self->{mode}; <> }; + @{$rows} = map { [ split(/\s+/, $_) ] } split(/\n/, $simulation); + } + return @{$rows}; +} + +sub func { + my $self = shift; + $self->{handle}->func(@_); +} + + +sub execute { + my $self = shift; + my $sql = shift; + eval { + my $sth = $self->{handle}->prepare($sql); + $sth->execute(); + }; + if ($@) { + printf STDERR "bumm %s\n", $@; + } +} + +sub DESTROY { + my $self = shift; + #$self->trace(sprintf "disconnecting DBD %s", + # $self->{handle} ? "with handle" : "without handle"); + #$self->{handle}->disconnect() if $self->{handle}; +} + + + + + +package Extraopts; + +use strict; +use File::Basename; +use Data::Dumper; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + file => $params{file}, + commandline => $params{commandline}, + config => {}, + section => 'default_no_section', + }; + bless $self, $class; + $self->prepare_file_and_section(); + $self->init(); + return $self; +} + +sub prepare_file_and_section { + my $self = shift; + if (! defined $self->{file}) { + # ./check_stuff --extra-opts + $self->{section} = basename($0); + $self->{file} = $self->get_default_file(); + } elsif ($self->{file} =~ /^[^@]+$/) { + # ./check_stuff --extra-opts=special_opts + $self->{section} = $self->{file}; + $self->{file} = $self->get_default_file(); + } elsif ($self->{file} =~ /^@(.*)/) { + # ./check_stuff --extra-opts=@/etc/myconfig.ini + $self->{section} = basename($0); + $self->{file} = $1; + } elsif ($self->{file} =~ /^(.*?)@(.*)/) { + # ./check_stuff --extra-opts=special_opts@/etc/myconfig.ini + $self->{section} = $1; + $self->{file} = $2; + } +} + +sub get_default_file { + my $self = shift; + foreach my $default (qw(/etc/nagios/plugins.ini + /usr/local/nagios/etc/plugins.ini + /usr/local/etc/nagios/plugins.ini + /etc/opt/nagios/plugins.ini + /etc/nagios-plugins.ini + /usr/local/etc/nagios-plugins.ini + /etc/opt/nagios-plugins.ini)) { + if (-f $default) { + return $default; + } + } + return undef; +} + +sub init { + my $self = shift; + if (! defined $self->{file}) { + $self->{errors} = sprintf 'no extra-opts file specified and no default file found'; + } elsif (! -f $self->{file}) { + $self->{errors} = sprintf 'could not open %s', $self->{file}; + } else { + my $data = do { local (@ARGV, $/) = $self->{file}; <> }; + my $in_section = 'default_no_section'; + foreach my $line (split(/\n/, $data)) { + if ($line =~ /\[(.*)\]/) { + $in_section = $1; + } elsif ($line =~ /(.*)=(.*)/) { + $self->{config}->{$in_section}->{$1} = $2; + } + } + } +} + +sub is_valid { + my $self = shift; + return ! exists $self->{errors}; +} + +sub overwrite { + my $self = shift; + my %commandline = (); + if (scalar(keys %{$self->{config}->{default_no_section}}) > 0) { + foreach (keys %{$self->{config}->{default_no_section}}) { + $commandline{$_} = $self->{config}->{default_no_section}->{$_}; + } + } + if (exists $self->{config}->{$self->{section}}) { + foreach (keys %{$self->{config}->{$self->{section}}}) { + $commandline{$_} = $self->{config}->{$self->{section}}->{$_}; + } + } + foreach (keys %commandline) { + if (! exists $self->{commandline}->{$_}) { + $self->{commandline}->{$_} = $commandline{$_}; + } + } +} + + + +package main; + +use strict; +use Getopt::Long qw(:config no_ignore_case); +use File::Basename; +use lib dirname($0); + + + +use vars qw ($PROGNAME $REVISION $CONTACT $TIMEOUT $STATEFILESDIR $needs_restart %commandline); + +$PROGNAME = "check_mssql_health"; +$REVISION = '$Revision: 1.5.8.2 $'; +$CONTACT = 'gerhard.lausser@consol.de'; +$TIMEOUT = 60; +$STATEFILESDIR = '/var/tmp/check_mssql_health'; +$needs_restart = 0; + +my @modes = ( + ['server::connectiontime', + 'connection-time', undef, + 'Time to connect to the server' ], + ['server::cpubusy', + 'cpu-busy', undef, + 'Cpu busy in percent' ], + ['server::iobusy', + 'io-busy', undef, + 'IO busy in percent' ], + ['server::fullscans', + 'full-scans', undef, + 'Full table scans per second' ], + ['server::connectedusers', + 'connected-users', undef, + 'Number of currently connected users' ], + ['server::database::transactions', + 'transactions', undef, + 'Transactions per second (per database)' ], + ['server::batchrequests', + 'batch-requests', undef, + 'Batch requests per second' ], + ['server::latch::waits', + 'latches-waits', undef, + 'Number of latch requests that could not be granted immediately' ], + ['server::latch::waittime', + 'latches-wait-time', undef, + 'Average time for a latch to wait before the request is met' ], + ['server::memorypool::lock::waits', + 'locks-waits', undef, + 'The number of locks per second that had to wait' ], + ['server::memorypool::lock::timeouts', + 'locks-timeouts', undef, + 'The number of locks per second that timed out' ], + ['server::memorypool::lock::deadlocks', + 'locks-deadlocks', undef, + 'The number of deadlocks per second' ], + ['server::sql::recompilations', + 'sql-recompilations', undef, + 'Re-Compilations per second' ], + ['server::sql::initcompilations', + 'sql-initcompilations', undef, + 'Initial compilations per second' ], + ['server::totalmemory', + 'total-server-memory', undef, + 'The amount of memory that SQL Server has allocated to it' ], + ['server::memorypool::buffercache::hitratio', + 'mem-pool-data-buffer-hit-ratio', ['buffer-cache-hit-ratio'], + 'Data Buffer Cache Hit Ratio' ], + + + ['server::memorypool::buffercache::lazywrites', + 'lazy-writes', undef, + 'Lazy writes per second' ], + ['server::memorypool::buffercache::pagelifeexpectancy', + 'page-life-expectancy', undef, + 'Seconds a page is kept in memory before being flushed' ], + ['server::memorypool::buffercache::freeliststalls', + 'free-list-stalls', undef, + 'Requests per second that had to wait for a free page' ], + ['server::memorypool::buffercache::checkpointpages', + 'checkpoint-pages', undef, + 'Dirty pages flushed to disk per second. (usually by a checkpoint)' ], + + + ['server::database::databasefree', + 'database-free', undef, + 'Free space in database' ], + ['server::database::backupage', + 'database-backup-age', ['backup-age'], + 'Elapsed time (in hours) since a database was last backupped' ], + ['server::sql', + 'sql', undef, + 'any sql command returning a single number' ], + ['server::database::listdatabases', + 'list-databases', undef, + 'convenience function which lists all databases' ], + ['server::database::datafile::listdatafiles', + 'list-datafiles', undef, + 'convenience function which lists all datafiles' ], + ['server::memorypool::lock::listlocks', + 'list-locks', undef, + 'convenience function which lists all locks' ], +); + +sub print_usage () { + print <] --hostname= + --username= --password= [--port ] + --mode= + $PROGNAME [-v] [-t ] --server= + --username= --password= + --mode= + $PROGNAME [-h | --help] + $PROGNAME [-V | --version] + + Options: + --hostname + the database server + --port + the database server's port + --server + the name of a predefined connection + --currentdb + the name of a database which is used as the current database + for the connection. (don't use this parameter unless you + know what you're doing) + --username + the mssql user + --password + the mssql user's password + --warning + the warning range + --critical + the critical range + --mode + the mode of the plugin. select one of the following keywords: +EOUS + 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) { + printf $format, $_->[1], $_->[3]; + } + printf "\n"; + print <new(file => $commandline{'extra-opts'}, commandline => \%commandline); + if (! $extras->is_valid()) { + printf "extra-opts are not valid: %s\n", $extras->{errors}; + exit $ERRORS{UNKNOWN}; + } else { + $extras->overwrite(); + } +} + +if (exists $commandline{version}) { + print_revision($PROGNAME, $REVISION); + exit $ERRORS{OK}; +} + +if (exists $commandline{help}) { + print_help(); + exit $ERRORS{OK}; +} elsif (! exists $commandline{mode}) { + printf "Please select a mode\n"; + print_help(); + exit $ERRORS{OK}; +} + +if ($commandline{mode} eq "encode") { + my $input = <>; + chomp $input; + $input =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; + printf "%s\n", $input; + exit $ERRORS{OK}; +} + +if (exists $commandline{3}) { + $ENV{NRPE_MULTILINESUPPORT} = 1; +} + +if (exists $commandline{timeout}) { + $TIMEOUT = $commandline{timeout}; +} + +if (exists $commandline{verbose}) { + $DBD::MSSQL::Server::verbose = exists $commandline{verbose}; +} + +if (exists $commandline{scream}) { +# $DBD::MSSQL::Server::hysterical = exists $commandline{scream}; +} + +if (exists $commandline{report}) { + # short, long, html +} else { + $commandline{report} = "long"; +} + +if (exists $commandline{'with-mymodules-dyn-dir'}) { + $DBD::MSSQL::Server::my_modules_dyn_dir = $commandline{'with-mymodules-dyn-dir'}; +} else { + $DBD::MSSQL::Server::my_modules_dyn_dir = '/usr/local/nagios/libexec'; +} + + +if (exists $commandline{environment}) { + # if the desired environment variable values are different from + # the environment of this running script, then a restart is necessary. + # because setting $ENV does _not_ change the environment of the running script. + foreach (keys %{$commandline{environment}}) { + if ((! $ENV{$_}) || ($ENV{$_} ne $commandline{environment}->{$_})) { + $needs_restart = 1; + $ENV{$_} = $commandline{environment}->{$_}; + printf STDERR "new %s=%s forces restart\n", $_, $ENV{$_} + if $DBD::MSSQL::Server::verbose; + } + } + # e.g. called with --runas dbnagio. shlib_path environment variable is stripped + # during the sudo. + # so the perl interpreter starts without a shlib_path. but --runas cares for + # a --environment shlib_path=... + # so setting the environment variable in the code above and restarting the + # perl interpreter will help it find shared libs +} + +if (exists $commandline{runas}) { + # remove the runas parameter + # exec sudo $0 ... the remaining parameters + $needs_restart = 1; + # if the calling script has a path for shared libs and there is no --environment + # parameter then the called script surely needs the variable too. + foreach my $important_env qw(LD_LIBRARY_PATH SHLIB_PATH + MSSQL_HOME TNS_ADMIN ORA_NLS ORA_NLS33 ORA_NLS10) { + if ($ENV{$important_env} && ! scalar(grep { /^$important_env=/ } + keys %{$commandline{environment}})) { + $commandline{environment}->{$important_env} = $ENV{$important_env}; + printf STDERR "add important --environment %s=%s\n", + $important_env, $ENV{$important_env} if $DBD::MSSQL::Server::verbose; + } + } +} + +if ($needs_restart) { + my @newargv = (); + my $runas = undef; + if (exists $commandline{runas}) { + $runas = $commandline{runas}; + delete $commandline{runas}; + } + foreach my $option (keys %commandline) { + if (grep { /^$option/ && /=/ } @params) { + if (ref ($commandline{$option}) eq "HASH") { + foreach (keys %{$commandline{$option}}) { + push(@newargv, sprintf "--%s", $option); + push(@newargv, sprintf "%s=%s", $_, $commandline{$option}->{$_}); + } + } else { + push(@newargv, sprintf "--%s", $option); + push(@newargv, sprintf "%s", $commandline{$option}); + } + } else { + push(@newargv, sprintf "--%s", $option); + } + } + if ($runas && ($> == 0)) { + # this was not my idea. some people connect as root to their nagios clients. + exec "su", "-c", sprintf("%s %s", $0, join(" ", @newargv)), "-", $runas; + } elsif ($runas) { + exec "sudo", "-S", "-u", $runas, $0, @newargv; + } else { + exec $0, @newargv; + # this makes sure that even a SHLIB or LD_LIBRARY_PATH are set correctly + # when the perl interpreter starts. Setting them during runtime does not + # help loading e.g. libclntsh.so + } + exit; +} + +if (exists $commandline{shell}) { + # forget what you see here. + system("/bin/sh"); +} + +if (exists $commandline{name}) { + # objects can be encoded like an url + # with s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; + if (($commandline{mode} ne "sql") || + (($commandline{mode} eq "sql") && + ($commandline{name} =~ /select%20/i))) { # protect ... like '%cac%' ... from decoding + $commandline{name} =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; + } + if ($commandline{name} =~ /^0$/) { + # without this, $params{selectname} would be treated like undef + $commandline{name} = "00"; + } +} + +$SIG{'ALRM'} = sub { + printf "UNKNOWN - %s timed out after %d seconds\n", $PROGNAME, $TIMEOUT; + exit $ERRORS{UNKNOWN}; +}; +alarm($TIMEOUT); + +my $nagios_level = $ERRORS{UNKNOWN}; +my $nagios_message = ""; +my $perfdata = ""; +my $racmode = 0; +if ($commandline{mode} =~ /^rac-([^\-.]+)/) { + $racmode = 1; + $commandline{mode} =~ s/^rac\-//g; +} +if ($commandline{mode} =~ /^my-([^\-.]+)/) { + my $param = $commandline{mode}; + $param =~ s/\-/::/g; + push(@modes, [$param, $commandline{mode}, undef, 'my extension']); +} elsif ((! grep { $commandline{mode} eq $_ } map { $_->[1] } @modes) && + (! grep { $commandline{mode} eq $_ } map { defined $_->[2] ? @{$_->[2]} : () } @modes)) { + printf "UNKNOWN - mode %s\n", $commandline{mode}; + print_usage(); + exit 3; +} + +my %params = ( + timeout => $TIMEOUT, + mode => ( + map { $_->[0] } + grep { + ($commandline{mode} eq $_->[1]) || + ( defined $_->[2] && grep { $commandline{mode} eq $_ } @{$_->[2]}) + } @modes + )[0], + cmdlinemode => $commandline{mode}, + method => $commandline{method} || + $ENV{NAGIOS__SERVICEMSSQL_METH} || + $ENV{NAGIOS__HOSTMSSQL_METH} || 'dbi', + hostname => $commandline{hostname} || + $ENV{NAGIOS__SERVICEMSSQL_HOST} || + $ENV{NAGIOS__HOSTMSSQL_HOST}, + username => $commandline{username} || + $ENV{NAGIOS__SERVICEMSSQL_USER} || + $ENV{NAGIOS__HOSTMSSQL_USER}, + password => $commandline{password} || + $ENV{NAGIOS__SERVICEMSSQL_PASS} || + $ENV{NAGIOS__HOSTMSSQL_PASS}, + port => $commandline{port} || + $ENV{NAGIOS__SERVICEMSSQL_PORT} || + $ENV{NAGIOS__HOSTMSSQL_PORT}, + server => $commandline{server} || + $ENV{NAGIOS__SERVICEMSSQL_SERVER} || + $ENV{NAGIOS__HOSTMSSQL_SERVER}, + currentdb => $commandline{currentdb} || + $ENV{NAGIOS__SERVICEMSSQL_CURRENTDB} || + $ENV{NAGIOS__HOSTMSSQL_CURRENTDB}, + warningrange => $commandline{warning}, + criticalrange => $commandline{critical}, + dbthresholds => $commandline{dbthresholds}, + absolute => $commandline{absolute}, + lookback => $commandline{lookback}, + tablespace => $commandline{tablespace}, + database => $commandline{database}, + datafile => $commandline{datafile}, + basis => $commandline{basis}, + selectname => $commandline{name} || $commandline{tablespace} || $commandline{datafile}, + regexp => $commandline{regexp}, + name => $commandline{name}, + name2 => $commandline{name2} || $commandline{name}, + units => $commandline{units}, + eyecandy => $commandline{eyecandy}, + statefilesdir => $STATEFILESDIR, + verbose => $commandline{verbose}, + report => $commandline{report}, +); + +my $server = undef; + +$server = DBD::MSSQL::Server->new(%params); +$server->nagios(%params); +$server->calculate_result(); +$nagios_message = $server->{nagios_message}; +$nagios_level = $server->{nagios_level}; +$perfdata = $server->{perfdata}; + +printf "%s - %s", $ERRORCODES{$nagios_level}, $nagios_message; +printf " | %s", $perfdata if $perfdata; +printf "\n"; +exit $nagios_level; diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health.pl b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health.pl new file mode 100644 index 0000000..f9f794b --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/check_mssql_health.pl @@ -0,0 +1,527 @@ + +package main; + +use strict; +use Getopt::Long qw(:config no_ignore_case); +use File::Basename; +use lib dirname($0); +use Nagios::DBD::MSSQL::Server; +use Nagios::DBD::MSSQL::Server::Instance; +use Nagios::DBD::MSSQL::Server::Instance::SGA; +use Nagios::DBD::MSSQL::Server::Instance::SGA::DataBuffer; +use Nagios::DBD::MSSQL::Server::Instance::SGA::SharedPool; +use Nagios::DBD::MSSQL::Server::Instance::SGA::SharedPool::LibraryCache; +use Nagios::DBD::MSSQL::Server::Instance::SGA::SharedPool::DictionaryCache; +use Nagios::DBD::MSSQL::Server::Instance::SGA::Latches; +use Nagios::DBD::MSSQL::Server::Instance::PGA; +use Nagios::DBD::MSSQL::Server::Instance::SGA::RedoLogBuffer; + + +my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 ); +my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' ); + +use vars qw ($PROGNAME $REVISION $CONTACT $TIMEOUT $STATEFILESDIR $needs_restart %commandline); + +$PROGNAME = "check_mssql_health"; +$REVISION = '$Revision: #PACKAGE_VERSION# $'; +$CONTACT = 'gerhard.lausser@consol.de'; +$TIMEOUT = 60; +$STATEFILESDIR = '#STATEFILES_DIR#'; +$needs_restart = 0; + +my @modes = ( + ['server::connectiontime', + 'connection-time', undef, + 'Time to connect to the server' ], + ['server::cpubusy', + 'cpu-busy', undef, + 'Cpu busy in percent' ], + ['server::iobusy', + 'io-busy', undef, + 'IO busy in percent' ], + ['server::fullscans', + 'full-scans', undef, + 'Full table scans per second' ], + ['server::connectedusers', + 'connected-users', undef, + 'Number of currently connected users' ], + ['server::database::transactions', + 'transactions', undef, + 'Transactions per second (per database)' ], + ['server::batchrequests', + 'batch-requests', undef, + 'Batch requests per second' ], + ['server::latch::waits', + 'latches-waits', undef, + 'Number of latch requests that could not be granted immediately' ], + ['server::latch::waittime', + 'latches-wait-time', undef, + 'Average time for a latch to wait before the request is met' ], + ['server::memorypool::lock::waits', + 'locks-waits', undef, + 'The number of locks per second that had to wait' ], + ['server::memorypool::lock::timeouts', + 'locks-timeouts', undef, + 'The number of locks per second that timed out' ], + ['server::memorypool::lock::deadlocks', + 'locks-deadlocks', undef, + 'The number of deadlocks per second' ], + ['server::sql::recompilations', + 'sql-recompilations', undef, + 'Re-Compilations per second' ], + ['server::sql::initcompilations', + 'sql-initcompilations', undef, + 'Initial compilations per second' ], + ['server::totalmemory', + 'total-server-memory', undef, + 'The amount of memory that SQL Server has allocated to it' ], + ['server::memorypool::buffercache::hitratio', + 'mem-pool-data-buffer-hit-ratio', ['buffer-cache-hit-ratio'], + 'Data Buffer Cache Hit Ratio' ], + + + ['server::memorypool::buffercache::lazywrites', + 'lazy-writes', undef, + 'Lazy writes per second' ], + ['server::memorypool::buffercache::pagelifeexpectancy', + 'page-life-expectancy', undef, + 'Seconds a page is kept in memory before being flushed' ], + ['server::memorypool::buffercache::freeliststalls', + 'free-list-stalls', undef, + 'Requests per second that had to wait for a free page' ], + ['server::memorypool::buffercache::checkpointpages', + 'checkpoint-pages', undef, + 'Dirty pages flushed to disk per second. (usually by a checkpoint)' ], + + + ['server::database::databasefree', + 'database-free', undef, + 'Free space in database' ], + ['server::database::backupage', + 'database-backup-age', ['backup-age'], + 'Elapsed time (in hours) since a database was last backupped' ], + ['server::sql', + 'sql', undef, + 'any sql command returning a single number' ], + ['server::database::listdatabases', + 'list-databases', undef, + 'convenience function which lists all databases' ], + ['server::database::datafile::listdatafiles', + 'list-datafiles', undef, + 'convenience function which lists all datafiles' ], + ['server::memorypool::lock::listlocks', + 'list-locks', undef, + 'convenience function which lists all locks' ], +); + +sub print_usage () { + print <] --hostname= + --username= --password= [--port ] + --mode= + $PROGNAME [-v] [-t ] --server= + --username= --password= + --mode= + $PROGNAME [-h | --help] + $PROGNAME [-V | --version] + + Options: + --hostname + the database server + --port + the database server's port + --server + the name of a predefined connection + --currentdb + the name of a database which is used as the current database + for the connection. (don't use this parameter unless you + know what you're doing) + --username + the mssql user + --password + the mssql user's password + --warning + the warning range + --critical + the critical range + --mode + the mode of the plugin. select one of the following keywords: +EOUS + 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) { + printf $format, $_->[1], $_->[3]; + } + printf "\n"; + print <new(file => $commandline{'extra-opts'}, commandline => \%commandline); + if (! $extras->is_valid()) { + printf "extra-opts are not valid: %s\n", $extras->{errors}; + exit $ERRORS{UNKNOWN}; + } else { + $extras->overwrite(); + } +} + +if (exists $commandline{version}) { + print_revision($PROGNAME, $REVISION); + exit $ERRORS{OK}; +} + +if (exists $commandline{help}) { + print_help(); + exit $ERRORS{OK}; +} elsif (! exists $commandline{mode}) { + printf "Please select a mode\n"; + print_help(); + exit $ERRORS{OK}; +} + +if ($commandline{mode} eq "encode") { + my $input = <>; + chomp $input; + $input =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; + printf "%s\n", $input; + exit $ERRORS{OK}; +} + +if (exists $commandline{3}) { + $ENV{NRPE_MULTILINESUPPORT} = 1; +} + +if (exists $commandline{timeout}) { + $TIMEOUT = $commandline{timeout}; +} + +if (exists $commandline{verbose}) { + $DBD::MSSQL::Server::verbose = exists $commandline{verbose}; +} + +if (exists $commandline{scream}) { +# $DBD::MSSQL::Server::hysterical = exists $commandline{scream}; +} + +if (exists $commandline{report}) { + # short, long, html +} else { + $commandline{report} = "long"; +} + +if (exists $commandline{'with-mymodules-dyn-dir'}) { + $DBD::MSSQL::Server::my_modules_dyn_dir = $commandline{'with-mymodules-dyn-dir'}; +} else { + $DBD::MSSQL::Server::my_modules_dyn_dir = '#MYMODULES_DYN_DIR#'; +} + + +if (exists $commandline{environment}) { + # if the desired environment variable values are different from + # the environment of this running script, then a restart is necessary. + # because setting $ENV does _not_ change the environment of the running script. + foreach (keys %{$commandline{environment}}) { + if ((! $ENV{$_}) || ($ENV{$_} ne $commandline{environment}->{$_})) { + $needs_restart = 1; + $ENV{$_} = $commandline{environment}->{$_}; + printf STDERR "new %s=%s forces restart\n", $_, $ENV{$_} + if $DBD::MSSQL::Server::verbose; + } + } + # e.g. called with --runas dbnagio. shlib_path environment variable is stripped + # during the sudo. + # so the perl interpreter starts without a shlib_path. but --runas cares for + # a --environment shlib_path=... + # so setting the environment variable in the code above and restarting the + # perl interpreter will help it find shared libs +} + +if (exists $commandline{runas}) { + # remove the runas parameter + # exec sudo $0 ... the remaining parameters + $needs_restart = 1; + # if the calling script has a path for shared libs and there is no --environment + # parameter then the called script surely needs the variable too. + foreach my $important_env qw(LD_LIBRARY_PATH SHLIB_PATH + MSSQL_HOME TNS_ADMIN ORA_NLS ORA_NLS33 ORA_NLS10) { + if ($ENV{$important_env} && ! scalar(grep { /^$important_env=/ } + keys %{$commandline{environment}})) { + $commandline{environment}->{$important_env} = $ENV{$important_env}; + printf STDERR "add important --environment %s=%s\n", + $important_env, $ENV{$important_env} if $DBD::MSSQL::Server::verbose; + } + } +} + +if ($needs_restart) { + my @newargv = (); + my $runas = undef; + if (exists $commandline{runas}) { + $runas = $commandline{runas}; + delete $commandline{runas}; + } + foreach my $option (keys %commandline) { + if (grep { /^$option/ && /=/ } @params) { + if (ref ($commandline{$option}) eq "HASH") { + foreach (keys %{$commandline{$option}}) { + push(@newargv, sprintf "--%s", $option); + push(@newargv, sprintf "%s=%s", $_, $commandline{$option}->{$_}); + } + } else { + push(@newargv, sprintf "--%s", $option); + push(@newargv, sprintf "%s", $commandline{$option}); + } + } else { + push(@newargv, sprintf "--%s", $option); + } + } + if ($runas && ($> == 0)) { + # this was not my idea. some people connect as root to their nagios clients. + exec "su", "-c", sprintf("%s %s", $0, join(" ", @newargv)), "-", $runas; + } elsif ($runas) { + exec "sudo", "-S", "-u", $runas, $0, @newargv; + } else { + exec $0, @newargv; + # this makes sure that even a SHLIB or LD_LIBRARY_PATH are set correctly + # when the perl interpreter starts. Setting them during runtime does not + # help loading e.g. libclntsh.so + } + exit; +} + +if (exists $commandline{shell}) { + # forget what you see here. + system("/bin/sh"); +} + +if (exists $commandline{name}) { + # objects can be encoded like an url + # with s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; + if (($commandline{mode} ne "sql") || + (($commandline{mode} eq "sql") && + ($commandline{name} =~ /select%20/i))) { # protect ... like '%cac%' ... from decoding + $commandline{name} =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; + } + if ($commandline{name} =~ /^0$/) { + # without this, $params{selectname} would be treated like undef + $commandline{name} = "00"; + } +} + +$SIG{'ALRM'} = sub { + printf "UNKNOWN - %s timed out after %d seconds\n", $PROGNAME, $TIMEOUT; + exit $ERRORS{UNKNOWN}; +}; +alarm($TIMEOUT); + +my $nagios_level = $ERRORS{UNKNOWN}; +my $nagios_message = ""; +my $perfdata = ""; +my $racmode = 0; +if ($commandline{mode} =~ /^rac-([^\-.]+)/) { + $racmode = 1; + $commandline{mode} =~ s/^rac\-//g; +} +if ($commandline{mode} =~ /^my-([^\-.]+)/) { + my $param = $commandline{mode}; + $param =~ s/\-/::/g; + push(@modes, [$param, $commandline{mode}, undef, 'my extension']); +} elsif ((! grep { $commandline{mode} eq $_ } map { $_->[1] } @modes) && + (! grep { $commandline{mode} eq $_ } map { defined $_->[2] ? @{$_->[2]} : () } @modes)) { + printf "UNKNOWN - mode %s\n", $commandline{mode}; + print_usage(); + exit 3; +} + +my %params = ( + timeout => $TIMEOUT, + mode => ( + map { $_->[0] } + grep { + ($commandline{mode} eq $_->[1]) || + ( defined $_->[2] && grep { $commandline{mode} eq $_ } @{$_->[2]}) + } @modes + )[0], + cmdlinemode => $commandline{mode}, + method => $commandline{method} || + $ENV{NAGIOS__SERVICEMSSQL_METH} || + $ENV{NAGIOS__HOSTMSSQL_METH} || 'dbi', + hostname => $commandline{hostname} || + $ENV{NAGIOS__SERVICEMSSQL_HOST} || + $ENV{NAGIOS__HOSTMSSQL_HOST}, + username => $commandline{username} || + $ENV{NAGIOS__SERVICEMSSQL_USER} || + $ENV{NAGIOS__HOSTMSSQL_USER}, + password => $commandline{password} || + $ENV{NAGIOS__SERVICEMSSQL_PASS} || + $ENV{NAGIOS__HOSTMSSQL_PASS}, + port => $commandline{port} || + $ENV{NAGIOS__SERVICEMSSQL_PORT} || + $ENV{NAGIOS__HOSTMSSQL_PORT}, + server => $commandline{server} || + $ENV{NAGIOS__SERVICEMSSQL_SERVER} || + $ENV{NAGIOS__HOSTMSSQL_SERVER}, + currentdb => $commandline{currentdb} || + $ENV{NAGIOS__SERVICEMSSQL_CURRENTDB} || + $ENV{NAGIOS__HOSTMSSQL_CURRENTDB}, + warningrange => $commandline{warning}, + criticalrange => $commandline{critical}, + dbthresholds => $commandline{dbthresholds}, + absolute => $commandline{absolute}, + lookback => $commandline{lookback}, + tablespace => $commandline{tablespace}, + database => $commandline{database}, + datafile => $commandline{datafile}, + basis => $commandline{basis}, + selectname => $commandline{name} || $commandline{tablespace} || $commandline{datafile}, + regexp => $commandline{regexp}, + name => $commandline{name}, + name2 => $commandline{name2} || $commandline{name}, + units => $commandline{units}, + eyecandy => $commandline{eyecandy}, + statefilesdir => $STATEFILESDIR, + verbose => $commandline{verbose}, + report => $commandline{report}, +); + +my $server = undef; + +$server = DBD::MSSQL::Server->new(%params); +$server->nagios(%params); +$server->calculate_result(); +$nagios_message = $server->{nagios_message}; +$nagios_level = $server->{nagios_level}; +$perfdata = $server->{perfdata}; + +printf "%s - %s", $ERRORCODES{$nagios_level}, $nagios_message; +printf " | %s", $perfdata if $perfdata; +printf "\n"; +exit $nagios_level; diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst new file mode 100644 index 0000000..dedf856 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst @@ -0,0 +1,61 @@ +#!/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 = "${exec_prefix}/libexec"; + led2 = "${prefix}"; + led3 = "/usr/local/nagios"; + 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/,"#! /usr/bin/perl");} +/^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! /usr/bin/gawk");} +/^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! /bin/bash");} + +# 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#/,"/usr/bin/perl");} +/#GZIP#/ {sub(/#GZIP#/,"/bin/gzip");} +/#STATEFILES_DIR#/ {sub(/#STATEFILES_DIR#/,"/var/tmp/check_mssql_health");} +/#PACKAGE_VERSION#/ {sub(/#PACKAGE_VERSION#/,"1.5.8.2");} +/#MYMODULES_DYN_DIR#/ {sub(/#MYMODULES_DYN_DIR#/,"/usr/local/nagios/libexec");} + +{ + print; +} + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst.in b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst.in new file mode 100644 index 0000000..7edf296 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/plugins-scripts/subst.in @@ -0,0 +1,61 @@ +#!/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@");} +/#GZIP#/ {sub(/#GZIP#/,"@GZIP@");} +/#STATEFILES_DIR#/ {sub(/#STATEFILES_DIR#/,"@STATEFILES_DIR@");} +/#PACKAGE_VERSION#/ {sub(/#PACKAGE_VERSION#/,"@PACKAGE_VERSION@");} +/#MYMODULES_DYN_DIR#/ {sub(/#MYMODULES_DYN_DIR#/,"@MYMODULES_DYN_DIR@");} + +{ + print; +} + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile new file mode 100644 index 0000000..4dc546a --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile @@ -0,0 +1,297 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# t/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +srcdir = . +top_srcdir = .. + +pkgdatadir = $(datadir)/check_mssql_health +pkglibdir = $(libdir)/check_mssql_health +pkgincludedir = $(includedir)/check_mssql_health +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +subdir = t +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +INSTALL = /usr/bin/install -c +ACLOCAL = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run aclocal-1.9 +AMTAR = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run tar +AUTOCONF = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoconf +AUTOHEADER = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run autoheader +AUTOMAKE = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run automake-1.9 +AWK = /usr/bin/gawk +CAT = /bin/cat +CYGPATH_W = echo +DEFS = -DPACKAGE_NAME=\"check_mssql_health\" -DPACKAGE_TARNAME=\"check_mssql_health\" -DPACKAGE_VERSION=\"1.5.8.2\" -DPACKAGE_STRING=\"check_mssql_health\ 1.5.8.2\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"check_mssql_health\" -DVERSION=\"1.5.8.2\" +ECHO = /bin/echo +ECHO_C = +ECHO_N = -n +ECHO_T = +GREP = /bin/grep +GZIP = /bin/gzip +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_OPTS = -o nagios -g nagios +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s +LIBOBJS = +LIBS = +LTLIBOBJS = +MAKEINFO = ${SHELL} /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/missing --run makeinfo +MYMODULES_DIR = /usr/local/nagios/libexec +MYMODULES_DYN_DIR = /usr/local/nagios/libexec +PACKAGE = check_mssql_health +PACKAGE_BUGREPORT = +PACKAGE_NAME = check_mssql_health +PACKAGE_STRING = check_mssql_health 1.5.8.2 +PACKAGE_TARNAME = check_mssql_health +PACKAGE_VERSION = 1.5.8.2 +PATH_SEPARATOR = : +PERL = /usr/bin/perl +RELEASE = 1 +SED = /bin/sed +SET_MAKE = +SH = /bin/sh +SHELL = /bin/bash +STATEFILES_DIR = /var/tmp/check_mssql_health +STRIP = +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 +VERSION = 1.5.8.2 +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_ct_STRIP = +am__leading_dot = . +am__tar = tar --format=posix -chf - "$$tardir" +am__untar = tar -xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +datadir = ${prefix}/share +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +includedir = ${prefix}/include +infodir = ${prefix}/info +install_sh = /home/palli/projects/okconfig/nagios-plugins/check_mssql_health/src/check_mssql_health-1.5.8.2/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localstatedir = ${prefix}/var +mandir = ${prefix}/man +mkdir_p = mkdir -p -- +oldincludedir = /usr/include +prefix = /usr/local/nagios +program_transform_name = s,x,x, +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +sysconfdir = ${prefix}/etc +target_alias = +with_nagios_group = nagios +with_nagios_user = nagios +AUTOMAKE_OPTIONS = 1.3 no-dependencies + +#all: tests +TEST_VERBOSE = 0 +TEST_TYPE = test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = *.t +TESTDB_SW = -d + +#EXTRA_DIST = *.t bin var etc +EXTRA_DIST = *.t +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu t/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu t/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + + +tests: + $(PERL) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES) +# PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.am b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.am new file mode 100644 index 0000000..152e4a7 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.am @@ -0,0 +1,21 @@ +## +## Process this file with automake to produce Makefile.in +## + +AUTOMAKE_OPTIONS = 1.3 no-dependencies + +#all: tests + +TEST_VERBOSE=0 +TEST_TYPE=test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = *.t +TESTDB_SW = -d + +#EXTRA_DIST = *.t bin var etc +EXTRA_DIST = *.t + +tests: + $(PERL) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES) +# PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) + diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.in b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.in new file mode 100644 index 0000000..4d9c8dd --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/Makefile.in @@ -0,0 +1,297 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = t +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +INSTALL = @INSTALL@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CAT = @CAT@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +GREP = @GREP@ +GZIP = @GZIP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_OPTS = @INSTALL_OPTS@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MYMODULES_DIR = @MYMODULES_DIR@ +MYMODULES_DYN_DIR = @MYMODULES_DYN_DIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +RELEASE = @RELEASE@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SH = @SH@ +SHELL = @SHELL@ +STATEFILES_DIR = @STATEFILES_DIR@ +STRIP = @STRIP@ +SUPPORT = @SUPPORT@ +VERSION = @VERSION@ +WARRANTY = @WARRANTY@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +with_nagios_group = @with_nagios_group@ +with_nagios_user = @with_nagios_user@ +AUTOMAKE_OPTIONS = 1.3 no-dependencies + +#all: tests +TEST_VERBOSE = 0 +TEST_TYPE = test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = *.t +TESTDB_SW = -d + +#EXTRA_DIST = *.t bin var etc +EXTRA_DIST = *.t +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu t/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu t/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + + +tests: + $(PERL) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES) +# PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/check_mssql_health/src/check_mssql_health-1.5.8.2/t/check_mssql_health.t b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/check_mssql_health.t new file mode 100644 index 0000000..e0b3876 --- /dev/null +++ b/check_mssql_health/src/check_mssql_health-1.5.8.2/t/check_mssql_health.t @@ -0,0 +1,485 @@ +#! /usr/bin/perl -w -I .. +# +# MySQL Database Server Tests via check_mssql_healthdb +# +# +# Check with: + # tysql -U $user -P $password -H $host + +use strict; +use Test::More; +use NPTest; + +use vars qw($tests); + +plan skip_all => "check_mssql_health not compiled" unless (-x "check_mssql_health"); + +plan tests => 51; + +my $bad_login_output = '/Access denied for user /'; +my $mssql_dsn = getTestParameter( + "MSSQL_DSN", + "Command line parameters to specify login access", + "bba" + ); + +my $mssql_user = getTestParameter( + "MSSQL_USER", + "Command line parameters to specify login access", + "nagios" + ); + +my $mssql_pass = getTestParameter( + "MSSQL_PASS", + "Command line parameters to specify login access", + "oradbmon" + ); + +my $mssql_method = getTestParameter( + "MSSQL_METHOD", + "Command line parameters to specify login access", + "tns" + ); + +my $login = { + 'ora9' => { + 'tns' => ' --connect=ora9 --user=system --password=consol --method=tns ', + 'sqlplus' => ' --connect=ora9 --user=system --password=consol --method=sqlplus ', + }, + 'ora10' => { + 'tns' => ' --connect=ora10 --user=system --password=consol --method=tns ', + 'sqlplus' => ' --connect=ora10 --user=system --password=consol --method=sqlplus ', + }, + 'bba' => { + 'tns' => ' --connect=bba --user=nagios --password=oradbmon --method=tns ', + 'sqlplus' => ' --connect=bba --user=nagios --password=oradbmon --method=sqlplus ', + }, +}; + +my $mssql_login_details = $login->{$mssql_dsn}->{$mssql_method}; + + +my $result; +SKIP: { + $result = NPTest->testCmd("./check_mssql_health -V"); + cmp_ok( $result->return_code, '==', 0, "expected result"); + like( $result->output, '/check_mssql_health \(\d+[\.\d]+\)/', "Expected message for -V"); + + $result = NPTest->testCmd("./check_mssql_health --help"); + cmp_ok( $result->return_code, '==', 0, "expected result"); + like( $result->output, "/connection-time/", "Expected message"); + like( $result->output, "/sga-data-buffer-hit-ratio/", "Expected message"); + like( $result->output, "/pga-in-memory-sort-ratio/", "Expected message"); +} + +SKIP: { + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tnsping"); + cmp_ok( $result->return_code, '==', 0, "connect ok"); + like( $result->output, "/OK - connection established/", "Expected output tnsping"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=connection-time --warning=10 --critical=20"); + cmp_ok( $result->return_code, '==', 0, "connect ok"); + like( $result->output, "/OK - (\\d+\\.\\d+) seconds to connect | connection_time=(\\d+\\.\\d+);1;5/", "Expected output connection-time"); + diag("./check_mssql_health $mssql_login_details --mode=connection-time"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=connected-users"); + cmp_ok( $result->return_code, '==', 0, "connect ok"); + like( $result->output, "/OK - ([0-9]+) connected users | connected_users=([0-9]+);1;5/", "Expected output connected-users"); + $result->output =~ /([0-9]+) connected users \| connected_users=([0-9]+);50;100/; + ok($1 == $2); + diag($result->output); +} + +SKIP: { + # caches + diag("buffer cache"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-data-buffer-hit-ratio"); + like( $result->output, "/SGA data buffer hit ratio ([\.0-9]+)% .* sga_data_buffer_hit_ratio=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+)/", "Expected message cache hits"); + $result->output =~ /SGA data buffer hit ratio ([\.0-9]+)% .* sga_data_buffer_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + my $value = $1; my $pvalue = $2; my $warn = $3; my $crit = $4; + my $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-data-buffer-hit-ratio --warning=80: --critical=50:"); + like( $result->output, "/SGA data buffer hit ratio ([\.0-9]+)% .* sga_data_buffer_hit_ratio=([\.0-9]+)%;80:;50:/", "Expected message own cache hits"); + $result->output =~ /SGA data buffer hit ratio ([\.0-9]+)% .* sga_data_buffer_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + diag($result->output); + + diag("library cache"); + # library cache + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-library-cache-hit-ratio"); + like( $result->output, "/SGA library cache hit ratio ([\.0-9]+)% .* sga_library_cache_hit_ratio=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+)/", "Expected message libcache hits"); + $result->output =~ /SGA library cache hit ratio ([\.0-9]+)% .* sga_library_cache_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-library-cache-hit-ratio --warning=80: --critical=50:"); + like( $result->output, "/SGA library cache hit ratio ([\.0-9]+)% .* sga_library_cache_hit_ratio=([\.0-9]+)%;80:;50:/", "Expected message own libcache hits"); + $result->output =~ /SGA library cache hit ratio ([\.0-9]+)% .* sga_library_cache_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + diag($result->output); + + + diag("dictionary cache"); + # dictionary cache + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-dictionary-cache-hit-ratio"); + like( $result->output, "/SGA dictionary cache hit ratio ([\.0-9]+)% .* sga_dictionary_cache_hit_ratio=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+)/", "Expected message dictcache hits"); + $result->output =~ /SGA dictionary cache hit ratio ([\.0-9]+)% .* sga_dictionary_cache_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-dictionary-cache-hit-ratio --warning=80: --critical=50:"); + like( $result->output, "/SGA dictionary cache hit ratio ([\.0-9]+)% .* sga_dictionary_cache_hit_ratio=([\.0-9]+)%;80:;50:/", "Expected message own dictcache hits"); + $result->output =~ /SGA dictionary cache hit ratio ([\.0-9]+)% .* sga_dictionary_cache_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + diag($result->output); + + diag("latches"); + # latches + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-latches-hit-ratio"); + like( $result->output, "/SGA latches hit ratio ([\.0-9]+)% .* sga_latches_hit_ratio=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+)/", "Expected message latch hits"); + $result->output =~ /SGA latches hit ratio ([\.0-9]+)% .* sga_latches_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-latches-hit-ratio --warning=85: --critical=55:"); + like( $result->output, "/SGA latches hit ratio ([\.0-9]+)% .* sga_latches_hit_ratio=([\.0-9]+)%;98:;95:/", "Expected message latches"); + $result->output =~ /SGA latches hit ratio ([\.0-9]+)% .* sga_latches_hit_ratio=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + diag($result->output); + + diag("reloads"); +diag("./check_mssql_health $mssql_login_details --mode=sga-shared-pool-reloads"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-shared-pool-reloads"); + like( $result->output, "/SGA shared pool reload ratio ([\.0-9]+)% .* sga_shared_pool_reload_ratio=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+)/", "Expected message reloads"); + $result->output =~ /SGA shared pool reload ratio ([\.0-9]+)% .* sga_shared_pool_reload_ratio=([\.0-9]+)%;([\.0-9]+);([\.0-9]+)/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value > $warn; + $expec = 2 if $value > $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-shared-pool-reload-ratio --warning=10 --critical=12"); + like( $result->output, "/SGA shared pool reload ratio ([\.0-9]+)% .* sga_shared_pool_reload_ratio=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+)/", "Expected message reloads"); + $result->output =~ /SGA shared pool reload ratio ([\.0-9]+)% .* sga_shared_pool_reload_ratio=([\.0-9]+)%;([\.0-9]+);([\.0-9]+)/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value > $warn; + $expec = 2 if $value > $crit; + diag($result->output); + ok($warn == 10 && $crit == 12); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + diag($result->output); + + diag("free"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-shared-pool-free"); + like( $result->output, "/SGA shared pool free ([\.0-9]+)% .* sga_shared_pool_free=([\.0-9]+)%;([\.0-9:]+):;([\.0-9:]+):/", "Expected message reloads"); + $result->output =~ /SGA shared pool free ([\.0-9]+)% .* sga_shared_pool_free=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + cmp_ok( $value, '==', $pvalue); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sga-shared-pool-free --warning=5: --critical=1:"); + like( $result->output, "/SGA shared pool free ([\.0-9]+)% .* sga_shared_pool_free=([\.0-9]+)%;([\.0-9:]+):;([\.0-9:]+):/", "Expected message free"); + $result->output =~ /SGA shared pool free ([\.0-9]+)% .* sga_shared_pool_free=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+):/; + $value = $1; $pvalue = $2; $warn = $3; $crit = $4; + $expec = 0; + $expec = 1 if $value < $warn; + $expec = 2 if $value < $crit; + ok($value == $pvalue); + ok($warn == 5 && $crit == 1); + cmp_ok( $result->return_code, '==', $expec, "exitcode ok"); + diag($result->output); + +} + +SKIP: { + diag("inmemsort"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=pga-in-memory-sort-ratio"); + like( $result->output, "/PGA in-memory sort ratio [0-9\.]+% \| pga_in_memory_sort_ratio=[0-9\.]+%;99:;90:/", "Expected inmemsort"); + $result->output =~ /PGA in-memory sort ratio ([0-9\.]+)% \| pga_in_memory_sort_ratio=([0-9\.]+)%;99:;90:/; + ok($1 == $2); + diag($result->output); +} + +SKIP: { + diag("top10"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=seg-top10-logical-reads"); + like( $result->output, "/[0-9]+ user processes among the top10 logical reads \| users_among_top10_logical_reads=[0-9]+;1;9/", "Expected top 10"); + $result->output =~ /([0-9]+) user processes among the top10 logical reads \| users_among_top10_logical_reads=([0-9]+);1;9/; + ok($1 == $2); + diag($result->output); +} + +SKIP: { + diag("invalid objects"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=invalid-objects"); +diag("./check_mssql_health $mssql_login_details --mode=invalid-objects"); + like( $result->output, "/(no invalid objects)|([0-9]+ invalid objects)/", "Expected no invalid objects"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=stale-statistics"); + like( $result->output, "/([0-9]+) objects with stale statistics .* stale_stats_objects=([0-9]+);10;100/", "Expected no stale objects"); + $result->output =~ /([0-9]+) objects with stale statistics .* stale_stats_objects=([0-9]+);10;100/; + ok($1 == $2); + diag($result->output); +} + +SKIP: { + diag("tablespace usage"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tablespace-usage"); + like( $result->output, '/tbs (\w+) usage is ([\.0-9]+)%, tbs (\w+) usage is ([\.0-9]+)%, .* \'tbs_(\w+)_usage_pct\'=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+) \'tbs_(\w+)_usage\'=(\d+)MB;\d+;\d+;0;\d+ \'tbs_users_alloc\'=(\d+)MB;;;0;(\d+) \'tbs_(\w+)_usage_pct\'=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+) \'tbs_(\w+)_usage\'=(\d+)MB;\d+;\d+;0;\d+ \'tbs_(\w+)_alloc\'=(\d+)MB;;;0;(\d+)/', "Expected message tbs usage"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tablespace-usage --tablespace=USERS"); + like( $result->output, '/tbs USERS usage is ([\.0-9]+)% \| \'tbs_users_usage_pct\'=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+) \'tbs_users_usage\'=(\d+)MB;\d+;\d+;0;\d+ \'tbs_users_alloc\'=(\d+)MB;;;0;(\d+)$/', "Expected message tbs usage"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tablespace-usage --name=USERS"); + like( $result->output, '/tbs USERS usage is ([\.0-9]+)% \| \'tbs_users_usage_pct\'=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+) \'tbs_users_usage\'=(\d+)MB;\d+;\d+;0;\d+ \'tbs_users_alloc\'=(\d+)MB;;;0;(\d+)$/', "Expected message tbs usage"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tablespace-usage --name=users"); + like( $result->output, '/tbs USERS usage is ([\.0-9]+)% \| \'tbs_users_usage_pct\'=([\.0-9]+)%;([\.0-9:]+);([\.0-9:]+) \'tbs_users_usage\'=(\d+)MB;\d+;\d+;0;\d+ \'tbs_users_alloc\'=(\d+)MB;;;0;(\d+)$/', "Expected message tbs usage"); + diag($result->output); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tablespace-fragmentation --name=users"); + like( $result->output, '/tbs USERS fsfi is ([\.0-9]+) \| \'tbs_users_fsfi\'=([\.0-9]+);([\.0-9:]+);([\.0-9:]+);0;100$/', "Expected message tbs frag"); +} + +SKIP: { + diag("tablespace free"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tablespace-free --name=SYSTEM"); + like( $result->output, '/tbs SYSTEM has ([\.0-9]+)% free space left .* \'tbs_system_free_pct\'=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+): \'tbs_system_free\'=([\.0-9]+)MB;([\.0-9]+):;([\.0-9]+):;0;([\.0-9]+)/'); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=tablespace-free --name=SYSTEM --units=KB"); + like( $result->output, '/tbs SYSTEM has ([\.0-9]+)KB free space left .* \'tbs_system_free_pct\'=([\.0-9]+)%;([\.0-9]+):;([\.0-9]+): \'tbs_system_free\'=([\.0-9]+)KB;([\.0-9]+):;([\.0-9]+):;0;([\.0-9]+)/'); +} + +SKIP: { + diag ("parser"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=soft-parse-ratio"); + like( $result->output, '/Soft parse ratio ([\.0-9]+)% \| soft_parse_ratio=([\.0-9]+)%;(\d+):;(\d+):/', "Expected ratio"); + $result->output =~ /Soft parse ratio ([\.0-9]+)% \| soft_parse_ratio=([\.0-9]+)%;(\d+):;(\d+):/; + my $ratio = $1; my $pratio = $2; my $warn = $3; my $crit = $4; + ok($ratio == $pratio); + ok($warn == 98 && $crit == 90); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=soft-parse-ratio --warning=80: --critical=50:"); + like( $result->output, '/Soft parse ratio ([\.0-9]+)% \| soft_parse_ratio=([\.0-9]+)%;(\d+):;(\d+):/', "Expected ratio"); + $result->output =~ /Soft parse ratio ([\.0-9]+)% \| soft_parse_ratio=([\.0-9]+)%;(\d+):;(\d+):/; + $ratio = $1; $pratio = $2; $warn = $3; $crit = $4; + ok($ratio == $pratio); + ok($warn == 80 && $crit == 50); + diag($result->output); + +} + +SKIP: { + diag("redo log switch interval"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=switch-interval"); + like( $result->output, '/(OK|WARNING|CRITICAL) - Last redo log file switch interval was (\d+) minutes \| redo_log_file_switch_interval=(\d+)s;(\d+):;(\d+):/', "expected interval"); + $result->output =~ / Last redo log file switch interval was (\d+) minutes \| redo_log_file_switch_interval=(\d+)s;(\d+):;(\d+):/; + my $ratio = $1; my $pratio = $2; my $warn = $3; my $crit = $4; + ok($ratio == int($pratio / 60)); + ok($warn == 600 && $crit == 60); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=switch-interval --warning=1000: --critical=10:"); + like( $result->output, '/(OK|WARNING|CRITICAL) - Last redo log file switch interval was (\d+) minutes \| redo_log_file_switch_interval=(\d+)s;1000:;10:/', "expected interval with threshold"); + $result->output =~ /OK - Last redo log file switch interval was (\d+) minutes \| redo_log_file_switch_interval=(\d+)s;(\d+):;(\d+):/; + $ratio = $1; $pratio = $2; $warn = $3; $crit = $4; + ok($ratio == int($pratio / 60)); + ok($warn == 1000 && $crit == 10); + diag($result->output); +} + +SKIP: { + diag("retry ratio"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=retry-ratio"); + like( $result->output, '/Redo log retry ratio is ([0-9\.]+)% \| redo_log_retry_ratio=([\d\.]+)%;1;10/', "expected ratio"); + $result->output =~ /Redo log retry ratio is ([0-9\.]+)% \| redo_log_retry_ratio=([\d\.]+)%;1;10/; + my $ratio = $1; my $pratio = $2; my $warn = $3; my $crit = $4; + ok($ratio == $pratio); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=retry-ratio --warning=2 --critical=20"); + like( $result->output, '/Redo log retry ratio is ([0-9\.]+)% \| redo_log_retry_ratio=([\d\.]+)%;(\d+);(\d+)/', "expected ratio"); + $result->output =~ /Redo log retry ratio is ([0-9\.]+)% \| redo_log_retry_ratio=([\d\.]+)%;(\d+);(\d+)/; + $ratio = $1; $pratio = $2; $warn = $3; $crit = $4; + ok($ratio == $pratio); + ok($warn == 2 && $crit == 20); + diag($result->output); +} + +SKIP: { + diag("redo io"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=redo-io-traffic --warning=101 --critical=201"); +diag($result->output); + like( $result->output, '/Redo log io is ([0-9\.]+) MB\/sec \| redo_log_io_per_sec=([0-9\.]+);101;201/', "expected traffic"); + $result->output =~ /Redo log io is ([0-9\.]+) MB\/sec \| redo_log_io_per_sec=([0-9\.]+);([0-9\.]+);([0-9\.]+)/; + my $io = $1; my $pio = $2; my $warn = $3; my $crit = $4; +printf "io %s pio %s\n", $io, $pio; + ok($io == $pio); + diag($result->output); +} + + +SKIP: { + diag ("rollback segments"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=roll-header-contention"); + like( $result->output, '/Rollback segment header contention is ([0-9\.]+)% \| rollback_segment_header_contention=([\d\.]+)%;1;2/', "expected contention"); + $result->output =~ /Rollback segment header contention is ([0-9\.]+)% \| rollback_segment_header_contention=([\d\.]+)%;1;2/; + my $cont = $1; my $pcont = $2; my $warn = $3; my $crit = $4; + ok(sprintf("%.2f", $cont) == $pcont); + + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=roll-header-contention --warning=5 --critical=25"); + like( $result->output, '/Rollback segment header contention is ([0-9\.]+)% \| rollback_segment_header_contention=([\d\.]+)%;5;25/', "expected contention"); + $result->output =~ /Rollback segment header contention is ([0-9\.]+)% \| rollback_segment_header_contention=([\d\.]+)%;(\d+);(\d+)/; + $cont = $1; $pcont = $2; $warn = $3; $crit = $4; + ok(sprintf("%.2f", $cont) == $pcont); + ok($warn == 5 && $crit == 25); + diag($result->output); +} + +SKIP: { + diag ("datafile io"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=datafile-io-traffic --datafile=system01.dbf --critical=3000"); + like( $result->output, '/system01.dbf: ([\d\.]+) IO Operations per Second \| \'dbf_system01.dbf_io_total_per_sec\'=([\d\.]+);1000;3000/'); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=datafile-io-traffic --name=system01.dbf --critical=3000"); + like( $result->output, '/system01.dbf: ([\d\.]+) IO Operations per Second \| \'dbf_system01.dbf_io_total_per_sec\'=([\d\.]+);1000;3000/'); + $result->output =~ /system01.dbf: ([\d\.]+) IO Operations per Second \| 'dbf_system01.dbf_io_total_per_sec'=([\d\.]+);1000;3000/; + diag($result->output); + ok($1 == $2); +} + +SKIP: { + diag("latches"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=latch-contention --name=1"); + like( $result->output, '/SGA (.*?) \(#1\) contention [0-9\.]+% \| \'latch_1_contention\'=[0-9\.]+%;1;2 \'latch_1_gets\'=[0-9]+/'); + $result->output =~ /SGA (.*?) \(#1\) contention ([\d\.]+)% \| 'latch_1_contention\'=([\d\.]+)%;1;2 \'latch_1_gets\'=\d+/; + ok($2 eq $3); + diag($result->output); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=latch-waiting --name=1"); + like( $result->output, '/SGA (.*?) \(#1\) sleeping [0-9\.]+% of the time \| \'latch_1_sleep_share\'=[0-9\.]+%;0.1;1;0;100/'); + $result->output =~ /SGA (.*?) \(#1\) sleeping ([\d\.]+)% of the time \| \'latch_1_sleep_share\'=([\d\.]+)%;0.1;1;0;100/; + ok($2 eq $3); + diag($result->output); +} + +SKIP: { + diag("events"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=event-waits --name='log file sync'"); + like( $result->output, '/log file sync : ([\d\.]+) waits\/sec \| \'log file sync_waits_per_sec\'=([\d\.]+);10;100/'); + $result->output =~ /log file sync : ([\d\.]+) waits\/sec \| \'log file sync_waits_per_sec\'=([\d\.]+);10;100/; + ok($1 eq $2); + diag($result->output); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=event-waiting --name='log file sync'"); + like( $result->output, '/log file sync waits ([\d\.]+)% of the time \| \'log file sync_percent_waited\'=([\d\.]+)%;0.1;0.5/'); + $result->output =~ /log file sync waits ([\d\.]+)% of the time \| \'log file sync_percent_waited\'=([\d\.]+)%;0.1;0.5/; + ok($1 eq $2); + diag($result->output); +} + +SKIP: { + diag("enqueues"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=enqueue-contention --name=HW"); + like( $result->output, '/enqueue HW High-Water Lock: ([\d\.]+)% of the requests must wait \| \'HW_contention\'=([\d\.]+)%;1;10 \'HW_requests\'=([\d]+) \'HW_waits\'=([\d]+)/'); + $result->output =~ /enqueue HW High-Water Lock: ([\d\.]+)% of the requests must wait \| \'HW_contention\'=([\d\.]+)%;1;10 \'HW_requests\'=([\d]+) \'HW_waits\'=([\d]+)/; + ok($1 eq $2); + diag($result->output); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=enqueue-waiting --name=HW"); + like( $result->output, '/enqueue HW High-Water Lock: waiting ([\d\.]+)% of the time \| \'HW_ms_waited\'=([\d]+) \'HW_pct_waited\'=([\d\.]+)%;0.0003333;0.003333/'); + $result->output =~ /enqueue HW High-Water Lock: waiting ([\d\.]+)% of the time \| \'HW_ms_waited\'=([\d]+) \'HW_pct_waited\'=([\d\.]+)%;0.0003333;0.003333/; + ok($3 == $1); + diag($result->output); +} + +SKIP: { + diag("systats"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sysstat --name='sorts (memory)' --warning=12 --critical=15"); + like( $result->output, '/([\d\.]+) sorts \(memory\)\/sec \| \'sorts \(memory\)_per_sec\'=([\d\.]+);12;15 \'sorts \(memory\)\'=([\d]+)/'); + $result->output =~ /([\d\.]+) sorts \(memory\)\/sec \| \'sorts \(memory\)_per_sec\'=([\d\.]+);12;15 \'sorts \(memory\)\'=([\d]+)/; + ok($1 eq $2); + diag($result->output); +} + +SKIP: { + diag ("generic sql"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sql --name='select count(*) from v\$latch'"); + like( $result->output, '/CRITICAL - select count\(\*\) from v\$latch: ([\d]+) \| \'select count\(\*\) from v\$latch\'=([\d]+);1;5/'); + $result->output =~ /CRITICAL - select count\(\*\) from v\$latch: ([\d]+) \| 'select count\(\*\) from v\$latch'=([\d]+);1;5/; + ok($1 == $2); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sql --name='select count(*) from v\$latch' --name2='so a kaas'"); + like( $result->output, '/CRITICAL - so a kaas: ([\d]+) \| \'so a kaas\'=([\d]+);1;5/'); + $result->output =~ /CRITICAL - so a kaas: ([\d]+) \| 'so a kaas'=([\d]+);1;5/; + ok($1 == $2); + diag($result->output); + + my $hash = NPTest->testCmd("echo 'select 4/3 from dual' | ./check_mssql_health $mssql_login_details --mode=encode")->output; + ok($hash eq "select%204%2F3%20from%20dual"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sql --name=$hash --name2=calc"); + my $match = 'WARNING \- calc\: 1\.33 | \'calc\'=1\.33;1;5'; + like( $result->output, '/'.$match.'/'); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sql --name=$hash --name2=calc --units=B"); + $match = 'WARNING \- calc\: 1\.33B | \'calc\'=1\.33B;1;5'; + like( $result->output, '/'.$match.'/'); + + $hash = NPTest->testCmd("echo 'select 4/2 from dual' | ./check_mssql_health $mssql_login_details --mode=encode")->output; + ok($hash eq "select%204%2F2%20from%20dual"); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sql --name=$hash --name2=calc"); + $match = 'WARNING \- calc\: 2 | \'calc\'=2;1;5'; + like( $result->output, '/'.$match.'/'); + $result = NPTest->testCmd("./check_mssql_health $mssql_login_details --mode=sql --name=$hash --name2=calc --units=B"); + $match = 'WARNING \- calc\: 2B | \'calc\'=2B;1;5'; + like( $result->output, '/'.$match.'/'); + +} + + + + + + + + + + + + + + + + + + + + +