From 899b9da5b412bb0bb3eb4b8b2fe6de97429d34cb Mon Sep 17 00:00:00 2001 From: Gunnar Beutner <gunnar.beutner@netways.de> Date: Sat, 12 Apr 2014 08:18:38 +0200 Subject: [PATCH] Update ITL commands. Refs #4865 --- components/agent/agentlistener.cpp | 9 ++---- doc/5-icinga-template-library.md | 18 +++++++++++- etc/CMakeLists.txt | 1 + etc/icinga2/conf.d/localhost.conf | 6 ++++ etc/icinga2/features-available/agent.conf | 11 +++++++ itl/command-common.conf | 35 +++++++++++++++++------ 6 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 etc/icinga2/features-available/agent.conf diff --git a/components/agent/agentlistener.cpp b/components/agent/agentlistener.cpp index 452935710..3d4675afa 100644 --- a/components/agent/agentlistener.cpp +++ b/components/agent/agentlistener.cpp @@ -151,18 +151,13 @@ void AgentListener::NewClientHandler(const Socket::Ptr& client, TlsRole role) JsonRpc::SendMessage(tlsStream, request); } - Dictionary::Ptr message; - try { - message = JsonRpc::ReadMessage(tlsStream); + Dictionary::Ptr message = JsonRpc::ReadMessage(tlsStream); + MessageHandler(tlsStream, identity, message); } catch (const std::exception& ex) { Log(LogWarning, "agent", "Error while reading JSON-RPC message for agent '" + identity + "': " + DiagnosticInformation(ex)); - - return; } - MessageHandler(tlsStream, identity, message); - tlsStream->Close(); } diff --git a/doc/5-icinga-template-library.md b/doc/5-icinga-template-library.md index 4b5b4d7b0..664e0789c 100644 --- a/doc/5-icinga-template-library.md +++ b/doc/5-icinga-template-library.md @@ -212,7 +212,7 @@ cgreater | **Optional.** The user count critical threshold. Defaults to 5 ### <a id="itl-processes"></a> processes -Check command object for the `check_processes` plugin. +Check command object for the `check_procs` plugin. Custom Attributes: @@ -221,6 +221,17 @@ Name | Description wgreater | **Optional.** The process count warning threshold. Defaults to 250. cgreater | **Optional.** The process count critical threshold. Defaults to 400. +### <a id="itl-swap"></a> swap + +Check command object for the `check_swap` plugin. + +Custom Attributes: + +Name | Description +----------------|-------------- +wfree | **Optional.** The free swap space warning threshold in %. Defaults to 50. +cfree | **Optional.** The free swap space critical threshold in %. Defaults to 25. + ### <a id="itl-load"></a> load Check command object for the `check_load` plugin. @@ -266,3 +277,8 @@ Check command for the built-in `icinga` check. This check returns performance data for the current Icinga instance. The `icinga` check command does not support any vars. + +### <a id="itl-kernel"></a> kernel + +Checks whether the version of the currently running kernel matches the +on-disk kernel image. diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt index a1f0a8fd1..8f60608e7 100644 --- a/etc/CMakeLists.txt +++ b/etc/CMakeLists.txt @@ -30,6 +30,7 @@ install_if_not_exists(icinga2/conf.d/localhost.conf ${CMAKE_INSTALL_SYSCONFDIR}/ install_if_not_exists(icinga2/conf.d/notifications.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) install_if_not_exists(icinga2/conf.d/timeperiods.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) install_if_not_exists(icinga2/conf.d/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/features-available/agent.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) install_if_not_exists(icinga2/features-available/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) install_if_not_exists(icinga2/features-available/command.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) install_if_not_exists(icinga2/features-available/compatlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) diff --git a/etc/icinga2/conf.d/localhost.conf b/etc/icinga2/conf.d/localhost.conf index f4b208347..432427f72 100644 --- a/etc/icinga2/conf.d/localhost.conf +++ b/etc/icinga2/conf.d/localhost.conf @@ -66,3 +66,9 @@ object Service "disk" { check_command = "disk" } +object Service "kernel" { + import "generic-service" + + host_name = "localhost" + check_command = "kernel" +} diff --git a/etc/icinga2/features-available/agent.conf b/etc/icinga2/features-available/agent.conf new file mode 100644 index 000000000..152e9fd5d --- /dev/null +++ b/etc/icinga2/features-available/agent.conf @@ -0,0 +1,11 @@ +/** + * The agent listener accepts checks from agents. + */ + +library "agent" + +object AgentListener "agent" { + cert_path = SysconfDir + "/icinga2/pki/your-master.crt" + key_path = SysconfDir + "/icinga2/pki/your-master.key" + ca_path = SysconfDir + "/icinga2/pki/ca.crt" +} diff --git a/itl/command-common.conf b/itl/command-common.conf index adc29de07..942466a19 100644 --- a/itl/command-common.conf +++ b/itl/command-common.conf @@ -199,7 +199,7 @@ object CheckCommand "disk" { vars.cfree = 10, } -object CheckCommand "users"{ +object CheckCommand "users" { import "plugin-check-command", command = [ @@ -212,7 +212,7 @@ object CheckCommand "users"{ vars.cgreater = 50, } -object CheckCommand "processes"{ +object CheckCommand "processes" { import "plugin-check-command", command = [ @@ -225,7 +225,20 @@ object CheckCommand "processes"{ vars.cgreater = 400, } -object CheckCommand "load"{ +object CheckCommand "swap" { + import "plugin-check-command", + + command = [ + PluginDir + "/check_swap", + "-w", "$wgreater$%", + "-c", "$cgreater$%" + ], + + vars.wfree = 50, + vars.cfree = 25, +} + +object CheckCommand "load" { import "plugin-check-command", command = [ @@ -243,7 +256,7 @@ object CheckCommand "load"{ vars.cload15 = 4.0 } -object CheckCommand "snmp"{ +object CheckCommand "snmp" { import "plugin-check-command", command = [ @@ -256,23 +269,23 @@ object CheckCommand "snmp"{ vars.community = "public" } -object CheckCommand "snmp-uptime"{ +object CheckCommand "snmp-uptime" { import "snmp", vars.oid = "1.3.6.1.2.1.1.3.0" } -object CheckCommand "icinga"{ +object CheckCommand "icinga" { import "icinga-check-command", } -object CheckCommand "cluster"{ +object CheckCommand "cluster" { import "cluster-check-command", } -object CheckCommand "snmp-extend"{ +object CheckCommand "snmp-extend" { import "plugin-check-command", command = [ @@ -285,6 +298,12 @@ object CheckCommand "snmp-extend"{ vars.community = "public" } +object CheckCommand "kernel" { + import "plugin-check-command" + + command = [ SysconfDir + "/icinga2/scripts/check_kernel" ] +} + object CheckCommand "agent" { import "agent-check-command" }