commit 7cacd3edc6bec07c544ceb5d55c8f321d869dcab Author: Yannik Schmidt Date: Thu Nov 25 11:40:55 2021 +0100 Initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd13c1d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.swp +*.sqlite +*.json diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..fcdc0c7 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2021 Yannik Schmidt + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cce1642 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# Icinga Client Webhooks and lazy report-in checks +# The Problem & The Solution + +This gateway meant as an alternative to passive checks for services which report in irregularly, like checks on your laptop or monthly backups which may be a few days late. The client sends an HTTP request to this server, the Icinga instance queries this server with active checks. The Server stores the check-ins by the client and response with *OK*, *Warning*, *CRITICAL* to the Icinga active checks according the the last report and time since the last report. + +By doing this you define leniency to late or missing reports easier than by using passive checks, for example define an two day grace time for a monthly backup to report completion, or the update status of your laptop which you may not use every day, something that's not really possible in native Icinga. Even if you find a way to create passive checks for your problems, they will inevitably have soft-state changes which will clutter up your dashboard. + +# Service Configuration +Services are configured in *services.json* as objects like this: + + { + "service_name" : { + "token" : "secret_client_token", + "timeout" : "timeout_in_seconds", # or 0 for infinite + }, + ... + } + +# Client Requests +Client must send a *POST-request* with *Content-Type: application/json* containing the service name and secret token as fields. + +For example: + + curl -X POST \ + -H "application/json" \ + -d "{ "service_name" : "name", "token" : "secret_token" } \ + https://server:port/ + +# Icinga Requests +Use the [python-script]() as a command to execute, you can pass *protocol*, *host*, *port* and *service\_name* as arguments. + + object CheckCommand "gateway" { + command = [ "/path/to/icinga-gateway-command.py" ] + arguments = { + "--protocol" = "$protocol$" + "--host" = "$host$" + "--port" = "$port$" + "--service" = "$service_name$ + } + } + + apply Service "service_name" { + import "generic-service" + check_command = "gateway" + vars.protocol = "https" + vars.host = "localhost" + vars.port = "5000" + vars.service = "service_name" + assign where host.name == "your_host" + } +