├── .gitignore ├── LICENSE ├── README.md ├── compiled └── icinga-powershell-mssql.ifw_compilation.psm1 ├── config ├── director │ ├── Invoke-IcingaCheckMSSQLBackupStatus.json │ ├── Invoke-IcingaCheckMSSQLHealth.json │ ├── Invoke-IcingaCheckMSSQLPerfCounter.json │ ├── Invoke-IcingaCheckMSSQLResource.json │ └── Mssql_Bundle.json ├── grafana │ ├── dashboards │ │ ├── mssql-base.json │ │ └── windows-mssql-web.json │ └── icingaweb2-grafana │ │ └── graphs.ini └── icinga │ ├── Invoke-IcingaCheckMSSQLBackupStatus.conf │ ├── Invoke-IcingaCheckMSSQLHealth.conf │ ├── Invoke-IcingaCheckMSSQLPerfCounter.conf │ ├── Invoke-IcingaCheckMSSQLResource.conf │ ├── Mssql_Bundle.conf │ └── PowerShell_Base.conf ├── doc ├── 01-Introduction.md ├── 02-Installation.md ├── 03-Icinga-Integration.md ├── 10-Icinga-Plugins.md ├── 30-Upgrading-Plugins.md ├── 31-Changelog.md └── plugins │ ├── 01-Invoke-IcingaCheckMSSQLBackupStatus.md │ ├── 02-Invoke-IcingaCheckMSSQLHealth.md │ ├── 03-Invoke-IcingaCheckMSSQLPerfCounter.md │ └── 04-Invoke-IcingaCheckMSSQLResource.md ├── icinga-powershell-mssql.psd1 ├── icinga-powershell-mssql.psm1 ├── plugins ├── Invoke-IcingaCheckMSSQLBackupStatus.psm1 ├── Invoke-IcingaCheckMSSQLHealth.psm1 ├── Invoke-IcingaCheckMSSQLPerfCounter.psm1 └── Invoke-IcingaCheckMSSQLResource.psm1 └── provider ├── enums └── Icinga_MSSQLProviderEnums.psm1 └── mssql ├── Get-IcingaMSSQLBackupOverallStatus.psm1 ├── Get-IcingaMSSQLPerfCounterNameFromDBObject.psm1 ├── Get-IcingaMSSQLPerfCounterPathFromDBObject.psm1 └── Get-IcingaMSSQLPerformanceCounter.psm1 /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Icinga PowerShell MSSQL 2 | 3 | This repository provides a collection of MSSQL check Plugins for the [Icinga PowerShell Framework](https://github.com/Icinga/icinga-powershell-framework) 4 | 5 | Before you continue, please take a look at the [installation guide](doc/02-Installation.md) 6 | 7 | ## Documentation 8 | 9 | Please take a look at the following content to get to know the extent of the module including examples on how to use it. 10 | 11 | * [Introduction](doc/01-Introduction.md) 12 | * [Installation Guide](doc/02-Installation.md) 13 | * [Icinga Integration](doc/03-Icinga-Integration.md) 14 | * [Plugin Documentation](doc/10-Icinga-Plugins.md) 15 | * [Changelog](doc/31-Changelog.md) 16 | 17 | ## Contributing 18 | 19 | The Icinga Windows Module is an Open Source project and lives from your contributions. No matter whether these are feature requests, issues, translations, documentation or code. 20 | 21 | * Please check whether a related issue already exists on our [Issue Tracker](https://github.com/Icinga/icinga-powershell-mssql/issues) 22 | * Send a [Pull Request](https://github.com/Icinga/icinga-powershell-mssql/pulls) 23 | * The master branch shall never be corrupt! 24 | -------------------------------------------------------------------------------- /compiled/icinga-powershell-mssql.ifw_compilation.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | Icinga for Windows Component compilation file. 3 | Will be overwritten to defaults with every update and contains 4 | all code pre-compiled for faster execution and for providing 5 | private/public commands. 6 | 7 | Fetches the current module and file location, reads all .psm1 files and compiles them into one large environment 8 | #> 9 | if ($null -eq (Get-Command -Name 'Write-IcingaForWindowsComponentCompilationFile' -ErrorAction SilentlyContinue)) { 10 | Write-Host '[' -NoNewline; 11 | Write-Host 'Error' -ForegroundColor Red -NoNewline; 12 | Write-Host ([string]::Format(']: Failed to compile Icinga for Windows component at location "{0}", because the required function "Write-IcingaForWindowsComponentCompilationFile" is not installed. Please ensure Icinga PowerShell Framework v1.9.0 or later is installed and try again.', $MyInvocation.MyCommand.Path)); 13 | 14 | return; 15 | } 16 | 17 | Write-IcingaForWindowsComponentCompilationFile ` 18 | -ScriptRootPath $PSScriptRoot ` 19 | -CompiledFilePath ($MyInvocation.MyCommand.Path); 20 | 21 | if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) { 22 | Copy-IcingaFrameworkCacheTemplate; 23 | } 24 | -------------------------------------------------------------------------------- /config/director/Invoke-IcingaCheckMSSQLBackupStatus.json: -------------------------------------------------------------------------------- 1 | {"DataList":{"PowerShell ExecutionPolicies":{"list_name":"PowerShell ExecutionPolicies","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"AllSigned","entry_name":"AllSigned","format":"string"},{"allowed_roles":null,"entry_value":"Bypass","entry_name":"Bypass","format":"string"},{"allowed_roles":null,"entry_value":"Default","entry_name":"Default","format":"string"},{"allowed_roles":null,"entry_value":"RemoteSigned","entry_name":"RemoteSigned","format":"string"},{"allowed_roles":null,"entry_value":"Restricted","entry_name":"Restricted","format":"string"},{"allowed_roles":null,"entry_value":"Undefined","entry_name":"Undefined","format":"string"},{"allowed_roles":null,"entry_value":"Unrestricted","entry_name":"Unrestricted","format":"string"}],"owner":"cstein"},"IcingaCheckMSSQLBackupStatus DatabaseStatusWarning":{"list_name":"IcingaCheckMSSQLBackupStatus DatabaseStatusWarning","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"Online","entry_name":"Online","format":"string"},{"allowed_roles":null,"entry_value":"Restoring","entry_name":"Restoring","format":"string"},{"allowed_roles":null,"entry_value":"Recovering","entry_name":"Recovering","format":"string"},{"allowed_roles":null,"entry_value":"Recovering_Pending","entry_name":"Recovering_Pending","format":"string"},{"allowed_roles":null,"entry_value":"Suspect","entry_name":"Suspect","format":"string"},{"allowed_roles":null,"entry_value":"Emergency","entry_name":"Emergency","format":"string"},{"allowed_roles":null,"entry_value":"Offline","entry_name":"Offline","format":"string"},{"allowed_roles":null,"entry_value":"Copying","entry_name":"Copying","format":"string"},{"allowed_roles":null,"entry_value":"Offline_Secondary","entry_name":"Offline_Secondary","format":"string"}],"owner":"cstein"},"IcingaCheckMSSQLBackupStatus Verbosity":{"list_name":"IcingaCheckMSSQLBackupStatus Verbosity","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"0","entry_name":"0","format":"string"},{"allowed_roles":null,"entry_value":"1","entry_name":"1","format":"string"},{"allowed_roles":null,"entry_value":"2","entry_name":"2","format":"string"},{"allowed_roles":null,"entry_value":"3","entry_name":"3","format":"string"}],"owner":"cstein"},"IcingaCheckMSSQLBackupStatus DatabaseStatusCritical":{"list_name":"IcingaCheckMSSQLBackupStatus DatabaseStatusCritical","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"Online","entry_name":"Online","format":"string"},{"allowed_roles":null,"entry_value":"Restoring","entry_name":"Restoring","format":"string"},{"allowed_roles":null,"entry_value":"Recovering","entry_name":"Recovering","format":"string"},{"allowed_roles":null,"entry_value":"Recovering_Pending","entry_name":"Recovering_Pending","format":"string"},{"allowed_roles":null,"entry_value":"Suspect","entry_name":"Suspect","format":"string"},{"allowed_roles":null,"entry_value":"Emergency","entry_name":"Emergency","format":"string"},{"allowed_roles":null,"entry_value":"Offline","entry_name":"Offline","format":"string"},{"allowed_roles":null,"entry_value":"Copying","entry_name":"Copying","format":"string"},{"allowed_roles":null,"entry_value":"Offline_Secondary","entry_name":"Offline_Secondary","format":"string"}],"owner":"cstein"}},"Command":{"Invoke-IcingaCheckMSSQLBackupStatus":{"fields":[{"datafield_id":4,"is_required":"n","var_filter":null},{"datafield_id":5,"is_required":"n","var_filter":null},{"datafield_id":6,"is_required":"n","var_filter":null},{"datafield_id":7,"is_required":"n","var_filter":null},{"datafield_id":8,"is_required":"n","var_filter":null},{"datafield_id":9,"is_required":"n","var_filter":null},{"datafield_id":10,"is_required":"n","var_filter":null},{"datafield_id":11,"is_required":"n","var_filter":null},{"datafield_id":12,"is_required":"n","var_filter":null},{"datafield_id":13,"is_required":"n","var_filter":null},{"datafield_id":14,"is_required":"n","var_filter":null},{"datafield_id":15,"is_required":"n","var_filter":null},{"datafield_id":16,"is_required":"n","var_filter":null},{"datafield_id":17,"is_required":"n","var_filter":null},{"datafield_id":18,"is_required":"n","var_filter":null},{"datafield_id":19,"is_required":"n","var_filter":null},{"datafield_id":20,"is_required":"n","var_filter":null},{"datafield_id":21,"is_required":"n","var_filter":null},{"datafield_id":22,"is_required":"n","var_filter":null},{"datafield_id":23,"is_required":"n","var_filter":null},{"datafield_id":24,"is_required":"n","var_filter":null},{"datafield_id":25,"is_required":"n","var_filter":null}],"object_name":"Invoke-IcingaCheckMSSQLBackupStatus","arguments":{"-TotalBackupSizeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeWarning$","order":"2"},"-IncludeDatabase":{"value":{"body":"var arr = macro(\"$IcingaCheckMSSQLBackupStatus_Array_IncludeDatabase$\");\r\n\r\nif (len(arr) == 0) {\r\n return \"@()\";\r\n}\r\n\r\nvar psarr = arr.map(\r\n x =\u003e if (typeof(x) == String) {\r\n var argLen = len(x);\r\n if (argLen != 0 \u0026\u0026 x.substr(0,1) == \"\u0027\" \u0026\u0026 x.substr(argLen - 1, argLen) == \"\u0027\") {\r\n x;\r\n } else {\r\n \"\u0027\" + x + \"\u0027\";\r\n }\r\n } else {\r\n x;\r\n }\r\n).join(\",\");\r\n\r\nreturn \"@(\" + psarr + \")\";","type":"Function"},"order":"14"},"-DatabaseStatusWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusWarning$","order":"12"},"-ExecutionTimeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeCritical$","order":"11"},"-NoPerfData":{"set_if":"$IcingaCheckMSSQLBackupStatus_Switchparameter_NoPerfData$","set_if_format":"string","order":"99"},"-SqlUsername":{"set_if":"var str = macro(\"$IcingaCheckMSSQLBackupStatus_String_SqlUsername$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLBackupStatus_String_SqlUsername$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"15"},"-LastBackupLogAgeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeCritical$","order":"7"},"-LastBackupAgeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeWarning$","order":"8"},"-ThresholdInterval":{"set_if":"var str = macro(\"$IcingaCheckMSSQLBackupStatus_String_ThresholdInterval$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLBackupStatus_String_ThresholdInterval$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"100"},"-ExecutionTimeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeWarning$","order":"10"},"-LastBackupLogAgeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeWarning$","order":"6"},"-AvgBackupSizeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeWarning$","order":"4"},"-IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLBackupStatus_Switchparameter_IntegratedSecurity$","set_if_format":"string","order":"99"},"-DatabaseStatusCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusCritical$","order":"13"},"-SqlHost":{"set_if":"var str = macro(\"$IcingaCheckMSSQLBackupStatus_String_SqlHost$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLBackupStatus_String_SqlHost$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"17"},"-Verbosity":{"value":"$IcingaCheckMSSQLBackupStatus_Object_Verbosity$","order":"20"},"-TotalBackupSizeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeCritical$","order":"3"},"-SqlPort":{"value":"$IcingaCheckMSSQLBackupStatus_Int32_SqlPort$","order":"18"},"-IncludeDays":{"value":"$IcingaCheckMSSQLBackupStatus_Object_IncludeDays$","order":"19"},"-LastBackupAgeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeCritical$","order":"9"},"-AvgBackupSizeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeCritical$","order":"5"},"-SqlPassword":{"value":"(ConvertTo-IcingaSecureString \u0027$IcingaCheckMSSQLBackupStatus_Securestring_SqlPassword$\u0027)","order":"16"}},"imports":["PowerShell Base"],"object_type":"object","vars":{"IcingaCheckMSSQLBackupStatus_Switchparameter_NoPerfData":false,"ifw_api_arguments":{"LastBackupAgeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeCritical$"},"SqlPort":{"value":"$IcingaCheckMSSQLBackupStatus_Int32_SqlPort$"},"LastBackupAgeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeWarning$"},"IncludeDays":{"value":"$IcingaCheckMSSQLBackupStatus_Object_IncludeDays$"},"ExecutionTimeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeCritical$"},"NoPerfData":{"set_if":"$IcingaCheckMSSQLBackupStatus_Switchparameter_NoPerfData$"},"SqlHost":{"value":"$IcingaCheckMSSQLBackupStatus_String_SqlHost$"},"ExecutionTimeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeWarning$"},"DatabaseStatusCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusCritical$"},"ThresholdInterval":{"value":"$IcingaCheckMSSQLBackupStatus_String_ThresholdInterval$"},"SqlPassword":{"value":"$IcingaCheckMSSQLBackupStatus_Securestring_SqlPassword$"},"AvgBackupSizeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeWarning$"},"LastBackupLogAgeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeWarning$"},"SqlUsername":{"value":"$IcingaCheckMSSQLBackupStatus_String_SqlUsername$"},"IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLBackupStatus_Switchparameter_IntegratedSecurity$"},"AvgBackupSizeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeCritical$"},"LastBackupLogAgeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeCritical$"},"IncludeDatabase":{"value":"$IcingaCheckMSSQLBackupStatus_Array_IncludeDatabase$"},"DatabaseStatusWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusWarning$"},"TotalBackupSizeCritical":{"value":"$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeCritical$"},"TotalBackupSizeWarning":{"value":"$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeWarning$"},"Verbosity":{"value":"$IcingaCheckMSSQLBackupStatus_Object_Verbosity$"}},"ifw_api_command":"Invoke-IcingaCheckMSSQLBackupStatus","IcingaCheckMSSQLBackupStatus_Switchparameter_IntegratedSecurity":false}},"PowerShell Base":{"methods_execute":"PluginCheck","object_name":"PowerShell Base","vars":{"IcingaPowerShellBase_String_ExecutionPolicy":"ByPass"},"is_string":null,"command":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","zone":null,"disabled":false,"fields":[{"datafield_id":2,"is_required":"n","var_filter":null}],"arguments":{"-C":{"value":"try { Use-Icinga -Minimal; } catch { Write-Output \u0027The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details\u0027; Write-Output \u0027Error:\u0027 $$($$_.Exception.Message)Components:`r`n$$( Get-Module -ListAvailable \u0027icinga-powershell-*\u0027 )`r`n\u0027Module-Path:\u0027`r`n$$($$Env:PSModulePath); exit 3; }; Exit-IcingaExecutePlugin -Command \u0027$ifw_api_command$\u0027 ","order":"0"},"-ExecutionPolicy":{"value":"$IcingaPowerShellBase_String_ExecutionPolicy$","order":"-1"},"-NoProfile":{"value":"-NoProfile","skip_key":true,"order":"-3"},"-NoLogo":{"value":"-NoLogo","skip_key":true,"order":"-2"}},"imports":[],"object_type":"object","timeout":"180"}},"Datafield":{"16":{"settings":{"datalist":"IcingaCheckMSSQLBackupStatus DatabaseStatusCritical","behavior":"strict","data_type":"string"},"description":"Critical threshold for the database status:\n Online\n Restoring\n Recovering\n Recovering_Pending\n Suspect\n Emergency\n Offline\n Copying\n Offline_Secondary","caption":"DatabaseStatusCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"16","varname":"IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusCritical","format":null},"7":{"settings":{"visibility":"visible"},"description":"Warning threshold for the average backupsize which represent an average backupsize of all backups","caption":"AvgBackupSizeWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"7","varname":"IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeWarning","format":null},"5":{"settings":{"visibility":"visible"},"description":"Warning threshold for the total backupsize which represent a count of all backups","caption":"TotalBackupSizeWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"5","varname":"IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeWarning","format":null},"21":{"settings":{"visibility":"visible"},"description":"The port of the MSSQL server/instance to connect to with the provided credentials","caption":"SqlPort","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeNumber","originalId":"21","varname":"IcingaCheckMSSQLBackupStatus_Int32_SqlPort","format":null},"18":{"settings":{"visibility":"visible"},"description":"The username for connecting to the MSSQL database","caption":"SqlUsername","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"18","varname":"IcingaCheckMSSQLBackupStatus_String_SqlUsername","format":null},"12":{"settings":{"visibility":"visible"},"description":"Critical threshold for the last backup age, which returns the elapsed time since a database was last backupped","caption":"LastBackupAgeCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"12","varname":"IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeCritical","format":null},"10":{"settings":{"visibility":"visible"},"description":null,"caption":"LastBackupLogAgeCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"10","varname":"IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeCritical","format":null},"2":{"settings":{"datalist":"PowerShell ExecutionPolicies","behavior":"strict","data_type":"string"},"description":"Defines with which Execution Policy the PowerShell is started","caption":"PowerShell Execution Policy","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"2","varname":"IcingaPowerShellBase_String_ExecutionPolicy","format":null},"22":{"settings":{"visibility":"visible"},"description":"Allows this plugin to use the credentials of the current PowerShell session inherited by\nthe user the PowerShell is running with. If this is set and the user the PowerShell is\nrunning with can access to the MSSQL database you will not require to provide username\nand password","caption":"IntegratedSecurity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"22","varname":"IcingaCheckMSSQLBackupStatus_Switchparameter_IntegratedSecurity","format":null},"8":{"settings":{"visibility":"visible"},"description":"Critical threshold for the average backupsize which represent an average backupsize of all backups","caption":"AvgBackupSizeCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"8","varname":"IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeCritical","format":null},"17":{"settings":{"visibility":"visible"},"description":"Specifies the database or databases which will be checked. Leave empty to fetch metrics from\nall databases on the given system","caption":"IncludeDatabase","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeArray","originalId":"17","varname":"IcingaCheckMSSQLBackupStatus_Array_IncludeDatabase","format":null},"11":{"settings":{"visibility":"visible"},"description":"Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped","caption":"LastBackupAgeWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"11","varname":"IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeWarning","format":null},"9":{"settings":{"visibility":"visible"},"description":"Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped","caption":"LastBackupLogAgeWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"9","varname":"IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeWarning","format":null},"24":{"settings":{"visibility":"visible"},"description":"Specifies the number of days to read the backup history from MSSQL. Over time, the history table can get quite\nlarge and if there is no maintenance task in place to shrink it, this script could time out. By default the entire\nhistory is evaluated.","caption":"IncludeDays","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"24","varname":"IcingaCheckMSSQLBackupStatus_Object_IncludeDays","format":null},"14":{"settings":{"visibility":"visible"},"description":"Critical threshold for the execution time, which returns the elapsed time how long the backup process took","caption":"ExecutionTimeCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"14","varname":"IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeCritical","format":null},"20":{"settings":{"visibility":"visible"},"description":"The IP address or FQDN to the MSSQL server to connect to","caption":"SqlHost","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"20","varname":"IcingaCheckMSSQLBackupStatus_String_SqlHost","format":null},"15":{"settings":{"datalist":"IcingaCheckMSSQLBackupStatus DatabaseStatusWarning","behavior":"strict","data_type":"string"},"description":"Warning threshold for the database status:\n Online\n Restoring\n Recovering\n Recovering_Pending\n Suspect\n Emergency\n Offline\n Copying\n Offline_Secondary","caption":"DatabaseStatusWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"15","varname":"IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusWarning","format":null},"25":{"settings":{"datalist":"IcingaCheckMSSQLBackupStatus Verbosity","behavior":"strict","data_type":"string"},"description":"Changes the behavior of the plugin output which check states are printed:\n0 (default): Only service checks/packages with state not OK will be printed\n1: Only services with not OK will be printed including OK checks of affected check packages including Package config\n2: Everything will be printed regardless of the check state\n3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])","caption":"Verbosity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"25","varname":"IcingaCheckMSSQLBackupStatus_Object_Verbosity","format":null},"23":{"settings":{"visibility":"visible"},"description":"Disables the performance data output of this plugin","caption":"NoPerfData","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"23","varname":"IcingaCheckMSSQLBackupStatus_Switchparameter_NoPerfData","format":null},"6":{"settings":{"visibility":"visible"},"description":"Critical threshold for the total backupsize which represent a count of all backups","caption":"TotalBackupSizeCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"6","varname":"IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeCritical","format":null},"4":{"settings":{"visibility":"visible"},"description":"Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring.","caption":"ThresholdInterval","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"4","varname":"IcingaCheckMSSQLBackupStatus_String_ThresholdInterval","format":null},"19":{"settings":{"visibility":"hidden"},"description":"The password for connecting to the MSSQL database as secure string","caption":"SqlPassword","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"19","varname":"IcingaCheckMSSQLBackupStatus_Securestring_SqlPassword","format":null},"13":{"settings":{"visibility":"visible"},"description":"Warning threshold for the execution time, which returns the elapsed time how long the backup process took","caption":"ExecutionTimeWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"13","varname":"IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeWarning","format":null}}} 2 | -------------------------------------------------------------------------------- /config/director/Invoke-IcingaCheckMSSQLHealth.json: -------------------------------------------------------------------------------- 1 | {"DataList":{"IcingaCheckMSSQLHealth Verbosity":{"list_name":"IcingaCheckMSSQLHealth Verbosity","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"0","entry_name":"0","format":"string"},{"allowed_roles":null,"entry_value":"1","entry_name":"1","format":"string"},{"allowed_roles":null,"entry_value":"2","entry_name":"2","format":"string"},{"allowed_roles":null,"entry_value":"3","entry_name":"3","format":"string"}],"owner":"cstein"},"PowerShell ExecutionPolicies":{"list_name":"PowerShell ExecutionPolicies","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"AllSigned","entry_name":"AllSigned","format":"string"},{"allowed_roles":null,"entry_value":"Bypass","entry_name":"Bypass","format":"string"},{"allowed_roles":null,"entry_value":"Default","entry_name":"Default","format":"string"},{"allowed_roles":null,"entry_value":"RemoteSigned","entry_name":"RemoteSigned","format":"string"},{"allowed_roles":null,"entry_value":"Restricted","entry_name":"Restricted","format":"string"},{"allowed_roles":null,"entry_value":"Undefined","entry_name":"Undefined","format":"string"},{"allowed_roles":null,"entry_value":"Unrestricted","entry_name":"Unrestricted","format":"string"}],"owner":"cstein"}},"Command":{"PowerShell Base":{"methods_execute":"PluginCheck","object_name":"PowerShell Base","vars":{"IcingaPowerShellBase_String_ExecutionPolicy":"ByPass"},"is_string":null,"command":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","zone":null,"disabled":false,"fields":[{"datafield_id":2,"is_required":"n","var_filter":null}],"arguments":{"-C":{"value":"try { Use-Icinga -Minimal; } catch { Write-Output \u0027The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details\u0027; Write-Output \u0027Error:\u0027 $$($$_.Exception.Message)Components:`r`n$$( Get-Module -ListAvailable \u0027icinga-powershell-*\u0027 )`r`n\u0027Module-Path:\u0027`r`n$$($$Env:PSModulePath); exit 3; }; Exit-IcingaExecutePlugin -Command \u0027$ifw_api_command$\u0027 ","order":"0"},"-ExecutionPolicy":{"value":"$IcingaPowerShellBase_String_ExecutionPolicy$","order":"-1"},"-NoProfile":{"value":"-NoProfile","skip_key":true,"order":"-3"},"-NoLogo":{"value":"-NoLogo","skip_key":true,"order":"-2"}},"imports":[],"object_type":"object","timeout":"180"},"Invoke-IcingaCheckMSSQLHealth":{"fields":[{"datafield_id":4,"is_required":"n","var_filter":null},{"datafield_id":5,"is_required":"n","var_filter":null},{"datafield_id":6,"is_required":"n","var_filter":null},{"datafield_id":7,"is_required":"n","var_filter":null},{"datafield_id":8,"is_required":"n","var_filter":null},{"datafield_id":9,"is_required":"n","var_filter":null},{"datafield_id":10,"is_required":"n","var_filter":null},{"datafield_id":11,"is_required":"n","var_filter":null},{"datafield_id":12,"is_required":"n","var_filter":null},{"datafield_id":13,"is_required":"n","var_filter":null},{"datafield_id":14,"is_required":"n","var_filter":null},{"datafield_id":15,"is_required":"n","var_filter":null}],"object_name":"Invoke-IcingaCheckMSSQLHealth","arguments":{"-Verbosity":{"value":"$IcingaCheckMSSQLHealth_Int32_Verbosity$","order":"10"},"-SqlUsername":{"set_if":"var str = macro(\"$IcingaCheckMSSQLHealth_String_SqlUsername$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLHealth_String_SqlUsername$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"5"},"-ThresholdInterval":{"set_if":"var str = macro(\"$IcingaCheckMSSQLHealth_String_ThresholdInterval$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLHealth_String_ThresholdInterval$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"100"},"-SqlPassword":{"value":"(ConvertTo-IcingaSecureString \u0027$IcingaCheckMSSQLHealth_Securestring_SqlPassword$\u0027)","order":"6"},"-SqlPort":{"value":"$IcingaCheckMSSQLHealth_Int32_SqlPort$","order":"8"},"-NoPerfData":{"set_if":"$IcingaCheckMSSQLHealth_Switchparameter_NoPerfData$","set_if_format":"string","order":"99"},"-Warning":{"value":"$IcingaCheckMSSQLHealth_Object_Warning$","order":"2"},"-Critical":{"value":"$IcingaCheckMSSQLHealth_Object_Critical$","order":"3"},"-SqlDatabase":{"set_if":"var str = macro(\"$IcingaCheckMSSQLHealth_String_SqlDatabase$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLHealth_String_SqlDatabase$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"9"},"-SqlHost":{"set_if":"var str = macro(\"$IcingaCheckMSSQLHealth_String_SqlHost$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLHealth_String_SqlHost$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"7"},"-Instance":{"set_if":"var str = macro(\"$IcingaCheckMSSQLHealth_String_Instance$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLHealth_String_Instance$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"4"},"-IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLHealth_Switchparameter_IntegratedSecurity$","set_if_format":"string","order":"99"}},"imports":["PowerShell Base"],"object_type":"object","vars":{"IcingaCheckMSSQLHealth_Switchparameter_NoPerfData":false,"ifw_api_arguments":{"SqlPort":{"value":"$IcingaCheckMSSQLHealth_Int32_SqlPort$"},"ThresholdInterval":{"value":"$IcingaCheckMSSQLHealth_String_ThresholdInterval$"},"SqlUsername":{"value":"$IcingaCheckMSSQLHealth_String_SqlUsername$"},"SqlPassword":{"value":"$IcingaCheckMSSQLHealth_Securestring_SqlPassword$"},"Critical":{"value":"$IcingaCheckMSSQLHealth_Object_Critical$"},"IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLHealth_Switchparameter_IntegratedSecurity$"},"Instance":{"value":"$IcingaCheckMSSQLHealth_String_Instance$"},"Warning":{"value":"$IcingaCheckMSSQLHealth_Object_Warning$"},"NoPerfData":{"set_if":"$IcingaCheckMSSQLHealth_Switchparameter_NoPerfData$"},"SqlHost":{"value":"$IcingaCheckMSSQLHealth_String_SqlHost$"},"SqlDatabase":{"value":"$IcingaCheckMSSQLHealth_String_SqlDatabase$"},"Verbosity":{"value":"$IcingaCheckMSSQLHealth_Int32_Verbosity$"}},"ifw_api_command":"Invoke-IcingaCheckMSSQLHealth","IcingaCheckMSSQLHealth_Switchparameter_IntegratedSecurity":false}}},"Datafield":{"7":{"settings":{"visibility":"visible"},"description":"The name of the database instance to check the service state for. Can either the MSSQL$DB1 or simply DB1\nfor example","caption":"Instance","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"7","varname":"IcingaCheckMSSQLHealth_String_Instance","format":null},"5":{"settings":{"visibility":"visible"},"description":"The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m)","caption":"Warning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"5","varname":"IcingaCheckMSSQLHealth_Object_Warning","format":null},"12":{"settings":{"visibility":"visible"},"description":"The name of a specific database to connect to. Leave empty to connect \"globally\"","caption":"SqlDatabase","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"12","varname":"IcingaCheckMSSQLHealth_String_SqlDatabase","format":null},"10":{"settings":{"visibility":"visible"},"description":"The IP address or FQDN to the MSSQL server to connect to","caption":"SqlHost","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"10","varname":"IcingaCheckMSSQLHealth_String_SqlHost","format":null},"2":{"settings":{"datalist":"PowerShell ExecutionPolicies","behavior":"strict","data_type":"string"},"description":"Defines with which Execution Policy the PowerShell is started","caption":"PowerShell Execution Policy","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"2","varname":"IcingaPowerShellBase_String_ExecutionPolicy","format":null},"8":{"settings":{"visibility":"visible"},"description":"The username for connecting to the MSSQL database","caption":"SqlUsername","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"8","varname":"IcingaCheckMSSQLHealth_String_SqlUsername","format":null},"11":{"settings":{"visibility":"visible"},"description":"The port of the MSSQL server/instance to connect to with the provided credentials","caption":"SqlPort","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeNumber","originalId":"11","varname":"IcingaCheckMSSQLHealth_Int32_SqlPort","format":null},"9":{"settings":{"visibility":"hidden"},"description":"The password for connecting to the MSSQL database as secure string","caption":"SqlPassword","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"9","varname":"IcingaCheckMSSQLHealth_Securestring_SqlPassword","format":null},"14":{"settings":{"visibility":"visible"},"description":"Disables the performance data output of this plugin","caption":"NoPerfData","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"14","varname":"IcingaCheckMSSQLHealth_Switchparameter_NoPerfData","format":null},"15":{"settings":{"datalist":"IcingaCheckMSSQLHealth Verbosity","behavior":"strict","data_type":"string"},"description":"Changes the behavior of the plugin output which check states are printed:\n0 (default): Only service checks/packages with state not OK will be printed\n1: Only services with not OK will be printed including OK checks of affected check packages including Package config\n2: Everything will be printed regardless of the check state\n3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])","caption":"Verbosity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"15","varname":"IcingaCheckMSSQLHealth_Int32_Verbosity","format":null},"6":{"settings":{"visibility":"visible"},"description":"The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m)","caption":"Critical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"6","varname":"IcingaCheckMSSQLHealth_Object_Critical","format":null},"4":{"settings":{"visibility":"visible"},"description":"Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring.","caption":"ThresholdInterval","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"4","varname":"IcingaCheckMSSQLHealth_String_ThresholdInterval","format":null},"13":{"settings":{"visibility":"visible"},"description":"Allows this plugin to use the credentials of the current PowerShell session inherited by\nthe user the PowerShell is running with. If this is set and the user the PowerShell is\nrunning with can access to the MSSQL database you will not require to provide username\nand password","caption":"IntegratedSecurity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"13","varname":"IcingaCheckMSSQLHealth_Switchparameter_IntegratedSecurity","format":null}}} 2 | -------------------------------------------------------------------------------- /config/director/Invoke-IcingaCheckMSSQLPerfCounter.json: -------------------------------------------------------------------------------- 1 | {"DataList":{"IcingaCheckMSSQLPerfCounter Verbosity":{"list_name":"IcingaCheckMSSQLPerfCounter Verbosity","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"0","entry_name":"0","format":"string"},{"allowed_roles":null,"entry_value":"1","entry_name":"1","format":"string"},{"allowed_roles":null,"entry_value":"2","entry_name":"2","format":"string"},{"allowed_roles":null,"entry_value":"3","entry_name":"3","format":"string"}],"owner":"cstein"},"PowerShell ExecutionPolicies":{"list_name":"PowerShell ExecutionPolicies","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"AllSigned","entry_name":"AllSigned","format":"string"},{"allowed_roles":null,"entry_value":"Bypass","entry_name":"Bypass","format":"string"},{"allowed_roles":null,"entry_value":"Default","entry_name":"Default","format":"string"},{"allowed_roles":null,"entry_value":"RemoteSigned","entry_name":"RemoteSigned","format":"string"},{"allowed_roles":null,"entry_value":"Restricted","entry_name":"Restricted","format":"string"},{"allowed_roles":null,"entry_value":"Undefined","entry_name":"Undefined","format":"string"},{"allowed_roles":null,"entry_value":"Unrestricted","entry_name":"Unrestricted","format":"string"}],"owner":"cstein"}},"Command":{"PowerShell Base":{"methods_execute":"PluginCheck","object_name":"PowerShell Base","vars":{"IcingaPowerShellBase_String_ExecutionPolicy":"ByPass"},"is_string":null,"command":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","zone":null,"disabled":false,"fields":[{"datafield_id":2,"is_required":"n","var_filter":null}],"arguments":{"-C":{"value":"try { Use-Icinga -Minimal; } catch { Write-Output \u0027The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details\u0027; Write-Output \u0027Error:\u0027 $$($$_.Exception.Message)Components:`r`n$$( Get-Module -ListAvailable \u0027icinga-powershell-*\u0027 )`r`n\u0027Module-Path:\u0027`r`n$$($$Env:PSModulePath); exit 3; }; Exit-IcingaExecutePlugin -Command \u0027$ifw_api_command$\u0027 ","order":"0"},"-ExecutionPolicy":{"value":"$IcingaPowerShellBase_String_ExecutionPolicy$","order":"-1"},"-NoProfile":{"value":"-NoProfile","skip_key":true,"order":"-3"},"-NoLogo":{"value":"-NoLogo","skip_key":true,"order":"-2"}},"imports":[],"object_type":"object","timeout":"180"},"Invoke-IcingaCheckMSSQLPerfCounter":{"fields":[{"datafield_id":4,"is_required":"n","var_filter":null},{"datafield_id":5,"is_required":"n","var_filter":null},{"datafield_id":6,"is_required":"n","var_filter":null},{"datafield_id":7,"is_required":"n","var_filter":null},{"datafield_id":8,"is_required":"n","var_filter":null},{"datafield_id":9,"is_required":"n","var_filter":null},{"datafield_id":10,"is_required":"n","var_filter":null},{"datafield_id":11,"is_required":"n","var_filter":null},{"datafield_id":12,"is_required":"n","var_filter":null},{"datafield_id":13,"is_required":"n","var_filter":null},{"datafield_id":14,"is_required":"n","var_filter":null},{"datafield_id":15,"is_required":"n","var_filter":null}],"object_name":"Invoke-IcingaCheckMSSQLPerfCounter","arguments":{"-Verbosity":{"value":"$IcingaCheckMSSQLPerfCounter_Int32_Verbosity$","order":"10"},"-SqlUsername":{"set_if":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_SqlUsername$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_SqlUsername$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"5"},"-ThresholdInterval":{"set_if":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_ThresholdInterval$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_ThresholdInterval$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"100"},"-SqlPassword":{"value":"(ConvertTo-IcingaSecureString \u0027$IcingaCheckMSSQLPerfCounter_Securestring_SqlPassword$\u0027)","order":"6"},"-SqlPort":{"value":"$IcingaCheckMSSQLPerfCounter_Int32_SqlPort$","order":"8"},"-NoPerfData":{"set_if":"$IcingaCheckMSSQLPerfCounter_Switchparameter_NoPerfData$","set_if_format":"string","order":"99"},"-Warning":{"value":"$IcingaCheckMSSQLPerfCounter_Object_Warning$","order":"2"},"-Critical":{"value":"$IcingaCheckMSSQLPerfCounter_Object_Critical$","order":"3"},"-SqlDatabase":{"set_if":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_SqlDatabase$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_SqlDatabase$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"9"},"-PerformanceCounter":{"value":{"body":"var arr = macro(\"$IcingaCheckMSSQLPerfCounter_Array_PerformanceCounter$\");\r\n\r\nif (len(arr) == 0) {\r\n return \"@()\";\r\n}\r\n\r\nvar psarr = arr.map(\r\n x =\u003e if (typeof(x) == String) {\r\n var argLen = len(x);\r\n if (argLen != 0 \u0026\u0026 x.substr(0,1) == \"\u0027\" \u0026\u0026 x.substr(argLen - 1, argLen) == \"\u0027\") {\r\n x;\r\n } else {\r\n \"\u0027\" + x + \"\u0027\";\r\n }\r\n } else {\r\n x;\r\n }\r\n).join(\",\");\r\n\r\nreturn \"@(\" + psarr + \")\";","type":"Function"},"order":"4"},"-SqlHost":{"set_if":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_SqlHost$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLPerfCounter_String_SqlHost$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"7"},"-IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLPerfCounter_Switchparameter_IntegratedSecurity$","set_if_format":"string","order":"99"}},"imports":["PowerShell Base"],"object_type":"object","vars":{"IcingaCheckMSSQLPerfCounter_Switchparameter_IntegratedSecurity":false,"ifw_api_arguments":{"SqlPort":{"value":"$IcingaCheckMSSQLPerfCounter_Int32_SqlPort$"},"ThresholdInterval":{"value":"$IcingaCheckMSSQLPerfCounter_String_ThresholdInterval$"},"Warning":{"value":"$IcingaCheckMSSQLPerfCounter_Object_Warning$"},"NoPerfData":{"set_if":"$IcingaCheckMSSQLPerfCounter_Switchparameter_NoPerfData$"},"SqlPassword":{"value":"$IcingaCheckMSSQLPerfCounter_Securestring_SqlPassword$"},"Critical":{"value":"$IcingaCheckMSSQLPerfCounter_Object_Critical$"},"IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLPerfCounter_Switchparameter_IntegratedSecurity$"},"PerformanceCounter":{"value":"$IcingaCheckMSSQLPerfCounter_Array_PerformanceCounter$"},"SqlUsername":{"value":"$IcingaCheckMSSQLPerfCounter_String_SqlUsername$"},"SqlHost":{"value":"$IcingaCheckMSSQLPerfCounter_String_SqlHost$"},"SqlDatabase":{"value":"$IcingaCheckMSSQLPerfCounter_String_SqlDatabase$"},"Verbosity":{"value":"$IcingaCheckMSSQLPerfCounter_Int32_Verbosity$"}},"ifw_api_command":"Invoke-IcingaCheckMSSQLPerfCounter","IcingaCheckMSSQLPerfCounter_Switchparameter_NoPerfData":false}}},"Datafield":{"7":{"settings":{"visibility":"visible"},"description":"List of Performance Counters specified by their full path (example \u0027\\SQLServer:Buffer Manager\\Buffer cache hit ratio\u0027)\nto fetch information for","caption":"PerformanceCounter","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeArray","originalId":"7","varname":"IcingaCheckMSSQLPerfCounter_Array_PerformanceCounter","format":null},"5":{"settings":{"visibility":"visible"},"description":"The warning threshold of the Performance Counter return values","caption":"Warning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"5","varname":"IcingaCheckMSSQLPerfCounter_Object_Warning","format":null},"12":{"settings":{"visibility":"visible"},"description":"The name of a specific database to connect to. Leave empty to connect \"globally\"","caption":"SqlDatabase","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"12","varname":"IcingaCheckMSSQLPerfCounter_String_SqlDatabase","format":null},"10":{"settings":{"visibility":"visible"},"description":"The IP address or FQDN to the MSSQL server to connect to","caption":"SqlHost","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"10","varname":"IcingaCheckMSSQLPerfCounter_String_SqlHost","format":null},"2":{"settings":{"datalist":"PowerShell ExecutionPolicies","behavior":"strict","data_type":"string"},"description":"Defines with which Execution Policy the PowerShell is started","caption":"PowerShell Execution Policy","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"2","varname":"IcingaPowerShellBase_String_ExecutionPolicy","format":null},"8":{"settings":{"visibility":"visible"},"description":"The username for connecting to the MSSQL database","caption":"SqlUsername","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"8","varname":"IcingaCheckMSSQLPerfCounter_String_SqlUsername","format":null},"11":{"settings":{"visibility":"visible"},"description":"The port of the MSSQL server/instance to connect to with the provided credentials","caption":"SqlPort","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeNumber","originalId":"11","varname":"IcingaCheckMSSQLPerfCounter_Int32_SqlPort","format":null},"9":{"settings":{"visibility":"hidden"},"description":"The password for connecting to the MSSQL database as secure string","caption":"SqlPassword","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"9","varname":"IcingaCheckMSSQLPerfCounter_Securestring_SqlPassword","format":null},"14":{"settings":{"visibility":"visible"},"description":"Disables the performance data output of this plugin","caption":"NoPerfData","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"14","varname":"IcingaCheckMSSQLPerfCounter_Switchparameter_NoPerfData","format":null},"15":{"settings":{"datalist":"IcingaCheckMSSQLPerfCounter Verbosity","behavior":"strict","data_type":"string"},"description":"Changes the behavior of the plugin output which check states are printed:\n0 (default): Only service checks/packages with state not OK will be printed\n1: Only services with not OK will be printed including OK checks of affected check packages including Package config\n2: Everything will be printed regardless of the check state\n3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])","caption":"Verbosity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"15","varname":"IcingaCheckMSSQLPerfCounter_Int32_Verbosity","format":null},"6":{"settings":{"visibility":"visible"},"description":"The critical threshold of the Performance Counter return values","caption":"Critical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"6","varname":"IcingaCheckMSSQLPerfCounter_Object_Critical","format":null},"4":{"settings":{"visibility":"visible"},"description":"Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring.","caption":"ThresholdInterval","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"4","varname":"IcingaCheckMSSQLPerfCounter_String_ThresholdInterval","format":null},"13":{"settings":{"visibility":"visible"},"description":"Allows this plugin to use the credentials of the current PowerShell session inherited by\nthe user the PowerShell is running with. If this is set and the user the PowerShell is\nrunning with can access to the MSSQL database you will not require to provide username\nand password","caption":"IntegratedSecurity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"13","varname":"IcingaCheckMSSQLPerfCounter_Switchparameter_IntegratedSecurity","format":null}}} 2 | -------------------------------------------------------------------------------- /config/director/Invoke-IcingaCheckMSSQLResource.json: -------------------------------------------------------------------------------- 1 | {"DataList":{"IcingaCheckMSSQLResource Verbosity":{"list_name":"IcingaCheckMSSQLResource Verbosity","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"0","entry_name":"0","format":"string"},{"allowed_roles":null,"entry_value":"1","entry_name":"1","format":"string"},{"allowed_roles":null,"entry_value":"2","entry_name":"2","format":"string"},{"allowed_roles":null,"entry_value":"3","entry_name":"3","format":"string"}],"owner":"cstein"},"PowerShell ExecutionPolicies":{"list_name":"PowerShell ExecutionPolicies","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"AllSigned","entry_name":"AllSigned","format":"string"},{"allowed_roles":null,"entry_value":"Bypass","entry_name":"Bypass","format":"string"},{"allowed_roles":null,"entry_value":"Default","entry_name":"Default","format":"string"},{"allowed_roles":null,"entry_value":"RemoteSigned","entry_name":"RemoteSigned","format":"string"},{"allowed_roles":null,"entry_value":"Restricted","entry_name":"Restricted","format":"string"},{"allowed_roles":null,"entry_value":"Undefined","entry_name":"Undefined","format":"string"},{"allowed_roles":null,"entry_value":"Unrestricted","entry_name":"Unrestricted","format":"string"}],"owner":"cstein"}},"Command":{"Invoke-IcingaCheckMSSQLResource":{"fields":[{"datafield_id":4,"is_required":"n","var_filter":null},{"datafield_id":5,"is_required":"n","var_filter":null},{"datafield_id":6,"is_required":"n","var_filter":null},{"datafield_id":7,"is_required":"n","var_filter":null},{"datafield_id":8,"is_required":"n","var_filter":null},{"datafield_id":9,"is_required":"n","var_filter":null},{"datafield_id":10,"is_required":"n","var_filter":null},{"datafield_id":11,"is_required":"n","var_filter":null},{"datafield_id":12,"is_required":"n","var_filter":null},{"datafield_id":13,"is_required":"n","var_filter":null},{"datafield_id":14,"is_required":"n","var_filter":null},{"datafield_id":15,"is_required":"n","var_filter":null},{"datafield_id":16,"is_required":"n","var_filter":null},{"datafield_id":17,"is_required":"n","var_filter":null},{"datafield_id":18,"is_required":"n","var_filter":null}],"object_name":"Invoke-IcingaCheckMSSQLResource","arguments":{"-SqlUsername":{"set_if":"var str = macro(\"$IcingaCheckMSSQLResource_String_SqlUsername$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLResource_String_SqlUsername$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"8"},"-AverageLatchWaitTimeWarning":{"value":"$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeWarning$","order":"5"},"-NoPerfData":{"set_if":"$IcingaCheckMSSQLResource_Switchparameter_NoPerfData$","set_if_format":"string","order":"99"},"-SqlPort":{"value":"$IcingaCheckMSSQLResource_Int32_SqlPort$","order":"11"},"-AverageLatchWaitTimeCritical":{"value":"$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeCritical$","order":"4"},"-ThresholdInterval":{"set_if":"var str = macro(\"$IcingaCheckMSSQLResource_String_ThresholdInterval$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLResource_String_ThresholdInterval$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"100"},"-BufferCacheHitRatioCritical":{"value":"$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioCritical$","order":"6"},"-BufferCacheHitRatioWarning":{"value":"$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioWarning$","order":"7"},"-IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLResource_Switchparameter_IntegratedSecurity$","set_if_format":"string","order":"99"},"-PageLifeExpectancyCritical":{"value":"$IcingaCheckMSSQLResource_Object_PageLifeExpectancyCritical$","order":"2"},"-SqlHost":{"set_if":"var str = macro(\"$IcingaCheckMSSQLResource_String_SqlHost$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLResource_String_SqlHost$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"10"},"-Verbosity":{"value":"$IcingaCheckMSSQLResource_Int32_Verbosity$","order":"13"},"-SqlPassword":{"value":"(ConvertTo-IcingaSecureString \u0027$IcingaCheckMSSQLResource_Securestring_SqlPassword$\u0027)","order":"9"},"-SqlDatabase":{"set_if":"var str = macro(\"$IcingaCheckMSSQLResource_String_SqlDatabase$\"); if (len(str) == 0) { return false; }; return true;","set_if_format":"expression","value":{"body":"var str = macro(\"$IcingaCheckMSSQLResource_String_SqlDatabase$\");\r\nvar argLen = len(str);\r\n\r\nif (argLen == 0) {\r\n return;\r\n}\r\n\r\nif (argLen != 0 \u0026\u0026 str.substr(0,1) == \"\u0027\" \u0026\u0026 str.substr(argLen - 1, argLen) == \"\u0027\") {\r\n return str;\r\n}\r\n\r\nreturn (\"\u0027\" + str + \"\u0027\");","type":"Function"},"order":"12"},"-PageLifeExpectancyWarning":{"value":"$IcingaCheckMSSQLResource_Object_PageLifeExpectancyWarning$","order":"3"}},"imports":["PowerShell Base"],"object_type":"object","vars":{"IcingaCheckMSSQLResource_Switchparameter_IntegratedSecurity":false,"ifw_api_arguments":{"SqlPort":{"value":"$IcingaCheckMSSQLResource_Int32_SqlPort$"},"AverageLatchWaitTimeCritical":{"value":"$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeCritical$"},"ThresholdInterval":{"value":"$IcingaCheckMSSQLResource_String_ThresholdInterval$"},"BufferCacheHitRatioCritical":{"value":"$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioCritical$"},"AverageLatchWaitTimeWarning":{"value":"$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeWarning$"},"SqlPassword":{"value":"$IcingaCheckMSSQLResource_Securestring_SqlPassword$"},"NoPerfData":{"set_if":"$IcingaCheckMSSQLResource_Switchparameter_NoPerfData$"},"SqlUsername":{"value":"$IcingaCheckMSSQLResource_String_SqlUsername$"},"IntegratedSecurity":{"set_if":"$IcingaCheckMSSQLResource_Switchparameter_IntegratedSecurity$"},"PageLifeExpectancyWarning":{"value":"$IcingaCheckMSSQLResource_Object_PageLifeExpectancyWarning$"},"PageLifeExpectancyCritical":{"value":"$IcingaCheckMSSQLResource_Object_PageLifeExpectancyCritical$"},"BufferCacheHitRatioWarning":{"value":"$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioWarning$"},"Verbosity":{"value":"$IcingaCheckMSSQLResource_Int32_Verbosity$"},"SqlHost":{"value":"$IcingaCheckMSSQLResource_String_SqlHost$"},"SqlDatabase":{"value":"$IcingaCheckMSSQLResource_String_SqlDatabase$"}},"ifw_api_command":"Invoke-IcingaCheckMSSQLResource","IcingaCheckMSSQLResource_Switchparameter_NoPerfData":false}},"PowerShell Base":{"methods_execute":"PluginCheck","object_name":"PowerShell Base","vars":{"IcingaPowerShellBase_String_ExecutionPolicy":"ByPass"},"is_string":null,"command":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","zone":null,"disabled":false,"fields":[{"datafield_id":2,"is_required":"n","var_filter":null}],"arguments":{"-C":{"value":"try { Use-Icinga -Minimal; } catch { Write-Output \u0027The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details\u0027; Write-Output \u0027Error:\u0027 $$($$_.Exception.Message)Components:`r`n$$( Get-Module -ListAvailable \u0027icinga-powershell-*\u0027 )`r`n\u0027Module-Path:\u0027`r`n$$($$Env:PSModulePath); exit 3; }; Exit-IcingaExecutePlugin -Command \u0027$ifw_api_command$\u0027 ","order":"0"},"-ExecutionPolicy":{"value":"$IcingaPowerShellBase_String_ExecutionPolicy$","order":"-1"},"-NoProfile":{"value":"-NoProfile","skip_key":true,"order":"-3"},"-NoLogo":{"value":"-NoLogo","skip_key":true,"order":"-2"}},"imports":[],"object_type":"object","timeout":"180"}},"Datafield":{"16":{"settings":{"visibility":"visible"},"description":"Allows this plugin to use the credentials of the current PowerShell session inherited by\nthe user the PowerShell is running with. If this is set and the user the PowerShell is\nrunning with can access to the MSSQL database you will not require to provide username\nand password","caption":"IntegratedSecurity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"16","varname":"IcingaCheckMSSQLResource_Switchparameter_IntegratedSecurity","format":null},"7":{"settings":{"visibility":"visible"},"description":"Critical threshold for the Average Latch Wait Time (ms) for latch requests that had to wait.","caption":"AverageLatchWaitTimeCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"7","varname":"IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeCritical","format":null},"5":{"settings":{"visibility":"visible"},"description":"Critical threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references.","caption":"PageLifeExpectancyCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"5","varname":"IcingaCheckMSSQLResource_Object_PageLifeExpectancyCritical","format":null},"18":{"settings":{"datalist":"IcingaCheckMSSQLResource Verbosity","behavior":"strict","data_type":"string"},"description":"Changes the behavior of the plugin output which check states are printed:\n0 (default): Only service checks/packages with state not OK will be printed\n1: Only services with not OK will be printed including OK checks of affected check packages including Package config\n2: Everything will be printed regardless of the check state\n3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])e","caption":"Verbosity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"18","varname":"IcingaCheckMSSQLResource_Int32_Verbosity","format":null},"12":{"settings":{"visibility":"hidden"},"description":"The password for connecting to the MSSQL database as secure string","caption":"SqlPassword","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"12","varname":"IcingaCheckMSSQLResource_Securestring_SqlPassword","format":null},"10":{"settings":{"visibility":"visible"},"description":"Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk.\nThe ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period\nof time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high.\nGenerally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension\nfeature.","caption":"BufferCacheHitRatioWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"10","varname":"IcingaCheckMSSQLResource_Object_BufferCacheHitRatioWarning","format":null},"2":{"settings":{"datalist":"PowerShell ExecutionPolicies","behavior":"strict","data_type":"string"},"description":"Defines with which Execution Policy the PowerShell is started","caption":"PowerShell Execution Policy","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"2","varname":"IcingaPowerShellBase_String_ExecutionPolicy","format":null},"8":{"settings":{"visibility":"visible"},"description":"Warning threshold for the Average Latch Wait Time (ms) for latch requests that had to wait.","caption":"AverageLatchWaitTimeWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"8","varname":"IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeWarning","format":null},"17":{"settings":{"visibility":"visible"},"description":"Disables the performance data output of this plugin","caption":"NoPerfData","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"17","varname":"IcingaCheckMSSQLResource_Switchparameter_NoPerfData","format":null},"11":{"settings":{"visibility":"visible"},"description":"The username for connecting to the MSSQL database","caption":"SqlUsername","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"11","varname":"IcingaCheckMSSQLResource_String_SqlUsername","format":null},"9":{"settings":{"visibility":"visible"},"description":"Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk.\nThe ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period\nof time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high.\nGenerally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension\nfeature.","caption":"BufferCacheHitRatioCritical","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"9","varname":"IcingaCheckMSSQLResource_Object_BufferCacheHitRatioCritical","format":null},"14":{"settings":{"visibility":"visible"},"description":"The port of the MSSQL server/instance to connect to with the provided credentials","caption":"SqlPort","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeNumber","originalId":"14","varname":"IcingaCheckMSSQLResource_Int32_SqlPort","format":null},"15":{"settings":{"visibility":"visible"},"description":"The name of a specific database to connect to. Leave empty to connect \"globally\"","caption":"SqlDatabase","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"15","varname":"IcingaCheckMSSQLResource_String_SqlDatabase","format":null},"6":{"settings":{"visibility":"visible"},"description":"Warning threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references.","caption":"PageLifeExpectancyWarning","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"6","varname":"IcingaCheckMSSQLResource_Object_PageLifeExpectancyWarning","format":null},"4":{"settings":{"visibility":"visible"},"description":"Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring.","caption":"ThresholdInterval","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"4","varname":"IcingaCheckMSSQLResource_String_ThresholdInterval","format":null},"13":{"settings":{"visibility":"visible"},"description":"The IP address or FQDN to the MSSQL server to connect to","caption":"SqlHost","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"13","varname":"IcingaCheckMSSQLResource_String_SqlHost","format":null}}} 2 | -------------------------------------------------------------------------------- /config/grafana/dashboards/windows-mssql-web.json: -------------------------------------------------------------------------------- 1 | { 2 | "annotations": { 3 | "list": [ 4 | { 5 | "builtIn": 1, 6 | "datasource": { 7 | "type": "grafana", 8 | "uid": "-- Grafana --" 9 | }, 10 | "enable": true, 11 | "hide": true, 12 | "iconColor": "rgba(0, 211, 255, 1)", 13 | "name": "Annotations & Alerts", 14 | "target": { 15 | "limit": 100, 16 | "matchAny": false, 17 | "tags": [], 18 | "type": "dashboard" 19 | }, 20 | "type": "dashboard" 21 | } 22 | ] 23 | }, 24 | "description": "Default Icinga for Windows Hyper-V dashboard, providing generic information for Hyper-V plugins for Icinga Web", 25 | "editable": true, 26 | "fiscalYearStartMonth": 0, 27 | "graphTooltip": 0, 28 | "id": 27, 29 | "links": [], 30 | "liveNow": false, 31 | "panels": [ 32 | { 33 | "datasource": { 34 | "type": "influxdb", 35 | "uid": "${influxdbdatasource}" 36 | }, 37 | "description": "", 38 | "fieldConfig": { 39 | "defaults": { 40 | "color": { 41 | "mode": "thresholds" 42 | }, 43 | "mappings": [], 44 | "noValue": "0", 45 | "thresholds": { 46 | "mode": "absolute", 47 | "steps": [ 48 | { 49 | "color": "green", 50 | "value": null 51 | }, 52 | { 53 | "color": "#EAB839", 54 | "value": 5 55 | }, 56 | { 57 | "color": "red", 58 | "value": 10 59 | } 60 | ] 61 | } 62 | }, 63 | "overrides": [] 64 | }, 65 | "gridPos": { 66 | "h": 7, 67 | "w": 8, 68 | "x": 0, 69 | "y": 0 70 | }, 71 | "id": 1, 72 | "options": { 73 | "colorMode": "background", 74 | "graphMode": "none", 75 | "justifyMode": "auto", 76 | "orientation": "horizontal", 77 | "reduceOptions": { 78 | "calcs": [ 79 | "lastNotNull" 80 | ], 81 | "fields": "", 82 | "limit": 100, 83 | "values": false 84 | }, 85 | "text": {}, 86 | "textMode": "auto" 87 | }, 88 | "pluginVersion": "9.0.6", 89 | "repeatDirection": "h", 90 | "targets": [ 91 | { 92 | "datasource": { 93 | "type": "influxdb", 94 | "uid": "${influxdbdatasource}" 95 | }, 96 | "hide": false, 97 | "query": "from(bucket: \"${influxbucket}\")\r\n |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\r\n |> filter(fn: (r) =>\r\n r._field == \"value\" and\r\n r.hostname == \"${hostname}\" and\r\n r.metric =~ /::ifw_mssqlbackupstatus::state\\b/ and\r\n r.service == \"${service}\" and\r\n r._value != 0\r\n )\r\n |> unique(column: \"_field\")\r\n |> map(fn: (r) => ({ _value:r._value, _time:r._time, _field: \"Unhealthy DB Backups\" }))\r\n |> count()", 98 | "refId": "DB Backup Health" 99 | } 100 | ], 101 | "title": "${hostname} Backup Problems", 102 | "transformations": [], 103 | "type": "stat" 104 | }, 105 | { 106 | "datasource": { 107 | "type": "influxdb", 108 | "uid": "${influxdbdatasource}" 109 | }, 110 | "description": "", 111 | "fieldConfig": { 112 | "defaults": { 113 | "color": { 114 | "mode": "thresholds" 115 | }, 116 | "mappings": [ 117 | { 118 | "options": { 119 | "1": { 120 | "color": "red", 121 | "index": 0, 122 | "text": "Stopped" 123 | }, 124 | "2": { 125 | "color": "super-light-green", 126 | "index": 1, 127 | "text": "Start Pending" 128 | }, 129 | "3": { 130 | "color": "super-light-red", 131 | "index": 2, 132 | "text": "Stop Pending" 133 | }, 134 | "4": { 135 | "color": "green", 136 | "index": 3, 137 | "text": "Running" 138 | }, 139 | "5": { 140 | "color": "light-green", 141 | "index": 4, 142 | "text": "Continue Pending" 143 | }, 144 | "6": { 145 | "color": "super-light-yellow", 146 | "index": 5, 147 | "text": "Pause Pending" 148 | }, 149 | "7": { 150 | "color": "light-yellow", 151 | "index": 6, 152 | "text": "Paused" 153 | } 154 | }, 155 | "type": "value" 156 | } 157 | ], 158 | "thresholds": { 159 | "mode": "absolute", 160 | "steps": [ 161 | { 162 | "color": "green", 163 | "value": null 164 | }, 165 | { 166 | "color": "red", 167 | "value": 80 168 | } 169 | ] 170 | } 171 | }, 172 | "overrides": [ 173 | { 174 | "matcher": { 175 | "id": "byFrameRefID", 176 | "options": "DB Health" 177 | }, 178 | "properties": [ 179 | { 180 | "id": "mappings", 181 | "value": [ 182 | { 183 | "options": { 184 | "1": { 185 | "index": 0, 186 | "text": "Stopped" 187 | }, 188 | "2": { 189 | "index": 1, 190 | "text": "Start Pending" 191 | }, 192 | "3": { 193 | "index": 2, 194 | "text": "Stop Pending" 195 | }, 196 | "4": { 197 | "index": 3, 198 | "text": "Running" 199 | }, 200 | "5": { 201 | "index": 4, 202 | "text": "Continue Pending" 203 | }, 204 | "6": { 205 | "index": 5, 206 | "text": "Pause Pending" 207 | }, 208 | "7": { 209 | "index": 6, 210 | "text": "Paused" 211 | } 212 | }, 213 | "type": "value" 214 | } 215 | ] 216 | } 217 | ] 218 | } 219 | ] 220 | }, 221 | "gridPos": { 222 | "h": 7, 223 | "w": 8, 224 | "x": 8, 225 | "y": 0 226 | }, 227 | "id": 2, 228 | "options": { 229 | "colorMode": "value", 230 | "graphMode": "none", 231 | "justifyMode": "auto", 232 | "orientation": "horizontal", 233 | "reduceOptions": { 234 | "calcs": [ 235 | "lastNotNull" 236 | ], 237 | "fields": "", 238 | "values": false 239 | }, 240 | "text": {}, 241 | "textMode": "auto" 242 | }, 243 | "pluginVersion": "9.0.6", 244 | "repeatDirection": "h", 245 | "targets": [ 246 | { 247 | "datasource": { 248 | "type": "influxdb", 249 | "uid": "${influxdbdatasource}" 250 | }, 251 | "query": "from(bucket: \"${influxbucket}\")\r\n |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\r\n |> filter(fn: (r) =>\r\n r._field == \"value\" and\r\n r.hostname == \"${hostname}\" and\r\n r.metric =~ /::ifw_mssqlhealth::state\\b/ and\r\n r.service == \"${service}\"\r\n )\r\n |> map(fn: (r) => ({ _value:r._value, _time:r._time, _field: r.metric }))", 252 | "refId": "DB Health" 253 | } 254 | ], 255 | "title": "${hostname} DB Health", 256 | "transformations": [ 257 | { 258 | "id": "renameByRegex", 259 | "options": { 260 | "regex": "/::ifw_mssqlhealth::state/", 261 | "renamePattern": "" 262 | } 263 | } 264 | ], 265 | "type": "stat" 266 | }, 267 | { 268 | "datasource": { 269 | "type": "influxdb", 270 | "uid": "${influxdbdatasource}" 271 | }, 272 | "description": "", 273 | "fieldConfig": { 274 | "defaults": { 275 | "color": { 276 | "mode": "thresholds" 277 | }, 278 | "mappings": [], 279 | "thresholds": { 280 | "mode": "absolute", 281 | "steps": [ 282 | { 283 | "color": "green", 284 | "value": null 285 | } 286 | ] 287 | } 288 | }, 289 | "overrides": [] 290 | }, 291 | "gridPos": { 292 | "h": 7, 293 | "w": 8, 294 | "x": 16, 295 | "y": 0 296 | }, 297 | "id": 3, 298 | "options": { 299 | "colorMode": "value", 300 | "graphMode": "none", 301 | "justifyMode": "auto", 302 | "orientation": "horizontal", 303 | "reduceOptions": { 304 | "calcs": [ 305 | "lastNotNull" 306 | ], 307 | "fields": "", 308 | "values": false 309 | }, 310 | "text": {}, 311 | "textMode": "auto" 312 | }, 313 | "pluginVersion": "9.0.6", 314 | "repeatDirection": "h", 315 | "targets": [ 316 | { 317 | "datasource": { 318 | "type": "influxdb", 319 | "uid": "${influxdbdatasource}" 320 | }, 321 | "query": "from(bucket: \"${influxbucket}\")\r\n |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\r\n |> filter(fn: (r) =>\r\n r._field == \"value\" and\r\n r.hostname == \"${hostname}\" and\r\n r.metric =~ /::ifw_mssqlperfcounter::/ and\r\n r.service == \"${service}\"\r\n )\r\n |> map(fn: (r) => ({ _value:r._value, _time:r._time, _field: r.metric }))", 322 | "refId": "DB Health" 323 | } 324 | ], 325 | "title": "${hostname} DB Performance Counter", 326 | "transformations": [ 327 | { 328 | "id": "renameByRegex", 329 | "options": { 330 | "regex": "/::ifw_mssqlperfcounter::/", 331 | "renamePattern": " " 332 | } 333 | } 334 | ], 335 | "type": "stat" 336 | }, 337 | { 338 | "datasource": { 339 | "type": "influxdb", 340 | "uid": "${influxdbdatasource}" 341 | }, 342 | "description": "", 343 | "fieldConfig": { 344 | "defaults": { 345 | "color": { 346 | "mode": "thresholds" 347 | }, 348 | "mappings": [], 349 | "noValue": "0", 350 | "thresholds": { 351 | "mode": "absolute", 352 | "steps": [ 353 | { 354 | "color": "green", 355 | "value": null 356 | } 357 | ] 358 | }, 359 | "unit": "percent" 360 | }, 361 | "overrides": [ 362 | { 363 | "matcher": { 364 | "id": "byFrameRefID", 365 | "options": "Buffer Cache Hit Ratio" 366 | }, 367 | "properties": [ 368 | { 369 | "id": "unit", 370 | "value": "percent" 371 | } 372 | ] 373 | }, 374 | { 375 | "matcher": { 376 | "id": "byFrameRefID", 377 | "options": "Average Latch Wait Time" 378 | }, 379 | "properties": [ 380 | { 381 | "id": "unit", 382 | "value": "s" 383 | } 384 | ] 385 | }, 386 | { 387 | "matcher": { 388 | "id": "byFrameRefID", 389 | "options": "Page Life Expectancy" 390 | }, 391 | "properties": [ 392 | { 393 | "id": "unit", 394 | "value": "none" 395 | } 396 | ] 397 | } 398 | ] 399 | }, 400 | "gridPos": { 401 | "h": 7, 402 | "w": 8, 403 | "x": 0, 404 | "y": 7 405 | }, 406 | "id": 4, 407 | "options": { 408 | "orientation": "auto", 409 | "reduceOptions": { 410 | "calcs": [ 411 | "lastNotNull" 412 | ], 413 | "fields": "", 414 | "values": false 415 | }, 416 | "showThresholdLabels": false, 417 | "showThresholdMarkers": true, 418 | "text": {} 419 | }, 420 | "pluginVersion": "9.0.6", 421 | "targets": [ 422 | { 423 | "datasource": { 424 | "type": "influxdb", 425 | "uid": "${influxdbdatasource}" 426 | }, 427 | "hide": false, 428 | "query": "from(bucket: \"${influxbucket}\")\r\n |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\r\n |> filter(fn: (r) =>\r\n r.hostname == \"${hostname}\" and\r\n (r._field == \"value\" or r._field == \"max\" or r._field == \"min\" or r._field == \"warn\" or r._field == \"crit\") and\r\n r.service == \"${service}\" and\r\n r.metric == \"sqlserverbuffermanager::ifw_mssqlresource::buffercachehitratio\"\r\n )\r\n |> map(fn: (r) => ({ _value:r._value, _time:r._time, _field: r.metric }))", 429 | "refId": "Buffer Cache Hit Ratio" 430 | }, 431 | { 432 | "datasource": { 433 | "type": "influxdb", 434 | "uid": "${influxdbdatasource}" 435 | }, 436 | "hide": false, 437 | "query": "from(bucket: \"${influxbucket}\")\r\n |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\r\n |> filter(fn: (r) =>\r\n r.hostname == \"${hostname}\" and\r\n (r._field == \"value\" or r._field == \"max\" or r._field == \"min\" or r._field == \"warn\" or r._field == \"crit\") and\r\n r.service == \"${service}\" and\r\n r.metric == \"sqlserverlatches::ifw_mssqlresource::averagelatchwaittimems\"\r\n )\r\n |> map(fn: (r) => ({ _value:r._value, _time:r._time, _field: r.metric }))", 438 | "refId": "Average Latch Wait Time" 439 | }, 440 | { 441 | "datasource": { 442 | "type": "influxdb", 443 | "uid": "${influxdbdatasource}" 444 | }, 445 | "hide": false, 446 | "query": "from(bucket: \"${influxbucket}\")\r\n |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\r\n |> filter(fn: (r) =>\r\n r.hostname == \"${hostname}\" and\r\n (r._field == \"value\" or r._field == \"max\" or r._field == \"min\" or r._field == \"warn\" or r._field == \"crit\") and\r\n r.service == \"${service}\" and\r\n r.metric == \"sqlserverbuffermanager::ifw_mssqlresource::pagelifeexpectancy\"\r\n )\r\n |> map(fn: (r) => ({ _value:r._value, _time:r._time, _field: r.metric }))", 447 | "refId": "Page Life Expectancy" 448 | } 449 | ], 450 | "title": "${hostname} Stats", 451 | "transformations": [ 452 | { 453 | "id": "renameByRegex", 454 | "options": { 455 | "regex": "sqlserverbuffermanager::ifw_mssqlresource::buffercachehitratio", 456 | "renamePattern": "Buffer Cache Hit Ratio" 457 | } 458 | }, 459 | { 460 | "id": "renameByRegex", 461 | "options": { 462 | "regex": "sqlserverlatches::ifw_mssqlresource::averagelatchwaittimems", 463 | "renamePattern": "Average Latch Wait Time" 464 | } 465 | }, 466 | { 467 | "id": "renameByRegex", 468 | "options": { 469 | "regex": "sqlserverbuffermanager::ifw_mssqlresource::pagelifeexpectancy", 470 | "renamePattern": "Page Life Expectancy" 471 | } 472 | } 473 | ], 474 | "type": "gauge" 475 | } 476 | ], 477 | "refresh": false, 478 | "schemaVersion": 36, 479 | "style": "dark", 480 | "tags": [ 481 | "mssql", 482 | "windows", 483 | "flux" 484 | ], 485 | "templating": { 486 | "list": [ 487 | { 488 | "current": { 489 | "selected": false, 490 | "text": "InfluxDB", 491 | "value": "InfluxDB" 492 | }, 493 | "description": "InfluxDB 2 DataSource for Icinga metrics", 494 | "hide": 0, 495 | "includeAll": false, 496 | "label": "InfluxDB DataSource", 497 | "multi": false, 498 | "name": "influxdbdatasource", 499 | "options": [], 500 | "query": "influxdb", 501 | "refresh": 1, 502 | "regex": "", 503 | "skipUrlSync": false, 504 | "type": "datasource" 505 | }, 506 | { 507 | "description": "Data Bucket for InfluxDB2 for Icinga monitoring data", 508 | "hide": 2, 509 | "label": "Icinga Data", 510 | "name": "influxbucket", 511 | "query": "icinga2", 512 | "skipUrlSync": false, 513 | "type": "constant" 514 | }, 515 | { 516 | "description": "The Icinga hostname to display data for", 517 | "hide": 2, 518 | "label": "Hostname", 519 | "name": "hostname", 520 | "query": "null", 521 | "skipUrlSync": false, 522 | "type": "constant" 523 | }, 524 | { 525 | "description": "The Icinga service to display data for", 526 | "hide": 2, 527 | "label": "Service", 528 | "name": "service", 529 | "query": "null", 530 | "skipUrlSync": false, 531 | "type": "constant" 532 | } 533 | ] 534 | }, 535 | "time": { 536 | "from": "now-1h", 537 | "to": "now" 538 | }, 539 | "timepicker": {}, 540 | "timezone": "", 541 | "title": "Windows-MSSQL-Web", 542 | "uid": "4JWfUAZVk", 543 | "version": 13, 544 | "weekStart": "" 545 | } -------------------------------------------------------------------------------- /config/grafana/icingaweb2-grafana/graphs.ini: -------------------------------------------------------------------------------- 1 | [Invoke-IcingaCheckMSSQLBackupStatus] 2 | dashboard = "windows-mssql-web" 3 | panelId = "1" 4 | orgId = "" 5 | repeatable = "no" 6 | dashboarduid = "4JWfUAZVk" 7 | 8 | [Invoke-IcingaCheckMSSQLHealth] 9 | dashboard = "windows-mssql-web" 10 | panelId = "2" 11 | orgId = "" 12 | repeatable = "no" 13 | dashboarduid = "4JWfUAZVk" 14 | 15 | [Invoke-IcingaCheckMSSQLPerfCounter] 16 | dashboard = "windows-mssql-web" 17 | panelId = "3" 18 | orgId = "" 19 | repeatable = "no" 20 | dashboarduid = "4JWfUAZVk" 21 | 22 | [Invoke-IcingaCheckMSSQLResource] 23 | dashboard = "windows-mssql-web" 24 | panelId = "4" 25 | orgId = "" 26 | repeatable = "no" 27 | dashboarduid = "4JWfUAZVk" -------------------------------------------------------------------------------- /config/icinga/Invoke-IcingaCheckMSSQLBackupStatus.conf: -------------------------------------------------------------------------------- 1 | object CheckCommand "Invoke-IcingaCheckMSSQLBackupStatus" { 2 | import "PowerShell Base" 3 | 4 | arguments += { 5 | "-TotalBackupSizeWarning" = { 6 | description = "Warning threshold for the total backupsize which represent a count of all backups" 7 | value = "$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeWarning$" 8 | order = 2 9 | } 10 | "-IncludeDatabase" = { 11 | description = "Specifies the database or databases which will be checked. Leave empty to fetch metrics from all databases on the given system" 12 | value = {{ 13 | var arr = macro("$IcingaCheckMSSQLBackupStatus_Array_IncludeDatabase$"); 14 | if (len(arr) == 0) { 15 | return "@()"; 16 | } 17 | var psarr = arr.map( 18 | x => if (typeof(x) == String) { 19 | var argLen = len(x); 20 | if (argLen != 0 && x.substr(0,1) == "'" && x.substr(argLen - 1, argLen) == "'") { 21 | x; 22 | } else { 23 | "'" + x + "'"; 24 | } 25 | } else { 26 | x; 27 | } 28 | ).join(","); 29 | return "@(" + psarr + ")"; 30 | }} 31 | order = 14 32 | } 33 | "-DatabaseStatusWarning" = { 34 | description = "Warning threshold for the database status: Online Restoring Recovering Recovering_Pending Suspect Emergency Offline Copying Offline_Secondary" 35 | value = "$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusWarning$" 36 | order = 12 37 | } 38 | "-ExecutionTimeCritical" = { 39 | description = "Critical threshold for the execution time, which returns the elapsed time how long the backup process took" 40 | value = "$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeCritical$" 41 | order = 11 42 | } 43 | "-NoPerfData" = { 44 | set_if = "$IcingaCheckMSSQLBackupStatus_Switchparameter_NoPerfData$" 45 | order = 99 46 | } 47 | "-SqlUsername" = { 48 | set_if = {{ 49 | var str = macro("$IcingaCheckMSSQLBackupStatus_String_SqlUsername$"); if (len(str) == 0) { return false; }; return true; 50 | }} 51 | description = "The username for connecting to the MSSQL database" 52 | value = {{ 53 | var str = macro("$IcingaCheckMSSQLBackupStatus_String_SqlUsername$"); 54 | var argLen = len(str); 55 | if (argLen == 0) { 56 | return; 57 | } 58 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 59 | return str; 60 | } 61 | return ("'" + str + "'"); 62 | }} 63 | order = 15 64 | } 65 | "-LastBackupLogAgeCritical" = { 66 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeCritical$" 67 | order = 7 68 | } 69 | "-LastBackupAgeWarning" = { 70 | description = "Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped" 71 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeWarning$" 72 | order = 8 73 | } 74 | "-ThresholdInterval" = { 75 | set_if = {{ 76 | var str = macro("$IcingaCheckMSSQLBackupStatus_String_ThresholdInterval$"); if (len(str) == 0) { return false; }; return true; 77 | }} 78 | description = "Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring." 79 | value = {{ 80 | var str = macro("$IcingaCheckMSSQLBackupStatus_String_ThresholdInterval$"); 81 | var argLen = len(str); 82 | if (argLen == 0) { 83 | return; 84 | } 85 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 86 | return str; 87 | } 88 | return ("'" + str + "'"); 89 | }} 90 | order = 100 91 | } 92 | "-ExecutionTimeWarning" = { 93 | description = "Warning threshold for the execution time, which returns the elapsed time how long the backup process took" 94 | value = "$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeWarning$" 95 | order = 10 96 | } 97 | "-LastBackupLogAgeWarning" = { 98 | description = "Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped" 99 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeWarning$" 100 | order = 6 101 | } 102 | "-AvgBackupSizeWarning" = { 103 | description = "Warning threshold for the average backupsize which represent an average backupsize of all backups" 104 | value = "$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeWarning$" 105 | order = 4 106 | } 107 | "-IntegratedSecurity" = { 108 | set_if = "$IcingaCheckMSSQLBackupStatus_Switchparameter_IntegratedSecurity$" 109 | order = 99 110 | } 111 | "-DatabaseStatusCritical" = { 112 | description = "Critical threshold for the database status: Online Restoring Recovering Recovering_Pending Suspect Emergency Offline Copying Offline_Secondary" 113 | value = "$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusCritical$" 114 | order = 13 115 | } 116 | "-SqlHost" = { 117 | set_if = {{ 118 | var str = macro("$IcingaCheckMSSQLBackupStatus_String_SqlHost$"); if (len(str) == 0) { return false; }; return true; 119 | }} 120 | description = "The IP address or FQDN to the MSSQL server to connect to" 121 | value = {{ 122 | var str = macro("$IcingaCheckMSSQLBackupStatus_String_SqlHost$"); 123 | var argLen = len(str); 124 | if (argLen == 0) { 125 | return; 126 | } 127 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 128 | return str; 129 | } 130 | return ("'" + str + "'"); 131 | }} 132 | order = 17 133 | } 134 | "-Verbosity" = { 135 | description = "Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])" 136 | value = "$IcingaCheckMSSQLBackupStatus_Object_Verbosity$" 137 | order = 20 138 | } 139 | "-TotalBackupSizeCritical" = { 140 | description = "Critical threshold for the total backupsize which represent a count of all backups" 141 | value = "$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeCritical$" 142 | order = 3 143 | } 144 | "-SqlPort" = { 145 | description = "The port of the MSSQL server/instance to connect to with the provided credentials" 146 | value = "$IcingaCheckMSSQLBackupStatus_Int32_SqlPort$" 147 | order = 18 148 | } 149 | "-IncludeDays" = { 150 | description = "Specifies the number of days to read the backup history from MSSQL. Over time, the history table can get quite large and if there is no maintenance task in place to shrink it, this script could time out. By default the entire history is evaluated." 151 | value = "$IcingaCheckMSSQLBackupStatus_Object_IncludeDays$" 152 | order = 19 153 | } 154 | "-LastBackupAgeCritical" = { 155 | description = "Critical threshold for the last backup age, which returns the elapsed time since a database was last backupped" 156 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeCritical$" 157 | order = 9 158 | } 159 | "-AvgBackupSizeCritical" = { 160 | description = "Critical threshold for the average backupsize which represent an average backupsize of all backups" 161 | value = "$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeCritical$" 162 | order = 5 163 | } 164 | "-SqlPassword" = { 165 | description = "The password for connecting to the MSSQL database as secure string" 166 | value = "(ConvertTo-IcingaSecureString '$IcingaCheckMSSQLBackupStatus_Securestring_SqlPassword$')" 167 | order = 16 168 | } 169 | } 170 | vars.IcingaCheckMSSQLBackupStatus_Switchparameter_NoPerfData = false 171 | vars.ifw_api_arguments = { 172 | "LastBackupAgeCritical" = { 173 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeCritical$" 174 | } 175 | "SqlPort" = { 176 | value = "$IcingaCheckMSSQLBackupStatus_Int32_SqlPort$" 177 | } 178 | "LastBackupAgeWarning" = { 179 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupAgeWarning$" 180 | } 181 | "IncludeDays" = { 182 | value = "$IcingaCheckMSSQLBackupStatus_Object_IncludeDays$" 183 | } 184 | "ExecutionTimeCritical" = { 185 | value = "$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeCritical$" 186 | } 187 | "NoPerfData" = { 188 | set_if = "$IcingaCheckMSSQLBackupStatus_Switchparameter_NoPerfData$" 189 | } 190 | "SqlHost" = { 191 | value = "$IcingaCheckMSSQLBackupStatus_String_SqlHost$" 192 | } 193 | "ExecutionTimeWarning" = { 194 | value = "$IcingaCheckMSSQLBackupStatus_Object_ExecutionTimeWarning$" 195 | } 196 | "DatabaseStatusCritical" = { 197 | value = "$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusCritical$" 198 | } 199 | "ThresholdInterval" = { 200 | value = "$IcingaCheckMSSQLBackupStatus_String_ThresholdInterval$" 201 | } 202 | "SqlPassword" = { 203 | value = "$IcingaCheckMSSQLBackupStatus_Securestring_SqlPassword$" 204 | } 205 | "AvgBackupSizeWarning" = { 206 | value = "$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeWarning$" 207 | } 208 | "LastBackupLogAgeWarning" = { 209 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeWarning$" 210 | } 211 | "SqlUsername" = { 212 | value = "$IcingaCheckMSSQLBackupStatus_String_SqlUsername$" 213 | } 214 | "IntegratedSecurity" = { 215 | set_if = "$IcingaCheckMSSQLBackupStatus_Switchparameter_IntegratedSecurity$" 216 | } 217 | "AvgBackupSizeCritical" = { 218 | value = "$IcingaCheckMSSQLBackupStatus_Object_AvgBackupSizeCritical$" 219 | } 220 | "LastBackupLogAgeCritical" = { 221 | value = "$IcingaCheckMSSQLBackupStatus_Object_LastBackupLogAgeCritical$" 222 | } 223 | "IncludeDatabase" = { 224 | value = "$IcingaCheckMSSQLBackupStatus_Array_IncludeDatabase$" 225 | } 226 | "DatabaseStatusWarning" = { 227 | value = "$IcingaCheckMSSQLBackupStatus_Object_DatabaseStatusWarning$" 228 | } 229 | "TotalBackupSizeCritical" = { 230 | value = "$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeCritical$" 231 | } 232 | "TotalBackupSizeWarning" = { 233 | value = "$IcingaCheckMSSQLBackupStatus_Object_TotalBackupSizeWarning$" 234 | } 235 | "Verbosity" = { 236 | value = "$IcingaCheckMSSQLBackupStatus_Object_Verbosity$" 237 | } 238 | } 239 | vars.ifw_api_command = "invoke-icingacheckmssqlbackupstatus" 240 | vars.IcingaCheckMSSQLBackupStatus_Switchparameter_IntegratedSecurity = false 241 | } 242 | -------------------------------------------------------------------------------- /config/icinga/Invoke-IcingaCheckMSSQLHealth.conf: -------------------------------------------------------------------------------- 1 | object CheckCommand "Invoke-IcingaCheckMSSQLHealth" { 2 | import "PowerShell Base" 3 | 4 | arguments += { 5 | "-Verbosity" = { 6 | description = "Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])" 7 | value = "$IcingaCheckMSSQLHealth_Int32_Verbosity$" 8 | order = 10 9 | } 10 | "-SqlUsername" = { 11 | set_if = {{ 12 | var str = macro("$IcingaCheckMSSQLHealth_String_SqlUsername$"); if (len(str) == 0) { return false; }; return true; 13 | }} 14 | description = "The username for connecting to the MSSQL database" 15 | value = {{ 16 | var str = macro("$IcingaCheckMSSQLHealth_String_SqlUsername$"); 17 | var argLen = len(str); 18 | if (argLen == 0) { 19 | return; 20 | } 21 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 22 | return str; 23 | } 24 | return ("'" + str + "'"); 25 | }} 26 | order = 5 27 | } 28 | "-ThresholdInterval" = { 29 | set_if = {{ 30 | var str = macro("$IcingaCheckMSSQLHealth_String_ThresholdInterval$"); if (len(str) == 0) { return false; }; return true; 31 | }} 32 | description = "Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring." 33 | value = {{ 34 | var str = macro("$IcingaCheckMSSQLHealth_String_ThresholdInterval$"); 35 | var argLen = len(str); 36 | if (argLen == 0) { 37 | return; 38 | } 39 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 40 | return str; 41 | } 42 | return ("'" + str + "'"); 43 | }} 44 | order = 100 45 | } 46 | "-SqlPassword" = { 47 | description = "The password for connecting to the MSSQL database as secure string" 48 | value = "(ConvertTo-IcingaSecureString '$IcingaCheckMSSQLHealth_Securestring_SqlPassword$')" 49 | order = 6 50 | } 51 | "-SqlPort" = { 52 | description = "The port of the MSSQL server/instance to connect to with the provided credentials" 53 | value = "$IcingaCheckMSSQLHealth_Int32_SqlPort$" 54 | order = 8 55 | } 56 | "-NoPerfData" = { 57 | set_if = "$IcingaCheckMSSQLHealth_Switchparameter_NoPerfData$" 58 | order = 99 59 | } 60 | "-Warning" = { 61 | description = "The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m)" 62 | value = "$IcingaCheckMSSQLHealth_Object_Warning$" 63 | order = 2 64 | } 65 | "-Critical" = { 66 | description = "The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m)" 67 | value = "$IcingaCheckMSSQLHealth_Object_Critical$" 68 | order = 3 69 | } 70 | "-SqlDatabase" = { 71 | set_if = {{ 72 | var str = macro("$IcingaCheckMSSQLHealth_String_SqlDatabase$"); if (len(str) == 0) { return false; }; return true; 73 | }} 74 | description = "The name of a specific database to connect to. Leave empty to connect 'globally'" 75 | value = {{ 76 | var str = macro("$IcingaCheckMSSQLHealth_String_SqlDatabase$"); 77 | var argLen = len(str); 78 | if (argLen == 0) { 79 | return; 80 | } 81 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 82 | return str; 83 | } 84 | return ("'" + str + "'"); 85 | }} 86 | order = 9 87 | } 88 | "-SqlHost" = { 89 | set_if = {{ 90 | var str = macro("$IcingaCheckMSSQLHealth_String_SqlHost$"); if (len(str) == 0) { return false; }; return true; 91 | }} 92 | description = "The IP address or FQDN to the MSSQL server to connect to" 93 | value = {{ 94 | var str = macro("$IcingaCheckMSSQLHealth_String_SqlHost$"); 95 | var argLen = len(str); 96 | if (argLen == 0) { 97 | return; 98 | } 99 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 100 | return str; 101 | } 102 | return ("'" + str + "'"); 103 | }} 104 | order = 7 105 | } 106 | "-Instance" = { 107 | set_if = {{ 108 | var str = macro("$IcingaCheckMSSQLHealth_String_Instance$"); if (len(str) == 0) { return false; }; return true; 109 | }} 110 | description = "The name of the database instance to check the service state for. Can either the MSSQL$DB1 or simply DB1 for example" 111 | value = {{ 112 | var str = macro("$IcingaCheckMSSQLHealth_String_Instance$"); 113 | var argLen = len(str); 114 | if (argLen == 0) { 115 | return; 116 | } 117 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 118 | return str; 119 | } 120 | return ("'" + str + "'"); 121 | }} 122 | order = 4 123 | } 124 | "-IntegratedSecurity" = { 125 | set_if = "$IcingaCheckMSSQLHealth_Switchparameter_IntegratedSecurity$" 126 | order = 99 127 | } 128 | } 129 | vars.IcingaCheckMSSQLHealth_Switchparameter_NoPerfData = false 130 | vars.ifw_api_arguments = { 131 | "SqlPort" = { 132 | value = "$IcingaCheckMSSQLHealth_Int32_SqlPort$" 133 | } 134 | "ThresholdInterval" = { 135 | value = "$IcingaCheckMSSQLHealth_String_ThresholdInterval$" 136 | } 137 | "SqlUsername" = { 138 | value = "$IcingaCheckMSSQLHealth_String_SqlUsername$" 139 | } 140 | "SqlPassword" = { 141 | value = "$IcingaCheckMSSQLHealth_Securestring_SqlPassword$" 142 | } 143 | "Critical" = { 144 | value = "$IcingaCheckMSSQLHealth_Object_Critical$" 145 | } 146 | "IntegratedSecurity" = { 147 | set_if = "$IcingaCheckMSSQLHealth_Switchparameter_IntegratedSecurity$" 148 | } 149 | "Instance" = { 150 | value = "$IcingaCheckMSSQLHealth_String_Instance$" 151 | } 152 | "Warning" = { 153 | value = "$IcingaCheckMSSQLHealth_Object_Warning$" 154 | } 155 | "NoPerfData" = { 156 | set_if = "$IcingaCheckMSSQLHealth_Switchparameter_NoPerfData$" 157 | } 158 | "SqlHost" = { 159 | value = "$IcingaCheckMSSQLHealth_String_SqlHost$" 160 | } 161 | "SqlDatabase" = { 162 | value = "$IcingaCheckMSSQLHealth_String_SqlDatabase$" 163 | } 164 | "Verbosity" = { 165 | value = "$IcingaCheckMSSQLHealth_Int32_Verbosity$" 166 | } 167 | } 168 | vars.ifw_api_command = "invoke-icingacheckmssqlhealth" 169 | vars.IcingaCheckMSSQLHealth_Switchparameter_IntegratedSecurity = false 170 | } 171 | -------------------------------------------------------------------------------- /config/icinga/Invoke-IcingaCheckMSSQLPerfCounter.conf: -------------------------------------------------------------------------------- 1 | object CheckCommand "Invoke-IcingaCheckMSSQLPerfCounter" { 2 | import "PowerShell Base" 3 | 4 | arguments += { 5 | "-Verbosity" = { 6 | description = "Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])" 7 | value = "$IcingaCheckMSSQLPerfCounter_Int32_Verbosity$" 8 | order = 10 9 | } 10 | "-SqlUsername" = { 11 | set_if = {{ 12 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_SqlUsername$"); if (len(str) == 0) { return false; }; return true; 13 | }} 14 | description = "The username for connecting to the MSSQL database" 15 | value = {{ 16 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_SqlUsername$"); 17 | var argLen = len(str); 18 | if (argLen == 0) { 19 | return; 20 | } 21 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 22 | return str; 23 | } 24 | return ("'" + str + "'"); 25 | }} 26 | order = 5 27 | } 28 | "-ThresholdInterval" = { 29 | set_if = {{ 30 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_ThresholdInterval$"); if (len(str) == 0) { return false; }; return true; 31 | }} 32 | description = "Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring." 33 | value = {{ 34 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_ThresholdInterval$"); 35 | var argLen = len(str); 36 | if (argLen == 0) { 37 | return; 38 | } 39 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 40 | return str; 41 | } 42 | return ("'" + str + "'"); 43 | }} 44 | order = 100 45 | } 46 | "-SqlPassword" = { 47 | description = "The password for connecting to the MSSQL database as secure string" 48 | value = "(ConvertTo-IcingaSecureString '$IcingaCheckMSSQLPerfCounter_Securestring_SqlPassword$')" 49 | order = 6 50 | } 51 | "-SqlPort" = { 52 | description = "The port of the MSSQL server/instance to connect to with the provided credentials" 53 | value = "$IcingaCheckMSSQLPerfCounter_Int32_SqlPort$" 54 | order = 8 55 | } 56 | "-NoPerfData" = { 57 | set_if = "$IcingaCheckMSSQLPerfCounter_Switchparameter_NoPerfData$" 58 | order = 99 59 | } 60 | "-Warning" = { 61 | description = "The warning threshold of the Performance Counter return values" 62 | value = "$IcingaCheckMSSQLPerfCounter_Object_Warning$" 63 | order = 2 64 | } 65 | "-Critical" = { 66 | description = "The critical threshold of the Performance Counter return values" 67 | value = "$IcingaCheckMSSQLPerfCounter_Object_Critical$" 68 | order = 3 69 | } 70 | "-SqlDatabase" = { 71 | set_if = {{ 72 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_SqlDatabase$"); if (len(str) == 0) { return false; }; return true; 73 | }} 74 | description = "The name of a specific database to connect to. Leave empty to connect 'globally'" 75 | value = {{ 76 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_SqlDatabase$"); 77 | var argLen = len(str); 78 | if (argLen == 0) { 79 | return; 80 | } 81 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 82 | return str; 83 | } 84 | return ("'" + str + "'"); 85 | }} 86 | order = 9 87 | } 88 | "-PerformanceCounter" = { 89 | description = "List of Performance Counters specified by their full path (example '\\SQLServer:Buffer Manager\\Buffer cache hit ratio') to fetch information for" 90 | value = {{ 91 | var arr = macro("$IcingaCheckMSSQLPerfCounter_Array_PerformanceCounter$"); 92 | if (len(arr) == 0) { 93 | return "@()"; 94 | } 95 | var psarr = arr.map( 96 | x => if (typeof(x) == String) { 97 | var argLen = len(x); 98 | if (argLen != 0 && x.substr(0,1) == "'" && x.substr(argLen - 1, argLen) == "'") { 99 | x; 100 | } else { 101 | "'" + x + "'"; 102 | } 103 | } else { 104 | x; 105 | } 106 | ).join(","); 107 | return "@(" + psarr + ")"; 108 | }} 109 | order = 4 110 | } 111 | "-SqlHost" = { 112 | set_if = {{ 113 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_SqlHost$"); if (len(str) == 0) { return false; }; return true; 114 | }} 115 | description = "The IP address or FQDN to the MSSQL server to connect to" 116 | value = {{ 117 | var str = macro("$IcingaCheckMSSQLPerfCounter_String_SqlHost$"); 118 | var argLen = len(str); 119 | if (argLen == 0) { 120 | return; 121 | } 122 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 123 | return str; 124 | } 125 | return ("'" + str + "'"); 126 | }} 127 | order = 7 128 | } 129 | "-IntegratedSecurity" = { 130 | set_if = "$IcingaCheckMSSQLPerfCounter_Switchparameter_IntegratedSecurity$" 131 | order = 99 132 | } 133 | } 134 | vars.IcingaCheckMSSQLPerfCounter_Switchparameter_IntegratedSecurity = false 135 | vars.ifw_api_arguments = { 136 | "SqlPort" = { 137 | value = "$IcingaCheckMSSQLPerfCounter_Int32_SqlPort$" 138 | } 139 | "ThresholdInterval" = { 140 | value = "$IcingaCheckMSSQLPerfCounter_String_ThresholdInterval$" 141 | } 142 | "Warning" = { 143 | value = "$IcingaCheckMSSQLPerfCounter_Object_Warning$" 144 | } 145 | "NoPerfData" = { 146 | set_if = "$IcingaCheckMSSQLPerfCounter_Switchparameter_NoPerfData$" 147 | } 148 | "SqlPassword" = { 149 | value = "$IcingaCheckMSSQLPerfCounter_Securestring_SqlPassword$" 150 | } 151 | "Critical" = { 152 | value = "$IcingaCheckMSSQLPerfCounter_Object_Critical$" 153 | } 154 | "IntegratedSecurity" = { 155 | set_if = "$IcingaCheckMSSQLPerfCounter_Switchparameter_IntegratedSecurity$" 156 | } 157 | "PerformanceCounter" = { 158 | value = "$IcingaCheckMSSQLPerfCounter_Array_PerformanceCounter$" 159 | } 160 | "SqlUsername" = { 161 | value = "$IcingaCheckMSSQLPerfCounter_String_SqlUsername$" 162 | } 163 | "SqlHost" = { 164 | value = "$IcingaCheckMSSQLPerfCounter_String_SqlHost$" 165 | } 166 | "SqlDatabase" = { 167 | value = "$IcingaCheckMSSQLPerfCounter_String_SqlDatabase$" 168 | } 169 | "Verbosity" = { 170 | value = "$IcingaCheckMSSQLPerfCounter_Int32_Verbosity$" 171 | } 172 | } 173 | vars.ifw_api_command = "invoke-icingacheckmssqlperfcounter" 174 | vars.IcingaCheckMSSQLPerfCounter_Switchparameter_NoPerfData = false 175 | } 176 | -------------------------------------------------------------------------------- /config/icinga/Invoke-IcingaCheckMSSQLResource.conf: -------------------------------------------------------------------------------- 1 | object CheckCommand "Invoke-IcingaCheckMSSQLResource" { 2 | import "PowerShell Base" 3 | 4 | arguments += { 5 | "-SqlUsername" = { 6 | set_if = {{ 7 | var str = macro("$IcingaCheckMSSQLResource_String_SqlUsername$"); if (len(str) == 0) { return false; }; return true; 8 | }} 9 | description = "The username for connecting to the MSSQL database" 10 | value = {{ 11 | var str = macro("$IcingaCheckMSSQLResource_String_SqlUsername$"); 12 | var argLen = len(str); 13 | if (argLen == 0) { 14 | return; 15 | } 16 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 17 | return str; 18 | } 19 | return ("'" + str + "'"); 20 | }} 21 | order = 8 22 | } 23 | "-AverageLatchWaitTimeWarning" = { 24 | description = "Warning threshold for the Average Latch Wait Time (ms) for latch requests that had to wait." 25 | value = "$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeWarning$" 26 | order = 5 27 | } 28 | "-NoPerfData" = { 29 | set_if = "$IcingaCheckMSSQLResource_Switchparameter_NoPerfData$" 30 | order = 99 31 | } 32 | "-SqlPort" = { 33 | description = "The port of the MSSQL server/instance to connect to with the provided credentials" 34 | value = "$IcingaCheckMSSQLResource_Int32_SqlPort$" 35 | order = 11 36 | } 37 | "-AverageLatchWaitTimeCritical" = { 38 | description = "Critical threshold for the Average Latch Wait Time (ms) for latch requests that had to wait." 39 | value = "$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeCritical$" 40 | order = 4 41 | } 42 | "-ThresholdInterval" = { 43 | set_if = {{ 44 | var str = macro("$IcingaCheckMSSQLResource_String_ThresholdInterval$"); if (len(str) == 0) { return false; }; return true; 45 | }} 46 | description = "Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring." 47 | value = {{ 48 | var str = macro("$IcingaCheckMSSQLResource_String_ThresholdInterval$"); 49 | var argLen = len(str); 50 | if (argLen == 0) { 51 | return; 52 | } 53 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 54 | return str; 55 | } 56 | return ("'" + str + "'"); 57 | }} 58 | order = 100 59 | } 60 | "-BufferCacheHitRatioCritical" = { 61 | description = "Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk. The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period of time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high. Generally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension feature." 62 | value = "$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioCritical$" 63 | order = 6 64 | } 65 | "-BufferCacheHitRatioWarning" = { 66 | description = "Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk. The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period of time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high. Generally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension feature." 67 | value = "$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioWarning$" 68 | order = 7 69 | } 70 | "-IntegratedSecurity" = { 71 | set_if = "$IcingaCheckMSSQLResource_Switchparameter_IntegratedSecurity$" 72 | order = 99 73 | } 74 | "-PageLifeExpectancyCritical" = { 75 | description = "Critical threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references." 76 | value = "$IcingaCheckMSSQLResource_Object_PageLifeExpectancyCritical$" 77 | order = 2 78 | } 79 | "-SqlHost" = { 80 | set_if = {{ 81 | var str = macro("$IcingaCheckMSSQLResource_String_SqlHost$"); if (len(str) == 0) { return false; }; return true; 82 | }} 83 | description = "The IP address or FQDN to the MSSQL server to connect to" 84 | value = {{ 85 | var str = macro("$IcingaCheckMSSQLResource_String_SqlHost$"); 86 | var argLen = len(str); 87 | if (argLen == 0) { 88 | return; 89 | } 90 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 91 | return str; 92 | } 93 | return ("'" + str + "'"); 94 | }} 95 | order = 10 96 | } 97 | "-Verbosity" = { 98 | description = "Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])e" 99 | value = "$IcingaCheckMSSQLResource_Int32_Verbosity$" 100 | order = 13 101 | } 102 | "-SqlPassword" = { 103 | description = "The password for connecting to the MSSQL database as secure string" 104 | value = "(ConvertTo-IcingaSecureString '$IcingaCheckMSSQLResource_Securestring_SqlPassword$')" 105 | order = 9 106 | } 107 | "-SqlDatabase" = { 108 | set_if = {{ 109 | var str = macro("$IcingaCheckMSSQLResource_String_SqlDatabase$"); if (len(str) == 0) { return false; }; return true; 110 | }} 111 | description = "The name of a specific database to connect to. Leave empty to connect 'globally'" 112 | value = {{ 113 | var str = macro("$IcingaCheckMSSQLResource_String_SqlDatabase$"); 114 | var argLen = len(str); 115 | if (argLen == 0) { 116 | return; 117 | } 118 | if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") { 119 | return str; 120 | } 121 | return ("'" + str + "'"); 122 | }} 123 | order = 12 124 | } 125 | "-PageLifeExpectancyWarning" = { 126 | description = "Warning threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references." 127 | value = "$IcingaCheckMSSQLResource_Object_PageLifeExpectancyWarning$" 128 | order = 3 129 | } 130 | } 131 | vars.IcingaCheckMSSQLResource_Switchparameter_IntegratedSecurity = false 132 | vars.ifw_api_arguments = { 133 | "SqlPort" = { 134 | value = "$IcingaCheckMSSQLResource_Int32_SqlPort$" 135 | } 136 | "AverageLatchWaitTimeCritical" = { 137 | value = "$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeCritical$" 138 | } 139 | "ThresholdInterval" = { 140 | value = "$IcingaCheckMSSQLResource_String_ThresholdInterval$" 141 | } 142 | "BufferCacheHitRatioCritical" = { 143 | value = "$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioCritical$" 144 | } 145 | "AverageLatchWaitTimeWarning" = { 146 | value = "$IcingaCheckMSSQLResource_Object_AverageLatchWaitTimeWarning$" 147 | } 148 | "SqlPassword" = { 149 | value = "$IcingaCheckMSSQLResource_Securestring_SqlPassword$" 150 | } 151 | "NoPerfData" = { 152 | set_if = "$IcingaCheckMSSQLResource_Switchparameter_NoPerfData$" 153 | } 154 | "SqlUsername" = { 155 | value = "$IcingaCheckMSSQLResource_String_SqlUsername$" 156 | } 157 | "IntegratedSecurity" = { 158 | set_if = "$IcingaCheckMSSQLResource_Switchparameter_IntegratedSecurity$" 159 | } 160 | "PageLifeExpectancyWarning" = { 161 | value = "$IcingaCheckMSSQLResource_Object_PageLifeExpectancyWarning$" 162 | } 163 | "PageLifeExpectancyCritical" = { 164 | value = "$IcingaCheckMSSQLResource_Object_PageLifeExpectancyCritical$" 165 | } 166 | "BufferCacheHitRatioWarning" = { 167 | value = "$IcingaCheckMSSQLResource_Object_BufferCacheHitRatioWarning$" 168 | } 169 | "Verbosity" = { 170 | value = "$IcingaCheckMSSQLResource_Int32_Verbosity$" 171 | } 172 | "SqlHost" = { 173 | value = "$IcingaCheckMSSQLResource_String_SqlHost$" 174 | } 175 | "SqlDatabase" = { 176 | value = "$IcingaCheckMSSQLResource_String_SqlDatabase$" 177 | } 178 | } 179 | vars.ifw_api_command = "invoke-icingacheckmssqlresource" 180 | vars.IcingaCheckMSSQLResource_Switchparameter_NoPerfData = false 181 | } 182 | -------------------------------------------------------------------------------- /config/icinga/PowerShell_Base.conf: -------------------------------------------------------------------------------- 1 | object CheckCommand "PowerShell Base" { 2 | import "plugin-check-command" 3 | command = [ 4 | "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" 5 | ] 6 | timeout = 3m 7 | arguments += { 8 | "-C" = { 9 | order = 0 10 | value = "try { Use-Icinga -Minimal; } catch { Write-Output 'The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details'; Write-Output 'Error:' $$($$_.Exception.Message)Components:`r`n$$( Get-Module -ListAvailable 'icinga-powershell-*' )`r`n'Module-Path:'`r`n$$($$Env:PSModulePath); exit 3; }; Exit-IcingaExecutePlugin -Command '$ifw_api_command$' " 11 | } 12 | "-ExecutionPolicy" = { 13 | order = -1 14 | value = "$IcingaPowerShellBase_String_ExecutionPolicy$" 15 | } 16 | "-NoLogo" = { 17 | order = -2 18 | set_if = "1" 19 | } 20 | "-NoProfile" = { 21 | order = -3 22 | set_if = "1" 23 | } 24 | } 25 | vars.IcingaPowerShellBase_String_ExecutionPolicy = "ByPass" 26 | } 27 | -------------------------------------------------------------------------------- /doc/01-Introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | This repository provides a number of check plugins for monitoring MSSQL databases on Windows with PowerShell and the [Icinga for Windows](https://icinga.com/docs/windows/latest) solution. 4 | 5 | To see the full list of available plugins for MSSQL and the documentation you can have a look on the [MSSQL Plugin page](10-Icinga-Plugins.md). 6 | 7 | ## Authentication 8 | 9 | For monitoring you will either require to authenticate by using a username and password against the database or by using the integrated security and adding the Icinga Agent user to the group of users being able to connect to the database. 10 | 11 | ## Requirements 12 | 13 | This repository will require 14 | 15 | * [Icinga PowerShell Framework v1.2.0](https://github.com/Icinga/icinga-powershell-framework/releases) or later 16 | * [Icinga PowerShell Plugins v1.2.0](https://github.com/Icinga/icinga-powershell-plugins/releases) or later 17 | 18 | ## Installation 19 | 20 | As all other Icinga for Windows components and extensions, the installation is straight forward. Further details and possibilities are explained within the [installation docs](02-Installation.md). 21 | -------------------------------------------------------------------------------- /doc/02-Installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | To install this [Icinga for Windows](https://icinga.com/docs/icinga-for-windows) component, you can use the [official Icinga repositories](https://packages.icinga.com/IcingaForWindows/). You can read more about this on how to [install components](https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/20-Install-Components/) for adding existing repositories or [create own repositories](https://icinga.com/docs/icinga-for-windows/latest/doc/120-Repository-Manager/07-Create-Own-Repositories/). 4 | 5 | ## General Note on Installation/Updates 6 | 7 | You should always stick to one way of installing/updating any modules for the [Icinga for Windows](https://icinga.com/docs/icinga-for-windows) solution. It is **not** supported and **not** recommended to mix different installation methods. 8 | 9 | ## Install Stable Version 10 | 11 | ```powershell 12 | Install-IcingaComponent -Name 'mssql'; 13 | ``` 14 | 15 | ## Install Snapshot Version 16 | 17 | ```powershell 18 | Install-IcingaComponent -Name 'mssql' -Snapshot; 19 | ``` 20 | 21 | ## Install Stable Updates 22 | 23 | ```powershell 24 | Update-Icinga -Name 'mssql'; 25 | ``` 26 | 27 | ## Install Snapshot Updates 28 | 29 | ```powershell 30 | Update-Icinga -Name 'mssql' -Snapshot; 31 | ``` 32 | -------------------------------------------------------------------------------- /doc/03-Icinga-Integration.md: -------------------------------------------------------------------------------- 1 | # Icinga Integration 2 | 3 | Once you followed the [Installation Guide](02-Installation.md) you are ready to start the integration into Icinga 2. This will allow you to configure your Check-Commands and start using them inside service templates and services. 4 | 5 | For this you will require to have the [Icinga PowerShell Framework](https://github.com/Icinga/icinga-powershell-framework) installed on your system. 6 | Once done, follow the [Icinga Integration](https://icinga.com/docs/icinga-for-windows/latest/doc/200-Icinga-Integration/01-Director-Baskets/) documentation there. 7 | -------------------------------------------------------------------------------- /doc/10-Icinga-Plugins.md: -------------------------------------------------------------------------------- 1 | # Icinga Plugins 2 | 3 | Below you will find a documentation for every single available plugin provided by this repository. Most of the plugins allow the usage of default Icinga threshold range handling, which is defined as follows: 4 | 5 | | Argument | Throws error on | Ok range | 6 | | --- | --- | --- | 7 | | 20 | < 0 or > 20 | 0 .. 20 | 8 | | 20: | < 20 | between 20 .. ∞ | 9 | | ~:20 | > 20 | between -∞ .. 20 | 10 | | 30:40 | < 30 or > 40 | between {30 .. 40} | 11 | | `@30:40 | ≥ 30 and ≤ 40 | outside -∞ .. 29 and 41 .. ∞ | 12 | 13 | Please ensure that you will escape the `@` if you are configuring it on the Icinga side. To do so, you will simply have to write an *\`* before the `@` symbol: \``@` 14 | 15 | To test thresholds with different input values, you can use the Framework Cmdlet `Get-IcingaHelpThresholds`. 16 | 17 | Each plugin ships with a constant Framework argument `-ThresholdInterval`. This can be used to modify the value your thresholds are compared against from the current, fetched value to one collected over time by the Icinga for Windows daemon. In case you [Collect Metrics Over Time](https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/) for specific time intervals, you can for example set the argument to `15m` to get the average value of 15m as base for your monitoring values. Please note that in this example, you will require to have collected the `15m` average for `Invoke-IcingaCheckCPU`. 18 | 19 | ```powershell 20 | icinga> icinga { Invoke-IcingaCheckCPU -Warning 20 -Critical 40 -Core _Total -ThresholdInterval 15m } 21 | 22 | [WARNING] CPU Load: [WARNING] Core Total (29,14817700%) 23 | \_ [WARNING] Core Total: 29,14817700% is greater than threshold 20% (15m avg.) 24 | | 'core_total_1'=31.545677%;;;0;100 'core_total_15'=29.148177%;20;40;0;100 'core_total_5'=28.827410%;;;0;100 'core_total_20'=30.032942%;;;0;100 'core_total_3'=27.731669%;;;0;100 'core_total'=33.87817%;;;0;100 25 | ``` 26 | 27 | | Plugin Name | Description | 28 | | --- | --- | 29 | | [Invoke-IcingaCheckMSSQLBackupStatus](plugins/01-Invoke-IcingaCheckMSSQLBackupStatus.md) | MSSQL plugin which checks for total backupsize, average backupsize, last backup age, last backup log age, last backup execution time, database status of a given database | 30 | | [Invoke-IcingaCheckMSSQLResource](plugins/04-Invoke-IcingaCheckMSSQLResource.md) | MSSQL plugin which checks for page life expectancy, buffer cache hit ratio', average latch wait time (ms) Performance Counters | 31 | | [Invoke-IcingaCheckMSSQLPerfCounter](plugins/03-Invoke-IcingaCheckMSSQLPerfCounter.md) | Checks specified Performance Counter inside the MSSQL database by fetching counters by a given name and compares them to input thresholds | 32 | | [Invoke-IcingaCheckMSSQLHealth](plugins/02-Invoke-IcingaCheckMSSQLHealth.md) | Checks if MSSQL services for a specific instance are running and if the connection to a database instance can be established | 33 | 34 | -------------------------------------------------------------------------------- /doc/30-Upgrading-Plugins.md: -------------------------------------------------------------------------------- 1 | # Upgrading Icinga PowerShell MSSQL 2 | 3 | Upgrading Icinga PowerShell MSSQL is usually quite straightforward. 4 | 5 | Specific version upgrades are described below. Please note that version updates are incremental. 6 | 7 | ## Upgrading to v1.1.0 (2021-03-02) 8 | 9 | To use the new MSSQL plugin version with the new check command configuration for Icinga Director and Icinga 2, you will require to update your entire environment to Icinga for Windows v1.4.0 before 10 | -------------------------------------------------------------------------------- /doc/31-Changelog.md: -------------------------------------------------------------------------------- 1 | # Icinga PowerShell MSSQL CHANGELOG 2 | 3 | **The latest release announcements are available on [https://icinga.com/blog/](https://icinga.com/blog/).** 4 | 5 | Please read the [upgrading](https://icinga.com/docs/windows/latest/mssql/doc/30-Upgrading-Plugins) 6 | documentation before upgrading to a new release. 7 | 8 | Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-mssql/milestones?state=closed). 9 | 10 | ## 1.6.0 (tbd) 11 | 12 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/8?closed=1) 13 | 14 | ### Enhancements 15 | 16 | ## 1.5.1 (tbd) 17 | 18 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/9?closed=1) 19 | 20 | ## Bugfixes 21 | 22 | * [#52](https://github.com/Icinga/icinga-powershell-mssql/pull/52) Fixes broken Icinga plain configuration 23 | 24 | ## 1.5.0 (2023-08-01) 25 | 26 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/7?closed=1) 27 | 28 | ### Enhancements 29 | 30 | * [51](https://github.com/Icinga/icinga-powershell-mssql/pull/51) Updates Icinga Director baskets and Icinga plain config for Icinga 2.14 31 | 32 | ## 1.4.0 (2022-08-30) 33 | 34 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/6?closed=1) 35 | 36 | ### Enhancements 37 | 38 | * [42](https://github.com/Icinga/icinga-powershell-mssql/pull/42) Adds option for `IncludeDays` to reduce the amount of backup data generated [ronnybremer] 39 | * [46](https://github.com/Icinga/icinga-powershell-mssql/pull/46) Updates configuration and dependencies for Icinga for Windows v1.10.0 40 | * [47](https://github.com/Icinga/icinga-powershell-mssql/pull/47) Adds new performance data handling for Icinga for Windows v1.10.0 and provides basic Grafana dashboards and Icinga Web integration 41 | * [48](https://github.com/Icinga/icinga-powershell-mssql/pull/48) Improves MSSQL backup plugin by fetching backups more granular by minutes now instead of hours 42 | 43 | ### Grafana Dashboards 44 | 45 | #### New Dashboards 46 | 47 | * MSSQL Base 48 | * Windows-MSSQL-Web 49 | 50 | #### New Plugin Integrations 51 | 52 | * Invoke-IcingaCheckMSSQLBackupStatus 53 | * Invoke-IcingaCheckMSSQLHealth 54 | * Invoke-IcingaCheckMSSQLPerfCounter 55 | * Invoke-IcingaCheckMSSQLResource 56 | 57 | ## 1.3.0 (2022-05-03) 58 | 59 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/5?closed=1) 60 | 61 | ### Bugfixes 62 | 63 | * [34](https://github.com/Icinga/icinga-powershell-mssql/issues/34) Fixes `IncludeDatabase` not being used by `Invoke-IcingaCheckMSSQLBackupStatus` 64 | 65 | ### Enhancements 66 | 67 | * [44](https://github.com/Icinga/icinga-powershell-mssql/pull/44) Adds support for Icinga for Windows v1.9.0 module isolation 68 | 69 | ## 1.2.0 (2021-06-02) 70 | 71 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/4?closed=1) 72 | 73 | ### Enhancements 74 | 75 | * [31](https://github.com/Icinga/icinga-powershell-mssql/pull/31) Updates plugins and configuration files for Icinga for Windows v1.5.0 76 | 77 | ### Bugfixes 78 | 79 | * [32](https://github.com/Icinga/icinga-powershell-mssql/issues/32) Fixes `MSSQLSERVER` service not being added by default for `Invoke-IcingaCheckMSSQLHealth` 80 | 81 | ## 1.1.0 (2021-03-02) 82 | 83 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/2?closed=1) 84 | 85 | ### Breaking Changes 86 | 87 | MSSQL v1.1.0 ships with new pre-compiled configuration for Icinga for Windows v1.4.0. Please ensure to update your entire environment before updating MSSQL plugins for CheckCommand configuration 88 | 89 | ### Enhancements 90 | 91 | * [#28](https://github.com/Icinga/icinga-powershell-mssql/pull/28) Updates Icinga config and dependency to v1.4.0 92 | 93 | ## 1.0.1 (2021-02-04) 94 | 95 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/3?closed=1) 96 | 97 | ### Bugfixes 98 | 99 | * [27](https://github.com/Icinga/icinga-powershell-mssql/pull/27) Fixes broken Icinga 2 plain conf files 100 | 101 | ### Enhancements 102 | 103 | * [#25](https://github.com/Icinga/icinga-powershell-mssql/pull/25) Adds Icinga 2 and Icinga Director pre-compiled configuration files and updates documentation 104 | 105 | ## 1.0.0 (2020-10-13) 106 | 107 | [Issue and PRs](https://github.com/Icinga/icinga-powershell-mssql/milestone/1?closed=1) 108 | 109 | ### Notes 110 | 111 | * Initial release candidate for the new Icinga PowerShell Plugins 112 | -------------------------------------------------------------------------------- /doc/plugins/01-Invoke-IcingaCheckMSSQLBackupStatus.md: -------------------------------------------------------------------------------- 1 | # Invoke-IcingaCheckMSSQLBackupStatus 2 | 3 | ## Description 4 | 5 | MSSQL plugin which checks for total backupsize, average backupsize, last backup age, 6 | last backup log age, last backup execution time, database status of a given database 7 | 8 | MSSQL plugin which checks for total backupsize, average backupsize, last backup age, 9 | last backup execution time, database status of a given database 10 | More Information on https://github.com/Icinga/icinga-powershell-mssql 11 | 12 | ## Permissions 13 | 14 | No special permissions required. 15 | 16 | ## Arguments 17 | 18 | | Argument | Type | Required | Default | Description | 19 | | --- | --- | --- | --- | --- | 20 | | TotalBackupSizeWarning | Object | false | | Warning threshold for the total backupsize which represent a count of all backups | 21 | | TotalBackupSizeCritical | Object | false | | Critical threshold for the total backupsize which represent a count of all backups | 22 | | AvgBackupSizeWarning | Object | false | | Warning threshold for the average backupsize which represent an average backupsize of all backups | 23 | | AvgBackupSizeCritical | Object | false | | Critical threshold for the average backupsize which represent an average backupsize of all backups | 24 | | LastBackupLogAgeWarning | Object | false | | Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped | 25 | | LastBackupLogAgeCritical | Object | false | | | 26 | | LastBackupAgeWarning | Object | false | | Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped | 27 | | LastBackupAgeCritical | Object | false | | Critical threshold for the last backup age, which returns the elapsed time since a database was last backupped | 28 | | ExecutionTimeWarning | Object | false | | Warning threshold for the execution time, which returns the elapsed time how long the backup process took | 29 | | ExecutionTimeCritical | Object | false | | Critical threshold for the execution time, which returns the elapsed time how long the backup process took | 30 | | DatabaseStatusWarning | Object | false | Offline | Warning threshold for the database status:
Online
Restoring
Recovering
Recovering_Pending
Suspect
Emergency
Offline
Copying
Offline_Secondary | 31 | | DatabaseStatusCritical | Object | false | Emergency | Critical threshold for the database status:
Online
Restoring
Recovering
Recovering_Pending
Suspect
Emergency
Offline
Copying
Offline_Secondary | 32 | | IncludeDatabase | Array | false | @() | Specifies the database or databases which will be checked. Leave empty to fetch metrics from
all databases on the given system | 33 | | SqlUsername | String | false | | The username for connecting to the MSSQL database | 34 | | SqlPassword | SecureString | false | | The password for connecting to the MSSQL database as secure string | 35 | | SqlHost | String | false | localhost | The IP address or FQDN to the MSSQL server to connect to | 36 | | SqlPort | Int32 | false | 1433 | The port of the MSSQL server/instance to connect to with the provided credentials | 37 | | IntegratedSecurity | SwitchParameter | false | False | Allows this plugin to use the credentials of the current PowerShell session inherited by
the user the PowerShell is running with. If this is set and the user the PowerShell is
running with can access to the MSSQL database you will not require to provide username
and password | 38 | | NoPerfData | SwitchParameter | false | False | Disables the performance data output of this plugin | 39 | | IncludeDays | Object | false | | Specifies the number of days to read the backup history from MSSQL. Over time, the history table can get quite
large and if there is no maintenance task in place to shrink it, this script could time out. By default the entire
history is evaluated. | 40 | | Verbosity | Object | false | 0 | Changes the behavior of the plugin output which check states are printed:
0 (default): Only service checks/packages with state not OK will be printed
1: Only services with not OK will be printed including OK checks of affected check packages including Package config
2: Everything will be printed regardless of the check state
3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) | 41 | | ThresholdInterval | String | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. | 42 | 43 | ## Examples 44 | 45 | ### Example Command 1 46 | 47 | ```powershell 48 | Invoke-IcingaMSSQLBackupOverallStatus -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com'; 49 | ``` 50 | 51 | ### Example Output 1 52 | 53 | ```powershell 54 | [OK] Check package "MSSQL Backup" 55 | | 'status'=0;6;5 'size'=10110976b;; 'execution_time'=0s;; 'age'=144000s;; 'average_size'=3370325.333333b;; 'status'=0;6;5 'size'=12664832b;; 56 | 'execution_time'=0s;; 'age'=493200s;; 'average_size'=6332416b;; 'status'=0;6;5 'size'=33445888b;; 'execution_time'=0s;; 'age'=144000s;; 'average_size'=16722944b;; 57 | ``` 58 | 59 | ### Example Command 2 60 | 61 | ```powershell 62 | Get-IcingaMSSQLBackupOverallStatus -IntegratedSecurity -SqlHost 'example.com' -IncludeDatabase 'ExampleDatabase','AnotherDatabase'; 63 | ``` 64 | 65 | ### Example Output 2 66 | 67 | ```powershell 68 | [OK] Check package "MSSQL Backup" 69 | | 'status'=0;6;5 'size'=12664832b;; 'execution_time'=0s;; 'age'=493200s;; 'average_size'=6332416b;; 'status'=0;6;5 'size'=10110976b;; 70 | 'execution_time'=0s;; 'age'=144000s;; 'average_size'=3370325.333333b;; 71 | ``` 72 | 73 | 74 | -------------------------------------------------------------------------------- /doc/plugins/02-Invoke-IcingaCheckMSSQLHealth.md: -------------------------------------------------------------------------------- 1 | # Invoke-IcingaCheckMSSQLHealth 2 | 3 | ## Description 4 | 5 | Checks if MSSQL services for a specific instance are running and if the connection 6 | to a database instance can be established 7 | 8 | The plugin will return CRITICAL in case MSSQL instance services are not running and 9 | WARNING or CRITICAL if the connection time is not matching your set thresholds 10 | More Information on https://github.com/Icinga/icinga-powershell-plugins 11 | 12 | ## Permissions 13 | 14 | No special permissions required. 15 | 16 | ## Arguments 17 | 18 | | Argument | Type | Required | Default | Description | 19 | | --- | --- | --- | --- | --- | 20 | | Warning | Object | false | | The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m) | 21 | | Critical | Object | false | | The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m) | 22 | | Instance | String | false | | The name of the database instance to check the service state for. Can either the MSSQL$DB1 or simply DB1
for example | 23 | | SqlUsername | String | false | | The username for connecting to the MSSQL database | 24 | | SqlPassword | SecureString | false | | The password for connecting to the MSSQL database as secure string | 25 | | SqlHost | String | false | localhost | The IP address or FQDN to the MSSQL server to connect to | 26 | | SqlPort | Int32 | false | 1433 | The port of the MSSQL server/instance to connect to with the provided credentials | 27 | | SqlDatabase | String | false | | The name of a specific database to connect to. Leave empty to connect "globally" | 28 | | IntegratedSecurity | SwitchParameter | false | False | Allows this plugin to use the credentials of the current PowerShell session inherited by
the user the PowerShell is running with. If this is set and the user the PowerShell is
running with can access to the MSSQL database you will not require to provide username
and password | 29 | | NoPerfData | SwitchParameter | false | False | Disables the performance data output of this plugin | 30 | | Verbosity | Int32 | false | 0 | Changes the behavior of the plugin output which check states are printed:
0 (default): Only service checks/packages with state not OK will be printed
1: Only services with not OK will be printed including OK checks of affected check packages including Package config
2: Everything will be printed regardless of the check state
3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) | 31 | | ThresholdInterval | String | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. | 32 | 33 | ## Examples 34 | 35 | ### Example Command 1 36 | 37 | ```powershell 38 | Invoke-IcingaCheckMSSQLHealth -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost example.com; 39 | ``` 40 | 41 | ### Example Output 1 42 | 43 | ```powershell 44 | [OK] Check package "MSSQL Health" 45 | | 'connection_time'=19ms;; 46 | ``` 47 | 48 | ### Example Command 2 49 | 50 | ```powershell 51 | Invoke-IcingaCheckMSSQLHealth -IntegratedSecurity -SqlHost example.com; 52 | ``` 53 | 54 | ### Example Output 2 55 | 56 | ```powershell 57 | [OK] Check package "MSSQL Health" 58 | | 'connection_time'=26ms;; 59 | ``` 60 | 61 | 62 | -------------------------------------------------------------------------------- /doc/plugins/03-Invoke-IcingaCheckMSSQLPerfCounter.md: -------------------------------------------------------------------------------- 1 | # Invoke-IcingaCheckMSSQLPerfCounter 2 | 3 | ## Description 4 | 5 | Checks specified Performance Counter inside the MSSQL database by fetching 6 | counters by a given name and compares them to input thresholds 7 | 8 | Checks specified Performance Counter inside the MSSQL database by fetching 9 | counters by a given name and compares them to input thresholds 10 | More Information on https://github.com/Icinga/icinga-powershell-mssql 11 | 12 | ## Permissions 13 | 14 | No special permissions required. 15 | 16 | ## Arguments 17 | 18 | | Argument | Type | Required | Default | Description | 19 | | --- | --- | --- | --- | --- | 20 | | Warning | Object | false | | The warning threshold of the Performance Counter return values | 21 | | Critical | Object | false | | The critical threshold of the Performance Counter return values | 22 | | PerformanceCounter | Array | false | @() | List of Performance Counters specified by their full path (example '\SQLServer:Buffer Manager\Buffer cache hit ratio')
to fetch information for | 23 | | SqlUsername | String | false | | The username for connecting to the MSSQL database | 24 | | SqlPassword | SecureString | false | | The password for connecting to the MSSQL database as secure string | 25 | | SqlHost | String | false | localhost | The IP address or FQDN to the MSSQL server to connect to | 26 | | SqlPort | Int32 | false | 1433 | The port of the MSSQL server/instance to connect to with the provided credentials | 27 | | SqlDatabase | String | false | | The name of a specific database to connect to. Leave empty to connect "globally" | 28 | | IntegratedSecurity | SwitchParameter | false | False | Allows this plugin to use the credentials of the current PowerShell session inherited by
the user the PowerShell is running with. If this is set and the user the PowerShell is
running with can access to the MSSQL database you will not require to provide username
and password | 29 | | NoPerfData | SwitchParameter | false | False | Disables the performance data output of this plugin | 30 | | Verbosity | Int32 | false | 0 | Changes the behavior of the plugin output which check states are printed:
0 (default): Only service checks/packages with state not OK will be printed
1: Only services with not OK will be printed including OK checks of affected check packages including Package config
2: Everything will be printed regardless of the check state
3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) | 31 | | ThresholdInterval | String | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. | 32 | 33 | ## Examples 34 | 35 | ### Example Command 1 36 | 37 | ```powershell 38 | Invoke-IcingaCheckMSSQLHealth -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com' -PerformanceCounter '\SQLServer:Buffer Manager\Buffer cache hit ratio', '\SQLServer:Latches\Average Latch Wait Time (ms)'; 39 | ``` 40 | 41 | ### Example Output 1 42 | 43 | ```powershell 44 | [OK] Check package "MSSQL Performance Counter" 45 | | 'sqlserverbuffer_manager'=22;; 'sqlserverlatches'=384199;; 46 | ``` 47 | 48 | ### Example Command 2 49 | 50 | ```powershell 51 | Invoke-IcingaCheckMSSQLHealth -IntegratedSecurity -SqlHost 'example.com' -PerformanceCounter '\SQLServer:Buffer Manager\Buffer cache hit ratio', '\SQLServer:Latches\Average Latch Wait Time (ms)'; 52 | ``` 53 | 54 | ### Example Output 2 55 | 56 | ```powershell 57 | [OK] Check package "MSSQL Performance Counter" 58 | | 'sqlserverbuffer_manager'=24;; 'sqlserverlatches'=387257;; 59 | ``` 60 | 61 | 62 | -------------------------------------------------------------------------------- /doc/plugins/04-Invoke-IcingaCheckMSSQLResource.md: -------------------------------------------------------------------------------- 1 | # Invoke-IcingaCheckMSSQLResource 2 | 3 | ## Description 4 | 5 | MSSQL plugin which checks for page life expectancy, buffer cache hit ratio', 6 | average latch wait time (ms) Performance Counters 7 | 8 | MSSQL plugin which checks for page life expectancy, buffer cache hit ratio', 9 | average latch wait time (ms) Performance Counters 10 | More Information on https://github.com/Icinga/icinga-powershell-mssql 11 | 12 | ## Permissions 13 | 14 | No special permissions required. 15 | 16 | ## Arguments 17 | 18 | | Argument | Type | Required | Default | Description | 19 | | --- | --- | --- | --- | --- | 20 | | PageLifeExpectancyCritical | Object | false | | Critical threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references. | 21 | | PageLifeExpectancyWarning | Object | false | | Warning threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references. | 22 | | AverageLatchWaitTimeCritical | Object | false | | Critical threshold for the Average Latch Wait Time (ms) for latch requests that had to wait. | 23 | | AverageLatchWaitTimeWarning | Object | false | | Warning threshold for the Average Latch Wait Time (ms) for latch requests that had to wait. | 24 | | BufferCacheHitRatioCritical | Object | false | | Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk.
The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period
of time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high.
Generally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension
feature. | 25 | | BufferCacheHitRatioWarning | Object | false | | Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk.
The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period
of time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high.
Generally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension
feature. | 26 | | SqlUsername | String | false | | The username for connecting to the MSSQL database | 27 | | SqlPassword | SecureString | false | | The password for connecting to the MSSQL database as secure string | 28 | | SqlHost | String | false | localhost | The IP address or FQDN to the MSSQL server to connect to | 29 | | SqlPort | Int32 | false | 1433 | The port of the MSSQL server/instance to connect to with the provided credentials | 30 | | SqlDatabase | String | false | | The name of a specific database to connect to. Leave empty to connect "globally" | 31 | | IntegratedSecurity | SwitchParameter | false | False | Allows this plugin to use the credentials of the current PowerShell session inherited by
the user the PowerShell is running with. If this is set and the user the PowerShell is
running with can access to the MSSQL database you will not require to provide username
and password | 32 | | NoPerfData | SwitchParameter | false | False | Disables the performance data output of this plugin | 33 | | Verbosity | Int32 | false | 0 | Changes the behavior of the plugin output which check states are printed:
0 (default): Only service checks/packages with state not OK will be printed
1: Only services with not OK will be printed including OK checks of affected check packages including Package config
2: Everything will be printed regardless of the check state
3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])e | 34 | | ThresholdInterval | String | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. | 35 | 36 | ## Examples 37 | 38 | ### Example Command 1 39 | 40 | ```powershell 41 | Invoke-IcingaCheckMSSQLResource -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com'; 42 | ``` 43 | 44 | ### Example Output 1 45 | 46 | ```powershell 47 | [OK] Check package "MSSQL Performance" 48 | | 'buffer_cache_hit_ratio'=62;; 'page_life_expectancy'=300;; 'average_latch_wait_time_ms'=389839;; 49 | ``` 50 | 51 | ### Example Command 2 52 | 53 | ```powershell 54 | Invoke-IcingaCheckMSSQLResource -IntegratedSecurity -SqlHost 'example.com'; 55 | ``` 56 | 57 | ### Example Output 2 58 | 59 | ```powershell 60 | [OK] Check package "MSSQL Performance" 61 | | 'buffer_cache_hit_ratio'=2;; 'page_life_expectancy'=300;; 'average_latch_wait_time_ms'=389839;; 62 | ``` 63 | 64 | 65 | -------------------------------------------------------------------------------- /icinga-powershell-mssql.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '1.6.0' 3 | GUID = '8441b44a-e105-42b7-82c9-8ecf69c13b8b' 4 | # ModuleToProcess = 'icinga-powershell-mssql.psm1' 5 | Author = 'Lord Hepipud, pdorschner' 6 | CompanyName = 'Icinga GmbH' 7 | Copyright = '(c) 2021 Icinga GmbH | GPLv2' 8 | Description = 'A collection of Icinga PowerShell MSSQL plugins for the Icinga PowerShell Framework' 9 | PowerShellVersion = '4.0' 10 | RequiredModules = @( 11 | @{ModuleName = 'icinga-powershell-framework'; ModuleVersion = '1.10.0' }, 12 | @{ModuleName = 'icinga-powershell-plugins'; ModuleVersion = '1.10.0' } 13 | ) 14 | NestedModules = @( 15 | '.\compiled\icinga-powershell-mssql.ifw_compilation.psm1' 16 | ) 17 | FunctionsToExport = @( 18 | 'Import-IcingaPowerShellComponentMSSQL', 19 | 'Invoke-IcingaCheckMSSQLBackupStatus', 20 | 'Invoke-IcingaCheckMSSQLResource', 21 | 'Invoke-IcingaCheckMSSQLPerfCounter', 22 | 'Invoke-IcingaCheckMSSQLHealth' 23 | ) 24 | CmdletsToExport = @( 25 | ) 26 | VariablesToExport = @( 27 | 'MSSQLProviderEnums' 28 | ) 29 | PrivateData = @{ 30 | PSData = @{ 31 | Tags = @( 'icinga', 'icinga2', 'mssqlplugins', 'icingamssql', 'icinga2mssql', 'icingawindows') 32 | LicenseUri = 'https://github.com/Icinga/icinga-powershell-mssql/blob/master/LICENSE' 33 | ProjectUri = 'https://github.com/Icinga/icinga-powershell-mssql' 34 | ReleaseNotes = 'https://github.com/Icinga/icinga-powershell-mssql/releases' 35 | }; 36 | Version = 'v1.6.0'; 37 | Name = 'Windows MSSQL'; 38 | Type = 'plugins'; 39 | Function = ''; 40 | Endpoint = ''; 41 | } 42 | HelpInfoURI = 'https://github.com/Icinga/icinga-powershell-mssql' 43 | } 44 | 45 | -------------------------------------------------------------------------------- /icinga-powershell-mssql.psm1: -------------------------------------------------------------------------------- 1 | function Import-IcingaPowerShellComponentMSSQL() 2 | { 3 | # Allows other components to load this component 4 | } 5 | 6 | Export-ModuleMember -Variable @('MSSQLProviderEnums'); 7 | -------------------------------------------------------------------------------- /plugins/Invoke-IcingaCheckMSSQLBackupStatus.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | MSSQL plugin which checks for total backupsize, average backupsize, last backup age, 4 | last backup log age, last backup execution time, database status of a given database 5 | .DESCRIPTION 6 | MSSQL plugin which checks for total backupsize, average backupsize, last backup age, 7 | last backup execution time, database status of a given database 8 | More Information on https://github.com/Icinga/icinga-powershell-mssql 9 | .FUNCTIONALITY 10 | MSSQL plugin which checks for total backupsize, average backupsize, last backup age, 11 | last backup execution time, database status of a given database 12 | .EXAMPLE 13 | PS>Invoke-IcingaMSSQLBackupOverallStatus -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com'; 14 | [OK] Check package "MSSQL Backup" 15 | | 'status'=0;6;5 'size'=10110976b;; 'execution_time'=0s;; 'age'=144000s;; 'average_size'=3370325.333333b;; 'status'=0;6;5 'size'=12664832b;; 16 | 'execution_time'=0s;; 'age'=493200s;; 'average_size'=6332416b;; 'status'=0;6;5 'size'=33445888b;; 'execution_time'=0s;; 'age'=144000s;; 'average_size'=16722944b;; 17 | .EXAMPLE 18 | PS>Get-IcingaMSSQLBackupOverallStatus -IntegratedSecurity -SqlHost 'example.com' -IncludeDatabase 'ExampleDatabase','AnotherDatabase'; 19 | [OK] Check package "MSSQL Backup" 20 | | 'status'=0;6;5 'size'=12664832b;; 'execution_time'=0s;; 'age'=493200s;; 'average_size'=6332416b;; 'status'=0;6;5 'size'=10110976b;; 21 | 'execution_time'=0s;; 'age'=144000s;; 'average_size'=3370325.333333b;; 22 | .PARAMETER TotalBackupSizeWarning 23 | Warning threshold for the total backupsize which represent a count of all backups 24 | .PARAMETER TotalBackupSizeCritical 25 | Critical threshold for the total backupsize which represent a count of all backups 26 | .PARAMETER AvgBackupSizeWarning 27 | Warning threshold for the average backupsize which represent an average backupsize of all backups 28 | .PARAMETER AvgBackupSizeCritical 29 | Critical threshold for the average backupsize which represent an average backupsize of all backups 30 | .PARAMETER LastBackupLogAgeWarning 31 | Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped 32 | .PARAMETER LastBackupAgeWarning 33 | Warning threshold for the last log backup age, which returns the elapsed time since a database was last backupped 34 | .PARAMETER LastBackupAgeCritical 35 | Critical threshold for the last backup age, which returns the elapsed time since a database was last backupped 36 | .PARAMETER ExecutionTimeWarning 37 | Warning threshold for the execution time, which returns the elapsed time how long the backup process took 38 | .PARAMETER ExecutionTimeCritical 39 | Critical threshold for the execution time, which returns the elapsed time how long the backup process took 40 | .PARAMETER DatabaseStatusWarning 41 | Warning threshold for the database status: 42 | Online 43 | Restoring 44 | Recovering 45 | Recovering_Pending 46 | Suspect 47 | Emergency 48 | Offline 49 | Copying 50 | Offline_Secondary 51 | .PARAMETER DatabaseStatusCritical 52 | Critical threshold for the database status: 53 | Online 54 | Restoring 55 | Recovering 56 | Recovering_Pending 57 | Suspect 58 | Emergency 59 | Offline 60 | Copying 61 | Offline_Secondary 62 | .PARAMETER IncludeDatabase 63 | Specifies the database or databases which will be checked. Leave empty to fetch metrics from 64 | all databases on the given system 65 | .PARAMETER SqlUsername 66 | The username for connecting to the MSSQL database 67 | .PARAMETER SqlPassword 68 | The password for connecting to the MSSQL database as secure string 69 | .PARAMETER SqlHost 70 | The IP address or FQDN to the MSSQL server to connect to 71 | .PARAMETER SqlPort 72 | The port of the MSSQL server/instance to connect to with the provided credentials 73 | .PARAMETER IntegratedSecurity 74 | Allows this plugin to use the credentials of the current PowerShell session inherited by 75 | the user the PowerShell is running with. If this is set and the user the PowerShell is 76 | running with can access to the MSSQL database you will not require to provide username 77 | and password 78 | .PARAMETER NoPerfData 79 | Disables the performance data output of this plugin 80 | .PARAMETER IncludeDays 81 | Specifies the number of days to read the backup history from MSSQL. Over time, the history table can get quite 82 | large and if there is no maintenance task in place to shrink it, this script could time out. By default the entire 83 | history is evaluated. 84 | .PARAMETER Verbosity 85 | Changes the behavior of the plugin output which check states are printed: 86 | 0 (default): Only service checks/packages with state not OK will be printed 87 | 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 88 | 2: Everything will be printed regardless of the check state 89 | 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) 90 | .INPUTS 91 | System.Array 92 | .OUTPUTS 93 | System.String 94 | .LINK 95 | https://github.com/Icinga/icinga-powershell-mssql 96 | .NOTES 97 | #> 98 | 99 | function Invoke-IcingaCheckMSSQLBackupStatus 100 | { 101 | param ( 102 | $TotalBackupSizeWarning = $null, 103 | $TotalBackupSizeCritical = $null, 104 | $AvgBackupSizeWarning = $null, 105 | $AvgBackupSizeCritical = $null, 106 | $LastBackupLogAgeWarning = $null, 107 | $LastBackupLogAgeCritical = $null, 108 | $LastBackupAgeWarning = $null, 109 | $LastBackupAgeCritical = $null, 110 | $ExecutionTimeWarning = $null, 111 | $ExecutionTimeCritical = $null, 112 | [ValidateSet('Online', 'Restoring', 'Recovering', 'Recovering_Pending', 'Suspect', 'Emergency', 'Offline', 'Copying', 'Offline_Secondary')] 113 | $DatabaseStatusWarning = 'Offline', 114 | [ValidateSet('Online', 'Restoring', 'Recovering', 'Recovering_Pending', 'Suspect', 'Emergency', 'Offline', 'Copying', 'Offline_Secondary')] 115 | $DatabaseStatusCritical = 'Emergency', 116 | [array]$IncludeDatabase = @(), 117 | [string]$SqlUsername, 118 | [securestring]$SqlPassword, 119 | [string]$SqlHost = "localhost", 120 | [int]$SqlPort = 1433, 121 | [switch]$IntegratedSecurity = $FALSE, 122 | [switch]$NoPerfData, 123 | $IncludeDays = $null, 124 | [ValidateSet(0, 1, 2, 3)] 125 | $Verbosity = 0 126 | ) 127 | 128 | $SqlConnection = Open-IcingaMSSQLConnection -Username $SqlUsername -Password $SqlPassword -Address $SqlHost -IntegratedSecurity:$IntegratedSecurity -Port $SqlPort; 129 | $BackupSet = Get-IcingaMSSQLBackupOverallStatus -SqlConnection $SqlConnection -IncludeDatabase $IncludeDatabase -IncludeDays $IncludeDays; 130 | $InstanceName = Get-IcingaMSSQLInstanceName -SqlConnection $SqlConnection; 131 | $CheckPackage = New-IcingaCheckPackage -Name ([string]::Format('MSSQL Backup ({0})', $InstanceName)) -OperatorAnd -Verbose $Verbosity; 132 | 133 | Close-IcingaMSSQLConnection -SqlConnection $SqlConnection; 134 | 135 | foreach ($Backup in $BackupSet.Keys) { 136 | $BackupObject = $BackupSet[$Backup].backup; 137 | 138 | $DBPackage = New-IcingaCheckPackage -Name $Backup -OperatorAnd -Verbose $Verbosity; 139 | 140 | $DBPackage.AddCheck( 141 | (New-IcingaCheck -Name 'Size' -Unit 'b' -Value $BackupObject.TotalBackupSize -MetricIndex $Backup -MetricName 'size').WarnOutOfRange($TotalBackupSizeWarning).CritOutOfRange($TotalBackupSizeCritical) 142 | ); 143 | $DBPackage.AddCheck( 144 | (New-IcingaCheck -Name 'Average Size' -Unit 'b' -Value $BackupObject.AvgBackupSize -MetricIndex $Backup -MetricName 'averagesize').WarnOutOfRange($AvgBackupSizeWarning).CritOutOfRange($AvgBackupSizeCritical) 145 | ); 146 | $DBPackage.AddCheck( 147 | (New-IcingaCheck -Name 'Log age' -Unit 's' -Value $BackupObject.LastBackupLogAge -MetricIndex $Backup -MetricName 'logage').WarnOutOfRange($LastBackupLogAgeWarning).CritOutOfRange($LastBackupLogAgeCritical) 148 | ); 149 | $DBPackage.AddCheck( 150 | (New-IcingaCheck -Name 'Age' -Unit 's' -Value $BackupObject.LastBackupAge -MetricIndex $Backup -MetricName 'age').WarnOutOfRange($LastBackupAgeWarning).CritOutOfRange($LastBackupAgeCritical) 151 | ); 152 | $DBPackage.AddCheck( 153 | ( 154 | New-IcingaCheck ` 155 | -Name 'Execution Time' ` 156 | -Unit 's' ` 157 | -Value $BackupObject.ExecutionTime ` 158 | -MetricIndex $Backup ` 159 | -MetricName 'executiontime' 160 | ).WarnOutOfRange($ExecutionTimeWarning).CritOutOfRange($ExecutionTimeCritical) 161 | ); 162 | $DBPackage.AddCheck( 163 | ( 164 | New-IcingaCheck ` 165 | -Name 'Status' ` 166 | -Value $BackupObject.Status ` 167 | -Translation $MSSQLProviderEnums.MSSQLDatabaseState ` 168 | -ObjectExists $BackupObject.Status ` 169 | -MetricIndex $Backup ` 170 | -MetricName 'state' 171 | ).WarnIfMatch($MSSQLProviderEnums.MSSQLDatabaseStateName[$DatabaseStatusWarning]).CritIfMatch($MSSQLProviderEnums.MSSQLDatabaseStateName[$DatabaseStatusCritical]) 172 | ); 173 | 174 | $CheckPackage.AddCheck($DBPackage); 175 | } 176 | 177 | return (New-IcingaCheckResult -Check $CheckPackage -Compile); 178 | } 179 | -------------------------------------------------------------------------------- /plugins/Invoke-IcingaCheckMSSQLHealth.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Checks if MSSQL services for a specific instance are running and if the connection 4 | to a database instance can be established 5 | .DESCRIPTION 6 | The plugin will return CRITICAL in case MSSQL instance services are not running and 7 | WARNING or CRITICAL if the connection time is not matching your set thresholds 8 | More Information on https://github.com/Icinga/icinga-powershell-plugins 9 | .FUNCTIONALITY 10 | Checks if MSSQL services for a specific instance are running and if the connection 11 | to a database instance can be established 12 | .EXAMPLE 13 | PS>Invoke-IcingaCheckMSSQLHealth -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost example.com; 14 | [OK] Check package "MSSQL Health" 15 | | 'connection_time'=19ms;; 16 | .EXAMPLE 17 | PS>Invoke-IcingaCheckMSSQLHealth -IntegratedSecurity -SqlHost example.com; 18 | [OK] Check package "MSSQL Health" 19 | | 'connection_time'=26ms;; 20 | .PARAMETER Warning 21 | The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m) 22 | .PARAMETER Critical 23 | The warning threshold for the connection time to the MSSQL database as time interval (ms, s, h, m) 24 | .PARAMETER Instance 25 | The name of the database instance to check the service state for. Can either the MSSQL$DB1 or simply DB1 26 | for example 27 | .PARAMETER SqlUsername 28 | The username for connecting to the MSSQL database 29 | .PARAMETER SqlPassword 30 | The password for connecting to the MSSQL database as secure string 31 | .PARAMETER SqlHost 32 | The IP address or FQDN to the MSSQL server to connect to 33 | .PARAMETER SqlPort 34 | The port of the MSSQL server/instance to connect to with the provided credentials 35 | .PARAMETER SqlDatabase 36 | The name of a specific database to connect to. Leave empty to connect "globally" 37 | .PARAMETER IntegratedSecurity 38 | Allows this plugin to use the credentials of the current PowerShell session inherited by 39 | the user the PowerShell is running with. If this is set and the user the PowerShell is 40 | running with can access to the MSSQL database you will not require to provide username 41 | and password 42 | .PARAMETER NoPerfData 43 | Disables the performance data output of this plugin 44 | .PARAMETER Verbosity 45 | Changes the behavior of the plugin output which check states are printed: 46 | 0 (default): Only service checks/packages with state not OK will be printed 47 | 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 48 | 2: Everything will be printed regardless of the check state 49 | 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) 50 | .INPUTS 51 | System.Array 52 | .OUTPUTS 53 | System.String 54 | .LINK 55 | https://github.com/Icinga/icinga-powershell-mssql 56 | .NOTES 57 | #> 58 | 59 | function Invoke-IcingaCheckMSSQLHealth() 60 | { 61 | param ( 62 | $Warning, 63 | $Critical, 64 | [string]$Instance, 65 | [string]$SqlUsername, 66 | [securestring]$SqlPassword, 67 | [string]$SqlHost = "localhost", 68 | [int]$SqlPort = 1433, 69 | [string]$SqlDatabase, 70 | [switch]$IntegratedSecurity = $FALSE, 71 | [switch]$NoPerfData, 72 | [ValidateSet(0, 1, 2, 3)] 73 | [int]$Verbosity = 0 74 | ); 75 | 76 | # Create a unique name for our timer 77 | [string]$MSSQLTimer = [string]::Format('MSSQL_Timer_{0}', $Instance); 78 | # Start the timer to store our connection time 79 | Start-IcingaTimer $MSSQLTimer | Out-Null; 80 | # Connect to MSSQL 81 | $SqlConnection = Open-IcingaMSSQLConnection -Username $SqlUsername -Password $SqlPassword -Address $SqlHost -IntegratedSecurity:$IntegratedSecurity -Port $SqlPort -SqlDatabase $SqlDatabase -TestConnection; 82 | # Stop the timer 83 | Stop-IcingaTimer $MSSQLTimer; 84 | 85 | $InstanceName = ''; 86 | $MSSQLConnCheck = $null; 87 | 88 | if ($null -ne $SqlConnection) { 89 | $InstanceName = Get-IcingaMSSQLInstanceName -SqlConnection $SqlConnection; 90 | # Build a check based on our connection time 91 | $MSSQLConnCheck = New-IcingaCheck -Name 'Connection Time' -Value (Get-IcingaTimer $MSSQLTimer).ElapsedMilliseconds -Unit 'ms' -MetricIndex $InstanceName -MetricName 'connectiontime'; 92 | $MSSQLConnCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; 93 | 94 | if ([string]::IsNullOrEmpty($Instance)) { 95 | $Instance = $InstanceName; 96 | } 97 | } else { 98 | # Build a check based on our connection time 99 | $MSSQLConnCheck = New-IcingaCheck -Name 'DB Connection error' -Value $TRUE -MetricIndex 'dbconnerror' -MetricName 'error'; 100 | $MSSQLConnCheck.SetCritical() | Out-Null; 101 | } 102 | 103 | # Close the connection as we no longer require it 104 | Close-IcingaMSSQLConnection -SqlConnection $SqlConnection; 105 | 106 | # Create a check package to store our checks 107 | $MSSQLCheckPackage = New-IcingaCheckPackage -Name ([string]::Format('MSSQL Health ({0})', $InstanceName)) -OperatorAnd -Verbose $Verbosity; 108 | 109 | # Fetch all services for MSSQL which are mandatory 110 | $MSSQLServices = Get-IcingaServices 'MSSQLSERVER', 'MSSQL$*', $InstanceName; 111 | 112 | # Now loop all services we found 113 | foreach ($service in $MSSQLServices.Keys) { 114 | # Setup some basic variables for later handling and usage 115 | $ServiceObject = $MSSQLServices[$service]; 116 | $ServiceName = Get-IcingaServiceCheckName -ServiceInput $service -Service $ServiceObject; 117 | $StatusRaw = $ServiceObject.configuration.Status.raw; 118 | 119 | # Now check if our instance name is either matching the exact service name of the instance name 120 | if ($service -eq 'MSSQLSERVER' -Or $service -eq $Instance -Or $service -eq ([string]::Format('MSSQL${0}', $Instance))) { 121 | $ServiceCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $service -Translation $ProviderEnums.ServiceStatusName -MetricIndex $service -MetricName 'state'; 122 | $ServiceCheck.CritIfNotMatch($ProviderEnums.ServiceStatus.Running) | Out-Null; 123 | $MSSQLCheckPackage.AddCheck($ServiceCheck); 124 | } 125 | } 126 | 127 | $MSSQLCheckPackage.AddCheck($MSSQLConnCheck); 128 | 129 | return (New-IcingaCheckResult -Check $MSSQLCheckPackage -Compile -NoPerfData $NoPerfData); 130 | } 131 | -------------------------------------------------------------------------------- /plugins/Invoke-IcingaCheckMSSQLPerfCounter.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Checks specified Performance Counter inside the MSSQL database by fetching 4 | counters by a given name and compares them to input thresholds 5 | .DESCRIPTION 6 | Checks specified Performance Counter inside the MSSQL database by fetching 7 | counters by a given name and compares them to input thresholds 8 | More Information on https://github.com/Icinga/icinga-powershell-mssql 9 | .FUNCTIONALITY 10 | Checks specified Performance Counter inside the MSSQL database by fetching 11 | counters by a given name and compares them to input thresholds 12 | .EXAMPLE 13 | PS>Invoke-IcingaCheckMSSQLHealth -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com' -PerformanceCounter '\SQLServer:Buffer Manager\Buffer cache hit ratio', '\SQLServer:Latches\Average Latch Wait Time (ms)'; 14 | [OK] Check package "MSSQL Performance Counter" 15 | | 'sqlserverbuffer_manager'=22;; 'sqlserverlatches'=384199;; 16 | .EXAMPLE 17 | PS>Invoke-IcingaCheckMSSQLHealth -IntegratedSecurity -SqlHost 'example.com' -PerformanceCounter '\SQLServer:Buffer Manager\Buffer cache hit ratio', '\SQLServer:Latches\Average Latch Wait Time (ms)'; 18 | [OK] Check package "MSSQL Performance Counter" 19 | | 'sqlserverbuffer_manager'=24;; 'sqlserverlatches'=387257;; 20 | .PARAMETER Warning 21 | The warning threshold of the Performance Counter return values 22 | .PARAMETER Critical 23 | The critical threshold of the Performance Counter return values 24 | .PARAMETER PerformanceCounter 25 | List of Performance Counters specified by their full path (example '\SQLServer:Buffer Manager\Buffer cache hit ratio') 26 | to fetch information for 27 | .PARAMETER SqlUsername 28 | The username for connecting to the MSSQL database 29 | .PARAMETER SqlPassword 30 | The password for connecting to the MSSQL database as secure string 31 | .PARAMETER SqlHost 32 | The IP address or FQDN to the MSSQL server to connect to 33 | .PARAMETER SqlPort 34 | The port of the MSSQL server/instance to connect to with the provided credentials 35 | .PARAMETER SqlDatabase 36 | The name of a specific database to connect to. Leave empty to connect "globally" 37 | .PARAMETER IntegratedSecurity 38 | Allows this plugin to use the credentials of the current PowerShell session inherited by 39 | the user the PowerShell is running with. If this is set and the user the PowerShell is 40 | running with can access to the MSSQL database you will not require to provide username 41 | and password 42 | .PARAMETER NoPerfData 43 | Disables the performance data output of this plugin 44 | .PARAMETER Verbosity 45 | Changes the behavior of the plugin output which check states are printed: 46 | 0 (default): Only service checks/packages with state not OK will be printed 47 | 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 48 | 2: Everything will be printed regardless of the check state 49 | 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) 50 | .INPUTS 51 | System.Array 52 | .OUTPUTS 53 | System.String 54 | .LINK 55 | https://github.com/Icinga/icinga-powershell-mssql 56 | .NOTES 57 | #> 58 | 59 | function Invoke-IcingaCheckMSSQLPerfCounter() 60 | { 61 | param ( 62 | $Warning, 63 | $Critical, 64 | [array]$PerformanceCounter = @(), 65 | [string]$SqlUsername, 66 | [securestring]$SqlPassword, 67 | [string]$SqlHost = "localhost", 68 | [int]$SqlPort = 1433, 69 | [string]$SqlDatabase, 70 | [switch]$IntegratedSecurity = $FALSE, 71 | [switch]$NoPerfData, 72 | [ValidateSet(0, 1, 2, 3)] 73 | [int]$Verbosity = 0 74 | ); 75 | 76 | [hashtable]$CheckPackages = @{}; 77 | 78 | $SqlConnection = Open-IcingaMSSQLConnection -Username $SqlUsername -Password $SqlPassword -Address $SqlHost -IntegratedSecurity:$IntegratedSecurity -Port $SqlPort; 79 | 80 | $PerfCounters = Get-IcingaMSSQLPerformanceCounter ` 81 | -SqlConnection $SqlConnection ` 82 | -PerformanceCounters $PerformanceCounter; 83 | 84 | $InstanceName = Get-IcingaMSSQLInstanceName -SqlConnection $SqlConnection; 85 | 86 | # Close the connection as we no longer require it 87 | Close-IcingaMSSQLConnection -SqlConnection $SqlConnection; 88 | 89 | $CheckPackage = New-IcingaCheckPackage ` 90 | -Name ([string]::Format('MSSQL Performance Counter ({0})', $InstanceName)) ` 91 | -OperatorAnd ` 92 | -Verbose $Verbosity; 93 | 94 | foreach ($Entry in $PerfCounters) { 95 | $FullName = Get-IcingaMSSQLPerfCounterPathFromDBObject -DBObject $Entry; 96 | $SerializedCounter = Get-IcingaPerformanceCounterDetails -Counter $FullName; 97 | 98 | Add-IcingaHashtableItem ` 99 | -Hashtable $CheckPackages ` 100 | -Key ($Entry.object_name) ` 101 | -Value (New-IcingaCheckPackage -Name $Entry.object_name -OperatorAnd -Verbose $Verbosity) | Out-Null; 102 | 103 | <# https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object?view=sql-server-ver15 #> 104 | $Check = (New-IcingaCheck -Name (Get-IcingaMSSQLPerfCounterNameFromDBObject -DBObject $Entry) -Value $Entry.cntr_value -MetricIndex $SerializedCounter.Category -MetricName $SerializedCounter.Counter).WarnOutOfRange($Warning).CritOutOfRange($Critical); 105 | 106 | if ($null -ne $Check) { 107 | # The check package for our counter category 108 | (Get-IcingaHashtableItem -Hashtable $CheckPackages -Key ($Entry.object_name)).AddCheck($Check) | Out-Null; 109 | } 110 | } 111 | 112 | # Add each counter category check package to our main check package 113 | foreach ($package in $CheckPackages.Values) { 114 | $CheckPackage.AddCheck($package); 115 | } 116 | 117 | return (New-IcingaCheckResult -Check $CheckPackage -NoPerfData $NoPerfData -Compile); 118 | } 119 | -------------------------------------------------------------------------------- /plugins/Invoke-IcingaCheckMSSQLResource.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | MSSQL plugin which checks for page life expectancy, buffer cache hit ratio', 4 | average latch wait time (ms) Performance Counters 5 | .DESCRIPTION 6 | MSSQL plugin which checks for page life expectancy, buffer cache hit ratio', 7 | average latch wait time (ms) Performance Counters 8 | More Information on https://github.com/Icinga/icinga-powershell-mssql 9 | .FUNCTIONALITY 10 | MSSQL plugin which checks for page life expectancy, buffer cache hit ratio', 11 | average latch wait time (ms) Performance Counters 12 | .EXAMPLE 13 | PS>Invoke-IcingaCheckMSSQLResource -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com'; 14 | [OK] Check package "MSSQL Performance" 15 | | 'buffer_cache_hit_ratio'=62;; 'page_life_expectancy'=300;; 'average_latch_wait_time_ms'=389839;; 16 | .EXAMPLE 17 | PS>Invoke-IcingaCheckMSSQLResource -IntegratedSecurity -SqlHost 'example.com'; 18 | [OK] Check package "MSSQL Performance" 19 | | 'buffer_cache_hit_ratio'=2;; 'page_life_expectancy'=300;; 'average_latch_wait_time_ms'=389839;; 20 | .PARAMETER PageLifeExpectancyWarning 21 | Warning threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references. 22 | .PARAMETER PageLifeExpectancyCritical 23 | Critical threshold for the page life expectancy which indicates the number of seconds a page will stay in the buffer pool without references. 24 | .PARAMETER BufferCacheHitRatioWarning 25 | Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk. 26 | The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period 27 | of time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high. 28 | Generally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension 29 | feature. 30 | .PARAMETER BufferCacheHitRatioCritical 31 | Warning threshold for the Buffer cache hit ratio which Indicates the percentage of pages found in the buffer cache without having to read from disk. 32 | The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period 33 | of time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high. 34 | Generally, you can increase the buffer cache hit ratio by increasing the amount of memory available to SQL Server or by using the buffer pool extension 35 | feature. 36 | .PARAMETER AverageLatchWaitTimeWarning 37 | Warning threshold for the Average Latch Wait Time (ms) for latch requests that had to wait. 38 | .PARAMETER AverageLatchWaitTimeCritical 39 | Critical threshold for the Average Latch Wait Time (ms) for latch requests that had to wait. 40 | .PARAMETER PerformanceCounter 41 | List of Performance Counters specified by their full path (example '\SQLServer:Buffer Manager\Buffer cache hit ratio') 42 | to fetch information for 43 | .PARAMETER SqlUsername 44 | The username for connecting to the MSSQL database 45 | .PARAMETER SqlPassword 46 | The password for connecting to the MSSQL database as secure string 47 | .PARAMETER SqlHost 48 | The IP address or FQDN to the MSSQL server to connect to 49 | .PARAMETER SqlPort 50 | The port of the MSSQL server/instance to connect to with the provided credentials 51 | .PARAMETER SqlDatabase 52 | The name of a specific database to connect to. Leave empty to connect "globally" 53 | .PARAMETER IntegratedSecurity 54 | Allows this plugin to use the credentials of the current PowerShell session inherited by 55 | the user the PowerShell is running with. If this is set and the user the PowerShell is 56 | running with can access to the MSSQL database you will not require to provide username 57 | and password 58 | .PARAMETER NoPerfData 59 | Disables the performance data output of this plugin 60 | .PARAMETER Verbosity 61 | Changes the behavior of the plugin output which check states are printed: 62 | 0 (default): Only service checks/packages with state not OK will be printed 63 | 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 64 | 2: Everything will be printed regardless of the check state 65 | 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])e 66 | .INPUTS 67 | System.Array 68 | .OUTPUTS 69 | System.String 70 | .LINK 71 | https://github.com/Icinga/icinga-powershell-mssql 72 | .NOTES 73 | #> 74 | 75 | function Invoke-IcingaCheckMSSQLResource() 76 | { 77 | param ( 78 | $PageLifeExpectancyCritical = $null, 79 | $PageLifeExpectancyWarning = $null, 80 | $AverageLatchWaitTimeCritical = $null, 81 | $AverageLatchWaitTimeWarning = $null, 82 | $BufferCacheHitRatioCritical = $null, 83 | $BufferCacheHitRatioWarning = $null, 84 | [string]$SqlUsername, 85 | [securestring]$SqlPassword, 86 | [string]$SqlHost = "localhost", 87 | [int]$SqlPort = 1433, 88 | [string]$SqlDatabase, 89 | [switch]$IntegratedSecurity = $FALSE, 90 | [switch]$NoPerfData, 91 | [ValidateSet(0, 1, 2, 3)] 92 | [int]$Verbosity = 0 93 | ); 94 | 95 | [hashtable]$CheckPackages = @{}; 96 | 97 | $SqlConnection = Open-IcingaMSSQLConnection -Username $SqlUsername -Password $SqlPassword -Address $SqlHost -IntegratedSecurity:$IntegratedSecurity -Port $SqlPort; 98 | 99 | $PerfCounters = Get-IcingaMSSQLPerformanceCounter ` 100 | -SqlConnection $SqlConnection ` 101 | -PerformanceCounters @( 102 | '\SQLServer:Buffer Manager\page life expectancy', 103 | '\SQLServer:Buffer Manager\Buffer cache hit ratio', 104 | '\SQLServer:Latches\Average Latch Wait Time (ms)', 105 | '\SQLServer:Buffer Manager\Buffer cache hit ratio base', 106 | '\SQLServer:Latches\Average Latch Wait Time Base' 107 | ); 108 | 109 | [decimal]$BufferRatioBase = 1; 110 | [decimal]$LatchWaitTimeBase = 1; 111 | 112 | foreach ($entry in $PerfCounters) { 113 | switch ($entry.counter_name) { 114 | 'Buffer cache hit ratio base' { 115 | $BufferRatioBase = $entry.cntr_value; 116 | break; 117 | }; 118 | 'Average Latch Wait Time Base' { 119 | $LatchWaitTimeBase = $entry.cntr_value; 120 | break; 121 | }; 122 | } 123 | } 124 | 125 | $InstanceName = Get-IcingaMSSQLInstanceName -SqlConnection $SqlConnection; 126 | 127 | # Close the connection as we no longer require it 128 | Close-IcingaMSSQLConnection -SqlConnection $SqlConnection; 129 | 130 | $CheckPackage = New-IcingaCheckPackage ` 131 | -Name ([string]::Format('MSSQL Performance ({0})', $InstanceName)) ` 132 | -OperatorAnd ` 133 | -Verbose $Verbosity; 134 | 135 | foreach ($Entry in $PerfCounters) { 136 | $FullName = Get-IcingaMSSQLPerfCounterPathFromDBObject -DBObject $Entry; 137 | $SerializedCounter = Get-IcingaPerformanceCounterDetails -Counter $FullName; 138 | 139 | <# https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object?view=sql-server-ver15 #> 140 | switch ($FullName) { 141 | '\SQLServer:Buffer Manager\page life expectancy' { 142 | $Check = (New-IcingaCheck -Name $Entry.counter_name -Value $Entry.cntr_value -MetricIndex $SerializedCounter.Category -MetricName $SerializedCounter.Counter).WarnOutOfRange($PageLifeExpectancyWarning).CritOutOfRange($PageLifeExpectancyCritical); 143 | break; 144 | }; 145 | '\SQLServer:Buffer Manager\Buffer cache hit ratio' { 146 | $Check = (New-IcingaCheck -Name $Entry.counter_name -Value (($Entry.cntr_value * 1.0 / $BufferRatioBase) * 100) -Unit '%' -MetricIndex $SerializedCounter.Category -MetricName $SerializedCounter.Counter).WarnOutOfRange($BufferCacheHitRatioWarning).CritOutOfRange($BufferCacheHitRatioCritical); 147 | break; 148 | }; 149 | '\SQLServer:Latches\Average Latch Wait Time (ms)' { 150 | $Check = (New-IcingaCheck -Name $Entry.counter_name -Value ($Entry.cntr_value / $LatchWaitTimeBase) -Unit 'ms' -MetricIndex $SerializedCounter.Category -MetricName $SerializedCounter.Counter).WarnOutOfRange($AverageLatchWaitTimeWarning).CritOutOfRange($AverageLatchWaitTimeCritical); 151 | break; 152 | }; 153 | } 154 | 155 | # Do not add these metrics to our check package of create checks for them 156 | if ($FullName -eq '\SQLServer:Buffer Manager\Buffer cache hit ratio base' -Or $FullName -eq '\SQLServer:Latches\Average Latch Wait Time Base') { 157 | continue; 158 | } 159 | 160 | Add-IcingaHashtableItem ` 161 | -Hashtable $CheckPackages ` 162 | -Key ($Entry.object_name) ` 163 | -Value (New-IcingaCheckPackage -Name $Entry.object_name -OperatorAnd -Verbose $Verbosity) | Out-Null; 164 | 165 | if ($null -ne $Check) { 166 | # The check package for our counter category 167 | (Get-IcingaHashtableItem -Hashtable $CheckPackages -Key ($Entry.object_name)).AddCheck($Check) | Out-Null; 168 | } 169 | } 170 | 171 | foreach ($package in $CheckPackages.Values) { 172 | $CheckPackage.AddCheck($package); 173 | } 174 | 175 | return (New-IcingaCheckResult -Check $CheckPackage -NoPerfData $NoPerfData -Compile); 176 | } 177 | -------------------------------------------------------------------------------- /provider/enums/Icinga_MSSQLProviderEnums.psm1: -------------------------------------------------------------------------------- 1 | [hashtable]$MSSQLBackupType = @{ 2 | 'D' = 'Database'; 3 | 'L' = 'Log'; 4 | 'I' = 'Differential database'; 5 | 'F' = 'File or filegroup'; 6 | 'G' = 'Differential file'; 7 | 'P' = 'Partial'; 8 | 'Q' = 'Differential partial'; 9 | }; 10 | 11 | [hashtable]$MSSQLDeviceType = @{ 12 | 2 = 'Disk'; 13 | 5 = 'Tape'; 14 | 7 = 'Virtual device'; 15 | 9 = 'Azure Storage'; 16 | 105 = 'A permanent backup device'; 17 | }; 18 | 19 | [hashtable]$MSSQLDatabaseState = @{ 20 | 0 = 'Online'; 21 | 1 = 'Restoring'; 22 | 2 = 'Recovering'; 23 | 3 = 'Recovering_Pending'; 24 | 4 = 'Suspect'; 25 | 5 = 'Emergency'; 26 | 6 = 'Offline'; 27 | 7 = 'Copying'; 28 | 10 = 'Offline_Secondary'; 29 | }; 30 | 31 | [hashtable]$MSSQLDatabaseStateName = @{ 32 | 'Online' = 0; 33 | 'Restoring' = 1; 34 | 'Recovering' = 2; 35 | 'Recovering_Pending' = 3; 36 | 'Suspect' = 4; 37 | 'Emergency' = 5; 38 | 'Offline' = 6; 39 | 'Copying' = 7; 40 | 'Offline_Secondary' = 10; 41 | }; 42 | 43 | [hashtable]$MSSQLRecoveryModel = @{ 44 | 1 = 'Full'; 45 | 2 = 'Bulk_Logged'; 46 | 3 = 'Simple'; 47 | }; 48 | 49 | [hashtable]$MSSQLProviderEnums = @{ 50 | 'MSSQLBackupType' = $MSSQLBackupType; 51 | 'MSSQLDeviceType' = $MSSQLDeviceType; 52 | 'MSSQLDatabaseState' = $MSSQLDatabaseState; 53 | 'MSSQLDatabaseStateName' = $MSSQLDatabaseStateName; 54 | 'MSSQLRecoveryModel' = $MSSQLRecoveryModel; 55 | } 56 | 57 | Export-ModuleMember -Variable @('MSSQLProviderEnums'); 58 | -------------------------------------------------------------------------------- /provider/mssql/Get-IcingaMSSQLBackupOverallStatus.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Checks overall Backupstatus metrics inside the MSSQL database by fetching 4 | metrics and compares them to input thresholds 5 | .DESCRIPTION 6 | Checks overall Backupstatus metrics inside the MSSQL database by fetching 7 | metrics and compares them to input thresholds 8 | More Information on https://github.com/Icinga/icinga-powershell-mssql 9 | .FUNCTIONALITY 10 | Checks overall Backupstatus metrics inside the MSSQL database by fetching 11 | metrics and compares them to input thresholds 12 | .EXAMPLE 13 | PS> Get-IcingaMSSQLBackupOverallStatus -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com'; 14 | [OK] Check package "MSSQL Backup" 15 | | 'status'=0;6;5 'size'=10110976b;; 'execution_time'=0s;; 'age'=144000s;; 'average_size'=3370325.333333b;; 'status'=0;6;5 'size'=12664832b;; 16 | 'execution_time'=0s;; 'age'=493200s;; 'average_size'=6332416b;; 'status'=0;6;5 'size'=33445888b;; 'execution_time'=0s;; 'age'=144000s;; 'average_size'=16722944b;; 17 | .EXAMPLE 18 | PS>Get-IcingaMSSQLBackupOverallStatus -IntegratedSecurity -SqlHost 'example.com' -IncludeDatabase 'ExampleDatabase','AnotherDatabase'; 19 | [OK] Check package "MSSQL Backup" 20 | | 'status'=0;6;5 'size'=12664832b;; 'execution_time'=0s;; 'age'=493200s;; 'average_size'=6332416b;; 'status'=0;6;5 'size'=10110976b;; 21 | 'execution_time'=0s;; 'age'=144000s;; 'average_size'=3370325.333333b;; 22 | .PARAMETER SqlConnection 23 | Use an already existing and established SQL object for query handling. Otherwise leave it empty and use the 24 | authentication by username/password or integrate security 25 | .PARAMETER IncludeDatabase 26 | Specifies the database or databases which will be checked. Leave empty to fetch metrics from 27 | all databases on the given system 28 | .PARAMETER SqlUsername 29 | The username for connecting to the MSSQL database 30 | .PARAMETER SqlPassword 31 | The password for connecting to the MSSQL database as secure string 32 | .PARAMETER SqlHost 33 | The IP address or FQDN to the MSSQL server to connect to 34 | .PARAMETER SqlPort 35 | The port of the MSSQL server/instance to connect to with the provided credentials 36 | .PARAMETER IntegratedSecurity 37 | Allows this plugin to use the credentials of the current PowerShell session inherited by 38 | the user the PowerShell is running with. If this is set and the user the PowerShell is 39 | running with can access to the MSSQL database you will not require to provide username 40 | and password 41 | .PARAMETER IncludeDays 42 | Specifies the number of days to read the backup history from MSSQL. Over time, the history table can get quite 43 | large and if there is no maintenance task in place to shrink it, this script could time out. By default the entire 44 | history is evaluated. 45 | .INPUTS 46 | System.Array 47 | .OUTPUTS 48 | System.Collections.Hashtable 49 | .LINK 50 | https://github.com/Icinga/icinga-powershell-mssql 51 | .NOTES 52 | #> 53 | 54 | function Get-IcingaMSSQLBackupOverallStatus 55 | { 56 | param ( 57 | $SqlConnection = $null, 58 | [array]$IncludeDatabase = @(), 59 | [string]$SqlUsername, 60 | [securestring]$SqlPassword, 61 | [string]$SqlHost = "localhost", 62 | [int]$SqlPort = 1433, 63 | [switch]$IntegratedSecurity = $FALSE, 64 | $IncludeDays = $null 65 | ); 66 | 67 | [bool]$NewSqlConnection = $FALSE; 68 | 69 | if ($null -eq $SqlConnection) { 70 | $SqlConnection = Open-IcingaMSSQLConnection -Username $SqlUsername -Password $SqlPassword -Address $SqlHost -IntegratedSecurity:$IntegratedSecurity -Port $SqlPort; 71 | $NewSqlConnection = $TRUE; 72 | } 73 | 74 | $Query = "SELECT 75 | msdb.dbo.backupset.database_name, 76 | msdb.dbo.backupset.backup_start_date, 77 | msdb.dbo.backupset.backup_finish_date, 78 | msdb.dbo.backupset.is_damaged, 79 | msdb.dbo.backupset.type, 80 | msdb.dbo.backupset.backup_size, 81 | msdb.dbo.backupset.backup_set_uuid, 82 | msdb.dbo.backupmediafamily.physical_device_name, 83 | msdb.dbo.backupmediafamily.device_type, 84 | sys.databases.state, 85 | sys.databases.recovery_model, 86 | DATEDIFF(MI, msdb.dbo.backupset.backup_finish_date, GETDATE()) AS last_backup_minutes, 87 | DATEDIFF(MI, msdb.dbo.backupset.backup_start_date, msdb.dbo.backupset.backup_finish_date) AS last_backup_duration_min 88 | FROM msdb.dbo.backupmediafamily 89 | INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id 90 | LEFT JOIN sys.databases ON sys.databases.name = msdb.dbo.backupset.database_name 91 | WHERE sys.databases.source_database_id IS NULL"; 92 | 93 | if ($null -ne $IncludeDays) { 94 | $Query = $Query + " AND msdb.dbo.backupset.backup_start_date >= DATEADD(day, -" + $IncludeDays + ", GETDATE())"; 95 | } 96 | $Query = $Query + " ORDER BY 97 | msdb.dbo.backupset.database_name, 98 | msdb.dbo.backupset.backup_finish_date"; 99 | 100 | $SqlCommand = New-IcingaMSSQLCommand -SqlConnection $SqlConnection -SqlQuery $Query; 101 | $Data = Send-IcingaMSSQLCommand -SqlCommand $SqlCommand; 102 | 103 | if ($NewSqlConnection -eq $TRUE) { 104 | Close-IcingaMSSQLConnection -SqlConnection $SqlConnection; 105 | } 106 | 107 | [hashtable]$Backupdata = @{} 108 | 109 | foreach ($Entry in $Data) { 110 | if ($IncludeDatabase.Count -ne 0 -And ($IncludeDatabase -Contains $Entry.database_name) -eq $FALSE) { 111 | continue; 112 | } 113 | 114 | Add-IcingaHashtableItem ` 115 | -Hashtable $Backupdata ` 116 | -Key $Entry.database_name ` 117 | -Value @{ 118 | 'backup' = @{}; 119 | 'history' = @(); 120 | } | Out-Null; 121 | 122 | [hashtable]$LastBackup = Get-IcingaHashtableItem -Hashtable $Backupdata[$Entry.database_name] -Key 'backup' -NullValue @{}; 123 | [array]$BackupHistory = Get-IcingaHashtableItem -Hashtable $Backupdata[$Entry.database_name] -Key 'history' -NullValue @(); 124 | [string]$BackupDrive = ''; 125 | 126 | if ($Entry.physical_device_name -match '\:' ) { 127 | $BackupDrive = $Entry.physical_device_name.Substring(0, [Math]::Min($Entry.physical_device_name.Length, 2)); 128 | } 129 | 130 | if ($Entry.type -eq 'L') { 131 | $LastBackupLogAge = ($Entry.last_backup_minutes * 60) 132 | } else { 133 | $LastBackupLogAge = 0; 134 | } 135 | 136 | $TotalBackupSize = (Get-IcingaHashtableItem -Hashtable $LastBackup -Key 'TotalBackupSize' -NullValue 0) + $Entry.backup_size; 137 | 138 | [hashtable]$CurrentBackup = @{ 139 | 'TotalBackupSize' = ([long]$TotalBackupSize); 140 | 'AvgBackupSize' = ([math]::round([decimal](([long]$TotalBackupSize) / ([Math]::Max($BackupHistory.Count, 1))), 4)); 141 | 'UUID' = $Entry.backup_set_uuid; 142 | 'StartDate' = $Entry.backup_start_date; 143 | 'FinishDate' = $Entry.backup_finish_date; 144 | 'IsDamaged' = $Entry.is_damaged; 145 | 'Type' = $Entry.type; 146 | 'LastBackupLogAge' = [long]$LastBackupLogAge; 147 | 'LastBackupAge' = (([long]$Entry.last_backup_minutes) * 60); 148 | 'ExecutionTime' = (([long]$Entry.last_backup_duration_min) * 60); 149 | 'Location' = $Entry.physical_device_name; 150 | 'Drive' = $BackupDrive; 151 | 'Status' = $Entry.state; 152 | 'DeviceType' = $Entry.device_type; 153 | 'TotalBackups' = $BackupHistory.Count; 154 | }; 155 | 156 | Add-IcingaHashtableItem -Hashtable $Backupdata[$Entry.database_name] -Key 'backup' -Value $CurrentBackup -Override | Out-Null; 157 | 158 | [hashtable]$HistoryEntry = $CurrentBackup.Clone(); 159 | 160 | Remove-IcingaHashtableItem -Hashtable $HistoryEntry -Key 'TotalBackupSize'; 161 | Remove-IcingaHashtableItem -Hashtable $HistoryEntry -Key 'AvgBackupSize'; 162 | Remove-IcingaHashtableItem -Hashtable $HistoryEntry -Key 'TotalBackups'; 163 | 164 | $BackupHistory += $HistoryEntry; 165 | 166 | Add-IcingaHashtableItem -Hashtable $Backupdata[$Entry.database_name] -Key 'history' -Value $BackupHistory -Override | Out-Null; 167 | } 168 | 169 | return $Backupdata; 170 | } 171 | -------------------------------------------------------------------------------- /provider/mssql/Get-IcingaMSSQLPerfCounterNameFromDBObject.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Returns the category name of a Performance Counter DB row, 4 | like 'SQLServer:Buffer Manager' 5 | .DESCRIPTION 6 | Returns the category name of a Performance Counter DB row, 7 | like 'SQLServer:Buffer Manager' 8 | More Information on https://github.com/Icinga/icinga-powershell-mssql 9 | .FUNCTIONALITY 10 | Returns the category name of a Performance Counter DB row, 11 | like 'SQLServer:Buffer Manager' 12 | .EXAMPLE 13 | PS>Get-IcingaMSSQLPerfCounterNameFromDBObject -DBObject $dbrow; 14 | 'SQLServer:Buffer Manager' 15 | .EXAMPLE 16 | PS>Get-IcingaMSSQLPerfCounterNameFromDBObject -DBObject $dbrow; 17 | 'Processor(*)' 18 | .PARAMETER DBObject 19 | Specifies the DB row of the query for which we fetched Performance Counters from 20 | .INPUTS 21 | System.String 22 | .OUTPUTS 23 | System.String 24 | .LINK 25 | https://github.com/Icinga/icinga-powershell-mssql 26 | .NOTES 27 | #> 28 | 29 | function Get-IcingaMSSQLPerfCounterNameFromDBObject() 30 | { 31 | param ( 32 | $DBObject = $null 33 | ); 34 | 35 | if ($null -eq $DBObject) { 36 | return ''; 37 | } 38 | 39 | if ([string]::IsNullOrEmpty($DBObject.instance_name)) { 40 | return $DBObject.object_name; 41 | } else { 42 | return ( 43 | [string]::Format( 44 | '{0} ({1})', 45 | $DBObject.counter_name, 46 | $DBObject.instance_name 47 | ) 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /provider/mssql/Get-IcingaMSSQLPerfCounterPathFromDBObject.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Returns the full, proper path of a Performance Counter DB row, 4 | like '\SQLServer:Buffer Manager\Buffer cache hit ratio' 5 | .DESCRIPTION 6 | Returns the full, proper path of a Performance Counter DB row, 7 | like '\SQLServer:Buffer Manager\Buffer cache hit ratio' 8 | More Information on https://github.com/Icinga/icinga-powershell-mssql 9 | .FUNCTIONALITY 10 | Returns the full, proper path of a Performance Counter DB row, 11 | like '\SQLServer:Buffer Manager\Buffer cache hit ratio' 12 | .EXAMPLE 13 | PS>Get-IcingaMSSQLPerfCounterPathFromDBObject -DBObject $dbrow; 14 | '\SQLServer:Buffer Manager\Buffer cache hit ratio' 15 | .PARAMETER DBObject 16 | Specifies the DB row of the query for which we fetched Performance Counters from 17 | .INPUTS 18 | System.String 19 | .OUTPUTS 20 | System.String 21 | .LINK 22 | https://github.com/Icinga/icinga-powershell-mssql 23 | .NOTES 24 | #> 25 | 26 | function Get-IcingaMSSQLPerfCounterPathFromDBObject() 27 | { 28 | param ( 29 | $DBObject = $null 30 | ); 31 | 32 | if ($null -eq $DBObject) { 33 | return ''; 34 | } 35 | 36 | if ([string]::IsNullOrEmpty($DBObject.instance_name)) { 37 | return ( 38 | [string]::Format( 39 | '\{0}\{1}', 40 | $DBObject.object_name, 41 | $DBObject.counter_name 42 | ) 43 | ); 44 | } else { 45 | return ( 46 | [string]::Format( 47 | '\{0}({1})\{2}', 48 | $DBObject.instance_name, 49 | $DBObject.object_name, 50 | $DBObject.counter_name 51 | ) 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /provider/mssql/Get-IcingaMSSQLPerformanceCounter.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Checks specified Performance Counter inside the MSSQL database by fetching 4 | counters by a given name and compares them to input thresholds 5 | .DESCRIPTION 6 | Checks specified Performance Counter inside the MSSQL database by fetching 7 | counters by a given name and compares them to input thresholds 8 | More Information on https://github.com/Icinga/icinga-powershell-mssql 9 | .FUNCTIONALITY 10 | Checks specified Performance Counter inside the MSSQL database by fetching 11 | counters by a given name and compares them to input thresholds 12 | .EXAMPLE 13 | PS>Get-IcingaMSSQLPerformanceCounter -SqlUsername 'username' -SqlPassword (ConvertTo-IcingaSecureString 'password') -SqlHost 'example.com' -PerformanceCounter '\SQLServer:Buffer Manager\Buffer cache hit ratio', '\SQLServer:Latches\Average Latch Wait Time (ms)'; 14 | [OK] Check package "MSSQL Performance Counter" 15 | | 'sqlserverbuffer_manager'=22;; 'sqlserverlatches'=384199;; 16 | .EXAMPLE 17 | PS>Get-IcingaMSSQLPerformanceCounter -IntegratedSecurity -SqlHost 'example.com' -PerformanceCounter '\SQLServer:Buffer Manager\Buffer cache hit ratio', '\SQLServer:Latches\Average Latch Wait Time (ms)'; 18 | [OK] Check package "MSSQL Performance Counter" 19 | | 'sqlserverbuffer_manager'=24;; 'sqlserverlatches'=387257;; 20 | .PARAMETER SqlConnection 21 | Use an already existing and established SQL object for query handling. Otherwise leave it empty and use the 22 | authentication by username/password or integrate security 23 | .PARAMETER PerformanceCounter 24 | List of Performance Counters specified by their full path (example '\SQLServer:Buffer Manager\Buffer cache hit ratio') 25 | to fetch information for 26 | .PARAMETER SqlUsername 27 | The username for connecting to the MSSQL database 28 | .PARAMETER SqlPassword 29 | The password for connecting to the MSSQL database as secure string 30 | .PARAMETER SqlHost 31 | The IP address or FQDN to the MSSQL server to connect to 32 | .PARAMETER SqlPort 33 | The port of the MSSQL server/instance to connect to with the provided credentials 34 | .PARAMETER SqlDatabase 35 | The name of a specific database to connect to. Leave empty to connect "globally" 36 | .PARAMETER IntegratedSecurity 37 | Allows this plugin to use the credentials of the current PowerShell session inherited by 38 | the user the PowerShell is running with. If this is set and the user the PowerShell is 39 | running with can access to the MSSQL database you will not require to provide username 40 | and password 41 | .INPUTS 42 | System.Array 43 | .OUTPUTS 44 | System.String 45 | .LINK 46 | https://github.com/Icinga/icinga-powershell-mssql 47 | .NOTES 48 | #> 49 | 50 | function Get-IcingaMSSQLPerformanceCounter 51 | { 52 | param ( 53 | $SqlConnection = $null, 54 | [array]$PerformanceCounters = @(), 55 | [string]$SqlUsername, 56 | [securestring]$SqlPassword, 57 | [string]$SqlHost = "localhost", 58 | [int]$SqlPort = 1433, 59 | [string]$SqlDatabase, 60 | [switch]$IntegratedSecurity = $FALSE 61 | ); 62 | 63 | if ($PerformanceCounters.Count -eq 0) { 64 | Exit-IcingaThrowException ` 65 | -ExceptionType 'Configuration' ` 66 | -ExceptionThrown $IcingaExceptions.Configuration.PluginArgumentMissing ` 67 | -CustomMessage 'Missing argument "-PerformanceCounters"' ` 68 | -Force; 69 | } 70 | 71 | [bool]$NewSqlConnection = $FALSE; 72 | 73 | if ($null -eq $SqlConnection) { 74 | $SqlConnection = Open-IcingaMSSQLConnection -Username $SqlUsername -Password $SqlPassword -Address $SqlHost -IntegratedSecurity:$IntegratedSecurity -Port $SqlPort; 75 | $NewSqlConnection = $TRUE; 76 | } 77 | 78 | $PerformanceCounterQuery = "SELECT 79 | RTRIM(object_name) as object_name, 80 | RTRIM(counter_name) as counter_name, 81 | RTRIM(instance_name) as instance_name, 82 | RTRIM(cntr_value) as cntr_value, 83 | RTRIM(cntr_type) as cntr_type 84 | FROM sys.dm_os_performance_counters 85 | WHERE "; 86 | 87 | foreach ($Counter in $PerformanceCounters) { 88 | $Category = $null; 89 | $CounterObject = $null; 90 | $ArrayCounter = $Counter.Split('\'); 91 | $Category = $ArrayCounter[1]; 92 | $InstanceName = ''; 93 | $CounterObject = $ArrayCounter[2]; 94 | 95 | if ($Category.Contains('(')) { 96 | [array]$InstanceArray = $Category.Split('('); 97 | $Category = $InstanceArray[0]; 98 | [string]$InstanceName = $InstanceArray[1]; 99 | $InstanceName = $InstanceName.Substring(0, $InstanceName.Length - 1); 100 | if ($InstanceName -eq '*') { 101 | $InstanceName = ''; 102 | } 103 | } 104 | 105 | if ([string]::IsNullOrEmpty($InstanceName)) { 106 | $PerformanceCounterQuery = ( 107 | [string]::Format( 108 | "{0}(object_name = '{1}' AND counter_name = '{2}') OR ", 109 | $PerformanceCounterQuery, 110 | $Category, 111 | $CounterObject 112 | ) 113 | ); 114 | } else { 115 | $PerformanceCounterQuery = ( 116 | [string]::Format( 117 | "{0}(object_name = '{1}' AND counter_name = '{2}' AND instance_name = '{3}') OR ", 118 | $PerformanceCounterQuery, 119 | $Category, 120 | $CounterObject, 121 | $InstanceName 122 | ) 123 | ); 124 | } 125 | } 126 | 127 | $PerformanceCounterQuery = $PerformanceCounterQuery.SubString(0, $PerformanceCounterQuery.Length - 4); 128 | $PerformanceCounterQuery += ';'; 129 | $SqlCommand = New-IcingaMSSQLCommand -SqlConnection $SqlConnection -SqlQuery $PerformanceCounterQuery; 130 | $Data = Send-IcingaMSSQLCommand -SqlCommand $SqlCommand; 131 | 132 | if ($NewSqlConnection -eq $TRUE) { 133 | Close-IcingaMSSQLConnection -SqlConnection $SqlConnection; 134 | } 135 | 136 | [array]$CounterResult = @(); 137 | 138 | foreach ($counter in $Data) { 139 | [decimal]$CounterValue = 0; 140 | if ((Test-Numeric $counter.cntr_value)) { 141 | $CounterValue = ([math]::round([decimal]$counter.cntr_value, 6)); 142 | } 143 | 144 | $CounterResult += @{ 145 | 'instance_name' = $counter.instance_name; 146 | 'object_name' = $counter.object_name; 147 | 'counter_name' = $counter.counter_name; 148 | 'cntr_value' = $CounterValue; 149 | } 150 | } 151 | 152 | return $CounterResult; 153 | } 154 | --------------------------------------------------------------------------------