├── LICENSE ├── README.md ├── ansible ├── nagios │ ├── nagios_log_server │ │ ├── README.md │ │ ├── files │ │ │ └── nxlog_conf.j2 │ │ ├── forward_eventlog.yml │ │ ├── forward_syslog_linux.yml │ │ ├── hosts │ │ └── roles │ │ │ ├── linux_apacheAccessLog_setup │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ ├── linux_apacheErrorLog_setup │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ ├── linux_base_setup │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ ├── linux_download_setup_script │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ ├── linux_mysqlLog_setup │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ ├── linux_selinux │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ ├── win_install_nxlog │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ ├── win_place_nxlog_conf │ │ │ └── tasks │ │ │ │ └── main.yml │ │ │ └── win_restart_nxlog │ │ │ └── tasks │ │ │ └── main.yml │ └── nagios_xi │ │ ├── CHANGELOG.rst │ │ ├── FILES.json │ │ ├── LICENSE │ │ ├── MAINTAINERS │ │ ├── MANIFEST.json │ │ ├── README.md │ │ ├── docs │ │ └── docsite │ │ │ └── links.yml │ │ ├── galaxy.yml │ │ ├── meta │ │ └── runtime.yml │ │ ├── plugins │ │ ├── README.md │ │ └── inventory │ │ │ ├── README.md │ │ │ └── nagiosxi.py │ │ └── roles │ │ ├── README.md │ │ ├── xi_host_scheduled_downtime_create │ │ ├── README.md │ │ └── tasks │ │ │ └── main.yml │ │ └── xi_host_scheduled_downtime_delete │ │ ├── README.md │ │ └── tasks │ │ └── main.yml └── ncpa │ ├── README.md │ ├── ansible.cfg │ ├── hosts │ ├── linux_ncpa_install_and_register.yml │ ├── roles │ ├── ncpa_install_linux │ │ └── tasks │ │ │ └── main.yml │ ├── ncpa_install_windows │ │ └── tasks │ │ │ └── main.yml │ ├── register_cpu_service_with_xi │ │ └── tasks │ │ │ └── main.yml │ ├── register_host_with_xi │ │ └── tasks │ │ │ └── main.yml │ ├── register_linux_disk_service_with_xi │ │ └── tasks │ │ │ └── main.yml │ ├── register_ram_service_with_xi │ │ └── tasks │ │ │ └── main.yml │ ├── register_swap_service_with_xi │ │ └── tasks │ │ │ └── main.yml │ ├── register_windows_disk_service_with_xi │ │ └── tasks │ │ │ └── main.yml │ └── xi_apply_config │ │ └── tasks │ │ └── main.yml │ ├── secrets.yml │ └── windows_ncpa_install_and_register.yml └── misc ├── auto_register.sh └── nmap_parser.py /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Automation 2 | 3 | 4 | > Central location for automation scripts and snippets relating to Nagios 5 | 6 | 7 | As the Nagios community has grown, the need for automating Nagios-related 8 | tasks has become increasingly common. Internally we've developed some scripts 9 | that leverage existing automation frameworks and this repository serves as a 10 | central hub of those scripts and snippets. 11 | 12 | 13 | ## Disclaimer 14 | 15 | Many of these automation scripts are not production-grade. They are built to 16 | perform a specific task or to demonstrate specific functionality. They may or 17 | may not follow currently accepted best-practices. 18 | 19 | ***Please read through each script before attempting to use it in your 20 | environment.*** 21 | 22 | These scripts are provided "as is" *without warranty of any kind*, either 23 | expressed or implied, including, but not limited to, the implied warranties 24 | of merchantability and fitness for a particular purpose. 25 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/README.md: -------------------------------------------------------------------------------- 1 | These playbooks and roles are designed to automatically configure log forwarding from the devices and applications in your environment to Nagios Log Server. 2 | 3 | Users adapt these files to their environments through required and optional setup. 4 | 5 | 6 | # Required Setup 7 | 8 | Users must supply the IP address or FQDN of the Nagios Log Server installation. 9 | 10 | 1) Tower/AWX: add the item in EXTRA VARIABLES in the Job Template: 11 | ```yml 12 | --- 13 | nls_ip: '192.168.100.100' 14 | ``` 15 | 16 | 2) Ansible CLI: add a vars section above the roles section(s) in the playbooks: 17 | ```yml 18 | vars: 19 | nls_ip: '192.168.100.100' 20 | ``` 21 | 22 | 23 | # Optional Setup 24 | 25 | ### Linux syslog 26 | You are welcome to edit which roles are called by the main Linux syslog playbook. If you don't have to contend with selinux or you don't have MySQL logs to monitor, you can remove those roles. 27 | 28 | 29 | ### Windows Eventlog 30 | The Windows Eventlog playbook installs a forwarding agent called NxLog, drops in a configuration file, and starts/restarts the NxLog service. The configuration file is a jinja template. The default template included here handles basic Eventlog forwarding, though the configuration file can be modified to also forward IIS or other logs as well. Please see the documentation for IIS and Windows files forwarding in the Nagios Log Server interface. -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/files/nxlog_conf.j2: -------------------------------------------------------------------------------- 1 | ## See the nxlog reference manual at 2 | ## http://nxlog.org/nxlog-docs/en/nxlog-reference-manual.html 3 | 4 | ## Please set the ROOT to the folder your nxlog was installed into, 5 | ## otherwise it will not start. 6 | #define ROOT C:\Program Files\nxlog 7 | define ROOT C:\Program Files (x86)\nxlog 8 | define CERT %ROOT%\cert 9 | 10 | Moduledir %ROOT%\modules 11 | CacheDir %ROOT%\data 12 | Pidfile %ROOT%\data\nxlog.pid 13 | SpoolDir %ROOT%\data 14 | LogFile %ROOT%\data\nxlog.log 15 | 16 | # Include fileop while debugging, also enable in the output module below 17 | # 18 | # Module xm_fileop 19 | # 20 | 21 | 22 | Module xm_json 23 | 24 | 25 | 26 | Module xm_syslog 27 | 28 | 29 | 30 | Module im_internal 31 | 32 | 33 | # Watch your own files 34 | 35 | Module im_file 36 | File '%ROOT%\data\nxlog.log' 37 | SavePos TRUE 38 | Exec $Message = $raw_event; 39 | 40 | 41 | # Windows Event Log 42 | 43 | # Uncomment im_msvistalog for Windows Vista/2008 and later 44 | Module im_msvistalog 45 | 46 | # Uncomment im_mseventlog for Windows XP/2000/2003 47 | # Module im_mseventlog 48 | 49 | 50 | 51 | Module om_tcp 52 | Host {{ nls_ip }} 53 | Port 3515 54 | 55 | Exec $tmpmessage = $Message; delete($Message); rename_field("tmpmessage","message"); 56 | Exec $raw_event = to_json(); 57 | 58 | # Uncomment for debug output 59 | # Exec file_write('%ROOT%\data\nxlog_output.log', $raw_event + "\n"); 60 | 61 | 62 | 63 | Path internal, file1, eventlog => out 64 | 65 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/forward_eventlog.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install, configure, (re)start Nxlog 3 | hosts: windows 4 | become: yes 5 | become_method: runas 6 | become_user: SYSTEM 7 | 8 | roles: 9 | - win_install_nxlog 10 | - win_place_nxlog_conf 11 | - win_restart_nxlog -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/forward_syslog_linux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Forward Linux syslog to Nagios Log Server 3 | remote_user: root 4 | hosts: linux 5 | 6 | roles: 7 | - linux_selinux 8 | - linux_download_setup_script 9 | - linux_base_setup 10 | - linux_apacheAccessLog_setup 11 | - linux_apacheErrorLog_setup 12 | - linux_mysqlLog_setup -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/hosts: -------------------------------------------------------------------------------- 1 | [linux] 2 | 192.168.1.100 3 | 4 | [windows] 5 | 192.168.1.101 6 | 7 | [windows:vars] 8 | ansible_port=5985 9 | ansible_connection=winrm 10 | ansible_winrm_server_cert_validation=ignore 11 | ansible_user=nagios 12 | ansible_password=demo -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/linux_apacheAccessLog_setup/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: run the script 3 | command: './setup-linux.sh -s {{ nls_ip }} -p 5544 -f "/var/log/httpd/access_log" -t apache_access' 4 | args: 5 | chdir: /tmp -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/linux_apacheErrorLog_setup/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: run the script 3 | command: './setup-linux.sh -s {{ nls_ip }} -p 5544 -f "/var/log/httpd/error_log" -t apache_error' 4 | args: 5 | chdir: /tmp -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/linux_base_setup/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: run the script 3 | command: './setup-linux.sh -s {{ nls_ip }} -p 5544' 4 | args: 5 | chdir: /tmp -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/linux_download_setup_script/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: get the syslog modification script from the Log Server master instance 3 | get_url: 4 | url: http://{{ nls_ip }}/nagioslogserver/scripts/setup-linux.sh 5 | dest: /tmp/setup-linux.sh 6 | mode: u+x -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/linux_mysqlLog_setup/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: run the script 3 | command: './setup-linux.sh -s {{ nls_ip }} -p 5544 -f "/var/log/mysqld.log" -t mysqld_log' 4 | args: 5 | chdir: /tmp -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/linux_selinux/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: RedHat install policycoreutils for SELinux using non-standard syslog port 3 | yum: 4 | name: policycoreutils 5 | state: present 6 | when: ansible_selinux.status == 'enabled' and ansible_os_family == "RedHat" 7 | 8 | - name: RedHat install setroubleshoot for SELinux using non-standard syslog port 9 | yum: 10 | name: setroubleshoot 11 | state: present 12 | when: ansible_selinux.status == 'enabled' and ansible_os_family == "RedHat" 13 | 14 | - name: selinux allow rsyslog export through non-standard port 15 | command: semanage port -a -t syslogd_port_t -p tcp 5544 16 | when: ansible_selinux.status == 'enabled' and ansible_os_family == "RedHat" 17 | register: result 18 | failed_when: 19 | - result.rc != 0 20 | - '"5544 already defined" not in result.stderr' -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/win_install_nxlog/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install package 3 | win_package: 4 | path: http://{{ nls_ip }}/nagioslogserver/scripts/nxlog-ce-latest.msi 5 | product_id: '{FC526514-AFD9-4A5C-8677-56241539609D}' 6 | state: present -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/win_place_nxlog_conf/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: place nxlog.conf 3 | template: 4 | src: files/nxlog_conf.j2 5 | dest: 'C:\Program Files (x86)\nxlog\conf\nxlog.conf' -------------------------------------------------------------------------------- /ansible/nagios/nagios_log_server/roles/win_restart_nxlog/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: restart nxlog 3 | win_service: 4 | name: nxlog 5 | state: restarted -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | Will be updated by antsibull-changelog. Do not edit this manually! 2 | 3 | See https://ansible.readthedocs.io/projects/antsibull-changelog/changelogs/ for information on how to use antsibull-changelog. 4 | 5 | Check out ``changelogs/config.yaml`` for its configuration. You need to change at least the ``title`` field in there. 6 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/FILES.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | { 4 | "name": ".", 5 | "ftype": "dir", 6 | "chksum_type": null, 7 | "chksum_sha256": null, 8 | "format": 1 9 | }, 10 | { 11 | "name": "README.md", 12 | "ftype": "file", 13 | "chksum_type": "sha256", 14 | "chksum_sha256": "bb71fdc16dddcf5cc80e2860eb9486dd9db3e0b4efcb0f0953a35ee88d9026be", 15 | "format": 1 16 | }, 17 | { 18 | "name": "docs", 19 | "ftype": "dir", 20 | "chksum_type": null, 21 | "chksum_sha256": null, 22 | "format": 1 23 | }, 24 | { 25 | "name": "docsite", 26 | "ftype": "dir", 27 | "chksum_type": null, 28 | "chksum_sha256": null, 29 | "format": 1 30 | }, 31 | { 32 | "name": "links.yml", 33 | "ftype": "file", 34 | "chksum_type": "sha256", 35 | "chksum_sha256": "aff3666c9beab13b377e3cfa3e854b3d0b175761dce14af643750d34eb6c0c7a", 36 | "format": 1 37 | }, 38 | { 39 | "name": "inventory", 40 | "ftype": "dir", 41 | "chksum_type": null, 42 | "chksum_sha256": null, 43 | "format": 1 44 | }, 45 | { 46 | "name": "inventory/nagiosxi.py", 47 | "ftype": "file", 48 | "chksum_type": "sha256", 49 | "chksum_sha256": "759f772d14ecf78b20b8f625a9a402e24dfa37be53aa88034bee8cfeae618d9f", 50 | "format": 1 51 | }, 52 | { 53 | "name": "inventory/README.md", 54 | "ftype": "file", 55 | "chksum_type": "sha256", 56 | "chksum_sha256": "97d86f839e0d8efe729e6391d255ae9d2ff68f167a5495ac53837b1c4556d14e", 57 | "format": 1 58 | }, 59 | { 60 | "name": "meta", 61 | "ftype": "dir", 62 | "chksum_type": null, 63 | "chksum_sha256": null, 64 | "format": 1 65 | }, 66 | { 67 | "name": "meta/ee-bindep.txt", 68 | "ftype": "file", 69 | "chksum_type": "sha256", 70 | "chksum_sha256": "3d4fe6a7070e1645176738fa9eed2b355a51cdfcc362afab414e3907aef590a0", 71 | "format": 1 72 | }, 73 | { 74 | "name": "meta/ee-requirements.txt", 75 | "ftype": "file", 76 | "chksum_type": "sha256", 77 | "chksum_sha256": "5425fade5cdbf6524e70c392737f57a85331ff5971298c7b5848942acda60174", 78 | "format": 1 79 | }, 80 | { 81 | "name": "execution-environment.yml", 82 | "ftype": "file", 83 | "chksum_type": "sha256", 84 | "chksum_sha256": "4d80b192e0813be8f167ddd1aa135ead0531044f8c5f4d8fba1577dd4655cca2", 85 | "format": 1 86 | }, 87 | { 88 | "name": "runtime.yml", 89 | "ftype": "file", 90 | "chksum_type": "sha256", 91 | "chksum_sha256": "43da2f3193293a9e67107f6e8562d7c95c067a313f718d645e8630094e60296b", 92 | "format": 1 93 | }, 94 | { 95 | "name": "roles", 96 | "ftype": "dir", 97 | "chksum_type": null, 98 | "chksum_sha256": null, 99 | "format": 1 100 | }, 101 | { 102 | "name": "xi_host_sch" 103 | } 104 | ] 105 | } -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Michael Bellerue -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/MANIFEST.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection_info": { 3 | "namespace": "nagios", 4 | "name": "nagios_xi", 5 | "version": "0.1.0", 6 | "authors": [ 7 | "Nagios Enterprises (github.com/NagiosEnterprises)" 8 | ], 9 | "readme": "README.md", 10 | "tags": [ 11 | "nagios", 12 | "monitoring", 13 | "nagiosxi" 14 | ], 15 | "description": "A collection of Ansible tools designed for use with Nagios XI.", 16 | "license_file": [ 17 | "LICENSE" 18 | ], 19 | "dependencies": { 20 | }, 21 | "repository": "https://github.com/NagiosEnterprises/automation.git", 22 | "documentation": "https://github.com/NagiosEnterprises/automation", 23 | "homepage": "https://github.com/NagiosEnterprises/automation", 24 | "issues": "https://github.com/NagiosEnterprises/automation/issues" 25 | }, 26 | "file_manifest_file": { 27 | "name": "FILES.json", 28 | "ftype": "file", 29 | "chksum_type": "sha256", 30 | "chksum_sha256": "31ca7eb3d22464164904715db3a5757d07438b8eb226bbfb200206144edf9d6f", 31 | "format": 1 32 | }, 33 | "format": 1 34 | } 35 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/README.md: -------------------------------------------------------------------------------- 1 | # Nagios XI Collection for Ansible 2 | 3 | This collection will help users get the most from their Nagios XI systems. From roles to make it easier to add or remove hosts and services from monitoring programmatically, to leveraging Nagios XI as an inventory source. 4 | 5 | ## Our mission 6 | 7 | Our mission is to make the lives of sysadmins easier. Whether that's providing convenient ways to adjust monitoring in your environment, or helping you manage systems that you are monitoring. 8 | 9 | ## Code of Conduct 10 | 11 | We follow the [Ansible Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html) in all our interactions within this project. 12 | 13 | If you encounter abusive behavior, please refer to the [policy violations](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html#policy-violations) section of the Code for information on how to raise a complaint. 14 | 15 | ## Governance 16 | 17 | The process of decision making in this collection is based on discussing and finding consensus among participants. 18 | 19 | Every voice is important. If you have something on your mind, create an issue or dedicated discussion and let's discuss it! 20 | 21 | 22 | ### Installing the Collection from Ansible Galaxy 23 | 24 | Before using this collection, you need to install it with the Ansible Galaxy command-line tool: 25 | ```bash 26 | ansible-galaxy collection install nagios.nagios_xi 27 | ``` 28 | 29 | You can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format: 30 | ```yaml 31 | --- 32 | collections: 33 | - name: nagios.nagios_xi 34 | ``` 35 | 36 | Note that if you install the collection from Ansible Galaxy, it will not be upgraded automatically when you upgrade the `ansible` package. To upgrade the collection to the latest available version, run the following command: 37 | ```bash 38 | ansible-galaxy collection install nagios.nagios_xi --upgrade 39 | ``` 40 | 41 | You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version `0.1.1`: 42 | 43 | ```bash 44 | ansible-galaxy collection install nagios.nagios_xi:==0.1.1 45 | ``` 46 | 47 | See [using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details. 48 | 49 | ## Licensing 50 | 51 | GNU General Public License v3.0 or later. 52 | 53 | See [LICENSE](https://www.gnu.org/licenses/gpl-3.0.txt) to see the full text. 54 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/docs/docsite/links.yml: -------------------------------------------------------------------------------- 1 | --- 2 | edit_on_github: 3 | repository: NagiosEnterprises/automation 4 | branch: main 5 | path_prefix: 'ansible/nagiosxi' 6 | 7 | communication: 8 | forums: 9 | - topic: Community Support Forum 10 | url: https://support.nagios.com/forum/ 11 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/galaxy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | namespace: nagios 4 | name: nagios_xi 5 | version: 0.1.1 6 | readme: README.md 7 | authors: 8 | - Michael Bellerue (github.com/MikeBellerue-Nagios) 9 | description: A collection of Ansible tools designed for use with Nagios XI. 10 | license_file: LICENSE 11 | tags: 12 | - nagios 13 | - monitoring 14 | - nagiosxi 15 | repository: https://github.com/NagiosEnterprises/automation 16 | homepage: https://github.com/NagiosEnterprises/automation 17 | issues: https://github.com/NagiosEnterprises/automation/issues 18 | build_ignore: 19 | - .gitignore 20 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/meta/runtime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | requires_ansible: '>=2.16.0' # Use '>=2.9.10' instead, if needed 3 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/plugins/README.md: -------------------------------------------------------------------------------- 1 | # Collections Plugins Directory 2 | 3 | This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that 4 | is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that 5 | would contain module utils and modules respectively. 6 | 7 | Here is an example directory of the majority of plugins currently supported by Ansible: 8 | 9 | ``` 10 | └── plugins 11 | ├── action 12 | ├── become 13 | ├── cache 14 | ├── callback 15 | ├── cliconf 16 | ├── connection 17 | ├── filter 18 | ├── httpapi 19 | ├── inventory 20 | ├── lookup 21 | ├── module_utils 22 | ├── modules 23 | ├── netconf 24 | ├── shell 25 | ├── strategy 26 | ├── terminal 27 | ├── test 28 | └── vars 29 | ``` 30 | 31 | A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible-core/2.16/plugins/plugins.html). 32 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/plugins/inventory/README.md: -------------------------------------------------------------------------------- 1 | # Nagios XI Dynamic Inventory Plugin 2 | 3 | ## Support 4 | The Nagios XI Dynamic Inventory Plugin is a community supported plugin for pulling hosts, host groups, and host custom variables from Nagios XI. The plugin will then translate these items into hosts, host groups, and host facts for use with Ansible. 5 | 6 | ## Installation 7 | The `nagiosxi.py` file should live in your home directory, under `~/.ansible/plugins/inventory/nagiosxi/` 8 | 9 | ## User Created Inventory File 10 | Create an inventory file with the following fields: 11 | 12 | ``` 13 | plugin: nagiosxi 14 | 15 | disable_warnings: False 16 | xi_ip: 17 | secure: True 18 | xi_api_key: 19 | xi_hostgroup: AnsibleManaged 20 | ``` 21 | 22 | `plugin` This field tells Ansible what inventory plugin to use. This should be the same name as the directory in `~/.ansible/plugins/inventory/` in this case, `nagiosxi`. 23 | 24 | `disable_warnings` This field will determine whether or not Python-related warnings will be disabled or not. Specifically for warnings like HTTPS servers with self-signed certificates. 25 | 26 | `xi_ip` This should be the IP address, or hostname, of your Nagios XI server. 27 | 28 | `secure` Determines whether Python will use HTTP or HTTPS to connect to your Nagios XI server. 29 | 30 | `xi_api_key` This is a key generated for a user in your Nagios XI system. Currently, the user _must_ be an Admin user. Making them a user and giving them full permissions. We highly recommend creating a service account for this, rather than using someone's actual API key. 31 | 32 | `xi_hostgroup` This is a hostgroup defined inside of Nagios XI. In the example, we are using AnsibleManaged as our starting hostgroup. 33 | 34 | ## Making the Nagios XI Dynamic Inventory Plugin useful 35 | This section is all about things you will want to know about in order to help use Nagios XI as your inventory source. 36 | 37 | ### Hostgroups 38 | Number one is going to be hostgroups. In Nagios XI, a hostgroup is a logical grouping of hosts. Pretty simple. Normally hostgroups are used to group up hosts that make sense to be grouped together in some way. Usually these are things like Linux server vs Windows servers, database servers vs application servers, or maybe datacentera vs datacenterb. 39 | 40 | Ansible has its own host group system, and it just so happens to line up quite nicely with Nagios XI. So when the dynamic inventory plugin pulls hosts from Nagios XI, one of the things it will grab is the hostgroup information from each of the hosts. This lets you expand Nagios hostgroups into areas that are useful for Ansible. 41 | 42 | A hostgroup in Nagios XI can be created by going to the Core Configuration Manager (CCM) -> Selecting Host Groups -> and clicking the Add New button. 43 | 44 | A host can be added to a hostgroup in two different ways. You can assign the hostgroup to the host, or the host to the hostgroup. I'm going to make a unilateral decision here, and give you the directions for the former, because that's what I like to do, and it will make a little more sense when we discuss Templates a little further down. 45 | 46 | First go to the Core Configuration Manager (CCM) -> Select Hosts -> Select a host you would like to add to a hostgroup -> Click the Manage Host Groups button. Select any hostgroups you want this host to be a member of, click Add Selected, and then Close. 47 | 48 | #### Hostgroups Example 1 49 | As an example, you might have prodhosts vs testhosts as hostgroups in Nagios XI. Any hosts in XI that are pulled by the dynamic inventory plugin will also read whether the hosts are members of prodhosts or testhosts. This could allow you to apply Windows updates to your testing environment to see how well they will roll out, before sending them on to production hosts. 50 | 51 | In my own use case, I put all of my hosts into the AnsibleManaged hostgroup in Nagios XI, and then determine which groups I want to run playbooks against after the fact. However, for larger environments, that may not be a good idea. 52 | 53 | #### Hostgroups Example 2 54 | Let's say, for example, that you have a large environment, of maybe 400-500 servers and devices that you're monitoring regularly. But then you also have a dynamically scalable application that you host for your customers. In this case you might have two AnsibleManaged type hostgroups. One for your regular servers and devices, and one specifically for your dynamic application. 55 | 56 | In doing this, you could then have two Ansible inventory files. One which starts at the hostgroup for your regular servers and devices, and one that only looks at the systems in your dynamic application. 57 | 58 | ### Custom Variables 59 | This is the lesser known feature of Nagios XI. But in similar fashion to hostgroups in Nagios XI, and host groups in Ansible, there is an amazing opportunity to pair Nagios XI custom variables with Ansible's host variables. This dynamic inventory plugin will help you take advantage of that pairing. 60 | 61 | In Nagios XI, custom variables can be defined at the host level, or the service level. Since we're working with Ansible's inventory, let's focus on host custom variables. In order to define a host custom variable in Nagios XI, go to the Core Configuration Manager (CCM) -> Click on Hosts -> Select a host you would like to add a variable to and click on it -> Click on the Misc Settings tab -> And then click the Manage Custom Variables button. 62 | 63 | Now you should have a window where you can add as many custom variables as you like. Note that custom variables need to start with an underscore ( _ ). Let's start by creating a custom variable that Ansible can use. In the `name` field, enter `_ansible_private_key_file` and for the value enter a path where there is an SSH key file that Ansible could use for SSH'ing into another host. For my example, I have, `/home/ansibelle/ansible/keys/id_ed25519`. *Please take special note, we are specifying the private key file, here.* 64 | 65 | As long as you're here, you can also define `_ansible_user` as a custom variable as well. 66 | 67 | These variables will show up on your Ansible system when you run `ansible-inventory --graph my_xi_inventory.yml`, assuming your inventory file is named `my_xi_inventory.yml`, of course. 68 | 69 | #### Potentialy Useful Custom Variables 70 | The three easy variables that come to mind are: 71 | `_ansible_user` 72 | `_ansible_connection` 73 | `_ansible_private_key_file` 74 | 75 | With these three variables, you can define what user to use to connect to a given system, how Ansible should go about connecting to it, and if the connection method is SSH, where Ansible can find the right private key file to use. 76 | 77 | But, if your connection method is WinRM, what then? Well, replace `_ansible_private_key_file` with `_ansible_password`. With WinRM, you'll also need an additional variable, which is the transport. `_ansible_winrm_transport` 78 | 79 | One other thing to consider is any variable you might use in your roles. Maybe you have a variable defined on your Nagios XI hosts that an Ansible `when` clause will evaluate. 80 | 81 | ### Templates 82 | Strictly speaking, Nagios XI templates won't help the integration with XI and Ansible, so much as they will help you manage hostgroups and custom variables in Nagios XI. Looking back at one of our examples, we talked about having four or five hundred devices to monitor. You really don't want to have to micromanage which hosts get which custom variables, and which hosts are members of which hostgroups. 83 | 84 | That's where templating comes into play. You can define multiple hostgroups, and custom variables in a single template, and then just apply that template to your variaous hosts. It will save you a ton of time. 85 | 86 | To create a new template in Nagios XI, go to the Core Configuration Manager (CCM) -> Select Templates -> In the left menu, under Templates, select Host Templates -> Click the Add New button. The page you are brought to looks very much like a host definition page. So managing hostgroups, and custom variables will be similar to what you've done previously. The Manage Host Groups button can be found in the Common Settings tab, and the Manage Custom Variables button can be found under the Misc Settings tab. 87 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/plugins/inventory/nagiosxi.py: -------------------------------------------------------------------------------- 1 | from __future__ import (absolute_import, division, print_function) 2 | __metaclass__ = type 3 | 4 | DOCUMENTATION = ''' 5 | name: nagiosxi 6 | plugin_type: inventory 7 | short_description: Returns Ansible inventory from a Nagios XI system 8 | description: Returns Ansible inventory from a Nagios XI system 9 | options: 10 | plugin: 11 | description: Name of the plugin 12 | required: True 13 | choices: ['nagiosxi'] 14 | disable_warnings: 15 | description: Disable TLS checks for https connections to Nagios XI's API 16 | required: True 17 | choices: ['True', 'False'] 18 | secure: 19 | description: Whether to use http or https. If False, http, if True, https. 20 | required: True 21 | choices: ['True', 'False'] 22 | xi_ip: 23 | description: The IP or hostname of the Nagios XI system. 24 | required: True 25 | xi_api_key: 26 | description: The API key capable of reading the Nagios XI API 27 | required: True 28 | xi_hostgroup: 29 | description: The Hostgroup containing hosts you want to manage with Ansible 30 | required: True 31 | ''' 32 | EXAMPLES = ''' 33 | plugin: nagiosxi 34 | disable_warnings: "True" 35 | secure: "False" 36 | xi_ip: 192.168.0.20 37 | xi_api_key: th0XBK6EiR9aJsg26ipq8CevPhLYPYlK3rnD2dqd6OFa6eb48 38 | xi_hostgroup: AnsibleManaged 39 | ''' 40 | 41 | import requests 42 | import sys 43 | import os 44 | 45 | from ansible import constants as C 46 | from ansible.errors import AnsibleParserError, AnsibleParserError 47 | from ansible.module_utils.common.text.converters import to_native, to_text 48 | from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable 49 | 50 | class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): 51 | 52 | NAME = 'nagiosxi' 53 | _load_name = 'nagiosxi' 54 | 55 | def _empty_inventory(): 56 | returnempty = self.inventory_header() 57 | 58 | return returnempty 59 | 60 | def __init__(self): 61 | 62 | self.secure = None 63 | self.xiurl = None 64 | self.xiapikey = None 65 | self.xihostgroup = None 66 | 67 | super(InventoryModule, self).__init__() 68 | 69 | #self.xiurl = self.get_option('xiurl') 70 | #self.xiapikey = self.get_option('xiapikey') 71 | #self.xihostgroup = self.get_option('xihostgroup') 72 | 73 | #if self.get_option('disable_warnings') == 'True': 74 | # requests.packages.urllib3.disable_warnings() 75 | 76 | 77 | 78 | def inventory_header(self): 79 | inv_headers = {} 80 | inv_headers['_meta'] = { 'hostvars': {} } 81 | 82 | return inv_headers 83 | 84 | def verify_file(self, path): 85 | 86 | valid = False 87 | if super(InventoryModule, self).verify_file(path): 88 | file_name, ext = os.path.splitext(path) 89 | 90 | if not ext or ext in C.YAML_FILENAME_EXTENSIONS: 91 | valid = True 92 | 93 | return valid 94 | 95 | def parse(self, inventory, loader, path, cache=True): 96 | 97 | super(InventoryModule, self).parse(inventory, loader, path, cache=cache) 98 | 99 | self._read_config_data(path) 100 | 101 | try: 102 | self.xiurl = self.get_option('xi_ip') 103 | self.xiapikey = self.get_option('xi_api_key') 104 | self.xihostgroup = self.get_option('xi_hostgroup') 105 | 106 | if self.get_option('disable_warnings') == 'True': 107 | requests.packages.urllib3.disable_warnings() 108 | 109 | if self.get_option('secure') == 'True': 110 | self.xiurl = 'https://{0}/nagiosxi/api/v1/'.format(self.xiurl) 111 | else: 112 | self.xiurl = 'http://{0}/nagiosxi/api/v1/'.format(self.xiurl) 113 | 114 | 115 | except Exception as e: 116 | raise AnsibleParseError( 117 | 'All correct options required: {}'.format(e)) 118 | 119 | self._populate() 120 | 121 | 122 | 123 | def _populate(self): 124 | hostsfromnagios = self.inventory_header() 125 | managedhostsurl = self.xiurl + 'objects/hostgroupmembers?apikey={0}&hostgroup_name={1}&pretty=0'.format(self.xiapikey,self.xihostgroup) 126 | managedhosts = requests.get(managedhostsurl, verify=False) 127 | 128 | for host in managedhosts.json()['hostgroup'][0]['members']['host']: 129 | hostdetailsurl = self.xiurl + 'objects/host?apikey={0}&host_name={1}&customvars=1&pretty=0'.format(self.xiapikey,host['host_name']) 130 | 131 | groupdetailurl = self.xiurl + 'config/host?apikey={0}&host_name={1}&pretty=0'.format(self.xiapikey,host['host_name']) 132 | 133 | #Grab host variables 134 | hostdetail = requests.get(hostdetailsurl, verify=False).json() 135 | 136 | #Grab additional hostgroup membership and put a new entry into hostsfromnagios 137 | groupdetail = requests.get(groupdetailurl, verify=False).json() 138 | 139 | for group in groupdetail[0]['hostgroups']: 140 | if group not in self.inventory.get_groups_dict(): 141 | self.inventory.add_group(group) 142 | 143 | self.inventory.add_host(host=hostdetail['host'][0]['address'], group=group) 144 | 145 | for var, value in hostdetail['host'][0]['customvars'].items(): 146 | self.inventory.set_variable(hostdetail['host'][0]['address'], var.lower(), value) 147 | 148 | #This will add the host to the Ansible host group. 149 | # hostsfromnagios[group]['hosts'].append(hostdetail['host'][0]['address']) 150 | 151 | #return hostsfromnagios 152 | 153 | 154 | def verifyhostgroupname(self): 155 | validcharacters = list(string.ascii_lowercase) 156 | validcharacters.extend(list(string.ascii_uppercase)) 157 | validcharacters.extend(list(range(0,10,1))) 158 | validcharacters.extend('_') 159 | invalidchars = [] 160 | 161 | for char in list(self.xi_hostgroup): 162 | if char not in validcharacters: 163 | invalidchars.append(char) 164 | 165 | if len(invalidchars) > 0: 166 | sys.exit("Ansible will not accept, or has difficulty dealing with the following characters: {0}".format(invalidchars)) 167 | else: 168 | return True 169 | 170 | def gethosts(self): 171 | try: 172 | response = requests.get(self.url) 173 | except ConnectionError as e: 174 | raise SystemExit(e) 175 | 176 | if 'error' in response.json(): 177 | e = "Error connecting to the API. Response was: {0}".format(response.json()['error']) 178 | return False 179 | 180 | return response 181 | 182 | def sorthosts(self, hostlist: requests.models.Response): 183 | for host in hostlist.json(): 184 | if xi_hostgroup in host['hostgroup']: 185 | pass 186 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/roles/README.md: -------------------------------------------------------------------------------- 1 | # Ansible roles for Nagios XI 2 | 3 | ## Support 4 | The Ansible roles for Nagios XI are a set of community supported roles for affecting changes within the Nagios XI monitoring environment via Ansible. 5 | 6 | ## Disclaimer 7 | ***Please read through each script before attempting to use it in your 8 | environment.*** 9 | 10 | These scripts are provided "as is" *without warranty of any kind*, either 11 | expressed or implied, including, but not limited to, the implied warranties 12 | of merchantability and fitness for a particular purpose. 13 | 14 | ## Installation 15 | The Nagios XI roles should live anywhere you keep roles that you reference in your playbooks. 16 | 17 | ## Required Ansible Variables 18 | ### For both xi_host_scheduled_downtime_create/delete 19 | - `xi_ip` - The IP address (or hostname) of your Nagios XI server 20 | - `xi_api_key` - The API key for a user on your Nagios XI server 21 | - `downtime_comment` - The comment you want to appear in Nagios XI for the downtime. If running from the commandline, you will be prompted for this variable. 22 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/roles/xi_host_scheduled_downtime_create/README.md: -------------------------------------------------------------------------------- 1 | # xi_host_scheduled_downtime_create 2 | --- 3 | 4 | ## *WORK IN PROGRESS* 5 | First, let it be known that this role is a work in progress. This role may not even work at present. Please be patient. 6 | 7 | ## The Goal 8 | The goal of this role is to create scheduled downtime in Nagios XI for one or more hosts. 9 | 10 | ## The Use Case 11 | Imagining this being used where Ansible is being used to run OS updates on multiple systems. Ansible, tied in to Nagios XI as its inventory source, can reach back out to Nagios XI and set the hosts into downtime. 12 | 13 | ## Current Variables 14 | - xi_ip - The IP address of your Nagios XI system 15 | - xi_api_key - The API key used for authenticating to Nagios XI 16 | - downtime_comment - Any comment you would like people to see in the Nagios XI interface related to this downtime 17 | - downtime_start - The start of the scheduled downtime. Usually right around this very instant. 18 | - downtime_end - The end of the scheduled downtime. Usually 2 hours after this very instant. 19 | - inventory_hostname - The hostname of the inventory host currently being processed. 20 | 21 | ## Other things to note 22 | I have this role delegated to localhost, meaning that the system running Ansible should be the one reaching out to Nagios XI's API. Feeling cute, might make this a variable later. Happy to hear thoughts on the matter. 23 | 24 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/roles/xi_host_scheduled_downtime_create/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Set downtime start 4 | command: "date +'%s'" 5 | register: downtime_start 6 | delegate_to: 127.0.0.1 7 | 8 | - name: Set downtime end 9 | command: "date +'%s' -d '120 minutes' " 10 | register: downtime_end 11 | delegate_to: 127.0.0.1 12 | 13 | - name: Set Downtime 14 | uri: 15 | url: http://{{ xi_ip }}/nagiosxi/api/v1/system/scheduleddowntime?apikey={{ xi_api_key }} 16 | body: "comment={{ downtime_comment }}&start={{ downtime_start.stdout }}&end={{ downtime_end.stdout }}&hosts[]={{ inventory_hostname }}" 17 | method: POST 18 | validate_certs: no 19 | timeout: 20 20 | delegate_to: 127.0.0.1 21 | -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/roles/xi_host_scheduled_downtime_delete/README.md: -------------------------------------------------------------------------------- 1 | # xi_host_scheduled_downtime_delete 2 | --- 3 | 4 | ## *WORK IN PROGRESS* 5 | First, let it be known that this role is a work in progress. This role may not even work at present. Please be patient. 6 | 7 | ## The Goal 8 | The goal of this role is to delete scheduled downtime in Nagios XI for one or more hosts. 9 | 10 | ## The Use Case 11 | Imagining this being used where Ansible is being used to run OS updates on multiple systems. Assuming that the updates were run within the downtime window, this role could be used to remove existing downtime. 12 | 13 | ## Current Variables 14 | - xi_ip - The IP address of your Nagios XI system 15 | - xi_api_key - The API key used for authenticating to Nagios XI 16 | - inventory_hostname - The hostname of the inventory host currently being processed. 17 | - downtime_result - The role queries the Nagios XI API for the downtime related to the current inventory host, then deletes the downtime. 18 | 19 | ## Other things to note 20 | I have this role delegated to localhost, meaning that the system running Ansible should be the one reaching out to Nagios XI's API. Feeling cute, might make this a variable later. Happy to hear thoughts on the matter. 21 | 22 | If you read the `downtime_result` variable description and thought, "Wait...What happens if there's more than 1 scheduled downtime entry for a given host," good catch! I don't know yet. I'm in the middle of 8 different things, all of which are irritating. But I will find out, and find a better way to make sure that we're destroying the appropriate downtime entry. -------------------------------------------------------------------------------- /ansible/nagios/nagios_xi/roles/xi_host_scheduled_downtime_delete/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Get Downtime ID 4 | uri: 5 | url: https://{{ xi_ip }}/nagiosxi/api/v1/objects/downtime?apikey={{ xi_api_key }}&host_name={{ inventory_hostname }}&pretty=0 6 | method: GET 7 | validate_certs: no 8 | timeout: 20 9 | return_content: no 10 | body_format: json 11 | register: downtime_result 12 | delegate_to: 127.0.0.1 13 | 14 | - name: Delete Downtime 15 | uri: 16 | url: https://{{ xi_ip }}/nagiosxi/api/v1/system/scheduleddowntime/{{ downtime_result.json.scheduleddowntime[0].internal_id }}?apikey={{ xi_api_key }}&pretty=0 17 | method: DELETE 18 | validate_certs: no 19 | timeout: 20 20 | delegate_to: 127.0.0.1 21 | -------------------------------------------------------------------------------- /ansible/ncpa/README.md: -------------------------------------------------------------------------------- 1 | These playbooks and roles are designed to distribute the Nagios Cross Platform Agent (NCPA) to devices in your environment, and then register the devices for monitoring via the Nagios XI API. 2 | 3 | Users adapt these files to their environments through required and optional setup. 4 | 5 | 6 | # Required Setup 7 | 8 | Users must supply three pieces of information: 9 | 1) the IP address or FQDN of the Nagios XI installation 10 | 2) an administrative-level Nagios XI API key 11 | 3) the NCPA authentication token 12 | 13 | 14 | ## Security considerations for required setup 15 | 16 | An administrative-level Nagios XI API key can be used to modify any or all XI configs programmatically. The NCPA authentication token grants access to NCPA functionality on the monitored device. 17 | 18 | 19 | ### Fast, less-secure required setup 20 | 21 | 1) Tower/AWX: add the items as EXTRA VARIABLES in the Job Template: 22 | ```yml 23 | --- 24 | xi_ip: '192.168.100.100' 25 | xi_api_key: 'XFbaUsuPi0OU3n0jmVkCAkYl78t2DodBkI0eav3sP8G8CHrXS5vooNNubAPOX3lh' 26 | ncpa_token: 'a_secure_token' 27 | ``` 28 | 29 | 2) Ansible CLI: add a vars section above the roles section(s) in linux_ncpa_install_and_register.yml and windows_ncpa_install_and_register.yml: 30 | ```yml 31 | vars: 32 | xi_ip: '192.168.100.100' 33 | xi_api_key: 'XFbaUsuPi0OU3n0jmVkCAkYl78t2DodBkI0eav3sP8G8CHrXS5vooNNubAPOX3lh' 34 | ncpa_token: 'a_secure_token' 35 | ``` 36 | 37 | ### More secure required setup 38 | 1) Tower/AWX: create credential types and credentials for the xi_api_key and ncpa_token vars. 39 | 40 | 2) Ansible CLI: add a vars_files and a vars section above the roles section(s) in linux_ncpa_install_and_register.yml and windows_ncpa_install_and_register.yml: 41 | ```yml 42 | vars_files: 43 | - 'secrets.yml' 44 | vars: 45 | xi_ip: '192.168.100.100' 46 | ``` 47 | 48 | Set the XI API Key and the NCPA Token in the vault-encrypted secrets.yml file by running: 49 | ``` 50 | ansible-vault edit secrets.yml 51 | ``` 52 | Enter password hunter2. Feel free to change this password. The file will look something like this, update to suit your environment: 53 | ```yml 54 | --- 55 | xi_api_key: 'XFbaUsuPi0OU3n0jmVkCAkYl78t2DodBkI0eav3sP8G8CHrXS5vooNNubAPOX3lh' 56 | ncpa_token: 'DabohKGprhau' 57 | ``` 58 | When running the playbook, have Ansible prompt for the vault password with the --ask-vault-pass flag as in this example: 59 | ``` 60 | ansible-playbook linux_ncpa_install_and_register.yml --ask-vault-pass 61 | ``` 62 | 63 | 64 | # Optional Setup 65 | Several of these roles generate API calls to Nagios XI. You may wish to edit lines the roles to perhaps assign an appropriate contact (for example) or perhaps change a threshold or adjust a notification_interval. You might wish to edit the main playbooks to remove certain roles/API calls, or create new roles/API calls to suit your environment. 66 | 67 | 68 | ### Nagios XI API documentation location 69 | The Nagios XI API is documented in the Help page of the Nagios XI interface. 70 | 71 | 72 | ### Notes on editing, adding, and deleting roles that create API calls 73 | If you exclude the xi_apply_config role in a playbook that makes API calls, XI will still receive the calls, though the changes will not be applied. You would apply the config manually in the XI CCM. 74 | 75 | The roles that register services provide the minimum configs (host_name, service_description, check_command, check_interval, retry_interval, max_check_attempts, check_period, contacts, notification_interval, notification_period) required for a valid Nagios service config. If you do not include at least those configs in a service role, the service will not be registered. You can add any additional config variable found here https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html#service . Make sure to follow the existing format exactly. Be alert for issues regarding commas, quotes, and escape characters. 76 | 77 | The role that registers hosts provides the minimum configs (host_name, address, max_check_attempts, check_period, contacts, notification_interval, notification_period) required for a valid Nagios host config. If you do not include at least those configs in the host role, the host will not be registered. You can add any additional config variable found here https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html#host . Make sure to follow the existing format exactly. Be alert for issues regarding commas, quotes, and escape characters. -------------------------------------------------------------------------------- /ansible/ncpa/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | inventory = ./hosts 3 | stdout_callback = skippy 4 | retry_files_enabled = False 5 | -------------------------------------------------------------------------------- /ansible/ncpa/hosts: -------------------------------------------------------------------------------- 1 | [linux] 2 | 192.168.1.100 3 | 4 | [windows] 5 | 192.168.1.101 6 | 7 | [windows:vars] 8 | ansible_port=5985 9 | ansible_connection=winrm 10 | ansible_winrm_server_cert_validation=ignore 11 | ansible_user=nagios 12 | ansible_password=demo -------------------------------------------------------------------------------- /ansible/ncpa/linux_ncpa_install_and_register.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install NCPA on Linux and register host and services 3 | hosts: linux 4 | remote_user: root 5 | 6 | roles: 7 | - ncpa_install_linux 8 | - register_host_with_xi 9 | - register_cpu_service_with_xi 10 | - register_ram_service_with_xi 11 | - register_swap_service_with_xi 12 | - register_linux_disk_service_with_xi 13 | - xi_apply_config 14 | -------------------------------------------------------------------------------- /ansible/ncpa/roles/ncpa_install_linux/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Download NCPA 3 | 4 | - name: Download NCPA (Debian 32) 5 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.d{{ ansible_distribution_major_version }}.i386.deb dest=/tmp/ncpa.deb 6 | when: ansible_distribution == "Debian" and ansible_architecture == "i386" 7 | - name: Download NCPA (Debian 64) 8 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.d{{ ansible_distribution_major_version }}.amd64.deb dest=/tmp/ncpa.deb 9 | when: ansible_distribution == "Debian" and ansible_architecture == "x86_64" 10 | 11 | - name: Download NCPA (Ubuntu 32) 12 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.i386.deb dest=/tmp/ncpa.deb 13 | when: ansible_distribution == "Ubuntu" and ansible_architecture == "i386" 14 | - name: Download NCPA (Ubuntu 64) 15 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.amd64.deb dest=/tmp/ncpa.deb 16 | when: ansible_distribution == "Ubuntu" and ansible_architecture == "x86_64" 17 | 18 | - name: Download NCPA (RedHat & CentOS 32) 19 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.el{{ ansible_distribution_major_version }}.i386.rpm dest=/tmp/ncpa.rpm 20 | when: ansible_os_family == "RedHat" and ansible_architecture == "i386" 21 | - name: Download NCPA (RedHat & CentOS 64) 22 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.el{{ ansible_distribution_major_version }}.x86_64.rpm dest=/tmp/ncpa.rpm 23 | when: ansible_os_family == "RedHat" and ansible_architecture == "x86_64" 24 | 25 | - name: Download NCPA (SUSE 11 32) 26 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.os{{ ansible_distribution_major_version }}.i386.rpm dest=/tmp/ncpa.rpm 27 | when: ansible_os_family == "Suse" and ansible_architecture == "i386" and ansible_distribution_major_version|int == 11 28 | - name: Download NCPA (SUSE 11 64) 29 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.os{{ ansible_distribution_major_version }}.x86_64.rpm dest=/tmp/ncpa.rpm 30 | when: ansible_os_family == "Suse" and ansible_architecture == "x86_64" and ansible_distribution_major_version|int == 11 31 | - name: Download NCPA (SUSE >=12) 32 | get_url: url=https://assets.nagios.com/downloads/ncpa/ncpa-latest.os.x86_64.rpm dest=/tmp/ncpa.rpm 33 | when: ansible_os_family == "Suse" and ansible_architecture == "x86_64" and ansible_distribution_major_version|int >= 12 34 | 35 | 36 | 37 | # Install NCPA 38 | 39 | - name: Install NCPA (Debian & Ubuntu) 40 | apt: 41 | deb: /tmp/ncpa.deb 42 | state: present 43 | when: ansible_os_family == "Debian" 44 | 45 | - name: Install NCPA (RedHat & CentOS) 46 | yum: 47 | name: /tmp/ncpa.rpm 48 | state: present 49 | when: ansible_os_family == "RedHat" 50 | 51 | - name: Install NCPA (SUSE & OpenSUSE) 52 | zypper: 53 | name: /tmp/ncpa.rpm 54 | disable_gpg_check: yes 55 | state: present 56 | when: ansible_os_family == "Suse" 57 | 58 | 59 | 60 | # Set NCPA Token 61 | 62 | - name: Set NCPA Token 63 | lineinfile: 64 | dest: /usr/local/ncpa/etc/ncpa.cfg 65 | regexp: ^community_string 66 | line: "community_string = {{ ncpa_token }}" 67 | 68 | 69 | 70 | # Restart NCPA 71 | 72 | - name: Restart NCPA 73 | service: 74 | name: ncpa_listener 75 | state: restarted 76 | enabled: yes 77 | 78 | 79 | 80 | # Configure Firewall 81 | 82 | # Debian by default has no firewall, so this script doesn't need to open anything. If you run Debian and have a firewall scheme, you must modify this script to fit your scheme. If you use UFW, the Ubuntu section should be helpful. 83 | # SUSE (once you enable eth0 to take connections) defaults to no restrictions on internal network traffic. If you are accessing SUSE machines from outside the internal network, or if you have internal network firewall settings, you must specifically allow traffic on 5693 for your environment. 84 | 85 | - name: Open NCPA Port (Ubuntu) 86 | ufw: 87 | state: enabled 88 | policy: allow 89 | proto: any 90 | rule: allow 91 | to_port: 5693 92 | when: ansible_distribution == "Ubuntu" 93 | 94 | - name: Open NCPA Port (CentOS & RHEL 6) 95 | iptables: 96 | chain: INPUT 97 | jump: ACCEPT 98 | destination_port: 5693 99 | state: present 100 | protocol: tcp 101 | when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 102 | 103 | - name: Open NCPA Port (CentOS 7) 104 | iptables: 105 | chain: INPUT 106 | jump: ACCEPT 107 | destination_port: 5693 108 | state: present 109 | protocol: tcp 110 | when: ansible_distribution == "CentOS" and ansible_distribution_major_version|int == 7 111 | 112 | - name: Open NCPA Port (RedHat 7) 113 | firewalld: 114 | immediate: yes 115 | permanent: yes 116 | port: 5693 117 | state: enabled 118 | when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 7 119 | 120 | - name: Save iptables Config (CentOS & RHEL 6) 121 | command: service iptables save 122 | when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 123 | 124 | - name: Save iptables Config (CentOS 7) 125 | command: iptables-save 126 | when: ansible_distribution == "CentOS" and ansible_distribution_major_version|int == 7 127 | 128 | -------------------------------------------------------------------------------- /ansible/ncpa/roles/ncpa_install_windows/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Windows install NCPA 3 | win_package: 4 | path: http://assets.nagios.com/downloads/ncpa/ncpa-latest.exe 5 | product_id: 'NCPA' 6 | state: present 7 | arguments: "/S /TOKEN='{{ ncpa_token }}'" -------------------------------------------------------------------------------- /ansible/ncpa/roles/register_cpu_service_with_xi/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register CPU Service with XI 3 | uri: 4 | url: http://{{ xi_ip }}/nagiosxi/api/v1/config/service?apikey={{ xi_api_key }} 5 | method: POST 6 | body_format: form-urlencoded 7 | body: 8 | - [ host_name, "{{ inventory_hostname }}" ] 9 | - [ service_description, CPU ] 10 | - [ check_command, "check_xi_ncpa\\!-t '{{ ncpa_token }}' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'" ] 11 | - [ check_interval, 5 ] 12 | - [ retry_interval, 1 ] 13 | - [ max_check_attempts, 2 ] 14 | - [ check_period, 24x7 ] 15 | - [ contacts, nagiosadmin ] 16 | - [ notification_interval, 5 ] 17 | - [ notification_period, 24x7 ] 18 | validate_certs: no 19 | timeout: 120 20 | delegate_to: 127.0.0.1 -------------------------------------------------------------------------------- /ansible/ncpa/roles/register_host_with_xi/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register Host With XI 3 | uri: 4 | url: http://{{ xi_ip }}/nagiosxi/api/v1/config/host?apikey={{ xi_api_key }} 5 | method: POST 6 | body_format: form-urlencoded 7 | body: 8 | - [ host_name, "{{ inventory_hostname }}" ] 9 | - [ address, "{{ inventory_hostname }}" ] 10 | - [ check_command, "check_ping\\!3000,80%\\!5000,100%" ] 11 | - [ max_check_attempts, 2 ] 12 | - [ check_period, 24x7 ] 13 | - [ contacts, nagiosadmin ] 14 | - [ notification_interval, 5 ] 15 | - [ notification_period, 24x7 ] 16 | validate_certs: no 17 | timeout: 120 18 | delegate_to: 127.0.0.1 -------------------------------------------------------------------------------- /ansible/ncpa/roles/register_linux_disk_service_with_xi/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register Linux Disk Service with XI 3 | uri: 4 | url: http://{{ xi_ip }}/nagiosxi/api/v1/config/service?apikey={{ xi_api_key }} 5 | method: POST 6 | body_format: form-urlencoded 7 | body: 8 | - [ host_name, "{{ inventory_hostname }}" ] 9 | - [ service_description, Disk ] 10 | - [ check_command, "check_xi_ncpa\\!-t '{{ ncpa_token }}' -P 5693 -M 'disk/logical/|/used_percent' -w 70 -c 90" ] 11 | - [ check_interval, 5 ] 12 | - [ retry_interval, 1 ] 13 | - [ max_check_attempts, 2 ] 14 | - [ check_period, 24x7 ] 15 | - [ contacts, nagiosadmin ] 16 | - [ notification_interval, 5 ] 17 | - [ notification_period, 24x7 ] 18 | validate_certs: no 19 | timeout: 120 20 | delegate_to: 127.0.0.1 -------------------------------------------------------------------------------- /ansible/ncpa/roles/register_ram_service_with_xi/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register RAM Service with XI 3 | uri: 4 | url: http://{{ xi_ip }}/nagiosxi/api/v1/config/service?apikey={{ xi_api_key }} 5 | method: POST 6 | body_format: form-urlencoded 7 | body: 8 | - [ host_name, "{{ inventory_hostname }}" ] 9 | - [ service_description, RAM ] 10 | - [ check_command, "check_xi_ncpa\\!-t '{{ ncpa_token }}' -P 5693 -M memory/virtual -u -w 50 -c 80" ] 11 | - [ check_interval, 5 ] 12 | - [ retry_interval, 1 ] 13 | - [ max_check_attempts, 2 ] 14 | - [ check_period, 24x7 ] 15 | - [ contacts, nagiosadmin ] 16 | - [ notification_interval, 5 ] 17 | - [ notification_period, 24x7 ] 18 | validate_certs: no 19 | timeout: 120 20 | delegate_to: 127.0.0.1 -------------------------------------------------------------------------------- /ansible/ncpa/roles/register_swap_service_with_xi/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register Swap Service with XI 3 | uri: 4 | url: http://{{ xi_ip }}/nagiosxi/api/v1/config/service?apikey={{ xi_api_key }} 5 | method: POST 6 | body_format: form-urlencoded 7 | body: 8 | - [ host_name, "{{ inventory_hostname }}" ] 9 | - [ service_description, Swap ] 10 | - [ check_command, "check_xi_ncpa\\!-t '{{ ncpa_token }}' -P 5693 -M memory/swap -u -w 50 -c 80" ] 11 | - [ check_interval, 5 ] 12 | - [ retry_interval, 1 ] 13 | - [ max_check_attempts, 2 ] 14 | - [ check_period, 24x7 ] 15 | - [ contacts, nagiosadmin ] 16 | - [ notification_interval, 5 ] 17 | - [ notification_period, 24x7 ] 18 | validate_certs: no 19 | timeout: 120 20 | delegate_to: 127.0.0.1 -------------------------------------------------------------------------------- /ansible/ncpa/roles/register_windows_disk_service_with_xi/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register Windows Disk Service with XI 3 | uri: 4 | url: http://{{ xi_ip }}/nagiosxi/api/v1/config/service?apikey={{ xi_api_key }} 5 | method: POST 6 | body_format: form-urlencoded 7 | body: 8 | - [ host_name, "{{ inventory_hostname }}" ] 9 | - [ service_description, Disk ] 10 | - [ check_command, "check_xi_ncpa\\!-t '{{ ncpa_token }}' -P 5693 -M 'disk/logical/C:|/used_percent' -w 70 -c 90" ] 11 | - [ check_interval, 5 ] 12 | - [ retry_interval, 1 ] 13 | - [ max_check_attempts, 2 ] 14 | - [ check_period, 24x7 ] 15 | - [ contacts, nagiosadmin ] 16 | - [ notification_interval, 5 ] 17 | - [ notification_period, 24x7 ] 18 | validate_certs: no 19 | timeout: 120 20 | delegate_to: 127.0.0.1 -------------------------------------------------------------------------------- /ansible/ncpa/roles/xi_apply_config/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Apply Configuration 3 | uri: 4 | url: http://{{ xi_ip }}/nagiosxi/api/v1/system/applyconfig?apikey={{ xi_api_key }} 5 | body: "applyconfig=1" 6 | method: POST 7 | validate_certs: no 8 | timeout: 120 9 | delegate_to: 127.0.0.1 10 | run_once: true -------------------------------------------------------------------------------- /ansible/ncpa/secrets.yml: -------------------------------------------------------------------------------- 1 | $ANSIBLE_VAULT;1.1;AES256 2 | 32313538653362383738623966636438363839643366663930356131666234353561613333363261 3 | 3131343432313238633866373865623662633637386666610a333963356630383237336565373035 4 | 37376663336466366338633962373531643864363563623862366634653331336335333536643366 5 | 6665613862383430310a313037626137646635313562366630373065623262396539343838633731 6 | 35653836616135653162373236393864643030633536613036646135313735656231326439363933 7 | 37343830633134343035656632383930626530326239373439643231633234646433396161613934 8 | 30326232613338663361356661333364313333613532643466393962383330303965346164313439 9 | 64393964646332356363613138363165643733366464353739653939363465336230306161393439 10 | 35663962613136343636333939643135336566353836646561323363343565646139 11 | -------------------------------------------------------------------------------- /ansible/ncpa/windows_ncpa_install_and_register.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install NCPA on Windows 3 | hosts: windows 4 | become: yes 5 | become_method: runas 6 | become_user: SYSTEM 7 | 8 | roles: 9 | - ncpa_install_windows 10 | 11 | - name: Register Windows host and services 12 | hosts: windows 13 | 14 | roles: 15 | - register_host_with_xi 16 | - register_cpu_service_with_xi 17 | - register_ram_service_with_xi 18 | - register_windows_disk_service_with_xi 19 | - xi_apply_config 20 | -------------------------------------------------------------------------------- /misc/auto_register.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #################### 4 | # 5 | # This script will auto-register this host with Nagios XI. 6 | # 7 | #################### 8 | 9 | ########## 10 | # 11 | # Replace the 127.0.0.1 IP address in the line below with the IP address of your Nagios XI server 12 | # 13 | ########## 14 | 15 | my_xi_serverip=$(127.0.0.1) 16 | 17 | ########## 18 | # 19 | # Replace this_key in the line below with your actual Nagios XI API key 20 | # 21 | ########## 22 | 23 | my_xi_apikey=$(this_key) 24 | 25 | ########## 26 | # 27 | # The command below stores the IP address of the machine as the variable my_ip 28 | # 29 | # The code is from https://stackoverflow.com/questions/21336126/linux-bash-script-to-extract-ip-address 30 | # 31 | # If you have a more elegant solution you are welcome to use it. 32 | # 33 | # The code shown here uses the Linux ip command, and parses out the ip of this host from the output of the ip command. 34 | # You will notice the ip address 8.8.8.8 for Google's DNS service. In theory, any ip address there ought to work 35 | # as the the command will return the ip address of this host whether the destination ip is reachable or not. 36 | # 37 | ########## 38 | 39 | my_ip=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}') 40 | 41 | ########## 42 | # 43 | # The command below stores the hostname of the machine as my_host_name 44 | # 45 | # Uncomment IF you set unique hostnames for your machines AND you want to use this hostname in Nagios XI. 46 | # 47 | ########## 48 | 49 | #my_host_name=$(hostname) 50 | 51 | ########## 52 | # 53 | # The command below is an API call to your Nagios XI instance that will 54 | # create the host with a Nagios Host_name of the ip address of the machine 55 | # 56 | # Optional edit: change host_name=${my_ip} to host_name=${my_host_name} in the API call below IF you uncommented the 57 | # $my_host_name=$(hostname) command immediately above this comment block 58 | # 59 | ########## 60 | 61 | curl -XPOST "http://${my_xi_serverip}/nagiosxi/api/v1/config/host?apikey=${my_xi_apikey}&pretty=1" -d "host_name=${my_ip}&address=${my_ip}&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1" 62 | 63 | 64 | -------------------------------------------------------------------------------- /misc/nmap_parser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # this script pulls IP addresses out of a file with nmap XML output 4 | # and then writes the addresses to a different file e.g. ansible host file 5 | # the script assumes the XML file with nmap out put is named nmapxml 6 | 7 | 8 | import xml.etree.ElementTree as ET 9 | tree = ET.parse(nmapxml) 10 | root = tree.getroot() 11 | 12 | with open('writetest', 'a') as f: 13 | for address in root.iter('address'): 14 | add = address.get('addr') 15 | f.write(add + '\n') 16 | 17 | 18 | 19 | 20 | 21 | --------------------------------------------------------------------------------