add vim icinga2 syntax

This commit is contained in:
Flo 2016-09-13 22:42:14 +02:00
parent 0ce1f753c2
commit d565a3891c
1100 changed files with 162339 additions and 0 deletions

2
vim/bundle/icinga2/.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
debian/ export-ignore
.gitattributes export-ignore

14
vim/bundle/icinga2/.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
.vagrant
.idea
*.patch
*.komodoproject
*.playground
.*.swp
.*.swo
build/
build-debug/
build-release/
build32/
build64/
debug/
release/

View File

@ -0,0 +1,16 @@
<gunnar.beutner@netways.de> <gunnar@beutner.name>
<gunnar.beutner@netways.de> <gunnar@blade9.beutner.name>
Gunnar Beutner <gunnar.beutner@netways.de> <icinga@net-icinga2.adm.netways.de>
<michael.friedrich@netways.de> <michael.friedrich@gmail.com>
<michael.friedrich@netways.de> <Michael.Friedrich@netways.de>
<tobias.vonderkrone@profitbricks.com> <tobias@vonderkrone.info>
Jean-Marcel Flach <jean-marcel.flach@netways.de> <jean-marcel.flach@netways.de>
Dolf Schimmel <dolf@transip.nl> <dolf@dolfschimmel.nl>
Markus Waldmüller <markus.waldmueller@netways.de>
Claudio Kuenzler <ck@claudiokuenzler.com>
<lazyfrosch@icinga.org> <markus@lazyfrosch.de>
<thomas.widhalm@netways.de> <widhalmt@widhalmt.or.at>
<assaf@aikilinux.com> <assaf.flatto@livepopuli.com>
<marius@graylog.com> <marius@torch.sh>
<jason.young@velaspan.com> <jyoung15@gmail.com>
<jo.goossens@hosted-power.com> <sales@hosted-power.com>

View File

@ -0,0 +1,29 @@
sudo: false
language: cpp
cache: ccache
compiler:
- gcc
addons:
apt_packages:
- libboost-all-dev
- flex
- bison
- libssl-dev
- libpq-dev
- libmysqlclient-dev
- libedit-dev
- libyajl-dev
- libwxbase3.0-dev
- libwxgtk3.0-dev
before_script:
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/tmp/icinga2
script:
- make && make test && make install && /tmp/icinga2/sbin/icinga2 --version

116
vim/bundle/icinga2/AUTHORS Normal file
View File

@ -0,0 +1,116 @@
Adam James <adam.james@transitiv.co.uk>
Alexander A. Klimov <alexander.klimov@netways.de>
Alexander Fuhr <alexander.fuhr@netways.de>
Alexander Schomburg <script.acc@alex.schomb.org>
Alexander Wirt <formorer@debian.org>
Andres Ivanov <andres@andres.wtf>
Andrew Meyer <ameyer+secure@nodnetwork.org>
Arnd Hannemann <arnd@arndnet.de>
Assaf Flatto <assaf@aikilinux.com>
Bastian Guse <bguse@nocopy.de>
Benedikt Heine <bebe@bebehei.de>
Bernd Erk <bernd.erk@icinga.org>
Berthold Cogel <cogel@uni-koeln.de>
Blerim Sheqa <blerim.sheqa@netways.de>
Brian De Wolf <git@bldewolf.com>
Brian Dockter <specus@gmail.com>
Bruno Lingner <mail@hugo.ro>
Bård Dahlmo-Lerbæk <bard.dahlmo-lerbaek@skatteetaten.no>
Carlos Cesario <carloscesario@gmail.com>
Carsten Köbke <carsten.koebke@gmx.de>
Christian Birk <mail@birkc.de>
Christian Harke <ch.harke@gmail.com>
Christian Jonak <christian@jonak.org>
Christian Lehmann <christian_lehmann@gmx.de>
Claudio Kuenzler <ck@claudiokuenzler.com>
Conrad Clement <cclement@printeron.com>
Daniel Helgenberger <daniel.helgenberger@m-box.de>
Daniil Yaroslavtsev <dyaroslavtsev@confyrm.com>
David Beck <techiscool@gmail.com>
Dinesh Majrekar <dinesh.majrekar@serverchoice.com>
Dirk Goetz <dirk.goetz@netways.de>
Dolf Schimmel <dolf@transip.nl>
Eduard Güldner <eduard.gueldner@gmail.com>
Edvin Seferovic <edvin@seferovic.net>
Eric Lippmann <eric.lippmann@netways.de>
Evgeni Golov <evgeni@golov.de>
Ferdi Gueran <ferdi.gueran@nextevolution.de>
Gaël Beaudoin <gaboo@gaboo.org>
Gerd von Egidy <gerd@egidy.de>
Gunnar Beutner <gunnar.beutner@netways.de>
Hannes Van de Vel <h@nnes.be>
Heike Jurzik <icinga@huhnix.org>
Hendrik Röder <hendrik.biz@gmail.com>
Ian Kelling <ian@iankelling.org>
Ildar Hizbulin <hizel@vyborg.ru>
James Pharaoh <james@pharaoh.uk>
Jan Andres <jan.andres@berenberg.de>
Jan Wagner <waja@cyconet.org>
Jason Young <jason.young@velaspan.com>
Jean-Louis Dupond <jean-louis@dupond.be>
Jean-Marcel Flach <jean-marcel.flach@netways.de>
Jens Schanz <mail@jensschanz.de>
Jeremy Armstrong <lepubel@gmail.com>
Jesse Morgan <morgajel@gmail.com>
Jo Goossens <jo.goossens@hosted-power.com>
Johannes Meyer <johannes.meyer@netways.de>
Jonas Meurer <jonas@freesources.org>
Joseph L. Casale <jcasale@activenetwerx.com>
Julian Brost <julian@0x4a42.net>
Jérôme Drouet <jerome.drouet@gmail.com>
Lars Engels <lars.engels@0x20.net>
Lee Clemens <java@leeclemens.net>
Lennart Betz <lennart.betz@netways.de>
Louis Sautier <sautier.louis@gmail.com>
Luca Lesinigo <luca@lm-net.it>
Malte Rabenseifner <mail@malte-rabenseifner.de>
Manuel Reiter <reiter@csc.uni-frankfurt.de>
Marcus van Dam <marcus@marcusvandam.nl>
Marius Sturm <marius@graylog.com>
Markus Frosch <lazyfrosch@icinga.org>
Markus Waldmüller <markus.waldmueller@netways.de>
Martin Stiborsky <martin.stiborsky@gmail.com>
Mathieu Lutfy <mathieu@bidon.ca>
Matthaus Owens <matthaus@puppetlabs.com>
Max Zhang <zhenzhan@tibco.com>
Mhd Sulhan <ms@kilabit.info>
Michael Friedrich <michael.friedrich@netways.de>
Michael Kraus <michael.kraus@consol.de>
Mirco Bauer <meebey@meebey.net>
Mirko Nardin <mirko.nardin@gmx.net>
Nicolas Limage <github@xephon.org>
Pall Sigurdsson <palli-github@minor.is>
Paul Richards <paul@minimoo.org>
Per von Zweigbergk <pvz@itassistans.se>
Petr Ruzicka <petr.ruzicka@gmail.com>
Phil Hutchinson <phil@volumedia.co.uk>
Philipp Dallig <philipp.dallig@gmail.com>
Ralph Breier <ralph.breier@roedl.com>
Reto Zeder <reto.zeder@arcade.ch>
Ricardo Bartels <ricardo@bitchbrothers.com>
Rune Darrud <theflyingcorpse@gmail.com>
Sam Kottler <shk@linux.com>
Sebastian Brückner <mail@invlid.com>
Sebastian Chrostek <sebastian@chrostek.net>
Simon Murray <spjmurray@yahoo.co.uk>
Simon Ruderich <simon@ruderich.org>
Siyalrach Anton Thomas <sat@level8.dk>
Stefan Triep <stefan@triep.net>
Stephan Platz <github@paalsteek.de>
Stephan Tesch <stephan@tesch.cx>
Steve McMaster <mcmaster@hurricanelabs.com>
Thomas Gelf <thomas@gelf.net>
Thomas Widhalm <thomas.widhalm@netways.de>
Tim Hardeck <thardeck@suse.de>
Timo Buhrmester <van.fstd@gmail.com>
Tobias Birnbaum <osterd@gmx.de>
Tobias von der Krone <tobias.vonderkrone@profitbricks.com>
Tom Geissler <Tom@d7031.de>
Uwe Ebel <kobmaki@aol.com>
Valentin Hoebel <valentin@xenuser.org>
Vytenis Darulis <vytenis@uber.com>
Wolfgang Nieder <wnd@gmx.net>
Yannick Charton <tontonitch-pro@yahoo.fr>
Yohan Jarosz <yohanjarosz@yahoo.fr>
Zoltan Nagy <abesto@abesto.net>
Élie Bouttier <elie@bouttier.eu>

View File

@ -0,0 +1,344 @@
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
cmake_minimum_required(VERSION 2.6)
set(BOOST_MIN_VERSION "1.41.0")
project(icinga2)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third-party/cmake")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
option(ICINGA2_WITH_MYSQL "Build the MySQL IDO module" ON)
option(ICINGA2_WITH_PGSQL "Build the PostgreSQL IDO module" ON)
option(ICINGA2_WITH_CHECKER "Build the checker module" ON)
option(ICINGA2_WITH_COMPAT "Build the compat module" ON)
option(ICINGA2_WITH_DEMO "Build the demo module" OFF)
option(ICINGA2_WITH_HELLO "Build the hello module" OFF)
option(ICINGA2_WITH_LIVESTATUS "Build the Livestatus module" ON)
option(ICINGA2_WITH_NOTIFICATION "Build the notification module" ON)
option(ICINGA2_WITH_PERFDATA "Build the perfdata module" ON)
option(ICINGA2_WITH_STUDIO "Build the Icinga Studio application" OFF)
option(ICINGA2_WITH_TESTS "Run unit tests" ON)
file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
include(GNUInstallDirs)
include(InstallConfig)
set(ICINGA2_USER "icinga" CACHE STRING "Icinga 2 user")
set(ICINGA2_GROUP "icinga" CACHE STRING "Icinga 2 group")
set(ICINGA2_COMMAND_GROUP "icingacmd" CACHE STRING "Icinga 2 command group")
set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run directory")
set(ICINGA2_PLUGINDIR "/usr/lib/nagios/plugins" CACHE STRING "Path for the check plugins")
set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe")
set(ICINGA2_UNITY_BUILD ON CACHE BOOL "Whether to perform a unity build")
set(ICINGA2_LTO_BUILD OFF CACHE BOOL "Whether to use LTO")
site_name(ICINGA2_BUILD_HOST_NAME)
set(ICINGA2_BUILD_COMPILER_NAME "${CMAKE_CXX_COMPILER_ID}")
if(NOT CMAKE_CXX_COMPILER_VERSION)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
set(ICINGA2_BUILD_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" ${ICINGA2_LICENSE})
file(STRINGS icinga2.spec SPEC_VERSION REGEX "^Version:")
string(LENGTH "${SPEC_VERSION}" SPEC_VERSION_LENGTH)
math(EXPR SPEC_VERSION_LENGTH "${SPEC_VERSION_LENGTH} - 9")
string(SUBSTRING ${SPEC_VERSION} 9 ${SPEC_VERSION_LENGTH} SPEC_VERSION)
configure_file(icinga-spec-version.h.cmake icinga-spec-version.h)
include(GetGitRevisionDescription)
git_describe(GIT_VERSION --tags)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/icinga-version.h.force)
configure_file(icinga-version.h.force ${CMAKE_CURRENT_BINARY_DIR}/icinga-version.h COPYONLY)
else()
if(NOT ICINGA2_GIT_VERSION_INFO OR GIT_VERSION MATCHES "-NOTFOUND$")
file(STRINGS icinga2.spec SPEC_REVISION REGEX "^%define revision ")
string(LENGTH "${SPEC_REVISION}" SPEC_REVISION_LENGTH)
math(EXPR SPEC_REVISION_LENGTH "${SPEC_REVISION_LENGTH} - 17")
string(SUBSTRING ${SPEC_REVISION} 17 ${SPEC_REVISION_LENGTH} SPEC_REVISION)
set(GIT_VERSION "r${SPEC_VERSION}-${SPEC_REVISION}")
endif()
configure_file(icinga-version.h.cmake icinga-version.h)
endif()
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
add_definitions(-DBOOST_ALL_NO_LIB)
add_definitions(/bigobj)
endif()
if(NOT DEFINED LOGROTATE_HAS_SU)
set(LOGROTATE_HAS_SU OFF)
find_program(LOGROTATE_BINARY logrotate)
execute_process(COMMAND ${LOGROTATE_BINARY} ERROR_VARIABLE LOGROTATE_OUTPUT)
if(LOGROTATE_OUTPUT)
string(REGEX REPLACE "^logrotate ([0-9.]*).*" "\\1" LOGROTATE_VERSION
${LOGROTATE_OUTPUT})
message(STATUS "Found logrotate (found version \"${LOGROTATE_VERSION}\")")
if("${LOGROTATE_VERSION}" VERSION_GREATER "3.7.9")
set(LOGROTATE_HAS_SU ON)
endif()
endif()
endif()
if(LOGROTATE_HAS_SU)
set(LOGROTATE_USE_SU "\n\tsu ${ICINGA2_USER} ${ICINGA2_GROUP}")
endif()
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS thread system program_options regex REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
find_package(YAJL)
if(NOT YAJL_FOUND)
include_directories(${icinga2_BINARY_DIR}/third-party/yajl/include)
link_directories(${icinga2_BINARY_DIR}/third-party/yajl)
set(YAJL_LIBRARIES "yajl")
endif()
find_package(Editline)
set(HAVE_EDITLINE "${EDITLINE_FOUND}")
find_package(Termcap)
set(HAVE_TERMCAP "${TERMCAP_FOUND}")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib
)
set(CMAKE_MACOSX_RPATH 1)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -g")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mt")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mt -library=stlport4")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
if(CMAKE_SYSTEM_NAME MATCHES AIX)
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -g -lpthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -lpthread")
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -pthread")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lpthread")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -pthread")
endif()
if(NOT CMAKE_SYSTEM_NAME MATCHES AIX AND NOT CMAKE_SYSTEM_NAME MATCHES OpenBSD AND NOT CMAKE_SYSTEM_NAME MATCHES SunOS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -Wl,--no-export-dynamic -Bsymbolic-functions -Wl,--dynamic-list-cpp-typeinfo -Wl,--dynamic-list-data")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--no-export-dynamic -Bsymbolic-functions -Wl,--dynamic-list-cpp-typeinfo -Wl,--dynamic-list-data")
endif()
endif()
include(CheckCXXCompilerFlag)
if(ICINGA2_LTO_BUILD)
check_cxx_compiler_flag("-flto" CXX_FLAG_LTO)
if(NOT CXX_FLAG_LTO)
message(WARNING "Compiler does not support LTO, falling back to non-LTO build")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
endif()
endif()
include(CheckCCompilerFlag)
check_c_compiler_flag(-fvisibility-inlines-hidden HAVE_VISIBILITY_INLINES_HIDDEN)
if(HAVE_VISIBILITY_INLINES_HIDDEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility-inlines-hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
endif()
check_c_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN)
if(HAVE_VISIBILITY_HIDDEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
endif()
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckIncludeFileCXX)
check_symbol_exists(__COUNTER__ "" HAVE_COUNTER_MACRO)
if(NOT HAVE_COUNTER_MACRO)
message(FATAL_ERROR "Your C/C++ compiler does not support the __COUNTER__ macro.")
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DI2_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DI2_DEBUG")
check_function_exists(vfork HAVE_VFORK)
check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
check_function_exists(pipe2 HAVE_PIPE2)
check_function_exists(nice HAVE_NICE)
check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR)
check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO)
check_include_file_cxx(cxxabi.h HAVE_CXXABI_H)
if(HAVE_LIBEXECINFO)
set(HAVE_BACKTRACE_SYMBOLS TRUE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
exec_program(${CMAKE_CXX_COMPILER}
ARGS -dumpversion
OUTPUT_VARIABLE _ICINGA2_COMPILER_VERSION
)
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.6.0")
message(FATAL_ERROR "Your version of GCC (${CMAKE_CXX_COMPILER_VERSION}) is too old for building Icinga 2 (GCC >= 4.6.0 is required).")
endif()
endif()
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
check_cxx_source_compiles("class Base { public: virtual void test(void) { } }; class Derived : public Base { virtual void test(void) override { } }; int main(){}" CXX_FEATURE_OVERRIDE)
if(NOT CXX_FEATURE_OVERRIDE)
add_definitions("-Doverride=")
endif()
endif()
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
install(
FILES README.md COPYING COPYING.Exceptions AUTHORS ChangeLog NEWS
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
include(CTest)
enable_testing()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_subdirectory(third-party)
add_subdirectory(tools)
add_subdirectory(lib)
add_subdirectory(icinga-app)
add_subdirectory(etc)
add_subdirectory(itl)
add_subdirectory(doc)
add_subdirectory(agent)
add_subdirectory(plugins)
add_subdirectory(choco)
if(MSVC)
add_subdirectory(icinga-installer)
endif()
if(ICINGA2_WITH_STUDIO)
add_subdirectory(icinga-studio)
endif()
if(ICINGA2_WITH_TESTS)
add_subdirectory(test)
endif()
set(CPACK_PACKAGE_NAME "Icinga 2")
set(CPACK_PACKAGE_VENDOR "Icinga Development Team")
set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ICINGA2")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard;icinga-studio;Icinga Studio")
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
set(CPACK_WIX_UPGRADE_GUID "52F2BEAA-4DF0-4C3E-ABDC-C0F61DE4DF8A")
set(CPACK_WIX_EXTENSIONS "WixUtilExtension")
set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/icinga-installer/bannrbmp.bmp")
set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/icinga-installer/dlgbmp.bmp")
set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_BINARY_DIR}/icinga-installer/icinga2.wixpatch.Debug")
set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_BINARY_DIR}/icinga-installer/icinga2.wixpatch")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
if(WIN32)
if(CMAKE_VS_PLATFORM_NAME STREQUAL "x64")
set(NSCP_URL "https://github.com/mickem/nscp/releases/download/0.4.4.19/NSCP-0.4.4.19-x64.msi")
set(NSCP_SHA256 "36c487777e9488cbf7a15db3a87f63ff6d6af46398d6f36b25734041e3e13900")
else()
set(NSCP_URL "https://github.com/mickem/nscp/releases/download/0.4.4.19/NSCP-0.4.4.19-Win32.msi")
set(NSCP_SHA256 "f05bc00712966901531d5a9354c57e95c34eb65b4748cf3ebc305ccc8fa29cce")
endif()
set(NSCP_SHA256SUM "")
if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/NSCP.msi)
file(SHA256 ${CMAKE_CURRENT_BINARY_DIR}/NSCP.msi NSCP_SHA256SUM)
endif()
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/NSCP.msi OR NOT ${NSCP_SHA256SUM} STREQUAL ${NSCP_SHA256})
file(DOWNLOAD ${NSCP_URL} ${CMAKE_CURRENT_BINARY_DIR}/NSCP.msi SHOW_PROGRESS)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NSCP.msi DESTINATION ${CMAKE_INSTALL_SBINDIR})
install(
PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
${OPENSSL_INCLUDE_DIR}/../bin/libeay32.dll ${OPENSSL_INCLUDE_DIR}/../bin/ssleay32.dll
DESTINATION ${CMAKE_INSTALL_SBINDIR}
)
endif()
include(CPack)

339
vim/bundle/icinga2/COPYING Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -0,0 +1,13 @@
In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations including
the two.
You must obey the GNU General Public License in all respects for all
of the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the
file(s), but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version. If you delete
this exception statement from all source files in the program, then
also delete it here.

2034
vim/bundle/icinga2/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,175 @@
# Installing Icinga 2
The recommended way of installing Icinga 2 is to use packages. The Icinga
project provides both release and development packages for a number
of operating systems.
Please check the documentation in the [doc/](doc/) directory for a current list
of available packages and detailed installation instructions.
There are a number of known caveats when installing from source such as
incorrect directory and file permissions. So even if you're planning to
not use the official packages it is advisable to build your own Debian
or RPM packages.
## Build Requirements
The following requirements need to be fulfilled in order to build the
application using a dist tarball (package names for RHEL and Debian in
parentheses):
* cmake >= 2.6
* GNU make (make)
* C++ compiler which supports C++11 (gcc-c++ >= 4.7 on RHEL/SUSE, build-essential on Debian, alternatively clang++)
* pkg-config
* OpenSSL library and header files >= 0.9.8 (openssl-devel on RHEL, libopenssl1-devel on SLES11,
libopenssl-devel on SLES12, libssl-dev on Debian)
* Boost library and header files >= 1.41.0 (boost-devel on RHEL, libboost-all-dev on Debian)
* GNU bison (bison)
* GNU flex (flex) >= 2.5.35
* recommended: libexecinfo on FreeBSD (automatically used when Icinga 2 is
installed via port or package)
* optional: MySQL (mysql-devel on RHEL, libmysqlclient-devel on SUSE, libmysqlclient-dev on Debian);
set CMake variable `ICINGA2_WITH_MYSQL` to `OFF` to disable this module
* optional: PostgreSQL (postgresql-devel on RHEL, libpq-dev on Debian); set CMake
variable `ICINGA2_WITH_PGSQL` to `OFF` to disable this module
* optional: YAJL (yajl-devel on RHEL, libyajl-dev on Debian)
* optional: libedit (libedit-devel on CentOS (RHEL requires rhel-7-server-optional-rpms
repository for el7 e.g.), libedit-dev on Debian)
* optional: Termcap (libtermcap-devel on RHEL, not necessary on Debian) - only
required if libedit doesn't already link against termcap/ncurses
* optional: libwxgtk2.8-dev or newer (wxGTK-devel and wxBase) - only required when building the Icinga 2 Studio
Note: RHEL5 ships an ancient flex version. Updated packages are available for
example from the repoforge buildtools repository.
* x86: http://mirror.hs-esslingen.de/repoforge/redhat/el5/en/i386/buildtools/
* x86\_64: http://mirror.hs-esslingen.de/repoforge/redhat/el5/en/x86\_64/buildtools/
### User Requirements
By default Icinga will run as user 'icinga' and group 'icinga'. Additionally the
external command pipe and livestatus features require a dedicated command group
'icingacmd'. You can choose your own user/group names and pass them to CMake
using the `ICINGA2_USER`, `ICINGA2_GROUP` and `ICINGA2_COMMAND_GROUP` variables.
# groupadd icinga
# groupadd icingacmd
# useradd -c "icinga" -s /sbin/nologin -G icingacmd -g icinga icinga
Add the web server user to the icingacmd group in order to grant it write
permissions to the external command pipe and livestatus socket:
# usermod -a -G icingacmd www-data
Make sure to replace "www-data" with the name of the user your web server
is running as.
## Building Icinga 2
Once you have installed all the necessary build requirements you can build
Icinga 2 using the following commands:
$ mkdir build && cd build
$ cmake ..
$ make
$ make install
You can specify an alternative installation prefix using `-DCMAKE_INSTALL_PREFIX`:
$ cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/icinga2
In addition to `CMAKE_INSTALL_PREFIX` the following Icinga-specific cmake
variables are supported:
- `ICINGA2_USER`: The user Icinga 2 should run as; defaults to `icinga`
- `ICINGA2_GROUP`: The group Icinga 2 should run as; defaults to `icinga`
- `ICINGA2_GIT_VERSION_INFO`: Whether to use Git to determine the version number; defaults to `ON`
- `ICINGA2_COMMAND_GROUP`: The command group Icinga 2 should use; defaults to `icingacmd`
- `ICINGA2_UNITY_BUILD`: Whether to perform a unity build; defaults to `ON`
- `ICINGA2_LTO_BUILD`: Whether to use link time optimization (LTO); defaults to `OFF`
- `ICINGA2_PLUGINDIR`: The path for the Monitoring Plugins project binaries; defaults to `/usr/lib/nagios/plugins`
- `ICINGA2_RUNDIR`: The location of the "run" directory; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/run`
- `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`
- `ICINGA2_SYSCONFIGFILE`: Where to put the config file the initscript/systemd pulls it's dirs from;
defaults to `CMAKE_INSTALL_PREFIX/etc/sysconfig/icinga2`
- `CMAKE_INSTALL_LOCALSTATEDIR`: The state directory; defaults to `CMAKE_INSTALL_PREFIX/var`
- `USE_SYSTEMD=ON|OFF`: Use systemd or a classic SysV initscript; defaults to `OFF`
- `INSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=ON|OFF` Force install both the systemd service definition file
and the SysV initscript in parallel, regardless of how `USE_SYSTEMD` is set.
Only use this for special packaging purposes and if you know what you are doing.
Defaults to `OFF`.
- `ICINGA2_WITH_MYSQL`: Determines whether the MySQL IDO module is built; defaults to `ON`
- `ICINGA2_WITH_PGSQL`: Determines whether the PostgreSQL IDO module is built; defaults to `ON`
- `ICINGA2_WITH_CHECKER`: Determines whether the checker module is built; defaults to `ON`
- `ICINGA2_WITH_COMPAT`: Determines whether the compat module is built; defaults to `ON`
- `ICINGA2_WITH_DEMO`: Determines whether the demo module is built; defaults to `OFF`
- `ICINGA2_WITH_HELLO`: Determines whether the hello module is built; defaults to `OFF`
- `ICINGA2_WITH_LIVESTATUS`: Determines whether the Livestatus module is built; defaults to `ON`
- `ICINGA2_WITH_NOTIFICATION`: Determines whether the notification module is built; defaults to `ON`
- `ICINGA2_WITH_PERFDATA`: Determines whether the perfdata module is built; defaults to `ON`
- `ICINGA2_WITH_STUDIO`: Determines whether the Icinga Studio application is built; defaults to `OFF`
- `ICINGA2_WITH_TESTS`: Determines whether the unit tests are built; defaults to `ON`
CMake determines the Icinga 2 version number using `git describe` if the
source directory is contained in a Git repository. Otherwise the version number
is extracted from the [icinga2.spec](icinga2.spec) file. This behavior can be
overridden by creating a file called `icinga-version.h.force` in the source
directory. Alternatively the `-DICINGA2_GIT_VERSION_INFO=OFF` option for CMake
can be used to disable the usage of `git describe`.
### Building Icinga 2 RPMs
Setup your build environment on RHEL/SUSE and copy the generated tarball from your git
repository to `rpmbuild/SOURCES`.
Copy the icinga2.spec file to `rpmbuild/SPEC` and then run this command:
$ rpmbuild -ba SPEC/icinga2.spec
### Building Icinga 2 Debs
Setup your build environment on Debian/Ubuntu, copy the 'debian' directory from
the Debian packaging Git repository (https://anonscm.debian.org/cgit/pkg-nagios/pkg-icinga2.git)
into your source tree and run the following command:
$ dpkg-buildpackage -uc -us
### Building Post Install Tasks
After building Icinga 2 yourself, your package build system should at least run the following post
install requirements:
* enable the `checker`, `notification` and `mainlog` feature by default
* run 'icinga2 api setup' in order to enable the `api` feature and generate SSL certificates for the node
## Running Icinga 2
Icinga 2 comes with a single binary that takes care of loading all the relevant
components (e.g. for check execution, notifications, etc.):
# /usr/sbin/icinga2 daemon
[2015-03-12 13:25:56 +0100] information/cli: Icinga application loader (version: v2.3.0-20-ga4d3713; debug)
[2015-03-12 13:25:56 +0100] information/cli: Loading application type: icinga/IcingaApplication
[2015-03-12 13:25:56 +0100] information/Utility: Loading library 'libicinga.dylib'
[2015-03-12 13:25:56 +0100] information/ConfigCompiler: Compiling config file: /Users/gunnar/i2/etc/icinga2/icinga2.conf
[2015-03-12 13:25:56 +0100] information/ConfigCompiler: Compiling config file: /Users/gunnar/i2/etc/icinga2/constants.conf
...
Icinga 2 can be started as a daemon using the provided init script:
# /etc/init.d/icinga2
Usage: /etc/init.d/icinga2 {start|stop|restart|reload|checkconfig|status}
Or if your distribution uses systemd:
# systemctl {start|stop|reload|status|enable|disable} icinga2
Icinga 2 reads a single configuration file which is used to specify all
configuration settings (global settings, hosts, services, etc.). The
configuration format is explained in detail in the [doc/](doc/) directory.
By default `make install` installs example configuration files in
`/usr/local/etc/icinga2` unless you have specified a different prefix or
sysconfdir.

1
vim/bundle/icinga2/NEWS Normal file
View File

@ -0,0 +1 @@
News for this application can be found on the project website at https://www.icinga.org

View File

@ -0,0 +1,26 @@
# Icinga 2
## About
Icinga 2 is an open source monitoring system which checks the availability of your
network resources, notifies users of outages, and generates performance data for reporting.
Scalable and extensible, Icinga 2 can monitor large, complex environments across
multiple locations.
More details online at [www.icinga.org](https://www.icinga.org/icinga/icinga-2/)
and inside the [documentation](doc/1-about.md).
## Installation
Read the [INSTALL.md](INSTALL.md) file for more information about how to install it.
## Documentation
The documentation is located in the [doc/](doc/) directory. The latest documentation
is also available on https://docs.icinga.org
## Support
Check the project website at https://www.icinga.org for status updates and
https://support.icinga.org if you want to contact us.

View File

@ -0,0 +1,172 @@
# Release Workflow
Print this document.
Specify the release version.
VERSION=2.5.4
## Issues
Check the following issue filters:
* [Pending backports](https://dev.icinga.org/projects/i2/issues?query_id=41)
* [Invalid target version](https://dev.icinga.org/projects/i2/issues?query_id=55)
## Backport Commits
$ git checkout master
$ ./pick.py -V $VERSION
The script creates a new branch 'auto-merged-<VERSION>' which is based on the
current support branch. It then merges all commits from the 'master' branch which
reference a ticket for the version that was specified.
If there are any merge commits you will need to manually fix them and continue the
rebase until no commits are left:
$ git rebase --continue
After finishing the rebase the branch needs to be merged into the support branch:
$ git checkout support/2.5
$ git merge --ff-only auto-merged-2.5.3
## Authors
Update the [.mailmap](.mailmap) and [AUTHORS](AUTHORS) files:
$ git checkout master
$ git log --use-mailmap | grep ^Author: | cut -f2- -d' ' | sort | uniq > AUTHORS
## Version
Update the version number in the following file:
* [icinga2.spec]: Version: (.*)
Example:
gsed -i "s/Version: .*/Version: $VERSION/g" icinga2.spec
gsed -i "s/<version>.*<\/version>/<version>$VERSION<\/version>/g" icinga2.nuspec
gsed -i "s/Icinga2-v.*-/Icinga2-v$VERSION-/g" tools/chocolateyInstall.ps1
## Changelog
Update the [ChangeLog](ChangeLog), [doc/1-about.md](doc/1-about.md) files using
the changelog.py script. Also generate HTML for the wordpress release announcement.
Changelog:
$ ./changelog.py -V $VERSION
Docs:
$ ./changelog.py -V $VERSION -l
Wordpress:
$ ./changelog.py -V $VERSION -H -l
## Git Tag
Commit these changes to the "master" branch:
$ git commit -v -a -m "Release version $VERSION"
For minor releases: Cherry-pick this commit into the "support" branch.
Create a signed tag (tags/v<VERSION>) on the "master" branch (for major
releases) or the "support" branch (for minor releases).
GB:
$ git tag -u EE8E0720 -m "Version $VERSION" v$VERSION
MF:
$ git tag -u D14A1F16 -m "Version $VERSION" v$VERSION
Push the tag.
$ git push --tags
For major releases: Create a new "support" branch:
$ git checkout master
$ git checkout -b support/2.5
$ git push -u origin support/2.5
For minor releases: Push the support branch, cherry-pick the release commit
into master and merge the support branch:
$ git push -u origin support/2.5
$ git checkout master
$ git cherry-pick support/2.5
$ git merge --strategy=ours support/2.5
$ git push origin master
# External Dependencies
## Build Server
* Update Git tags for the release jobs.
* Build the newly created Git tag for Debian/RHEL/SuSE.
* Build the newly created Git tag for Windows.
## Release Tests
* Test DB IDO with MySQL and PostgreSQL.
* Provision the vagrant boxes and test the release packages.
* Test the [setup wizard](http://packages.icinga.org/windows/) inside a Windows VM.
* Start a new docker container and install/run icinga2.
Example for CentOS7:
$ docker run -ti centos:latest bash
# yum -y install http://packages.icinga.org/epel/7/release/noarch/icinga-rpm-release-7-1.el7.centos.noarch.rpm
# yum -y install icinga2
# icinga2 daemon -C
# systemctl start icinga2
# tail -f /var/log/icinga2/icinga2.log
## GitHub Release
Create a new release for the newly created Git tag.
https://github.com/Icinga/icinga2/releases
## Chocolatey
Navigate to the git repository on your Windows box which
already has chocolatey installed. Pull/checkout the release.
Create the nupkg package:
cpack
Install the created icinga2 package locally:
choco install icinga2 -version 2.5.4 -fdv "%cd%" -source "'%cd%;https://chocolatey.org/api/v2/'"
Upload the package to [chocolatey](https://chocolatey.org/packages/upload).
## Online Documentation
SSH into the web box, navigate into `icinga2-latest/module/icinga2`
and pull the current support branch.
## Announcement
* Create a new blog post on www.icinga.org/blog
* Send announcement mail to icinga-announce@lists.icinga.org
* Social media: [Twitter](https://twitter.com/icinga), [Facebook](https://www.facebook.com/icinga), [G+](http://plus.google.com/+icinga), [Xing](https://www.xing.com/communities/groups/icinga-da4b-1060043), [LinkedIn](https://www.linkedin.com/groups/Icinga-1921830/about)
* Update IRC channel topic
# After the release
* Add new minor version
* Close the released version
* Update Redmine filters for the next major/minor version

View File

@ -0,0 +1,30 @@
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
if(MSVC)
include_external_msproject(
icinga2setupagent
${CMAKE_CURRENT_SOURCE_DIR}/windows-setup-agent/Icinga2SetupAgent.csproj
TYPE FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
PLATFORM Win32
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/windows-setup-agent/bin/\${CMAKE_INSTALL_CONFIG_NAME}/Icinga2SetupAgent.exe ${CMAKE_CURRENT_SOURCE_DIR}/windows-setup-agent/bin/\${CMAKE_INSTALL_CONFIG_NAME}/Icinga2SetupAgent.exe.config
DESTINATION ${CMAKE_INSTALL_SBINDIR}
)
endif()

View File

@ -0,0 +1,2 @@
bin
obj

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v4.0" />
</startup>
</configuration>

View File

@ -0,0 +1,177 @@
namespace Icinga
{
partial class EndpointInputBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtHost = new System.Windows.Forms.TextBox();
this.txtPort = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.lblHost = new System.Windows.Forms.Label();
this.lblPort = new System.Windows.Forms.Label();
this.lblInstanceName = new System.Windows.Forms.Label();
this.txtInstanceName = new System.Windows.Forms.TextBox();
this.chkConnect = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(196, 171);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 4;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.CausesValidation = false;
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(277, 171);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 5;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// txtHost
//
this.txtHost.Enabled = false;
this.txtHost.Location = new System.Drawing.Point(101, 103);
this.txtHost.Name = "txtHost";
this.txtHost.Size = new System.Drawing.Size(251, 20);
this.txtHost.TabIndex = 2;
//
// txtPort
//
this.txtPort.Enabled = false;
this.txtPort.Location = new System.Drawing.Point(101, 134);
this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(100, 20);
this.txtPort.TabIndex = 3;
this.txtPort.Text = "5665";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(276, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Please enter the connection details for the new endpoint:";
//
// lblHost
//
this.lblHost.AutoSize = true;
this.lblHost.Location = new System.Drawing.Point(15, 106);
this.lblHost.Name = "lblHost";
this.lblHost.Size = new System.Drawing.Size(32, 13);
this.lblHost.TabIndex = 5;
this.lblHost.Text = "Host:";
//
// lblPort
//
this.lblPort.AutoSize = true;
this.lblPort.Location = new System.Drawing.Point(15, 137);
this.lblPort.Name = "lblPort";
this.lblPort.Size = new System.Drawing.Size(29, 13);
this.lblPort.TabIndex = 6;
this.lblPort.Text = "Port:";
//
// lblInstanceName
//
this.lblInstanceName.AutoSize = true;
this.lblInstanceName.Location = new System.Drawing.Point(15, 41);
this.lblInstanceName.Name = "lblInstanceName";
this.lblInstanceName.Size = new System.Drawing.Size(82, 13);
this.lblInstanceName.TabIndex = 7;
this.lblInstanceName.Text = "Instance Name:";
//
// txtInstanceName
//
this.txtInstanceName.Location = new System.Drawing.Point(101, 37);
this.txtInstanceName.Name = "txtInstanceName";
this.txtInstanceName.Size = new System.Drawing.Size(251, 20);
this.txtInstanceName.TabIndex = 0;
//
// chkConnect
//
this.chkConnect.AutoSize = true;
this.chkConnect.Location = new System.Drawing.Point(18, 73);
this.chkConnect.Name = "chkConnect";
this.chkConnect.Size = new System.Drawing.Size(141, 17);
this.chkConnect.TabIndex = 1;
this.chkConnect.Text = "Connect to this endpoint";
this.chkConnect.UseVisualStyleBackColor = true;
this.chkConnect.CheckedChanged += new System.EventHandler(this.chkConnect_CheckedChanged);
//
// EndpointInputBox
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(360, 202);
this.Controls.Add(this.chkConnect);
this.Controls.Add(this.txtInstanceName);
this.Controls.Add(this.lblInstanceName);
this.Controls.Add(this.lblPort);
this.Controls.Add(this.lblHost);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtPort);
this.Controls.Add(this.txtHost);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "EndpointInputBox";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Add Endpoint";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblHost;
private System.Windows.Forms.Label lblPort;
public System.Windows.Forms.TextBox txtHost;
public System.Windows.Forms.TextBox txtPort;
public System.Windows.Forms.TextBox txtInstanceName;
private System.Windows.Forms.Label lblInstanceName;
public System.Windows.Forms.CheckBox chkConnect;
}
}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Icinga
{
public partial class EndpointInputBox : Form
{
public EndpointInputBox()
{
InitializeComponent();
}
private void Warning(string message)
{
MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
private void chkConnect_CheckedChanged(object sender, EventArgs e)
{
txtHost.Enabled = chkConnect.Checked;
txtPort.Enabled = chkConnect.Checked;
}
private void btnOK_Click(object sender, EventArgs e)
{
if (txtInstanceName.Text.Length == 0) {
Warning("Please enter an instance name.");
return;
}
if (chkConnect.Checked) {
if (txtHost.Text.Length == 0) {
Warning("Please enter a host name.");
return;
}
if (txtPort.Text.Length == 0) {
Warning("Please enter a port.");
return;
}
}
DialogResult = DialogResult.OK;
Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{A86F1159-66E8-4BDB-BF28-A2BDAF76517C}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Icinga</RootNamespace>
<AssemblyName>Icinga2SetupAgent</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'RelWithDebInfo|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\RelWithDebInfo\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'MinSizeRel|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\MinSizeRel\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'RelWithDebInfo|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\RelWithDebInfo\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'MinSizeRel|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\MinSizeRel\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icinga.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ServiceStatus.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ServiceStatus.Designer.cs">
<DependentUpon>ServiceStatus.cs</DependentUpon>
</Compile>
<Compile Include="SetupWizard.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SetupWizard.Designer.cs">
<DependentUpon>SetupWizard.cs</DependentUpon>
</Compile>
<Compile Include="EndpointInputBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="EndpointInputBox.Designer.cs">
<DependentUpon>EndpointInputBox.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="ServiceStatus.resx">
<DependentUpon>ServiceStatus.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SetupWizard.resx">
<DependentUpon>SetupWizard.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="EndpointInputBox.resx">
<DependentUpon>EndpointInputBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="icinga-banner.png" />
</ItemGroup>
<ItemGroup>
<Content Include="icinga.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,89 @@
using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Text;
namespace Icinga
{
static class Program
{
[DllImport("msi.dll", SetLastError = true)]
static extern int MsiEnumProducts(int iProductIndex, StringBuilder lpProductBuf);
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len);
public static string Icinga2InstallDir
{
get
{
StringBuilder szProduct;
for (int index = 0; ; index++) {
szProduct = new StringBuilder(39);
if (MsiEnumProducts(index, szProduct) != 0)
break;
int cbName = 128;
StringBuilder szName = new StringBuilder(cbName);
if (MsiGetProductInfo(szProduct.ToString(), "ProductName", szName, ref cbName) != 0)
continue;
if (szName.ToString() != "Icinga 2")
continue;
int cbLocation = 1024;
StringBuilder szLocation = new StringBuilder(cbLocation);
if (MsiGetProductInfo(szProduct.ToString(), "InstallLocation", szLocation, ref cbLocation) == 0)
return szLocation.ToString();
}
return "";
}
}
public static string Icinga2DataDir
{
get
{
return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\icinga2";
}
}
public static void FatalError(Form owner, string message)
{
MessageBox.Show(owner, message, "Icinga 2 Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string installDir = Program.Icinga2InstallDir;
if (installDir == "") {
FatalError(null, "Icinga 2 does not seem to be installed properly.");
return;
}
Form form;
if (File.Exists(Program.Icinga2DataDir + "\\etc\\icinga2\\features-enabled\\api.conf"))
form = new ServiceStatus();
else
form = new SetupWizard();
Application.Run(form);
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Icinga 2 Agent Wizard")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Icinga Development Team")]
[assembly: AssemblyProduct("Icinga 2")]
[assembly: AssemblyCopyright("Copyright © 2014-2015 Icinga Development Team")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("51f4fcaf-8cf8-4d1c-9fde-61526c17a0d8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Icinga.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Icinga.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icinga_banner {
get {
object obj = ResourceManager.GetObject("icinga-banner", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="icinga-banner" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\icinga-banner.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Icinga.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,132 @@
namespace Icinga
{
partial class ServiceStatus
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServiceStatus));
this.picBanner = new System.Windows.Forms.PictureBox();
this.lblStatus = new System.Windows.Forms.Label();
this.txtStatus = new System.Windows.Forms.TextBox();
this.btnReconfigure = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.btnOpenConfigDir = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.picBanner)).BeginInit();
this.SuspendLayout();
//
// picBanner
//
this.picBanner.Image = global::Icinga.Properties.Resources.icinga_banner;
this.picBanner.Location = new System.Drawing.Point(0, 0);
this.picBanner.Name = "picBanner";
this.picBanner.Size = new System.Drawing.Size(625, 77);
this.picBanner.TabIndex = 2;
this.picBanner.TabStop = false;
//
// lblStatus
//
this.lblStatus.AutoSize = true;
this.lblStatus.Location = new System.Drawing.Point(12, 105);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(79, 13);
this.lblStatus.TabIndex = 3;
this.lblStatus.Text = "Service Status:";
//
// txtStatus
//
this.txtStatus.Location = new System.Drawing.Point(97, 102);
this.txtStatus.Name = "txtStatus";
this.txtStatus.ReadOnly = true;
this.txtStatus.Size = new System.Drawing.Size(278, 20);
this.txtStatus.TabIndex = 3;
//
// btnReconfigure
//
this.btnReconfigure.Location = new System.Drawing.Point(195, 143);
this.btnReconfigure.Name = "btnReconfigure";
this.btnReconfigure.Size = new System.Drawing.Size(89, 23);
this.btnReconfigure.TabIndex = 1;
this.btnReconfigure.Text = "Reconfigure";
this.btnReconfigure.UseVisualStyleBackColor = true;
this.btnReconfigure.Click += new System.EventHandler(this.btnReconfigure_Click);
//
// btnOK
//
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnOK.Location = new System.Drawing.Point(290, 143);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(89, 23);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnOpenConfigDir
//
this.btnOpenConfigDir.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnOpenConfigDir.Location = new System.Drawing.Point(100, 143);
this.btnOpenConfigDir.Name = "btnOpenConfigDir";
this.btnOpenConfigDir.Size = new System.Drawing.Size(89, 23);
this.btnOpenConfigDir.TabIndex = 2;
this.btnOpenConfigDir.Text = "Examine Config";
this.btnOpenConfigDir.UseVisualStyleBackColor = true;
this.btnOpenConfigDir.Click += new System.EventHandler(this.btnOpenConfigDir_Click);
//
// ServiceStatus
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnOK;
this.ClientSize = new System.Drawing.Size(391, 186);
this.Controls.Add(this.btnOpenConfigDir);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnReconfigure);
this.Controls.Add(this.txtStatus);
this.Controls.Add(this.lblStatus);
this.Controls.Add(this.picBanner);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "ServiceStatus";
this.Text = "Icinga 2 Service Status";
((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox picBanner;
private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.TextBox txtStatus;
private System.Windows.Forms.Button btnReconfigure;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnOpenConfigDir;
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ServiceProcess;
using System.Diagnostics;
namespace Icinga
{
public partial class ServiceStatus : Form
{
public ServiceStatus()
{
InitializeComponent();
try {
ServiceController sc = new ServiceController("icinga2");
txtStatus.Text = sc.Status.ToString();
} catch (InvalidOperationException) {
txtStatus.Text = "Not Available";
}
}
private void btnReconfigure_Click(object sender, EventArgs e)
{
new SetupWizard().ShowDialog(this);
}
private void btnOK_Click(object sender, EventArgs e)
{
Close();
}
private void btnOpenConfigDir_Click(object sender, EventArgs e) {
Process.Start("explorer.exe", Program.Icinga2DataDir);
}
}
}

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAICAQAAAABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAAAAAAAAAAEAAAABAA
AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP//
AAD///8AAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAcAAAcAB3AAAAAAAAAAAAAAcABwB///cA
AAAAAAAAAAAAcAAA////AAAAAAAAAAAAAAAAAP///3AAAAAAAAAAAAAAAAD///9wAAAAAAAAAAAAAAAA
j//4AAAAB3AAAAAAAAAAAAj/jwAAAA/4AAAAAAAAAAAAAAiAAAAP9wAAAAAAAAAAAAAH9wAAf3AAAAAA
AAAAAAAAAH93d/cAAAAAAAAAAAAAAAB////3AAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAB/////9w
AAAAAAAAAAAAAAf/////gAAAAAAAAAAAAAAH//////h3AAAAAAAAAAAAB/////+I//h3eHAAAAAAAAD/
////AAB3j//3AAAAAAB4////9wAAAAf/+AAAAAf/+AB4iPAAAAAAj/cAAAAH//AAAAD3AAAAAAcAAAAA
B/+AAAAAjwAAAAAAAAAAAAB3AAAAAA9wAAAAAAAAAAAAAAAAAAAIh3AAAAAAAAAAAAAAAAAAD//wAAAA
AAAAAAAAAAAAAH//9wAAAAAAAAAAAAAAAAB///cAAAAAAAcAAAAAAAAACP+AAAAAAHAAcAAAAAAAAAB3
AAAAAAcAAAcAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAAAAAAAAD/////4AAAB8AAAAOAAAABgAAAAYAA
AAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAA
AAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAcAAAAPgAAAH/////w==
</value>
</data>
</root>

View File

@ -0,0 +1,702 @@
namespace Icinga
{
partial class SetupWizard
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupWizard));
this.btnBack = new System.Windows.Forms.Button();
this.btnNext = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.tabFinish = new System.Windows.Forms.TabPage();
this.lblSetupCompleted = new System.Windows.Forms.Label();
this.tabConfigure = new System.Windows.Forms.TabPage();
this.lblConfigStatus = new System.Windows.Forms.Label();
this.prgConfig = new System.Windows.Forms.ProgressBar();
this.tabParameters = new System.Windows.Forms.TabPage();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.chkAcceptConfig = new System.Windows.Forms.CheckBox();
this.chkAcceptCommands = new System.Windows.Forms.CheckBox();
this.txtTicket = new System.Windows.Forms.TextBox();
this.lblTicket = new System.Windows.Forms.Label();
this.txtInstanceName = new System.Windows.Forms.TextBox();
this.lblInstanceName = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.rdoNoListener = new System.Windows.Forms.RadioButton();
this.txtListenerPort = new System.Windows.Forms.TextBox();
this.lblListenerPort = new System.Windows.Forms.Label();
this.rdoListener = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnRemoveEndpoint = new System.Windows.Forms.Button();
this.btnAddEndpoint = new System.Windows.Forms.Button();
this.lvwEndpoints = new System.Windows.Forms.ListView();
this.colInstanceName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colHost = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colPort = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.rdoNoMaster = new System.Windows.Forms.RadioButton();
this.rdoNewMaster = new System.Windows.Forms.RadioButton();
this.tbcPages = new System.Windows.Forms.TabControl();
this.tabRetrieveCertificate = new System.Windows.Forms.TabPage();
this.lblRetrieveCertificate = new System.Windows.Forms.Label();
this.prgRetrieveCertificate = new System.Windows.Forms.ProgressBar();
this.tabVerifyCertificate = new System.Windows.Forms.TabPage();
this.grpX509Fields = new System.Windows.Forms.GroupBox();
this.txtX509Field = new System.Windows.Forms.TextBox();
this.lvwX509Fields = new System.Windows.Forms.ListView();
this.colField = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.txtX509Subject = new System.Windows.Forms.TextBox();
this.txtX509Issuer = new System.Windows.Forms.TextBox();
this.lblX509Subject = new System.Windows.Forms.Label();
this.lblX509Issuer = new System.Windows.Forms.Label();
this.lblX509Prompt = new System.Windows.Forms.Label();
this.tabError = new System.Windows.Forms.TabPage();
this.txtError = new System.Windows.Forms.TextBox();
this.lblError = new System.Windows.Forms.Label();
this.picBanner = new System.Windows.Forms.PictureBox();
this.chkInstallNSCP = new System.Windows.Forms.CheckBox();
this.tabFinish.SuspendLayout();
this.tabConfigure.SuspendLayout();
this.tabParameters.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tbcPages.SuspendLayout();
this.tabRetrieveCertificate.SuspendLayout();
this.tabVerifyCertificate.SuspendLayout();
this.grpX509Fields.SuspendLayout();
this.tabError.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picBanner)).BeginInit();
this.SuspendLayout();
//
// btnBack
//
this.btnBack.Enabled = false;
this.btnBack.Location = new System.Drawing.Point(367, 592);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(75, 23);
this.btnBack.TabIndex = 1;
this.btnBack.Text = "< &Back";
this.btnBack.UseVisualStyleBackColor = true;
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
//
// btnNext
//
this.btnNext.Location = new System.Drawing.Point(448, 592);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(75, 23);
this.btnNext.TabIndex = 2;
this.btnNext.Text = "&Next >";
this.btnNext.UseVisualStyleBackColor = true;
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(538, 592);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// tabFinish
//
this.tabFinish.Controls.Add(this.lblSetupCompleted);
this.tabFinish.Location = new System.Drawing.Point(4, 5);
this.tabFinish.Name = "tabFinish";
this.tabFinish.Padding = new System.Windows.Forms.Padding(3);
this.tabFinish.Size = new System.Drawing.Size(617, 500);
this.tabFinish.TabIndex = 5;
this.tabFinish.Text = "Finish";
this.tabFinish.UseVisualStyleBackColor = true;
//
// lblSetupCompleted
//
this.lblSetupCompleted.AutoSize = true;
this.lblSetupCompleted.Location = new System.Drawing.Point(34, 35);
this.lblSetupCompleted.Name = "lblSetupCompleted";
this.lblSetupCompleted.Size = new System.Drawing.Size(214, 13);
this.lblSetupCompleted.TabIndex = 0;
this.lblSetupCompleted.Text = "The Icinga 2 agent was set up successfully.";
//
// tabConfigure
//
this.tabConfigure.Controls.Add(this.lblConfigStatus);
this.tabConfigure.Controls.Add(this.prgConfig);
this.tabConfigure.Location = new System.Drawing.Point(4, 5);
this.tabConfigure.Name = "tabConfigure";
this.tabConfigure.Padding = new System.Windows.Forms.Padding(3);
this.tabConfigure.Size = new System.Drawing.Size(617, 500);
this.tabConfigure.TabIndex = 4;
this.tabConfigure.Text = "Configure Icinga 2";
this.tabConfigure.UseVisualStyleBackColor = true;
//
// lblConfigStatus
//
this.lblConfigStatus.AutoSize = true;
this.lblConfigStatus.Location = new System.Drawing.Point(184, 204);
this.lblConfigStatus.Name = "lblConfigStatus";
this.lblConfigStatus.Size = new System.Drawing.Size(141, 13);
this.lblConfigStatus.TabIndex = 1;
this.lblConfigStatus.Text = "Updating the configuration...";
//
// prgConfig
//
this.prgConfig.Location = new System.Drawing.Point(184, 223);
this.prgConfig.Name = "prgConfig";
this.prgConfig.Size = new System.Drawing.Size(289, 23);
this.prgConfig.TabIndex = 0;
//
// tabParameters
//
this.tabParameters.Controls.Add(this.groupBox3);
this.tabParameters.Controls.Add(this.txtTicket);
this.tabParameters.Controls.Add(this.lblTicket);
this.tabParameters.Controls.Add(this.txtInstanceName);
this.tabParameters.Controls.Add(this.lblInstanceName);
this.tabParameters.Controls.Add(this.groupBox2);
this.tabParameters.Controls.Add(this.groupBox1);
this.tabParameters.Location = new System.Drawing.Point(4, 5);
this.tabParameters.Name = "tabParameters";
this.tabParameters.Padding = new System.Windows.Forms.Padding(3);
this.tabParameters.Size = new System.Drawing.Size(617, 500);
this.tabParameters.TabIndex = 3;
this.tabParameters.Text = "Agent Parameters";
this.tabParameters.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.chkInstallNSCP);
this.groupBox3.Controls.Add(this.chkAcceptConfig);
this.groupBox3.Controls.Add(this.chkAcceptCommands);
this.groupBox3.Location = new System.Drawing.Point(308, 359);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(301, 111);
this.groupBox3.TabIndex = 5;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Advanced Options";
//
// chkAcceptConfig
//
this.chkAcceptConfig.AutoSize = true;
this.chkAcceptConfig.Location = new System.Drawing.Point(9, 47);
this.chkAcceptConfig.Name = "chkAcceptConfig";
this.chkAcceptConfig.Size = new System.Drawing.Size(190, 17);
this.chkAcceptConfig.TabIndex = 1;
this.chkAcceptConfig.Text = "Accept config updates from master";
this.chkAcceptConfig.UseVisualStyleBackColor = true;
//
// chkAcceptCommands
//
this.chkAcceptCommands.AutoSize = true;
this.chkAcceptCommands.Location = new System.Drawing.Point(9, 24);
this.chkAcceptCommands.Name = "chkAcceptCommands";
this.chkAcceptCommands.Size = new System.Drawing.Size(171, 17);
this.chkAcceptCommands.TabIndex = 0;
this.chkAcceptCommands.Text = "Accept commands from master";
this.chkAcceptCommands.UseVisualStyleBackColor = true;
//
// txtTicket
//
this.txtTicket.Location = new System.Drawing.Point(98, 45);
this.txtTicket.Name = "txtTicket";
this.txtTicket.Size = new System.Drawing.Size(340, 20);
this.txtTicket.TabIndex = 1;
//
// lblTicket
//
this.lblTicket.AutoSize = true;
this.lblTicket.Location = new System.Drawing.Point(9, 48);
this.lblTicket.Name = "lblTicket";
this.lblTicket.Size = new System.Drawing.Size(71, 13);
this.lblTicket.TabIndex = 4;
this.lblTicket.Text = "Setup Ticket:";
//
// txtInstanceName
//
this.txtInstanceName.Location = new System.Drawing.Point(98, 16);
this.txtInstanceName.Name = "txtInstanceName";
this.txtInstanceName.Size = new System.Drawing.Size(340, 20);
this.txtInstanceName.TabIndex = 0;
//
// lblInstanceName
//
this.lblInstanceName.AutoSize = true;
this.lblInstanceName.Location = new System.Drawing.Point(9, 20);
this.lblInstanceName.Name = "lblInstanceName";
this.lblInstanceName.Size = new System.Drawing.Size(82, 13);
this.lblInstanceName.TabIndex = 3;
this.lblInstanceName.Text = "Instance Name:";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.rdoNoListener);
this.groupBox2.Controls.Add(this.txtListenerPort);
this.groupBox2.Controls.Add(this.lblListenerPort);
this.groupBox2.Controls.Add(this.rdoListener);
this.groupBox2.Location = new System.Drawing.Point(8, 359);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(294, 111);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "TCP Listener";
//
// rdoNoListener
//
this.rdoNoListener.AutoSize = true;
this.rdoNoListener.Checked = true;
this.rdoNoListener.Location = new System.Drawing.Point(11, 82);
this.rdoNoListener.Name = "rdoNoListener";
this.rdoNoListener.Size = new System.Drawing.Size(163, 17);
this.rdoNoListener.TabIndex = 9;
this.rdoNoListener.TabStop = true;
this.rdoNoListener.Text = "Do not listen for connections.";
this.rdoNoListener.UseVisualStyleBackColor = true;
this.rdoNoListener.CheckedChanged += new System.EventHandler(this.RadioListener_CheckedChanged);
//
// txtListenerPort
//
this.txtListenerPort.Enabled = false;
this.txtListenerPort.Location = new System.Drawing.Point(132, 51);
this.txtListenerPort.Name = "txtListenerPort";
this.txtListenerPort.Size = new System.Drawing.Size(84, 20);
this.txtListenerPort.TabIndex = 8;
this.txtListenerPort.Text = "5665";
//
// lblListenerPort
//
this.lblListenerPort.AutoSize = true;
this.lblListenerPort.Location = new System.Drawing.Point(43, 55);
this.lblListenerPort.Name = "lblListenerPort";
this.lblListenerPort.Size = new System.Drawing.Size(29, 13);
this.lblListenerPort.TabIndex = 1;
this.lblListenerPort.Text = "Port:";
//
// rdoListener
//
this.rdoListener.AutoSize = true;
this.rdoListener.Location = new System.Drawing.Point(11, 24);
this.rdoListener.Name = "rdoListener";
this.rdoListener.Size = new System.Drawing.Size(250, 17);
this.rdoListener.TabIndex = 7;
this.rdoListener.Text = "Listen for connections from the master instance:";
this.rdoListener.UseVisualStyleBackColor = true;
this.rdoListener.CheckedChanged += new System.EventHandler(this.RadioListener_CheckedChanged);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnRemoveEndpoint);
this.groupBox1.Controls.Add(this.btnAddEndpoint);
this.groupBox1.Controls.Add(this.lvwEndpoints);
this.groupBox1.Controls.Add(this.rdoNoMaster);
this.groupBox1.Controls.Add(this.rdoNewMaster);
this.groupBox1.Location = new System.Drawing.Point(8, 77);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(601, 276);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Master Instance";
//
// btnRemoveEndpoint
//
this.btnRemoveEndpoint.Enabled = false;
this.btnRemoveEndpoint.Location = new System.Drawing.Point(520, 112);
this.btnRemoveEndpoint.Name = "btnRemoveEndpoint";
this.btnRemoveEndpoint.Size = new System.Drawing.Size(75, 23);
this.btnRemoveEndpoint.TabIndex = 6;
this.btnRemoveEndpoint.Text = "Remove";
this.btnRemoveEndpoint.UseVisualStyleBackColor = true;
this.btnRemoveEndpoint.Click += new System.EventHandler(this.btnRemoveEndpoint_Click);
//
// btnAddEndpoint
//
this.btnAddEndpoint.Location = new System.Drawing.Point(520, 83);
this.btnAddEndpoint.Name = "btnAddEndpoint";
this.btnAddEndpoint.Size = new System.Drawing.Size(75, 23);
this.btnAddEndpoint.TabIndex = 5;
this.btnAddEndpoint.Text = "Add";
this.btnAddEndpoint.UseVisualStyleBackColor = true;
this.btnAddEndpoint.Click += new System.EventHandler(this.btnAddEndpoint_Click);
//
// lvwEndpoints
//
this.lvwEndpoints.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colInstanceName,
this.colHost,
this.colPort});
this.lvwEndpoints.FullRowSelect = true;
this.lvwEndpoints.Location = new System.Drawing.Point(11, 83);
this.lvwEndpoints.Name = "lvwEndpoints";
this.lvwEndpoints.Size = new System.Drawing.Size(500, 176);
this.lvwEndpoints.TabIndex = 4;
this.lvwEndpoints.UseCompatibleStateImageBehavior = false;
this.lvwEndpoints.View = System.Windows.Forms.View.Details;
this.lvwEndpoints.SelectedIndexChanged += new System.EventHandler(this.lvwEndpoints_SelectedIndexChanged);
//
// colInstanceName
//
this.colInstanceName.Text = "Instance Name";
this.colInstanceName.Width = 200;
//
// colHost
//
this.colHost.Text = "Host";
this.colHost.Width = 200;
//
// colPort
//
this.colPort.Text = "Port";
this.colPort.Width = 80;
//
// rdoNoMaster
//
this.rdoNoMaster.AutoSize = true;
this.rdoNoMaster.Checked = true;
this.rdoNoMaster.Location = new System.Drawing.Point(11, 50);
this.rdoNoMaster.Name = "rdoNoMaster";
this.rdoNoMaster.Size = new System.Drawing.Size(374, 17);
this.rdoNoMaster.TabIndex = 3;
this.rdoNoMaster.TabStop = true;
this.rdoNoMaster.Text = "This instance should report its check results to an existing Icinga 2 master:";
this.rdoNoMaster.UseVisualStyleBackColor = true;
this.rdoNoMaster.CheckedChanged += new System.EventHandler(this.RadioMaster_CheckedChanged);
//
// rdoNewMaster
//
this.rdoNewMaster.AutoSize = true;
this.rdoNewMaster.Enabled = false;
this.rdoNewMaster.Location = new System.Drawing.Point(11, 22);
this.rdoNewMaster.Name = "rdoNewMaster";
this.rdoNewMaster.Size = new System.Drawing.Size(167, 17);
this.rdoNewMaster.TabIndex = 2;
this.rdoNewMaster.TabStop = true;
this.rdoNewMaster.Text = "This is a new master instance.";
this.rdoNewMaster.UseVisualStyleBackColor = true;
this.rdoNewMaster.CheckedChanged += new System.EventHandler(this.RadioMaster_CheckedChanged);
//
// tbcPages
//
this.tbcPages.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
this.tbcPages.Controls.Add(this.tabParameters);
this.tbcPages.Controls.Add(this.tabRetrieveCertificate);
this.tbcPages.Controls.Add(this.tabVerifyCertificate);
this.tbcPages.Controls.Add(this.tabConfigure);
this.tbcPages.Controls.Add(this.tabFinish);
this.tbcPages.Controls.Add(this.tabError);
this.tbcPages.ItemSize = new System.Drawing.Size(0, 1);
this.tbcPages.Location = new System.Drawing.Point(0, 80);
this.tbcPages.Margin = new System.Windows.Forms.Padding(0);
this.tbcPages.Name = "tbcPages";
this.tbcPages.SelectedIndex = 0;
this.tbcPages.Size = new System.Drawing.Size(625, 509);
this.tbcPages.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.tbcPages.TabIndex = 0;
this.tbcPages.SelectedIndexChanged += new System.EventHandler(this.tbcPages_SelectedIndexChanged);
//
// tabRetrieveCertificate
//
this.tabRetrieveCertificate.Controls.Add(this.lblRetrieveCertificate);
this.tabRetrieveCertificate.Controls.Add(this.prgRetrieveCertificate);
this.tabRetrieveCertificate.Location = new System.Drawing.Point(4, 5);
this.tabRetrieveCertificate.Name = "tabRetrieveCertificate";
this.tabRetrieveCertificate.Padding = new System.Windows.Forms.Padding(3);
this.tabRetrieveCertificate.Size = new System.Drawing.Size(617, 500);
this.tabRetrieveCertificate.TabIndex = 7;
this.tabRetrieveCertificate.Text = "Checking Certificate";
this.tabRetrieveCertificate.UseVisualStyleBackColor = true;
//
// lblRetrieveCertificate
//
this.lblRetrieveCertificate.AutoSize = true;
this.lblRetrieveCertificate.Location = new System.Drawing.Point(164, 229);
this.lblRetrieveCertificate.Name = "lblRetrieveCertificate";
this.lblRetrieveCertificate.Size = new System.Drawing.Size(110, 13);
this.lblRetrieveCertificate.TabIndex = 3;
this.lblRetrieveCertificate.Text = "Checking certificate...";
//
// prgRetrieveCertificate
//
this.prgRetrieveCertificate.Location = new System.Drawing.Point(164, 248);
this.prgRetrieveCertificate.Name = "prgRetrieveCertificate";
this.prgRetrieveCertificate.Size = new System.Drawing.Size(289, 23);
this.prgRetrieveCertificate.TabIndex = 2;
//
// tabVerifyCertificate
//
this.tabVerifyCertificate.Controls.Add(this.grpX509Fields);
this.tabVerifyCertificate.Controls.Add(this.txtX509Subject);
this.tabVerifyCertificate.Controls.Add(this.txtX509Issuer);
this.tabVerifyCertificate.Controls.Add(this.lblX509Subject);
this.tabVerifyCertificate.Controls.Add(this.lblX509Issuer);
this.tabVerifyCertificate.Controls.Add(this.lblX509Prompt);
this.tabVerifyCertificate.Location = new System.Drawing.Point(4, 5);
this.tabVerifyCertificate.Name = "tabVerifyCertificate";
this.tabVerifyCertificate.Padding = new System.Windows.Forms.Padding(3);
this.tabVerifyCertificate.Size = new System.Drawing.Size(617, 500);
this.tabVerifyCertificate.TabIndex = 6;
this.tabVerifyCertificate.Text = "Verify Certificate";
this.tabVerifyCertificate.UseVisualStyleBackColor = true;
//
// grpX509Fields
//
this.grpX509Fields.Controls.Add(this.txtX509Field);
this.grpX509Fields.Controls.Add(this.lvwX509Fields);
this.grpX509Fields.Location = new System.Drawing.Point(11, 115);
this.grpX509Fields.Name = "grpX509Fields";
this.grpX509Fields.Size = new System.Drawing.Size(598, 369);
this.grpX509Fields.TabIndex = 8;
this.grpX509Fields.TabStop = false;
this.grpX509Fields.Text = "X509 Fields";
//
// txtX509Field
//
this.txtX509Field.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtX509Field.Location = new System.Drawing.Point(6, 197);
this.txtX509Field.Multiline = true;
this.txtX509Field.Name = "txtX509Field";
this.txtX509Field.ReadOnly = true;
this.txtX509Field.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtX509Field.Size = new System.Drawing.Size(586, 166);
this.txtX509Field.TabIndex = 9;
//
// lvwX509Fields
//
this.lvwX509Fields.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colField,
this.colValue});
this.lvwX509Fields.Location = new System.Drawing.Point(6, 19);
this.lvwX509Fields.Name = "lvwX509Fields";
this.lvwX509Fields.Size = new System.Drawing.Size(586, 172);
this.lvwX509Fields.TabIndex = 8;
this.lvwX509Fields.UseCompatibleStateImageBehavior = false;
this.lvwX509Fields.View = System.Windows.Forms.View.Details;
this.lvwX509Fields.SelectedIndexChanged += new System.EventHandler(this.lvwX509Fields_SelectedIndexChanged);
//
// colField
//
this.colField.Text = "Field";
this.colField.Width = 200;
//
// colValue
//
this.colValue.Text = "Value";
this.colValue.Width = 350;
//
// txtX509Subject
//
this.txtX509Subject.Location = new System.Drawing.Point(71, 73);
this.txtX509Subject.Name = "txtX509Subject";
this.txtX509Subject.ReadOnly = true;
this.txtX509Subject.Size = new System.Drawing.Size(532, 20);
this.txtX509Subject.TabIndex = 4;
//
// txtX509Issuer
//
this.txtX509Issuer.Location = new System.Drawing.Point(71, 47);
this.txtX509Issuer.Name = "txtX509Issuer";
this.txtX509Issuer.ReadOnly = true;
this.txtX509Issuer.Size = new System.Drawing.Size(532, 20);
this.txtX509Issuer.TabIndex = 3;
//
// lblX509Subject
//
this.lblX509Subject.AutoSize = true;
this.lblX509Subject.Location = new System.Drawing.Point(8, 77);
this.lblX509Subject.Name = "lblX509Subject";
this.lblX509Subject.Size = new System.Drawing.Size(46, 13);
this.lblX509Subject.TabIndex = 2;
this.lblX509Subject.Text = "Subject:";
//
// lblX509Issuer
//
this.lblX509Issuer.AutoSize = true;
this.lblX509Issuer.Location = new System.Drawing.Point(8, 50);
this.lblX509Issuer.Name = "lblX509Issuer";
this.lblX509Issuer.Size = new System.Drawing.Size(38, 13);
this.lblX509Issuer.TabIndex = 1;
this.lblX509Issuer.Text = "Issuer:";
//
// lblX509Prompt
//
this.lblX509Prompt.AutoSize = true;
this.lblX509Prompt.Location = new System.Drawing.Point(8, 15);
this.lblX509Prompt.Name = "lblX509Prompt";
this.lblX509Prompt.Size = new System.Drawing.Size(201, 13);
this.lblX509Prompt.TabIndex = 0;
this.lblX509Prompt.Text = "Please verify the master\'s SSL certificate:";
//
// tabError
//
this.tabError.Controls.Add(this.txtError);
this.tabError.Controls.Add(this.lblError);
this.tabError.Location = new System.Drawing.Point(4, 5);
this.tabError.Name = "tabError";
this.tabError.Padding = new System.Windows.Forms.Padding(3);
this.tabError.Size = new System.Drawing.Size(617, 500);
this.tabError.TabIndex = 8;
this.tabError.Text = "Error";
this.tabError.UseVisualStyleBackColor = true;
//
// txtError
//
this.txtError.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtError.Location = new System.Drawing.Point(11, 38);
this.txtError.Multiline = true;
this.txtError.Name = "txtError";
this.txtError.ReadOnly = true;
this.txtError.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtError.Size = new System.Drawing.Size(598, 397);
this.txtError.TabIndex = 1;
//
// lblError
//
this.lblError.AutoSize = true;
this.lblError.Location = new System.Drawing.Point(8, 12);
this.lblError.Name = "lblError";
this.lblError.Size = new System.Drawing.Size(209, 13);
this.lblError.TabIndex = 0;
this.lblError.Text = "An error occurred while setting up Icinga 2:";
//
// picBanner
//
this.picBanner.Image = global::Icinga.Properties.Resources.icinga_banner;
this.picBanner.Location = new System.Drawing.Point(0, 0);
this.picBanner.Name = "picBanner";
this.picBanner.Size = new System.Drawing.Size(625, 77);
this.picBanner.TabIndex = 1;
this.picBanner.TabStop = false;
//
// chkInstallNSCP
//
this.chkInstallNSCP.AutoSize = true;
this.chkInstallNSCP.Location = new System.Drawing.Point(9, 70);
this.chkInstallNSCP.Name = "chkInstallNSCP";
this.chkInstallNSCP.Size = new System.Drawing.Size(149, 17);
this.chkInstallNSCP.TabIndex = 6;
this.chkInstallNSCP.Text = "Install/Update NSClient++";
this.chkInstallNSCP.UseVisualStyleBackColor = true;
//
// SetupWizard
//
this.AcceptButton = this.btnNext;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(625, 624);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnNext);
this.Controls.Add(this.btnBack);
this.Controls.Add(this.picBanner);
this.Controls.Add(this.tbcPages);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "SetupWizard";
this.Text = "Icinga 2 Setup Wizard";
this.tabFinish.ResumeLayout(false);
this.tabFinish.PerformLayout();
this.tabConfigure.ResumeLayout(false);
this.tabConfigure.PerformLayout();
this.tabParameters.ResumeLayout(false);
this.tabParameters.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.tbcPages.ResumeLayout(false);
this.tabRetrieveCertificate.ResumeLayout(false);
this.tabRetrieveCertificate.PerformLayout();
this.tabVerifyCertificate.ResumeLayout(false);
this.tabVerifyCertificate.PerformLayout();
this.grpX509Fields.ResumeLayout(false);
this.grpX509Fields.PerformLayout();
this.tabError.ResumeLayout(false);
this.tabError.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox picBanner;
private System.Windows.Forms.Button btnBack;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.TabPage tabFinish;
private System.Windows.Forms.Label lblSetupCompleted;
private System.Windows.Forms.TabPage tabConfigure;
private System.Windows.Forms.Label lblConfigStatus;
private System.Windows.Forms.ProgressBar prgConfig;
private System.Windows.Forms.TabPage tabParameters;
private System.Windows.Forms.TextBox txtInstanceName;
private System.Windows.Forms.Label lblInstanceName;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton rdoNoListener;
private System.Windows.Forms.TextBox txtListenerPort;
private System.Windows.Forms.Label lblListenerPort;
private System.Windows.Forms.RadioButton rdoListener;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnRemoveEndpoint;
private System.Windows.Forms.Button btnAddEndpoint;
private System.Windows.Forms.ListView lvwEndpoints;
private System.Windows.Forms.ColumnHeader colHost;
private System.Windows.Forms.ColumnHeader colPort;
private System.Windows.Forms.RadioButton rdoNoMaster;
private System.Windows.Forms.RadioButton rdoNewMaster;
private System.Windows.Forms.TabControl tbcPages;
private System.Windows.Forms.TabPage tabVerifyCertificate;
private System.Windows.Forms.Label lblX509Prompt;
private System.Windows.Forms.TextBox txtX509Subject;
private System.Windows.Forms.TextBox txtX509Issuer;
private System.Windows.Forms.Label lblX509Subject;
private System.Windows.Forms.Label lblX509Issuer;
private System.Windows.Forms.GroupBox grpX509Fields;
private System.Windows.Forms.ListView lvwX509Fields;
private System.Windows.Forms.ColumnHeader colField;
private System.Windows.Forms.ColumnHeader colValue;
private System.Windows.Forms.TextBox txtX509Field;
private System.Windows.Forms.TabPage tabRetrieveCertificate;
private System.Windows.Forms.Label lblRetrieveCertificate;
private System.Windows.Forms.ProgressBar prgRetrieveCertificate;
private System.Windows.Forms.TabPage tabError;
private System.Windows.Forms.TextBox txtError;
private System.Windows.Forms.Label lblError;
private System.Windows.Forms.TextBox txtTicket;
private System.Windows.Forms.Label lblTicket;
private System.Windows.Forms.ColumnHeader colInstanceName;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox chkAcceptConfig;
private System.Windows.Forms.CheckBox chkAcceptCommands;
private System.Windows.Forms.CheckBox chkInstallNSCP;
}
}

View File

@ -0,0 +1,483 @@
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Net.NetworkInformation;
using System.IO.Compression;
using System.Diagnostics;
using System.ServiceProcess;
using System.Security.AccessControl;
namespace Icinga
{
public partial class SetupWizard : Form
{
private string _TrustedFile;
public SetupWizard()
{
InitializeComponent();
txtInstanceName.Text = Icinga2InstanceName;
}
private void Warning(string message)
{
MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
private string Icinga2InstanceName
{
get
{
IPGlobalProperties props = IPGlobalProperties.GetIPGlobalProperties();
string fqdn = props.HostName;
if (props.DomainName != "")
fqdn += "." + props.DomainName;
return fqdn;
}
}
private bool GetMasterHostPort(out string host, out string port)
{
foreach (ListViewItem lvi in lvwEndpoints.Items) {
if (lvi.SubItems.Count > 1) {
host = lvi.SubItems[1].Text;
port = lvi.SubItems[2].Text;
return true;
}
}
host = null;
port = null;
return false;
}
private void EnableFeature(string feature)
{
FileStream fp = null;
try {
fp = File.Open(Program.Icinga2DataDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create);
using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) {
fp = null;
sw.Write(String.Format("include \"../features-available/{0}.conf\"\n", feature));
}
} finally {
if (fp != null)
fp.Dispose();
}
}
private void SetRetrievalStatus(int pct)
{
if (InvokeRequired) {
Invoke((MethodInvoker)delegate { SetRetrievalStatus(pct); });
return;
}
prgRetrieveCertificate.Value = pct;
}
private void SetConfigureStatus(int pct, string message)
{
if (InvokeRequired) {
Invoke((MethodInvoker)delegate { SetConfigureStatus(pct, message); });
return;
}
prgConfig.Value = pct;
lblConfigStatus.Text = message;
}
private void ShowErrorText(string text)
{
if (InvokeRequired) {
Invoke((MethodInvoker)delegate { ShowErrorText(text); });
return;
}
txtError.Text = text;
tbcPages.SelectedTab = tabError;
}
private bool RunProcess(string filename, string arguments, out string output)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = filename;
psi.Arguments = arguments;
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
String result = "";
using (Process proc = Process.Start(psi)) {
proc.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs args) {
result += args.Data + "\r\n";
};
proc.OutputDataReceived += delegate(object sender, DataReceivedEventArgs args) {
result += args.Data + "\r\n";
};
proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.WaitForExit();
output = result;
if (proc.ExitCode != 0)
return false;
}
return true;
}
private void VerifyCertificate(string host, string port)
{
SetRetrievalStatus(25);
string pathPrefix = Program.Icinga2DataDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text;
string processArguments = "pki new-cert --cn \"" + txtInstanceName.Text + "\" --key \"" + pathPrefix + ".key\" --cert \"" + pathPrefix + ".crt\"";
string output;
if (!File.Exists(pathPrefix + ".crt")) {
if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe",
processArguments,
out output)) {
ShowErrorText("Running command 'icinga2.exe " + processArguments + "' produced the following output:\n" + output);
return;
}
}
SetRetrievalStatus(50);
_TrustedFile = Path.GetTempFileName();
processArguments = "pki save-cert --host \"" + host + "\" --port \"" + port + "\" --key \"" + pathPrefix + ".key\" --cert \"" + pathPrefix + ".crt\" --trustedcert \"" + _TrustedFile + "\"";
if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe",
processArguments,
out output)) {
ShowErrorText("Running command 'icinga2.exe " + processArguments + "' produced the following output:\n" + output);
return;
}
SetRetrievalStatus(100);
X509Certificate2 cert = new X509Certificate2(_TrustedFile);
Invoke((MethodInvoker)delegate { ShowCertificatePrompt(cert); });
}
private void ConfigureService()
{
SetConfigureStatus(0, "Updating configuration files...");
string output;
string args = "";
if (rdoNewMaster.Checked)
args += " --master";
Invoke((MethodInvoker)delegate {
string master_host, master_port;
GetMasterHostPort(out master_host, out master_port);
args += " --master_host " + master_host + "," + master_port;
foreach (ListViewItem lvi in lvwEndpoints.Items) {
args += " --endpoint " + lvi.SubItems[0].Text;
if (lvi.SubItems.Count > 1)
args += "," + lvi.SubItems[1].Text + "," + lvi.SubItems[2].Text;
}
});
if (rdoListener.Checked)
args += " --listen ::," + txtListenerPort.Text;
if (chkAcceptConfig.Checked)
args += " --accept-config";
if (chkAcceptCommands.Checked)
args += " --accept-commands";
args += " --ticket \"" + txtTicket.Text + "\"";
args += " --trustedcert \"" + _TrustedFile + "\"";
args += " --cn \"" + txtInstanceName.Text + "\"";
args += " --zone \"" + txtInstanceName.Text + "\"";
if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe",
"node setup" + args,
out output)) {
ShowErrorText("Running command 'icinga2.exe " + "node setup" + args + "' produced the following output:\n" + output);
return;
}
SetConfigureStatus(50, "Setting ACLs for the Icinga 2 directory...");
DirectoryInfo di = new DirectoryInfo(Program.Icinga2InstallDir);
DirectorySecurity ds = di.GetAccessControl();
FileSystemAccessRule rule = new FileSystemAccessRule("NT AUTHORITY\\NetworkService",
FileSystemRights.Modify,
InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow);
ds.AddAccessRule(rule);
di.SetAccessControl(ds);
SetConfigureStatus(75, "Installing the Icinga 2 service...");
RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe",
"--scm-uninstall",
out output);
if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe",
"daemon --validate",
out output)) {
ShowErrorText("Running command 'icinga2.exe daemon --validate' produced the following output:\n" + output);
return;
}
if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe",
"--scm-install daemon",
out output)) {
ShowErrorText("Running command 'icinga2.exe daemon --scm-install daemon' produced the following output:\n" + output);
return;
}
if (chkInstallNSCP.Checked)
{
SetConfigureStatus(85, "Waiting for NSClient++ installation to complete...");
Process proc = new Process();
proc.StartInfo.FileName = "msiexec.exe";
proc.StartInfo.Arguments = "/i \"" + Program.Icinga2InstallDir + "\\sbin\\NSCP.msi\"";
proc.Start();
proc.WaitForExit();
}
SetConfigureStatus(100, "Finished.");
FinishConfigure();
}
private void FinishConfigure()
{
if (InvokeRequired) {
Invoke((MethodInvoker)FinishConfigure);
return;
}
tbcPages.SelectedTab = tabFinish;
}
private void btnBack_Click(object sender, EventArgs e)
{
if (tbcPages.SelectedTab == tabError) {
tbcPages.SelectedIndex = 0;
return;
}
int offset = 1;
if (tbcPages.SelectedTab == tabVerifyCertificate)
offset++;
tbcPages.SelectedIndex -= offset;
}
private void btnNext_Click(object sender, EventArgs e)
{
if (tbcPages.SelectedTab == tabParameters) {
if (txtInstanceName.Text.Length == 0) {
Warning("Please enter an instance name.");
return;
}
if (txtTicket.Text.Length == 0) {
Warning("Please enter an agent ticket.");
return;
}
if (rdoNoMaster.Checked) {
if (lvwEndpoints.Items.Count == 0) {
Warning("You need to add at least one master endpoint.");
return;
}
string host, port;
if (!GetMasterHostPort(out host, out port)) {
Warning("Please enter a remote host and port for at least one of your endpoints.");
return;
}
}
if (rdoListener.Checked && (txtListenerPort.Text == "")) {
Warning("You need to specify a listener port.");
return;
}
}
if (tbcPages.SelectedTab == tabFinish || tbcPages.SelectedTab == tabError)
Application.Exit();
tbcPages.SelectedIndex++;
}
private void btnCancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void tbcPages_SelectedIndexChanged(object sender, EventArgs e)
{
Refresh();
btnBack.Enabled = (tbcPages.SelectedTab == tabVerifyCertificate || tbcPages.SelectedTab == tabError);
btnNext.Enabled = (tbcPages.SelectedTab == tabParameters || tbcPages.SelectedTab == tabVerifyCertificate || tbcPages.SelectedTab == tabFinish);
if (tbcPages.SelectedTab == tabFinish) {
btnNext.Text = "&Finish >";
btnCancel.Enabled = false;
}
if (tbcPages.SelectedTab == tabRetrieveCertificate) {
ListViewItem lvi = lvwEndpoints.Items[0];
string master_host, master_port;
GetMasterHostPort(out master_host, out master_port);
Thread thread = new Thread((ThreadStart)delegate { VerifyCertificate(master_host, master_port); });
thread.Start();
}
/*if (tbcPages.SelectedTab == tabParameters &&
!File.Exists(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) {
byte[] bytes = Convert.FromBase64String(txtBundle.Text);
MemoryStream ms = new MemoryStream(bytes);
GZipStream gz = new GZipStream(ms, CompressionMode.Decompress);
MemoryStream ms2 = new MemoryStream();
byte[] buffer = new byte[512];
int rc;
while ((rc = gz.Read(buffer, 0, buffer.Length)) > 0)
ms2.Write(buffer, 0, rc);
ms2.Position = 0;
TarReader tr = new TarReader(ms2);
tr.ReadToEnd(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent");
}*/
if (tbcPages.SelectedTab == tabConfigure) {
Thread thread = new Thread(ConfigureService);
thread.Start();
}
}
private void RadioMaster_CheckedChanged(object sender, EventArgs e)
{
lvwEndpoints.Enabled = !rdoNewMaster.Checked;
btnAddEndpoint.Enabled = !rdoNewMaster.Checked;
btnRemoveEndpoint.Enabled = !rdoNewMaster.Checked && lvwEndpoints.SelectedItems.Count > 0;
}
private void RadioListener_CheckedChanged(object sender, EventArgs e)
{
txtListenerPort.Enabled = rdoListener.Checked;
}
private void AddCertificateField(string name, string shortValue, string longValue = null)
{
ListViewItem lvi = new ListViewItem();
lvi.Text = name;
lvi.SubItems.Add(shortValue);
if (longValue == null)
longValue = shortValue;
lvi.Tag = longValue;
lvwX509Fields.Items.Add(lvi);
}
private string PadText(string input)
{
string output = "";
for (int i = 0; i < input.Length; i += 2) {
if (output != "")
output += " ";
int len = 2;
if (input.Length - i < 2)
len = input.Length - i;
output += input.Substring(i, len);
}
return output;
}
private void ShowCertificatePrompt(X509Certificate2 certificate)
{
txtX509Issuer.Text = certificate.Issuer;
txtX509Subject.Text = certificate.Subject;
lvwX509Fields.Items.Clear();
AddCertificateField("Version", "V" + certificate.Version.ToString());
AddCertificateField("Serial number", certificate.SerialNumber);
AddCertificateField("Signature algorithm", certificate.SignatureAlgorithm.FriendlyName);
AddCertificateField("Valid from", certificate.NotBefore.ToString());
AddCertificateField("Valid to", certificate.NotAfter.ToString());
string pkey = BitConverter.ToString(certificate.PublicKey.EncodedKeyValue.RawData).Replace("-", " ");
AddCertificateField("Public key", certificate.PublicKey.Oid.FriendlyName + " (" + certificate.PublicKey.Key.KeySize + " bits)", pkey);
string thumbprint = PadText(certificate.Thumbprint);
AddCertificateField("Thumbprint", thumbprint);
tbcPages.SelectedTab = tabVerifyCertificate;
}
private void btnAddEndpoint_Click(object sender, EventArgs e)
{
EndpointInputBox eib = new EndpointInputBox();
if (eib.ShowDialog(this) == DialogResult.Cancel)
return;
ListViewItem lvi = new ListViewItem();
lvi.Text = eib.txtInstanceName.Text;
if (eib.chkConnect.Checked) {
lvi.SubItems.Add(eib.txtHost.Text);
lvi.SubItems.Add(eib.txtPort.Text);
}
lvwEndpoints.Items.Add(lvi);
}
private void lvwEndpoints_SelectedIndexChanged(object sender, EventArgs e)
{
btnRemoveEndpoint.Enabled = lvwEndpoints.SelectedItems.Count > 0;
}
private void lvwX509Fields_SelectedIndexChanged(object sender, EventArgs e)
{
if (lvwX509Fields.SelectedItems.Count == 0)
return;
ListViewItem lvi = lvwX509Fields.SelectedItems[0];
txtX509Field.Text = (string)lvi.Tag;
}
private void btnRemoveEndpoint_Click(object sender, EventArgs e)
{
while (lvwEndpoints.SelectedItems.Count > 0) {
lvwEndpoints.Items.Remove(lvwEndpoints.SelectedItems[0]);
}
}
}
}

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAICAQAAAABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAAAAAAAAAAEAAAABAA
AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP//
AAD///8AAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAcAAAcAB3AAAAAAAAAAAAAAcABwB///cA
AAAAAAAAAAAAcAAA////AAAAAAAAAAAAAAAAAP///3AAAAAAAAAAAAAAAAD///9wAAAAAAAAAAAAAAAA
j//4AAAAB3AAAAAAAAAAAAj/jwAAAA/4AAAAAAAAAAAAAAiAAAAP9wAAAAAAAAAAAAAH9wAAf3AAAAAA
AAAAAAAAAH93d/cAAAAAAAAAAAAAAAB////3AAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAB/////9w
AAAAAAAAAAAAAAf/////gAAAAAAAAAAAAAAH//////h3AAAAAAAAAAAAB/////+I//h3eHAAAAAAAAD/
////AAB3j//3AAAAAAB4////9wAAAAf/+AAAAAf/+AB4iPAAAAAAj/cAAAAH//AAAAD3AAAAAAcAAAAA
B/+AAAAAjwAAAAAAAAAAAAB3AAAAAA9wAAAAAAAAAAAAAAAAAAAIh3AAAAAAAAAAAAAAAAAAD//wAAAA
AAAAAAAAAAAAAH//9wAAAAAAAAAAAAAAAAB///cAAAAAAAcAAAAAAAAACP+AAAAAAHAAcAAAAAAAAAB3
AAAAAAcAAAcAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAAAAAAAAD/////4AAAB8AAAAOAAAABgAAAAYAA
AAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAA
AAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAcAAAAPgAAAH/////w==
</value>
</data>
</root>

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->
<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
<!-- If your application is designed to work with Windows 8.1, uncomment the following supportedOS node-->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>-->
</application>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

158
vim/bundle/icinga2/changelog.py Executable file
View File

@ -0,0 +1,158 @@
#!/usr/bin/env python
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
import urllib2, json, sys, string
from argparse import ArgumentParser
DESCRIPTION="update release changes"
VERSION="1.0.0"
ISSUE_URL= "https://dev.icinga.org/issues/"
ISSUE_PROJECT="i2"
arg_parser = ArgumentParser(description= "%s (Version: %s)" % (DESCRIPTION, VERSION))
arg_parser.add_argument('-V', '--version', required=True, type=str, help="define version to query")
arg_parser.add_argument('-p', '--project', type=str, help="add urls to issues")
arg_parser.add_argument('-l', '--links', action='store_true', help="add urls to issues")
arg_parser.add_argument('-H', '--html', action='store_true', help="print html output (defaults to markdown)")
args = arg_parser.parse_args(sys.argv[1:])
ftype = "md" if not args.html else "html"
def format_header(text, lvl, ftype = ftype):
if ftype == "html":
return "<h%s>%s</h%s>" % (lvl, text, lvl)
if ftype == "md":
return "#" * lvl + " " + text
def format_logentry(log_entry, args = args, issue_url = ISSUE_URL):
if args.links:
if args.html:
return "<li> {0} <a href=\"{4}{1}\">{1}</a> ({2}): {3}</li>".format(log_entry[0], log_entry[1], log_entry[2], log_entry[3],issue_url)
else:
return "* {0} [{1}]({4}{1} \"{0} {1}\") ({2}): {3}".format(log_entry[0], log_entry[1], log_entry[2], log_entry[3], issue_url)
else:
if args.html:
return "<li>%s %d (%s): %s</li>" % log_entry
else:
return "* %s %d (%s): %s" % log_entry
def print_category(category, entries):
if len(entries) > 0:
print ""
print format_header(category, 4)
print ""
if args.html:
print "<ul>"
for entry in sorted(entries):
print format_logentry(entry)
if args.html:
print "</ul>"
print ""
version_name = args.version
if args.project:
ISSUE_PROJECT=args.project
rsp = urllib2.urlopen("https://dev.icinga.org/projects/%s/versions.json" % (ISSUE_PROJECT))
versions_data = json.loads(rsp.read())
version_id = None
for version in versions_data["versions"]:
if version["name"] == version_name:
version_id = version["id"]
break
if version_id == None:
print "Version '%s' not found." % (version_name)
sys.exit(1)
changes = ""
if "custom_fields" in version:
for field in version["custom_fields"]:
if field["id"] == 14:
changes = field["value"]
break
changes = string.join(string.split(changes, "\r\n"), "\n")
print format_header("What's New in Version %s" % (version_name), 3)
print ""
if changes:
print format_header("Changes", 4)
print ""
print changes
print ""
offset = 0
features = []
bugfixes = []
support = []
while True:
# We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set
# for some of the older tickets:
rsp = urllib2.urlopen("https://dev.icinga.org/projects/%s/issues.json?offset=%d&status_id=closed&fixed_version_id=%d" % (ISSUE_PROJECT, offset, version_id))
issues_data = json.loads(rsp.read())
issues_count = len(issues_data["issues"])
offset = offset + issues_count
if issues_count == 0:
break
for issue in issues_data["issues"]:
ignore_issue = False
if "custom_fields" in issue:
for field in issue["custom_fields"]:
if field["id"] == 13 and "value" in field and field["value"] == "0":
ignore_issue = True
break
if ignore_issue:
continue
if "category" in issue:
category = issue["category"]["name"]
else:
category = "no category"
# the order is important for print_category()
entry = (issue["tracker"]["name"], issue["id"], category, issue["subject"].strip())
if issue["tracker"]["name"] == "Feature":
features.append(entry)
elif issue["tracker"]["name"] == "Bug":
bugfixes.append(entry)
elif issue["tracker"]["name"] == "Support":
support.append(entry)
print_category("Feature", features)
print_category("Bugfixes", bugfixes)
print_category("Support", support)
sys.exit(0)

View File

@ -0,0 +1,29 @@
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
if(WIN32)
find_program(CHOCO_BINARY choco)
configure_file(icinga2.nuspec.cmake icinga2.nuspec)
configure_file(chocolateyInstall.ps1.cmake chocolateyInstall.ps1)
add_custom_target(choco-pkg ALL
COMMAND choco pack
COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/icinga2.${SPEC_VERSION}.nupkg ${CMAKE_CURRENT_BINARY_DIR}/icinga2.nupkg
DEPENDS icinga2.nuspec ${CMAKE_CURRENT_BINARY_DIR}/chocolateyInstall.ps1 chocolateyUninstall.ps1
)
endif()

View File

@ -0,0 +1,8 @@
$packageName = 'icinga2'
$installerType = 'msi'
$url32 = 'https://packages.icinga.org/windows/Icinga2-v${SPEC_VERSION}-x86.msi'
$url64 = 'https://packages.icinga.org/windows/Icinga2-v${SPEC_VERSION}-x86_64.msi'
$silentArgs = '/qn /norestart'
$validExitCodes = @(0)
Install-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url32" "$url64" -validExitCodes $validExitCodes

View File

@ -0,0 +1,28 @@
$packageName = "Icinga 2";
$fileType = 'msi';
$silentArgs = '/qr /norestart'
$validExitCodes = @(0)
try {
$packageGuid = Get-ChildItem HKLM:\SOFTWARE\Classes\Installer\Products |
Get-ItemProperty -Name 'ProductName' |
? { $_.ProductName -like $packageName + "*"} |
Select -ExpandProperty PSChildName -First 1
$properties = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\$packageGuid\InstallProperties
$file = $properties.LocalPackage
# Would like to use the following, but looks like there is a bug in this method when uninstalling MSI's
# Uninstall-ChocolateyPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes
# Use this instead
$msiArgs = "/x $file $silentArgs";
Start-ChocolateyProcessAsAdmin "$msiArgs" 'msiexec' -validExitCodes $validExitCodes
Write-ChocolateySuccess $package
}
catch {
Write-ChocolateyFailure $package "$($_.Exception.Message)"
throw
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if ??? doesn?t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<!--package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"-->
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata>
<!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
<id>icinga2</id>
<title>Icinga2</title>
<version>${SPEC_VERSION}</version>
<authors>2016 - The Icinga Project</authors>
<owners>Icinga Development Team</owners>
<summary>icinga2 - Monitoring Agent for Windows</summary>
<description>Icinga 2 is an open source monitoring platform which notifies users about host and service outages.</description>
<projectUrl>https://www.icinga.org/</projectUrl>
<tags>icinga2 agent monitoring</tags>
<licenseUrl>https://www.icinga.org/resources/faq/</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<iconUrl>https://www.icinga.org/wp-content/uploads/2015/05/icinga_icon_128x128.png</iconUrl>
</metadata>
<files>
<file src="${CMAKE_CURRENT_BINARY_DIR}/chocolateyInstall.ps1" target="tools" />
<file src="${CMAKE_CURRENT_SOURCE_DIR}/chocolateyUninstall.ps1" target="tools" />
</files>
</package>

View File

@ -0,0 +1,28 @@
# - Try to find libyajl
# Once done this will define
# YAJL_FOUND - System has YAJL
# YAJL_INCLUDE_DIRS - The YAJL include directories
# YAJL_LIBRARIES - The libraries needed to use YAJL
# YAJL_DEFINITIONS - Compiler switches required for using YAJL
find_package(PkgConfig)
pkg_check_modules(PC_YAJL QUIET yajl)
set(YAJL_DEFINITIONS ${PC_YAJL_CFLAGS_OTHER})
find_path(YAJL_INCLUDE_DIR yajl/yajl_version.h
HINTS ${PC_YAJL_INCLUDEDIR} ${PC_YAJL_INCLUDE_DIRS}
PATH_SUFFIXES libyajl)
find_library(YAJL_LIBRARY NAMES yajl libyajl
HINTS ${PC_YAJL_LIBDIR} ${PC_YAJL_LIBRARY_DIRS})
set(YAJL_LIBRARIES ${YAJL_LIBRARY} )
set(YAJL_INCLUDE_DIRS ${YAJL_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set YAJL_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(yajl DEFAULT_MSG
YAJL_LIBRARY YAJL_INCLUDE_DIR)
mark_as_advanced(YAJL_INCLUDE_DIR YAJL_LIBRARY)

View File

@ -0,0 +1,52 @@
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (http://www.icinga.org)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
function(install_if_not_exists src dest)
set(real_dest "${dest}")
if(NOT IS_ABSOLUTE "${src}")
set(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
endif()
get_filename_component(src_name "${src}" NAME)
get_filename_component(basename_dest "${src}" NAME)
string(REPLACE "/" "\\\\" nsis_src "${src}")
string(REPLACE "/" "\\\\" nsis_dest_dir "${real_dest}")
string(REPLACE "/" "\\\\" nsis_dest "${real_dest}/${basename_dest}")
install(CODE "
if(\"\$ENV{DESTDIR}\" STREQUAL \"\")
set(target_dir \${CMAKE_INSTALL_PREFIX})
else()
set(target_dir \$ENV{DESTDIR})
endif()
if(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.* OR NOT EXISTS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${skel_prefix}${dest}/${src_name}\")
message(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${src_name}\")
if(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.*)
set(skel_prefix \"share/skel/\")
else()
set(skel_prefix \"\")
endif()
execute_process(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\"
\"\${target_dir}/\${skel_prefix}${dest}/${src_name}\"
RESULT_VARIABLE copy_result
ERROR_VARIABLE error_output)
if(copy_result)
message(FATAL_ERROR \${error_output})
endif()
else()
message(STATUS \"Skipping : \${target_dir}/${dest}/${src_name}\")
endif()
")
endfunction(install_if_not_exists)

View File

@ -0,0 +1,28 @@
#ifndef CONFIG_H
#define CONFIG_H
#cmakedefine HAVE_BACKTRACE_SYMBOLS
#cmakedefine HAVE_PIPE2
#cmakedefine HAVE_VFORK
#cmakedefine HAVE_DLADDR
#cmakedefine HAVE_LIBEXECINFO
#cmakedefine HAVE_CXXABI_H
#cmakedefine HAVE_NICE
#cmakedefine HAVE_EDITLINE
#cmakedefine ICINGA2_UNITY_BUILD
#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
#define ICINGA_RUNDIR "${ICINGA2_RUNDIR}"
#define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
#define ICINGA_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2"
#define ICINGA_INCLUDECONFDIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2/include"
#define ICINGA_USER "${ICINGA2_USER}"
#define ICINGA_GROUP "${ICINGA2_GROUP}"
#define ICINGA_BUILD_HOST_NAME "${ICINGA2_BUILD_HOST_NAME}"
#define ICINGA_BUILD_COMPILER_NAME "${ICINGA2_BUILD_COMPILER_NAME}"
#define ICINGA_BUILD_COMPILER_VERSION "${ICINGA2_BUILD_COMPILER_VERSION}"
#endif /* CONFIG_H */

View File

@ -0,0 +1,19 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/

View File

@ -0,0 +1,6 @@
Icinga 2 Contrib files
======================
This directory contains various unsupported scripts. Chances are that they're
either completely broken or at least need some changes to work with the most
recent version of Icinga 2.

View File

@ -0,0 +1,146 @@
#!/usr/bin/env python
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
import sys
import subprocess
import socket
import urlparse
import requests
import json
from xml.dom.minidom import parse
api_url = "https://localhost:5665/"
api_user = "root"
api_password = "root"
if len(sys.argv) < 2:
print "Syntax: %s <xml-file> [<xml-file> ...]" % (sys.argv[0])
sys.exit(1)
tcp_service_commands = {
'ssh': 'ssh',
'http': 'http',
'smtp': 'smtp',
'ssmtp': 'ssmtp'
}
udp_service_commands = {
'ntp': 'ntp_time',
'snmp': 'snmp-uptime'
}
hosts = {}
def process_host(host_element):
global hosts
status = "down"
for status_element in host_element.getElementsByTagName("status"):
status = status_element.getAttribute("state")
if status != "up":
return
for address_element in host_element.getElementsByTagName("address"):
if not address_element.getAttribute("addrtype") in [ "ipv4", "ipv6" ]:
continue
address = address_element.getAttribute("addr")
break
name = address
for hostname_element in host_element.getElementsByTagName("hostname"):
name = hostname_element.getAttribute("name")
try:
services = hosts[name]["services"]
except:
services = {}
for port_element in host_element.getElementsByTagName("port"):
state = "closed"
for state_element in port_element.getElementsByTagName("state"):
state = state_element.getAttribute("state")
if state != "open":
continue
port = int(port_element.getAttribute("portid"))
protocol = port_element.getAttribute("protocol")
try:
serv = socket.getservbyport(port, protocol)
except:
serv = str(port)
try:
if protocol == "tcp":
command = tcp_service_commands[serv]
elif protocol == "udp":
command = udp_service_commands[serv]
else:
raise "Unknown protocol."
except:
command = protocol
if command == "udp":
continue
services[serv] = { "command": command, "port": port }
hosts[name] = { "name": name, "address": address, "services": services }
def create_host(host):
global api_url, api_user, api_password
req = {
"templates": [ "discovered-host" ],
"attrs": {
"address": host["address"]
}
}
headers = {"Accept": "application/json"}
url = urlparse.urljoin(api_url, "v1/objects/hosts/%s" % (host["name"]))
requests.put(url, headers=headers, auth=(api_user, api_password), data=json.dumps(req), verify=False)
for serv, service in host["services"].iteritems():
req = {
"templates": [ "discovered-service" ],
"attrs": {
"vars.%s_port" % (service["command"]): service["port"],
"check_command": service["command"],
}
}
headers = {"Accept": "application/json"}
url = urlparse.urljoin(api_url, "v1/objects/services/%s!%s" % (host["name"], serv))
requests.put(url, headers=headers, auth=(api_user, api_password), data=json.dumps(req), verify=False)
for arg in sys.argv[1:]:
# Expects XML output from 'nmap -oX'
dom = parse(arg)
for host in dom.getElementsByTagName("host"):
process_host(host)
for host in hosts.values():
create_host(host)

View File

@ -0,0 +1,132 @@
#!/usr/bin/env python
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
import sys
import subprocess
import socket
from xml.dom.minidom import parse
if len(sys.argv) < 2:
print "Syntax: %s <xml-file> [<xml-file> ...]" % (sys.argv[0])
sys.exit(1)
tcp_service_commands = {
'ssh': 'ssh',
'http': 'http_ip',
'https': 'https_ip',
'smtp': 'smtp',
'ssmtp': 'ssmtp'
}
udp_service_commands = {
'ntp': 'ntp_time',
'snmp': 'snmp-uptime'
}
hosts = {}
def process_host(host_element):
global hosts
status = "down"
for status_element in host_element.getElementsByTagName("status"):
status = status_element.getAttribute("state")
if status != "up":
return
for address_element in host_element.getElementsByTagName("address"):
if not address_element.getAttribute("addrtype") in [ "ipv4", "ipv6" ]:
continue
address = address_element.getAttribute("addr")
break
name = address
for hostname_element in host_element.getElementsByTagName("hostname"):
name = hostname_element.getAttribute("name")
try:
services = hosts[name]["services"]
except:
services = {}
for port_element in host_element.getElementsByTagName("port"):
state = "closed"
for state_element in port_element.getElementsByTagName("state"):
state = state_element.getAttribute("state")
if state != "open":
continue
port = int(port_element.getAttribute("portid"))
protocol = port_element.getAttribute("protocol")
try:
serv = socket.getservbyport(port, protocol)
except:
serv = str(port)
try:
if protocol == "tcp":
command = tcp_service_commands[serv]
elif protocol == "udp":
command = udp_service_commands[serv]
else:
raise "Unknown protocol."
except:
command = protocol
if command == "udp":
continue
services[serv] = { "command": command, "port": port }
hosts[name] = { "name": name, "address": address, "services": services }
def print_host(host):
print "object Host \"%s\" {" % (host["name"])
print "\timport \"discovered-host\","
print ""
print "\taddress = \"%s\"," % (host["address"])
print "}"
print ""
for serv, service in host["services"].iteritems():
print "object Service \"%s\" {" % (serv)
print "\timport \"discovered-service\","
print ""
print "\thost_name = \"%s\"" % (host["name"])
print "\tcheck_command = \"%s\"," % (service["command"])
print ""
print "\tvars.port = %s" % (service["port"])
print "}"
print ""
for arg in sys.argv[1:]:
# Expects XML output from 'nmap -oX'
dom = parse(arg)
for host in dom.getElementsByTagName("host"):
process_host(host)
for host in hosts.values():
print_host(host)

View File

@ -0,0 +1,3 @@
i2tcl.so: i2tcl.cpp i2tcl.hpp
swig -c++ -o i2tcl_wrap.cpp i2tcl.hpp
g++ -g -std=c++11 -I/usr/include/tcl8.5 -shared -fpic -Iicinga2/lib -Iicinga2/build -Iicinga2/build/lib -L/opt/icinga2/lib/icinga2 -lbase -lconfig -Wl,-rpath=/opt/icinga2/lib/icinga2 -o i2tcl.so i2tcl_wrap.cpp i2tcl.cpp

View File

@ -0,0 +1 @@
This is the source code for the 'i2eval' IRC bot that's on #icinga and #icinga-devel.

View File

@ -0,0 +1,176 @@
#include "i2tcl.hpp"
#include "config/configcompiler.hpp"
#include "config/configcompilercontext.hpp"
#include "base/function.hpp"
#include "base/json.hpp"
#include "base/application.hpp"
#include <boost/algorithm/string.hpp>
using namespace icinga;
static bool l_Init_Called;
static Tcl_Interp *l_Interp;
static Tcl_Encoding l_Encoding;
static std::map<String, String> l_Lines;
static int l_NextLine = 1;
static Value i2_call_tcl(const String& command, const String& mtype, const std::vector<Value>& args)
{
Tcl_Obj **objv = new Tcl_Obj *[args.size() + 1];
objv[0] = Tcl_NewStringObj(command.CStr(), -1);
Tcl_IncrRefCount(objv[0]);
for (size_t i = 0; i < args.size(); i++) {
Tcl_DString dsText;
String arg = static_cast<String>(args[i]);
Tcl_ExternalToUtfDString(l_Encoding, arg.CStr(), -1, &dsText);
objv[i + 1] = Tcl_NewStringObj(Tcl_DStringValue(&dsText), Tcl_DStringLength(&dsText));
Tcl_DStringFree(&dsText);
Tcl_IncrRefCount(objv[i + 1]);
}
int code = Tcl_EvalObjv(l_Interp, args.size() + 1, objv, TCL_EVAL_GLOBAL);
Tcl_Obj *result = Tcl_GetObjResult(l_Interp);
for (size_t i = 0; i < args.size() + 1; i++)
Tcl_DecrRefCount(objv[i]);
delete [] objv;
if (code == TCL_ERROR)
BOOST_THROW_EXCEPTION(std::runtime_error("An error occurred in the TCL script"));
Value vresult;
if (mtype == "list") {
Array::Ptr arr = new Array();
int len;
if (Tcl_ListObjLength(l_Interp, result, &len) != TCL_OK)
BOOST_THROW_EXCEPTION(std::invalid_argument("TCL proc returned something that is not a list"));
for (size_t i = 0; i < len; i++) {
Tcl_Obj *obj;
Tcl_ListObjIndex(l_Interp, result, i, &obj);
const char* strObj = Tcl_GetString(obj);
Tcl_DString dsObj;
arr->Add(Tcl_UtfToExternalDString(l_Encoding, strObj, -1, &dsObj));
Tcl_DStringFree(&dsObj);
}
vresult = arr;
} else if (mtype == "null") {
/* Nothing to do here */
} else if (mtype == "number") {
const char* strResult = Tcl_GetString(result);
vresult = Convert::ToDouble(strResult);
} else if (mtype == "bool") {
const char* strResult = Tcl_GetString(result);
vresult = Convert::ToBool(Convert::ToLong(strResult));
} else {
const char* strResult = Tcl_GetString(result);
Tcl_DString dsResult;
vresult = Tcl_UtfToExternalDString(l_Encoding, strResult, -1, &dsResult);
Tcl_DStringFree(&dsResult);
}
return vresult;
}
void i2_register_command(const char *icmd, const char *tcmd, const char *mtype, Tcl_Interp *interp)
{
Function::Ptr sf = new Function(icmd, boost::bind(i2_call_tcl, String(tcmd), String(mtype), _1));
ScriptGlobal::Set(icmd, sf);
}
void *i2_new_frame(Tcl_Interp *interp)
{
if (!l_Init_Called) {
l_Init_Called = true;
l_Encoding = Tcl_GetEncoding(l_Interp, "ISO8859-1");
Application::InitializeBase();
}
ScriptFrame *frame = new ScriptFrame();
frame->Self = ScriptGlobal::GetGlobals();
return frame;
}
void i2_free_frame(void *frame, Tcl_Interp *interp)
{
delete reinterpret_cast<ScriptFrame *>(frame);
}
char *i2_eval(void *uframe, const char *text, Tcl_Interp *interp)
{
std::ostringstream msgbuf;
Expression *expr;
ScriptFrame *frame = reinterpret_cast<ScriptFrame *>(uframe);
l_Interp = interp;
try {
String lineNum = Convert::ToString(l_NextLine);
l_NextLine++;
String fileName = "<" + lineNum + ">";
l_Lines[fileName] = text;
expr = ConfigCompiler::CompileText(fileName, text);
if (expr) {
Value result = expr->Evaluate(*frame);
if (!result.IsObject() || result.IsObjectType<Array>() || result.IsObjectType<Dictionary>())
msgbuf << JsonEncode(result);
else
msgbuf << result;
}
} catch (const ScriptError& ex) {
DebugInfo di = ex.GetDebugInfo();
if (di.FirstLine != 0) {
String text = l_Lines[di.Path];
std::vector<String> lines;
boost::algorithm::split(lines, text, boost::is_any_of("\n"));
for (int i = di.FirstLine; i <= di.LastLine; i++) {
int start, len;
if (i == di.FirstLine)
start = di.FirstColumn;
else
start = 0;
if (i == di.LastLine)
len = di.LastColumn - di.FirstColumn + 1;
else
len = lines[i].GetLength();
String pathInfo = di.Path;
if (i != 1)
pathInfo += "(" + Convert::ToString(i) + ")";
pathInfo += ": ";
msgbuf << pathInfo << lines[i - 1] << "\n";
msgbuf << String(pathInfo.GetLength(), ' ');
msgbuf << String(start, ' ') << String(len, '^') << "\n";
}
}
msgbuf << ex.what();
} catch (const std::exception& ex) {
msgbuf << "Error: " << DiagnosticInformation(ex);
}
delete expr;
std::string str = msgbuf.str();
return strdup(str.c_str());
}

View File

@ -0,0 +1,23 @@
#ifdef SWIG
%module i2tcl
%{
#include "i2tcl.hpp"
%}
%typemap(in,numinputs=0) Tcl_Interp *interp {
$1 = interp;
}
#endif /* SWIG */
#include <tcl.h>
#ifndef I2TCL_H
#define I2TCL_H
void i2_register_command(const char *icmd, const char *tcmd, const char *mtype, Tcl_Interp *interp);
void *i2_new_frame(Tcl_Interp *interp);
void i2_free_frame(void *frame, Tcl_Interp *interp);
char *i2_eval(void *frame, const char *text, Tcl_Interp *interp);
#endif /* I2TCL_H */

View File

@ -0,0 +1,109 @@
package require http
package require tls
http::register https 443 [list ::tls::socket -tls1 1]
load /home/gunnar/i2tcl.so i2tcl
bind pub - > i2tcl
bind pub - >u i2tcl_url
bind pub - ^ i2tcl
bind pub - ^u i2tcl_url
if {![info exists ::i2frame]} {
set ::i2frame [i2_new_frame]
}
set ::i2chan ""
set ::i2nick ""
i2_register_command irc i2_irc null
i2_register_command channels channels list
i2_register_command chanlist internalchanlist list
i2_register_command getnick getcurrentnick string
i2_register_command onchan onchan bool
i2_register_command topic topic string
i2_register_command topicnick topicnick string
i2_register_command topicstamp topicstamp number
i2_register_command chanmodes getchanmode string
i2_register_command isop isop bool
i2_register_command isvoice isvoice bool
i2_register_command ishop ishop bool
i2_register_command chanhost getchanhost string
i2_register_command chanbans chanbans list
i2_register_command getnick i2_getnick string
i2_register_command getchan i2_getchan string
i2_register_command "Internal.run_with_activation_context" i2_null null
i2_register_command exit i2_null null
proc i2_null {} {
}
proc i2_getnick {} {
global i2nick
return $i2nick
}
proc i2_getchan {} {
global i2chan
return $i2chan
}
proc i2_irc {message} {
global i2chan
if {[string first "\n" $message] != -1 || [string first "\r" $message] != -1} {
return
}
putserv "PRIVMSG $i2chan :$message"
}
proc i2tcl {nick host hand chan arg} {
global i2frame i2chan i2nick
set i2chan $chan
set i2nick $nick
set result [i2_eval $i2frame $arg]
if {$result == ""} { set result "<no error>" }
foreach sline [split $result \n] {
putserv "PRIVMSG $chan :( $arg ) = $sline"
}
}
proc i2tcl_url {nick host hand chan arg} {
global i2frame i2chan i2nick
set i2chan $chan
set i2nick $nick
if {[catch {set token [http::geturl $arg]} msg]} {
putserv "PRIVMSG $chan :HTTP request failed: $msg"
http::cleanup $token
return
}
if {[http::status $token] != "ok"} {
putserv "PRIVMSG $chan :HTTP request failed: [http::error $token]"
http::cleanup $token
return
}
set rpl [split [http::code $token] " "]
if {[lindex $rpl 1] != 200} {
putserv "PRIVMSG $chan :HTTP request failed: [join [lrange $rpl 1 end]]"
http::cleanup $token
return
}
set code [http::data $token]
http::cleanup $token
set result [i2_eval $i2frame $code]
if {$result == ""} { set result "<no error>" }
foreach sline [split $result \n] {
putserv "PRIVMSG $chan :( $arg ) = $sline"
}
}

View File

@ -0,0 +1,44 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
using System;
using System.Collections;
namespace Icinga
{
public enum ServiceState
{
ServiceOK,
ServiceWarning,
ServiceCritical,
ServiceUnknown
}
public class CheckResult
{
public ServiceState State;
public String Output;
public String PerformanceData;
}
public interface ICheckPlugin
{
CheckResult Check(Hashtable args);
}
}

View File

@ -0,0 +1,68 @@
#!/usr/bin/env python
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
import subprocess, json
inventory_json = subprocess.check_output(["icinga2", "agent", "list", "--batch"])
inventory = json.loads(inventory_json)
for agent, agent_info in inventory.items():
print "object Endpoint \"%s\" {" % (agent)
print " host = \"%s\"" % (agent)
print "}"
print ""
print "object Zone \"%s\" {" % (agent_info["zone"])
if "parent_zone" in agent_info:
print " parent = \"%s\"" % (agent_info["parent_zone"])
print " endpoints = [ \"%s\" ]" % (agent)
print "}"
print ""
print "object Host \"%s\" {" % (agent_info["zone"])
print " check_command = \"cluster-zone\""
print "}"
print ""
print "apply Dependency \"host-zone-%s\" to Host {" % (agent_info["zone"])
print " parent_host_name = \"%s\"" % (agent_info["zone"])
print " assign where host.zone == \"%s\"" % (agent_info["zone"])
print "}"
print ""
print "apply Dependency \"service-zone-%s\" to Service {" % (agent_info["zone"])
print " parent_host_name = \"%s\"" % (agent_info["zone"])
print " assign where service.zone == \"%s\"" % (agent_info["zone"])
print "}"
print ""
for host, services in agent_info["repository"].items():
if host != agent_info["zone"]:
print "object Host \"%s\" {" % (host)
print " check_command = \"dummy\""
print " zone = \"%s\"" % (agent_info["zone"])
print "}"
print ""
for service in services:
print "object Service \"%s\" {" % (service)
print " check_command = \"dummy\""
print " host_name = \"%s\"" % (host)
print " zone = \"%s\"" % (agent_info["zone"])
print "}"
print ""

2
vim/bundle/icinga2/doc/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
build
*.rst

View File

@ -0,0 +1,316 @@
# <a id="about-icinga2"></a> About Icinga 2
## <a id="what-is-icinga2"></a> What is Icinga 2?
Icinga 2 is an open source monitoring system which checks the availability of
your network resources, notifies users of outages, and generates performance
data for reporting.
Scalable and extensible, Icinga 2 can monitor large, complex environments across
multiple locations.
## <a id="licensing"></a> Licensing
Icinga 2 and the Icinga 2 documentation are licensed under the terms of the GNU
General Public License Version 2, you will find a copy of this license in the
LICENSE file included in the source package.
## <a id="support"></a> Support
Support for Icinga 2 is available in a number of ways. Please have a look at
the [support overview page](https://support.icinga.org).
## <a id="contribute"></a> Contribute
There are many ways to contribute to Icinga -- whether it be sending patches,
testing, reporting bugs, or reviewing and updating the documentation. Every
contribution is appreciated!
Please get in touch with the Icinga team at https://www.icinga.org/community/.
If you want to help update this documentation, please read
[this howto](https://wiki.icinga.org/display/community/Update+the+Icinga+2+documentation).
### <a id="development-info"></a> Icinga 2 Development
You can follow Icinga 2's development closely by checking
out these resources:
* [Development Bug Tracker](https://dev.icinga.org/projects/i2): [How to report a bug?](https://www.icinga.org/icinga/faq/)
* Git Repositories: [main mirror on icinga.org](https://git.icinga.org/?p=icinga2.git;a=summary) [release mirror at github.com](https://github.com/Icinga/icinga2)
* [Git Checkins Mailinglist](https://lists.icinga.org/mailman/listinfo/icinga-checkins)
* [Development](https://lists.icinga.org/mailman/listinfo/icinga-devel) and [Users](https://lists.icinga.org/mailman/listinfo/icinga-users) Mailinglists
* [#icinga-devel on irc.freenode.net](http://webchat.freenode.net/?channels=icinga-devel) including a Git Commit Bot
For general support questions, please refer to the [community support channels](https://support.icinga.org).
### <a id="how-to-report-bug-feature-requests"></a> How to Report a Bug or Feature Request
More details in the [Icinga FAQ](https://www.icinga.org/icinga/faq/).
* [Register](https://accounts.icinga.org/register) an Icinga account.
* Create a new issue at the [Icinga 2 Development Tracker](https://dev.icinga.org/projects/i2).
* When reporting a bug, please include the details described in the [Troubleshooting](15-troubleshooting.md#troubleshooting-information-required) chapter (version, configs, logs, etc.).
## <a id="whats-new"></a> What's New
### What's New in Version 2.5.4
#### Bugfixes
* Bug [11932](https://dev.icinga.org/issues/11932 "Bug 11932") (Checker): many check commands executed at same time when master reload
### What's New in Version 2.5.3
#### Changes
This release addresses an issue with PostgreSQL support for the IDO database module.
#### Bugfixes
* Bug [12533](https://dev.icinga.org/issues/12533 "Bug 12533") (DB IDO): ido pgsql migration from 2.4.0 to 2.5.0 : wrong size for config_hash
### What's New in Version 2.5.2
#### Bugfixes
* Bug [12527](https://dev.icinga.org/issues/12527 "Bug 12527") (DB IDO): Newly added group member tables in the IDO database are not updated
* Bug [12529](https://dev.icinga.org/issues/12529 "Bug 12529") (Checker): Icinga 2 sends SOFT recovery notifications
### What's New in Version 2.5.1
#### Bugfixes
* Bug [12517](https://dev.icinga.org/issues/12517 "Bug 12517") (Notifications): Icinga 2 sends recovery notifications for SOFT NOT-OK states
### What's New in Version 2.5.0
#### Changes
* InfluxdbWriter feature
* API
* New endpoints: /v1/variables and /v1/templates (GET requests), /v1/action/generate-ticket (POST request)
* State/type filters for notifications/users are now string values (PUT, POST, GET requests)
* Configuration
* TimePeriod excludes/includes attributes
* DateTime object for formatting time strings
* New prototype methods: Array#filter, Array#unique, Array#map, Array#reduce
* icinga2.conf now includes plugins-contrib, manubulon, windows-plugins, nscp by default (ITL CheckCommand definitions)
* Performance improvements (config compiler and validation)
* CLI
* 'icinga2 object list' formats state/type filters as string values
* Compiled config files are now visible with "notice" debug level (hidden by default)
* CA serial file now uses a hash value (HA cluster w/ 2 CA directories)
* Cluster
* There is a known issue with >2 endpoints inside a zone. Icinga 2 will now log a warning.
* Support for accepted ciphers and minimum TLS version
* Connection and error logging has been improved.
* DB IDO
* Schema upgrade required (2.5.0.sql)
* Incremental config dump (performance boost)
* `categories` attribute is now an array. Previous method is deprecated and to be removed.
* DbCatLog is not enabled by default anymore.
* SSL support for MySQL
* New packages
* vim-icinga2 for syntax highlighting
* libicinga2 (Debian), icinga2-libs (RPM) for Icinga Studio packages
#### Feature
* Feature [7355](https://dev.icinga.org/issues/7355 "Feature 7355") (libicinga): Exclude option for TimePeriod definitions
* Feature [8401](https://dev.icinga.org/issues/8401 "Feature 8401") (Packages): Package for syntax highlighting
* Feature [9184](https://dev.icinga.org/issues/9184 "Feature 9184") (Perfdata): Add timestamp support for GelfWriter
* Feature [9264](https://dev.icinga.org/issues/9264 "Feature 9264") (ITL): Extend CheckCommand definitions for nscp-local
* Feature [9725](https://dev.icinga.org/issues/9725 "Feature 9725") (DB IDO): Add SSL support for the IdoMysqlConnection feature
* Feature [9839](https://dev.icinga.org/issues/9839 "Feature 9839") (Configuration): Implement support for formatting date/time
* Feature [9858](https://dev.icinga.org/issues/9858 "Feature 9858") (Perfdata): Gelf module: expose 'perfdata' fields for 'CHECK_RESULT' events
* Feature [10140](https://dev.icinga.org/issues/10140 "Feature 10140") (libicinga): Remove the deprecated IcingaStatusWriter feature
* Feature [10480](https://dev.icinga.org/issues/10480 "Feature 10480") (Perfdata): Add InfluxDbWriter feature
* Feature [10553](https://dev.icinga.org/issues/10553 "Feature 10553") (Documentation): Update SELinux documentation
* Feature [10669](https://dev.icinga.org/issues/10669 "Feature 10669") (ITL): Add IPv4/IPv6 support to the rest of the monitoring-plugins
* Feature [10722](https://dev.icinga.org/issues/10722 "Feature 10722") (ITL): icinga2.conf: Include plugins-contrib, manubulon, windows-plugins, nscp by default
* Feature [10816](https://dev.icinga.org/issues/10816 "Feature 10816") (libbase): Add name attribute for WorkQueue class
* Feature [10952](https://dev.icinga.org/issues/10952 "Feature 10952") (Packages): Provide packages for icinga-studio on Fedora
* Feature [11063](https://dev.icinga.org/issues/11063 "Feature 11063") (API): Implement SSL cipher configuration support for the API feature
* Feature [11290](https://dev.icinga.org/issues/11290 "Feature 11290") (API): ApiListener: Force server's preferred cipher
* Feature [11292](https://dev.icinga.org/issues/11292 "Feature 11292") (API): ApiListener: Make minimum TLS version configurable
* Feature [11359](https://dev.icinga.org/issues/11359 "Feature 11359") (ITL): Add "retries" option to check_snmp command
* Feature [11419](https://dev.icinga.org/issues/11419 "Feature 11419") (Configuration): Config parser should not log names of included files by default
* Feature [11423](https://dev.icinga.org/issues/11423 "Feature 11423") (libicinga): Cleanup downtimes created by ScheduleDowntime
* Feature [11445](https://dev.icinga.org/issues/11445 "Feature 11445") (Configuration): Allow strings in state/type filters
* Feature [11599](https://dev.icinga.org/issues/11599 "Feature 11599") (Documentation): Documentation review
* Feature [11612](https://dev.icinga.org/issues/11612 "Feature 11612") (Configuration): Improve performance for field accesses
* Feature [11623](https://dev.icinga.org/issues/11623 "Feature 11623") (Installation): Add script for automatically cherry-picking commits for minor versions
* Feature [11659](https://dev.icinga.org/issues/11659 "Feature 11659") (Configuration): Remove the (unused) 'inherits' keyword
* Feature [11706](https://dev.icinga.org/issues/11706 "Feature 11706") (API): Improve logging for HTTP API requests
* Feature [11739](https://dev.icinga.org/issues/11739 "Feature 11739") (Packages): Windows Installer: Remove dependency on KB2999226 package
* Feature [11772](https://dev.icinga.org/issues/11772 "Feature 11772") (Cluster): Add lag threshold for cluster-zone check
* Feature [11837](https://dev.icinga.org/issues/11837 "Feature 11837") (Documentation): Use HTTPS for debmon.org links in the documentation
* Feature [11869](https://dev.icinga.org/issues/11869 "Feature 11869") (ITL): Add CIM port parameter for esxi_hardware CheckCommand
* Feature [11875](https://dev.icinga.org/issues/11875 "Feature 11875") (Tests): Add debugging mode for Utility::GetTime
* Feature [11931](https://dev.icinga.org/issues/11931 "Feature 11931") (ITL): Adding option to access ifName for manubulon snmp-interface check command
* Feature [11941](https://dev.icinga.org/issues/11941 "Feature 11941") (API): Support for enumerating available templates via the API
* Feature [11955](https://dev.icinga.org/issues/11955 "Feature 11955") (API): Implement support for getting a list of global variables from the API
* Feature [11967](https://dev.icinga.org/issues/11967 "Feature 11967") (DB IDO): Update DB IDO schema version to 1.14.1
* Feature [11968](https://dev.icinga.org/issues/11968 "Feature 11968") (DB IDO): Enhance IDO check with schema version info
* Feature [11970](https://dev.icinga.org/issues/11970 "Feature 11970") (ITL): add check command for plugin check_apache_status
* Feature [12006](https://dev.icinga.org/issues/12006 "Feature 12006") (ITL): Add check command definitions for kdc and rbl
* Feature [12018](https://dev.icinga.org/issues/12018 "Feature 12018") (Graphite): Add acknowledgement type to Graphite, InfluxDB, OpenTSDB metadata
* Feature [12024](https://dev.icinga.org/issues/12024 "Feature 12024") (DB IDO): Change Ido*Connection 'categories' attribute to an array
* Feature [12041](https://dev.icinga.org/issues/12041 "Feature 12041") (API): API: Add missing downtime_depth attribute
* Feature [12061](https://dev.icinga.org/issues/12061 "Feature 12061") (ITL): Add check command definition for db2_health
* Feature [12106](https://dev.icinga.org/issues/12106 "Feature 12106") (DB IDO): Do not populate logentries table by default
* Feature [12116](https://dev.icinga.org/issues/12116 "Feature 12116") (Cluster): Enhance client disconnect message for "No data received on new API connection."
* Feature [12189](https://dev.icinga.org/issues/12189 "Feature 12189") (ITL): Add support for "-A" command line switch to CheckCommand "snmp-process"
* Feature [12194](https://dev.icinga.org/issues/12194 "Feature 12194") (Cluster): Improve log message for connecting nodes without configured Endpoint object
* Feature [12201](https://dev.icinga.org/issues/12201 "Feature 12201") (Cluster): Improve error messages for failed certificate validation
* Feature [12215](https://dev.icinga.org/issues/12215 "Feature 12215") (Cluster): Include IP address and port in the "New connection" log message
* Feature [12221](https://dev.icinga.org/issues/12221 "Feature 12221") (ITL): A lot of missing parameters for (latest) mysql_health
* Feature [12222](https://dev.icinga.org/issues/12222 "Feature 12222") (Cluster): Log a warning if there are more than 2 zone endpoint members
* Feature [12234](https://dev.icinga.org/issues/12234 "Feature 12234") (CLI): Add history for icinga2 console
* Feature [12247](https://dev.icinga.org/issues/12247 "Feature 12247") (Configuration): Add map/reduce and filter functionality for the Array class
* Feature [12254](https://dev.icinga.org/issues/12254 "Feature 12254") (API): Remove obsolete debug log message
* Feature [12256](https://dev.icinga.org/issues/12256 "Feature 12256") (ITL): Add check command definition for check_graphite
* Feature [12287](https://dev.icinga.org/issues/12287 "Feature 12287") (Cluster): Enhance TLS handshake error messages with connection information
* Feature [12304](https://dev.icinga.org/issues/12304 "Feature 12304") (Notifications): Add the notification type into the log message
* Feature [12314](https://dev.icinga.org/issues/12314 "Feature 12314") (ITL): Add command definition for check_mysql_query
* Feature [12327](https://dev.icinga.org/issues/12327 "Feature 12327") (API): Support for determining the Icinga 2 version via the API
* Feature [12329](https://dev.icinga.org/issues/12329 "Feature 12329") (libicinga): Implement process_check_result script method for the Checkable class
* Feature [12336](https://dev.icinga.org/issues/12336 "Feature 12336") (libbase): Improve logging for the WorkQueue class
* Feature [12338](https://dev.icinga.org/issues/12338 "Feature 12338") (Configuration): Move internal script functions into the 'Internal' namespace
* Feature [12386](https://dev.icinga.org/issues/12386 "Feature 12386") (Documentation): Rewrite Client and Cluster chapter and; add service monitoring chapter
* Feature [12389](https://dev.icinga.org/issues/12389 "Feature 12389") (libbase): Include compiler name/version and build host name in --version
* Feature [12392](https://dev.icinga.org/issues/12392 "Feature 12392") (ITL): Add custom variables for all check_swap arguments
* Feature [12393](https://dev.icinga.org/issues/12393 "Feature 12393") (libbase): Implement support for marking functions as deprecated
* Feature [12407](https://dev.icinga.org/issues/12407 "Feature 12407") (CLI): Implement support for inspecting variables with LLDB/GDB
* Feature [12408](https://dev.icinga.org/issues/12408 "Feature 12408") (Configuration): Implement support for namespaces
* Feature [12412](https://dev.icinga.org/issues/12412 "Feature 12412") (Documentation): Add URL and short description for Monitoring Plugins inside the ITL documentation
* Feature [12424](https://dev.icinga.org/issues/12424 "Feature 12424") (ITL): Add perfsyntax parameter to nscp-local-counter CheckCommand
* Feature [12426](https://dev.icinga.org/issues/12426 "Feature 12426") (Configuration): Implement comparison operators for the Array class
* Feature [12433](https://dev.icinga.org/issues/12433 "Feature 12433") (API): Add API action for generating a PKI ticket
* Feature [12434](https://dev.icinga.org/issues/12434 "Feature 12434") (DB IDO): Remove unused code from the IDO classes
* Feature [12435](https://dev.icinga.org/issues/12435 "Feature 12435") (DB IDO): Incremental updates for the IDO database
* Feature [12448](https://dev.icinga.org/issues/12448 "Feature 12448") (libbase): Improve performance for type lookups
* Feature [12450](https://dev.icinga.org/issues/12450 "Feature 12450") (Cluster): Improve performance for Endpoint config validation
* Feature [12457](https://dev.icinga.org/issues/12457 "Feature 12457") (libbase): Remove unnecessary Dictionary::Contains calls
* Feature [12468](https://dev.icinga.org/issues/12468 "Feature 12468") (ITL): Add interfacetable CheckCommand options --trafficwithpkt and --snmp-maxmsgsize
* Feature [12477](https://dev.icinga.org/issues/12477 "Feature 12477") (Documentation): Development docs: Add own section for gdb backtrace from a running process
* Feature [12481](https://dev.icinga.org/issues/12481 "Feature 12481") (libbase): Remove some unused #includes
#### Bugfixes
* Bug [7354](https://dev.icinga.org/issues/7354 "Bug 7354") (libicinga): Disable immediate hard state after first checkresult
* Bug [9242](https://dev.icinga.org/issues/9242 "Bug 9242") (Cluster): Custom notification external commands do not work in a master-master setup
* Bug [9848](https://dev.icinga.org/issues/9848 "Bug 9848") (libbase): Function::Invoke should optionally register ScriptFrame
* Bug [10061](https://dev.icinga.org/issues/10061 "Bug 10061") (DB IDO): IDO: icinga_host/service_groups alias columns are TEXT columns
* Bug [10066](https://dev.icinga.org/issues/10066 "Bug 10066") (DB IDO): Missing indexes for icinga_endpoints* and icinga_zones* tables in DB IDO schema
* Bug [10069](https://dev.icinga.org/issues/10069 "Bug 10069") (DB IDO): IDO: check_source should not be a TEXT field
* Bug [10070](https://dev.icinga.org/issues/10070 "Bug 10070") (DB IDO): IDO: there is no usable object index on icinga_{scheduleddowntime,comments}
* Bug [10075](https://dev.icinga.org/issues/10075 "Bug 10075") (libbase): Race condition in CreatePipeOverlapped
* Bug [10363](https://dev.icinga.org/issues/10363 "Bug 10363") (Notifications): Notification times w/ empty begin/end specifications prevent sending notifications
* Bug [10570](https://dev.icinga.org/issues/10570 "Bug 10570") (API): /v1 returns HTML even if JSON is requested
* Bug [10903](https://dev.icinga.org/issues/10903 "Bug 10903") (Perfdata): GELF multi-line output
* Bug [10937](https://dev.icinga.org/issues/10937 "Bug 10937") (Configuration): High CPU usage with self-referenced parent zone config
* Bug [11182](https://dev.icinga.org/issues/11182 "Bug 11182") (DB IDO): IDO: entry_time of all comments is set to the date and time when Icinga 2 was restarted
* Bug [11196](https://dev.icinga.org/issues/11196 "Bug 11196") (Cluster): High load when pinning command endpoint on HA cluster
* Bug [11483](https://dev.icinga.org/issues/11483 "Bug 11483") (libicinga): Numbers are not properly formatted in runtime macro strings
* Bug [11562](https://dev.icinga.org/issues/11562 "Bug 11562") (Notifications): last_problem_notification should be synced in HA cluster
* Bug [11590](https://dev.icinga.org/issues/11590 "Bug 11590") (Notifications): notification interval = 0 not honoured in HA clusters
* Bug [11622](https://dev.icinga.org/issues/11622 "Bug 11622") (Configuration): Don't allow flow control keywords outside of other flow control constructs
* Bug [11648](https://dev.icinga.org/issues/11648 "Bug 11648") (Packages): Reload permission error with SELinux
* Bug [11650](https://dev.icinga.org/issues/11650 "Bug 11650") (Packages): RPM update starts disabled icinga2 service
* Bug [11688](https://dev.icinga.org/issues/11688 "Bug 11688") (DB IDO): Outdated downtime/comments not removed from IDO database (restart)
* Bug [11730](https://dev.icinga.org/issues/11730 "Bug 11730") (libicinga): Icinga 2 client gets killed during network scans
* Bug [11782](https://dev.icinga.org/issues/11782 "Bug 11782") (Packages): Incorrect filter in pick.py
* Bug [11793](https://dev.icinga.org/issues/11793 "Bug 11793") (Documentation): node setup: Add a note for --endpoint syntax for client-master connection
* Bug [11817](https://dev.icinga.org/issues/11817 "Bug 11817") (Installation): Windows: Error with repository handler (missing /var/lib/icinga2/api/repository path)
* Bug [11823](https://dev.icinga.org/issues/11823 "Bug 11823") (DB IDO): Volatile check results for OK->OK transitions are logged into DB IDO statehistory
* Bug [11825](https://dev.icinga.org/issues/11825 "Bug 11825") (libicinga): Problems with check scheduling for HARD state changes (standalone/command_endpoint)
* Bug [11832](https://dev.icinga.org/issues/11832 "Bug 11832") (Tests): Boost tests are missing a dependency on libmethods
* Bug [11847](https://dev.icinga.org/issues/11847 "Bug 11847") (Documentation): Missing quotes for API action URL
* Bug [11851](https://dev.icinga.org/issues/11851 "Bug 11851") (Notifications): Downtime notifications do not pass author and comment
* Bug [11862](https://dev.icinga.org/issues/11862 "Bug 11862") (libicinga): SOFT OK-state after returning from a soft state
* Bug [11887](https://dev.icinga.org/issues/11887 "Bug 11887") (ITL): Add "fuse.gvfsd-fuse" to the list of excluded file systems for check_disk
* Bug [11890](https://dev.icinga.org/issues/11890 "Bug 11890") (Configuration): Config validation should not delete comments/downtimes w/o reference
* Bug [11894](https://dev.icinga.org/issues/11894 "Bug 11894") (Configuration): Incorrect custom variable name in the hosts.conf example config
* Bug [11898](https://dev.icinga.org/issues/11898 "Bug 11898") (libicinga): last SOFT state should be hard (max_check_attempts)
* Bug [11899](https://dev.icinga.org/issues/11899 "Bug 11899") (libicinga): Flapping Notifications dependent on state change
* Bug [11903](https://dev.icinga.org/issues/11903 "Bug 11903") (Documentation): Fix systemd client command formatting
* Bug [11905](https://dev.icinga.org/issues/11905 "Bug 11905") (Documentation): Improve "Endpoint" documentation
* Bug [11926](https://dev.icinga.org/issues/11926 "Bug 11926") (API): Trying to delete an object protected by a permissions filter, ends up deleting all objects that match the filter instead
* Bug [11933](https://dev.icinga.org/issues/11933 "Bug 11933") (DB IDO): SOFT state changes with the same state are not logged
* Bug [11962](https://dev.icinga.org/issues/11962 "Bug 11962") (DB IDO): Overflow in current_notification_number column in DB IDO MySQL
* Bug [11991](https://dev.icinga.org/issues/11991 "Bug 11991") (Documentation): Incorrect URL for API examples in the documentation
* Bug [11993](https://dev.icinga.org/issues/11993 "Bug 11993") (DB IDO): Comment/Downtime delete queries are slow
* Bug [12003](https://dev.icinga.org/issues/12003 "Bug 12003") (libbase): Hang in TlsStream::Handshake
* Bug [12008](https://dev.icinga.org/issues/12008 "Bug 12008") (Documentation): Add a note about creating Zone/Endpoint objects with the API
* Bug [12016](https://dev.icinga.org/issues/12016 "Bug 12016") (Configuration): ConfigWriter::EmitScope incorrectly quotes dictionary keys
* Bug [12022](https://dev.icinga.org/issues/12022 "Bug 12022") (Configuration): Icinga crashes when using include_recursive in an object definition
* Bug [12029](https://dev.icinga.org/issues/12029 "Bug 12029") (Documentation): Migration docs still show unsupported CHANGE_*MODATTR external commands
* Bug [12044](https://dev.icinga.org/issues/12044 "Bug 12044") (Packages): Icinga fails to build with OpenSSL 1.1.0
* Bug [12046](https://dev.icinga.org/issues/12046 "Bug 12046") (Documentation): Typo in Manubulon CheckCommand documentation
* Bug [12067](https://dev.icinga.org/issues/12067 "Bug 12067") (Documentation): Documentation: Setting up Plugins section is broken
* Bug [12077](https://dev.icinga.org/issues/12077 "Bug 12077") (Documentation): Add a note to the docs that API POST updates to custom attributes/groups won't trigger re-evaluation
* Bug [12085](https://dev.icinga.org/issues/12085 "Bug 12085") (DB IDO): deadlock in ido reconnect
* Bug [12092](https://dev.icinga.org/issues/12092 "Bug 12092") (API): Icinga incorrectly disconnects all endpoints if one has a wrong certificate
* Bug [12098](https://dev.icinga.org/issues/12098 "Bug 12098") (Configuration): include_recursive should gracefully handle inaccessible files
* Bug [12099](https://dev.icinga.org/issues/12099 "Bug 12099") (Packages): Build fails with Visual Studio 2013
* Bug [12100](https://dev.icinga.org/issues/12100 "Bug 12100") (libbase): Ensure to clear the SSL error queue before calling SSL_{read,write,do_handshake}
* Bug [12107](https://dev.icinga.org/issues/12107 "Bug 12107") (DB IDO): Add missing index on state history for DB IDO cleanup
* Bug [12135](https://dev.icinga.org/issues/12135 "Bug 12135") (ITL): ITL: check_iftraffic64.pl default values, wrong postfix value in CheckCommand
* Bug [12144](https://dev.icinga.org/issues/12144 "Bug 12144") (Documentation): pkg-config is not listed as a build requirement in INSTALL.md
* Bug [12147](https://dev.icinga.org/issues/12147 "Bug 12147") (DB IDO): IDO module starts threads before daemonize
* Bug [12179](https://dev.icinga.org/issues/12179 "Bug 12179") (Cluster): Duplicate messages for command_endpoint w/ master and satellite
* Bug [12180](https://dev.icinga.org/issues/12180 "Bug 12180") (Cluster): CheckerComponent sometimes fails to schedule checks in time
* Bug [12193](https://dev.icinga.org/issues/12193 "Bug 12193") (Cluster): Increase cluster reconnect interval
* Bug [12199](https://dev.icinga.org/issues/12199 "Bug 12199") (API): Fix URL encoding for '&'
* Bug [12204](https://dev.icinga.org/issues/12204 "Bug 12204") (Documentation): Improve author information about check_yum
* Bug [12210](https://dev.icinga.org/issues/12210 "Bug 12210") (DB IDO): Do not clear {host,service,contact}group_members tables on restart
* Bug [12216](https://dev.icinga.org/issues/12216 "Bug 12216") (libicinga): icinga check reports "-1" for minimum latency and execution time and only uptime has a number but 0
* Bug [12217](https://dev.icinga.org/issues/12217 "Bug 12217") (Documentation): Incorrect documentation about apply rules in zones.d directories
* Bug [12219](https://dev.icinga.org/issues/12219 "Bug 12219") (Documentation): Missing explanation for three level clusters with CSR auto-signing
* Bug [12225](https://dev.icinga.org/issues/12225 "Bug 12225") (libicinga): Icinga stats min_execution_time and max_execution_time are invalid
* Bug [12227](https://dev.icinga.org/issues/12227 "Bug 12227") (Perfdata): Incorrect escaping / formatting of perfdata to InfluxDB
* Bug [12237](https://dev.icinga.org/issues/12237 "Bug 12237") (Installation): Increase default systemd timeout
* Bug [12257](https://dev.icinga.org/issues/12257 "Bug 12257") (Notifications): Notification interval mistimed
* Bug [12259](https://dev.icinga.org/issues/12259 "Bug 12259") (Documentation): Incorrect API permission name for /v1/status in the documentation
* Bug [12267](https://dev.icinga.org/issues/12267 "Bug 12267") (Notifications): Multiple notifications when master fails
* Bug [12274](https://dev.icinga.org/issues/12274 "Bug 12274") (ITL): -q option for check_ntp_time is wrong
* Bug [12288](https://dev.icinga.org/issues/12288 "Bug 12288") (DB IDO): Change the way outdated comments/downtimes are deleted on restart
* Bug [12293](https://dev.icinga.org/issues/12293 "Bug 12293") (Notifications): Missing notification for recovery during downtime
* Bug [12302](https://dev.icinga.org/issues/12302 "Bug 12302") (Cluster): Remove obsolete README files in tools/syntax
* Bug [12310](https://dev.icinga.org/issues/12310 "Bug 12310") (Notifications): Notification sent too fast when one master fails
* Bug [12318](https://dev.icinga.org/issues/12318 "Bug 12318") (Configuration): Icinga doesn't delete temporary icinga2.debug file when config validation fails
* Bug [12331](https://dev.icinga.org/issues/12331 "Bug 12331") (libbase): Fix building Icinga with -fvisibility=hidden
* Bug [12333](https://dev.icinga.org/issues/12333 "Bug 12333") (Notifications): Incorrect downtime notification events
* Bug [12334](https://dev.icinga.org/issues/12334 "Bug 12334") (libbase): Handle I/O errors while writing the Icinga state file more gracefully
* Bug [12390](https://dev.icinga.org/issues/12390 "Bug 12390") (libbase): Disallow casting "" to an Object
* Bug [12391](https://dev.icinga.org/issues/12391 "Bug 12391") (libbase): Don't violate POSIX by ensuring that the argument to usleep(3) is less than 1000000
* Bug [12395](https://dev.icinga.org/issues/12395 "Bug 12395") (libicinga): Flexible downtimes should be removed after trigger_time+duration
* Bug [12401](https://dev.icinga.org/issues/12401 "Bug 12401") (DB IDO): Fixed downtime start does not update actual_start_time
* Bug [12402](https://dev.icinga.org/issues/12402 "Bug 12402") (Notifications): Notification resent, even if interval = 0
* Bug [12404](https://dev.icinga.org/issues/12404 "Bug 12404") (Notifications): Add log message if notifications are forced (i.e. filters are not checked)
* Bug [12409](https://dev.icinga.org/issues/12409 "Bug 12409") (Configuration): 'use' keyword cannot be used with templates
* Bug [12416](https://dev.icinga.org/issues/12416 "Bug 12416") (Documentation): The description for the http_certificate attribute doesn't have the right default value
* Bug [12417](https://dev.icinga.org/issues/12417 "Bug 12417") (DB IDO): IDO does duplicate config updates
* Bug [12418](https://dev.icinga.org/issues/12418 "Bug 12418") (DB IDO): IDO marks objects as inactive on shutdown
* Bug [12422](https://dev.icinga.org/issues/12422 "Bug 12422") (CLI): pki sign-csr does not log where it is writing the certificate file
* Bug [12425](https://dev.icinga.org/issues/12425 "Bug 12425") (libicinga): CompatUtility::GetCheckableNotificationStateFilter is returning an incorrect value
* Bug [12428](https://dev.icinga.org/issues/12428 "Bug 12428") (DB IDO): Fix the "ido" check command for use with command_endpoint
* Bug [12430](https://dev.icinga.org/issues/12430 "Bug 12430") (DB IDO): ido CheckCommand returns returns "Could not connect to database server" when HA enabled
* Bug [12432](https://dev.icinga.org/issues/12432 "Bug 12432") (Cluster): Only allow sending command_endpoint checks to directly connected child zones
* Bug [12438](https://dev.icinga.org/issues/12438 "Bug 12438") (libbase): Replace GetType()->GetName() calls with GetReflectionType()->GetName()
* Bug [12442](https://dev.icinga.org/issues/12442 "Bug 12442") (Documentation): Missing documentation for "legacy-timeperiod" template
* Bug [12452](https://dev.icinga.org/issues/12452 "Bug 12452") (Installation): Remove unused functions from icinga-installer
* Bug [12453](https://dev.icinga.org/issues/12453 "Bug 12453") (libbase): Use hash-based serial numbers for new certificates
* Bug [12454](https://dev.icinga.org/issues/12454 "Bug 12454") (API): API: action schedule-downtime requires a duration also when fixed is true
* Bug [12458](https://dev.icinga.org/issues/12458 "Bug 12458") (DB IDO): Insert fails for the icinga_scheduleddowntime table due to duplicate key
* Bug [12459](https://dev.icinga.org/issues/12459 "Bug 12459") (DB IDO): Query for customvariablestatus incorrectly updates the host's/service's insert ID
* Bug [12460](https://dev.icinga.org/issues/12460 "Bug 12460") (Cluster): DB IDO started before daemonizing (no systemd)
* Bug [12461](https://dev.icinga.org/issues/12461 "Bug 12461") (DB IDO): IDO query fails due to key contraint violation for the icinga_customvariablestatus table
* Bug [12464](https://dev.icinga.org/issues/12464 "Bug 12464") (API): API: events for DowntimeTriggered does not provide needed information
* Bug [12473](https://dev.icinga.org/issues/12473 "Bug 12473") (Documentation): Docs: API example uses wrong attribute name
* Bug [12474](https://dev.icinga.org/issues/12474 "Bug 12474") (libmethods): ClrCheck is null on *nix
* Bug [12475](https://dev.icinga.org/issues/12475 "Bug 12475") (Cluster): Incorrect certificate validation error message
* Bug [12487](https://dev.icinga.org/issues/12487 "Bug 12487") (Configuration): Memory leak when using closures
* Bug [12488](https://dev.icinga.org/issues/12488 "Bug 12488") (Documentation): Typo in Notification object documentation

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,632 @@
# <a id="cli-commands"></a> Icinga 2 CLI Commands
Icinga 2 comes with a number of CLI commands which support bash autocompletion.
These CLI commands will allow you to use certain functionality
provided by and around the Icinga 2 daemon.
Each CLI command provides its own help and usage information, so please
make sure to always run them with the `--help` parameter.
Run `icinga2` without any arguments to get a list of all available global
options.
# icinga2
icinga2 - The Icinga 2 network monitoring daemon (version: v2.5.0)
Usage:
icinga2 <command> [<arguments>]
Supported commands:
* console (Icinga console)
* daemon (starts Icinga 2)
* feature disable (disables specified feature)
* feature enable (enables specified feature)
* feature list (lists all enabled features)
* node add (add node)
* node blacklist add (adds a new blacklist filter)
* node blacklist list (lists all blacklist filters)
* node blacklist remove (removes a blacklist filter)
* node list (lists all nodes)
* node remove (removes node)
* node set (set node attributes)
* node setup (set up node)
* node update-config (update node config)
* node whitelist add (adds a new whitelist filter)
* node whitelist list (lists all whitelist filters)
* node whitelist remove (removes a whitelist filter)
* node wizard (wizard for node setup)
* object list (lists all objects)
* pki new-ca (sets up a new CA)
* pki new-cert (creates a new CSR)
* pki request (requests a certificate)
* pki save-cert (saves another Icinga 2 instance's certificate)
* pki sign-csr (signs a CSR)
* pki ticket (generates a ticket)
* repository clear-changes (clear uncommitted repository changes)
* repository commit (commit repository changes)
* repository endpoint add (adds a new Endpoint object)
* repository endpoint list (lists all Endpoint objects)
* repository endpoint remove (removes a Endpoint object)
* repository host add (adds a new Host object)
* repository host list (lists all Host objects)
* repository host remove (removes a Host object)
* repository service add (adds a new Service object)
* repository service list (lists all Service objects)
* repository service remove (removes a Service object)
* repository zone add (adds a new Zone object)
* repository zone list (lists all Zone objects)
* repository zone remove (removes a Zone object)
* troubleshoot (collect information for troubleshooting)
* variable get (gets a variable)
* variable list (lists all variables)
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
--color use VT100 color codes even when stdout is not a
terminal
-D [ --define ] arg define a constant
-a [ --app ] arg application library name (default: icinga)
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
Command options:
Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
## <a id="cli-commands-autocompletion"></a> Icinga 2 CLI Bash Autocompletion
Bash Auto-Completion (pressing `<TAB>`) is provided only for the corresponding context.
While `--config` will suggest and auto-complete files and directories on disk,
`feature enable` will only suggest disabled features. `repository` will know
about object specific attributes, and so on. Try it yourself.
RPM and Debian packages install the bash completion files into
`/etc/bash_completion.d/icinga2`.
You will need to install the `bash-completion` package if not already installed.
RHEL/CentOS/Fedora:
# yum install bash-completion
SUSE:
# zypper install bash-completion
Debian/Ubuntu:
# apt-get install bash-completion
## <a id="cli-commands-global-options"></a> Icinga 2 CLI Global Options
### Application Type
By default the `icinga2` binary loads the `icinga` library. A different application type
can be specified with the `--app` command-line option.
### Libraries
Instead of loading libraries using the [`library` config directive](17-language-reference.md#library)
you can also use the `--library` command-line option.
### Constants
[Global constants](17-language-reference.md#constants) can be set using the `--define` command-line option.
### <a id="config-include-path"></a> Config Include Path
When including files you can specify that the include search path should be
checked. You can do this by putting your configuration file name in angle
brackets like this:
include <test.conf>
This would cause Icinga 2 to search its include path for the configuration file
`test.conf`. By default the installation path for the Icinga Template Library
is the only search directory.
Using the `--include` command-line option additional search directories can be
added.
## <a id="cli-command-console"></a> CLI command: Console
The CLI command `console` can be used to evaluate Icinga config expressions, e.g. to test
[functions](17-language-reference.md#functions).
$ icinga2 console
Icinga 2 (version: v2.4.0)
<1> => function test(name) {
<1> .. log("Hello " + name)
<1> .. }
null
<2> => test("World")
information/config: Hello World
null
<3> =>
On operating systems without the `libedit` library installed there is no
support for line-editing or a command history. However you can
use the `rlwrap` program if you require those features:
$ rlwrap icinga2 console
The `console` can be used to connect to a running Icinga 2 instance using
the [REST API](12-icinga2-api.md#icinga2-api). [API permissions](12-icinga2-api.md#icinga2-api-permissions)
are required for executing config expressions and auto-completion.
> **Note**
> The console does not currently support SSL certificate verification.
You can specify the API URL using the `--connect` parameter.
Although the password can be specified there process arguments on UNIX platforms are usually visible to other users (e.g. through `ps`). In order to securely specify the user credentials the console supports two environment variables:
Environment variable | Description
---------------------|-------------
ICINGA2_API_USERNAME | The API username.
ICINGA2_API_PASSWORD | The API password.
Here's an example:
$ ICINGA2_API_PASSWORD=icinga icinga2 console --connect 'https://root@localhost:5665/'
Icinga 2 (version: v2.4.0)
<1> =>
Once connected you can inspect variables and execute other expressions by entering them at the prompt:
<1> => var h = get_host("example.localdomain")
null
<2> => h.last_check_result
{
active = true
check_source = "example.localdomain"
command = [ "/usr/local/sbin/check_ping", "-H", "127.0.0.1", "-c", "5000,100%", "-w", "3000,80%" ]
execution_end = 1446653527.174983
execution_start = 1446653523.152673
exit_status = 0.000000
output = "PING OK - Packet loss = 0%, RTA = 0.11 ms"
performance_data = [ "rta=0.114000ms;3000.000000;5000.000000;0.000000", "pl=0%;80;100;0" ]
schedule_end = 1446653527.175133
schedule_start = 1446653583.150000
state = 0.000000
type = "CheckResult"
vars_after = {
attempt = 1.000000
reachable = true
state = 0.000000
state_type = 1.000000
}
vars_before = {
attempt = 1.000000
reachable = true
state = 0.000000
state_type = 1.000000
}
}
<3> =>
You can use the `--eval` parameter to evaluate a single expression in batch mode. Using the `--file` option you can specify a file which should be evaluated. The output format for batch mode is JSON.
The `--syntax-only` option can be used in combination with `--eval` or `--file` to check a script for syntax errors. In this mode the script is parsed to identify syntax errors but not evaluated.
Here's an example that retrieves the command that was used by Icinga to check the `example.localdomain` host:
$ ICINGA2_API_PASSWORD=icinga icinga2 console --connect 'https://root@localhost:5665/' --eval 'get_host("example.localdomain").last_check_result.command' | python -m json.tool
[
"/usr/local/sbin/check_ping",
"-H",
"127.0.0.1",
"-c",
"5000,100%",
"-w",
"3000,80%"
]
## <a id="cli-command-daemon"></a> CLI command: Daemon
The CLI command `daemon` provides the functionality to start/stop Icinga 2.
Furthermore it provides the [configuration validation](11-cli-commands.md#config-validation).
# icinga2 daemon --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.5.0)
Usage:
icinga2 daemon [<arguments>]
Starts Icinga 2.
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
--color use VT100 color codes even when stdout is not a
terminal
-D [ --define ] arg define a constant
-a [ --app ] arg application library name (default: icinga)
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
Command options:
-c [ --config ] arg parse a configuration file
-z [ --no-config ] start without a configuration file
-C [ --validate ] exit after validating the configuration
-e [ --errorlog ] arg log fatal errors to the specified log file (only works
in combination with --daemonize)
-d [ --daemonize ] detach from the controlling terminal
Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
### Config Files
Using the `--config` option you can specify one or more configuration files.
Config files are processed in the order they're specified on the command-line.
When no configuration file is specified and the `--no-config` is not used
Icinga 2 automatically falls back to using the configuration file
`SysconfDir + "/icinga2/icinga2.conf"` (where SysconfDir is usually `/etc`).
### Config Validation
The `--validate` option can be used to check if your configuration files
contain errors. If any errors are found, the exit status is 1, otherwise 0
is returned. More details in the [configuration validation](11-cli-commands.md#config-validation) chapter.
## <a id="cli-command-feature"></a> CLI command: Feature
The `feature enable` and `feature disable` commands can be used to enable and disable features:
# icinga2 feature disable <tab>
checker --color --define --help --include --library --log-level mainlog notification --version
# icinga2 feature enable <tab>
api command debuglog graphite icingastatus ido-pgsql --library --log-level statusdata --version
--color compatlog --define --help ido-mysql --include livestatus perfdata syslog
The `feature list` command shows which features are currently enabled:
# icinga2 feature list
Disabled features: agent command compatlog debuglog gelf graphite icingastatus notification perfdata statusdata syslog
Enabled features: api checker livestatus mainlog
## <a id="cli-command-node"></a> CLI command: Node
Provides the functionality to install and manage master and client
nodes in a [distributed monitoring](6-distributed-monitoring.md#distributed-monitoring) scenario.
# icinga2 node --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.5.0)
Usage:
icinga2 <command> [<arguments>]
Supported commands:
* node add (add node)
* node blacklist add (adds a new blacklist filter)
* node blacklist list (lists all blacklist filters)
* node blacklist remove (removes a blacklist filter)
* node list (lists all nodes)
* node remove (removes node)
* node set (set node attributes)
* node setup (set up node)
* node update-config (update node config)
* node whitelist add (adds a new whitelist filter)
* node whitelist list (lists all whitelist filters)
* node whitelist remove (removes a whitelist filter)
* node wizard (wizard for node setup)
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
--color use VT100 color codes even when stdout is not a
terminal
-D [ --define ] arg define a constant
-a [ --app ] arg application library name (default: icinga)
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
Command options:
Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
## <a id="cli-command-object"></a> CLI command: Object
The `object` CLI command can be used to list all configuration objects and their
attributes. The command also shows where each of the attributes was modified.
That way you can also identify which objects have been created from your [apply rules](17-language-reference.md#apply).
More information can be found in the [troubleshooting](15-troubleshooting.md#list-configuration-objects) section.
# icinga2 object --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.5.0)
Usage:
icinga2 <command> [<arguments>]
Supported commands:
* object list (lists all objects)
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
--color use VT100 color codes even when stdout is not a
terminal
-D [ --define ] arg define a constant
-a [ --app ] arg application library name (default: icinga)
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
Command options:
Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
## <a id="cli-command-pki"></a> CLI command: Pki
Provides the CLI commands to
* generate a new local CA
* generate a new CSR or self-signed certificate
* sign a CSR and return a certificate
* save a master certificate manually
* request a signed certificate from the master
* generate a new ticket for the client setup
This functionality is used by the [node setup/wizard](11-cli-commands.md#cli-command-pki) CLI commands too.
# icinga2 pki --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.5.0)
Usage:
icinga2 <command> [<arguments>]
Supported commands:
* pki new-ca (sets up a new CA)
* pki new-cert (creates a new CSR)
* pki request (requests a certificate)
* pki save-cert (saves another Icinga 2 instance's certificate)
* pki sign-csr (signs a CSR)
* pki ticket (generates a ticket)
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
--color use VT100 color codes even when stdout is not a
terminal
-D [ --define ] arg define a constant
-a [ --app ] arg application library name (default: icinga)
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
Command options:
Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
## <a id="cli-command-repository"></a> CLI command: Repository
This command is not supported anymore. Parts of its functionality
are used in the [node update-config](11-cli-commands.md#cli-command-node) cli command.
## <a id="cli-command-troubleshoot"></a> CLI command: Troubleshoot
Collects basic information like version, paths, log files and crash reports for troubleshooting purposes and prints them to a file or the console. See [troubleshooting](15-troubleshooting.md#troubleshooting-information-required).
Its output defaults to a file named `troubleshooting-[TIMESTAMP].log` so it won't overwrite older troubleshooting files.
> **Note**
> Keep in mind that this tool can not collect information from other icinga2 nodes, you will have to run it on
> each of one of you instances.
> This is only a tool to collect information to help others help you, it will not attempt to fix anything.
# icinga2 troubleshoot --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.2.0-551-g1d0f6ed)
Usage:
icinga2 troubleshoot [<arguments>]
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
--color use VT100 color codes even when stdout is not aterminal
-D [ --define ] arg define a constant
-a [ --app ] arg application library name (default: icinga)
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
Command options:
-c [ --console ] print to console instead of file
-o [ --output ] arg path to output file
--include-vars print variables to separate file
--inluce-objects print object to separate file
Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
## <a id="cli-command-variable"></a> CLI command: Variable
Lists all configured variables (constants) in a similar fasion like [object list](11-cli-commands.md#cli-command-object).
# icinga2 variable --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.5.0)
Usage:
icinga2 <command> [<arguments>]
Supported commands:
* variable get (gets a variable)
* variable list (lists all variables)
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
--color use VT100 color codes even when stdout is not a
terminal
-D [ --define ] arg define a constant
-a [ --app ] arg application library name (default: icinga)
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
Command options:
Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
## <a id="enable-features"></a> Enabling/Disabling Features
Icinga 2 provides configuration files for some commonly used features. These
are installed in the `/etc/icinga2/features-available` directory and can be
enabled and disabled using the `icinga2 feature enable` and `icinga2 feature disable`
[CLI commands](11-cli-commands.md#cli-command-feature), respectively.
The `icinga2 feature enable` CLI command creates symlinks in the
`/etc/icinga2/features-enabled` directory which is included by default
in the example configuration file.
You can view a list of enabled and disabled features:
# icinga2 feature list
Disabled features: api command compatlog debuglog graphite icingastatus ido-mysql ido-pgsql livestatus notification perfdata statusdata syslog
Enabled features: checker mainlog notification
Using the `icinga2 feature enable` command you can enable features:
# icinga2 feature enable graphite
Enabling feature graphite. Make sure to restart Icinga 2 for these changes to take effect.
You can disable features using the `icinga2 feature disable` command:
# icinga2 feature disable ido-mysql livestatus
Disabling feature ido-mysql. Make sure to restart Icinga 2 for these changes to take effect.
Disabling feature livestatus. Make sure to restart Icinga 2 for these changes to take effect.
The `icinga2 feature enable` and `icinga2 feature disable` commands do not
restart Icinga 2. You will need to restart Icinga 2 using the init script
after enabling or disabling features.
## <a id="config-validation"></a> Configuration Validation
Once you've edited the configuration files make sure to tell Icinga 2 to validate
the configuration changes. Icinga 2 will log any configuration error including
a hint on the file, the line number and the affected configuration line itself.
The following example creates an apply rule without any `assign` condition.
apply Service "5872-ping4" {
import "generic-service"
check_command = "ping4"
//assign where match("5872-*", host.name)
}
Validate the configuration with the init script option `checkconfig`:
# /etc/init.d/icinga2 checkconfig
> **Note**
>
> Using [systemd](2-getting-started.md#systemd-service) you need to manually validate the configuration using
> the CLI command below.
Or manually passing the `-C` argument:
# /usr/sbin/icinga2 daemon -c /etc/icinga2/icinga2.conf -C
[2014-05-22 17:07:25 +0200] critical/ConfigItem: Location:
/etc/icinga2/conf.d/tests/5872.conf(5): }
/etc/icinga2/conf.d/tests/5872.conf(6):
/etc/icinga2/conf.d/tests/5872.conf(7): apply Service "5872-ping4" {
^^^^^^^^^^^^^
/etc/icinga2/conf.d/tests/5872.conf(8): import "test-generic-service"
/etc/icinga2/conf.d/tests/5872.conf(9): check_command = "ping4"
Config error: 'apply' is missing 'assign'
[2014-05-22 17:07:25 +0200] critical/ConfigItem: 1 errors, 0 warnings.
Icinga 2 detected configuration errors.
> **Tip**
>
> Icinga 2 will automatically detect the default path for `icinga2.conf`
> in `SysconfDir + /icinga2/icinga2.conf` and you can safely omit this parameter.
>
> `# icinga2 daemon -C`
If you encounter errors during configuration validation, please make sure
to read the [troubleshooting](15-troubleshooting.md#troubleshooting) chapter.
You can also use the [CLI command](11-cli-commands.md#cli-command-object) `icinga2 object list`
after validation passes to analyze object attributes, inheritance or created
objects by apply rules.
Find more on troubleshooting with `object list` in [this chapter](15-troubleshooting.md#list-configuration-objects).
Example filtered by `Service` objects with the name `ping*`:
# icinga2 object list --type Service --name *ping*
Object 'icinga.org!ping4' of type 'Service':
* __name = 'icinga.org!ping4'
* check_command = 'ping4'
% = modified in '/etc/icinga2/conf.d/services.conf', lines 17:3-17:25
* check_interval = 60
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 28:3-28:21
* host_name = 'icinga.org'
% = modified in '/etc/icinga2/conf.d/services.conf', lines 14:1-14:21
* max_check_attempts = 3
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 27:3-27:24
* name = 'ping4'
% = modified in '/etc/icinga2/conf.d/services.conf', lines 14:1-14:21
* retry_interval = 30
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 29:3-29:22
* templates = [ 'ping4', 'generic-service' ]
% += modified in '/etc/icinga2/conf.d/services.conf', lines 14:1-14:21
% += modified in '/etc/icinga2/conf.d/templates.conf', lines 26:1-30:1
* type = 'Service'
* vars
% += modified in '/etc/icinga2/conf.d/services.conf', lines 18:3-18:19
* sla = '24x7'
% = modified in '/etc/icinga2/conf.d/services.conf', lines 18:3-18:19
## <a id="config-change-reload"></a> Reload on Configuration Changes
Everytime you have changed your configuration you should first tell Icinga 2
to [validate](11-cli-commands.md#config-validation). If there are no validation errors, you can
safely reload the Icinga 2 daemon.
# /etc/init.d/icinga2 reload
> **Note**
>
> The `reload` action will send the `SIGHUP` signal to the Icinga 2 daemon
> which will validate the configuration in a separate process and not stop
> the other events like check execution, notifications, etc.
>
> Details can be found [here](22-migrating-from-icinga-1x.md#differences-1x-2-real-reload).

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,195 @@
# <a id="addons"></a> Icinga 2 Addons
## <a id="addons-graphing"></a> Graphing
### <a id="addons-graphing-pnp"></a> PNP
[PNP](http://www.pnp4nagios.org) is a graphing addon.
[PNP](http://www.pnp4nagios.org) is an addon which adds a graphical representation of the performance data collected
by the monitoring plugins. The data is stored as rrd (round robin database) files.
Use your distribution's package manager to install the `pnp4nagios` package.
If you're planning to use it, configure it to use the
[bulk mode with npcd and npcdmod](http://docs.pnp4nagios.org/pnp-0.6/modes#bulk_mode_with_npcd_and_npcdmod)
in combination with Icinga 2's [PerfdataWriter](14-features.md#performance-data). NPCD collects the performance
data files which Icinga 2 generates.
Enable performance data writer in icinga 2
# icinga2 feature enable perfdata
Configure npcd to use the performance data created by Icinga 2:
vim /etc/pnp4nagios/npcd.cfg
Set `perfdata_spool_dir = /var/spool/icinga2/perfdata` and restart the `npcd` daemon.
There's also an Icinga Web 2 module for direct PNP graph integration
available at [Icinga Exchange](https://exchange.icinga.org/icinga/PNP).
More information on [action_url as attribute](13-addons.md#addons-graphing-pnp-action-url)
and [graph template names](13-addons.md#addons-graphing-pnp-custom-templates).
### <a id="addons-graphing-graphite"></a> Graphite
[Graphite](http://graphite.readthedocs.org/en/latest/) is a time-series database
storing collected metrics and making them available through restful apis
and web interfaces.
Graphite consists of 3 software components:
* carbon -- a Twisted daemon that listens for time-series data
* whisper -- a simple database library for storing time-series data (similar in design to RRD)
* graphite webapp -- a Django webapp that renders graphs on-demand using Cairo
Use the [GraphiteWriter](14-features.md#graphite-carbon-cache-writer) feature
for sending real-time metrics from Icinga 2 to Graphite.
# icinga2 feature enable graphite
There are Graphite addons available for collecting the performance data files too (e.g. `Graphios`).
A popular alternative frontend for Graphite is for example [Grafana](http://grafana.org).
### <a id="addons-graphing-influxdb"></a> InfluxDB
[InfluxDB](https://influxdb.com) is a time series, metrics, and analytics database.
Its written in Go and has no external dependencies.
Use the [InfluxdbWriter](14-features.md#influxdb-writer) feature
for sending real-time metrics from Icinga 2 to InfluxDB.
# icinga2 feature enable influxdb
A popular frontend for InfluxDB is for example [Grafana](http://grafana.org).
## <a id="addons-visualization"></a> Visualization
### <a id="addons-visualization-reporting"></a> Icinga Reporting
By enabling the [DB IDO](14-features.md#db-ido) feature you can use the
[Icinga Reporting package](https://wiki.icinga.org/display/howtos/Setting+up+Icinga+with+Reporting).
### <a id="addons-visualization-nagvis"></a> NagVis
By using either [Livestatus](14-features.md#setting-up-livestatus) or
[DB IDO](14-features.md#db-ido) as a backend you can create your own network maps
based on your monitoring configuration and status data using [NagVis](http://www.nagvis.org).
The configuration in nagvis.ini.php should look like this for Livestatus for example:
[backend_live_1]
backendtype="mklivestatus"
socket="unix:/var/run/icinga2/cmd/livestatus"
If you are planning an integration into Icinga Web 2, look at [this module](https://github.com/Icinga/icingaweb2-module-nagvis).
### <a id="addons-visualization-thruk"></a> Thruk
[Thruk](http://www.thruk.org) is an alternative web interface which can be used with Icinga 2
and the [Livestatus](14-features.md#setting-up-livestatus) feature.
## <a id="log-monitoring"></a> Log Monitoring
Using [Logstash](https://www.elastic.co/guide/en/logstash/current/introduction.html) or
[Graylog](https://www.graylog.org) in your infrastructure and correlate events with your monitoring
is even simpler these days.
* Use the `GelfWriter` feature to write Icinga 2's check and notification events to Graylog or Logstash.
* Configure the logstash `nagios` output to send passive traps to Icinga 2 using the external command pipe.
* Execute a plugin to check Graylog alert streams.
More details can be found in [this blog post](https://www.icinga.org/2014/12/02/team-icinga-at-osmc-2014/).
## <a id="notification-scripts-interfaces"></a> Notification Scripts and Interfaces
There's a variety of resources available, for example different notification scripts such as:
* E-Mail ([examples](3-monitoring-basics.md#notifications) provided)
* SMS
* Pager (XMPP, etc.)
* Twitter
* IRC
* Ticket systems
* etc.
Additionally external services can be [integrated with Icinga 2](https://www.icinga.org/icinga/integration/):
* [Pagerduty](https://www.icinga.org/partners/pagerduty/)
* [VictorOps](https://www.icinga.org/partners/victorops/)
* [StackStorm](https://www.icinga.org/partners/stackstorm/)
More information can be found on the [Icinga Website](https://www.icinga.org/)
and the [Icinga Wiki](https://wiki.icinga.org/display/howtos/Home).
## <a id="configuration-tools"></a> Configuration Management Tools
If you require your favourite configuration tool to export the Icinga 2 configuration, please get in
touch with their developers. The Icinga project does not provide a configuration web interface
yet. Follow the [Icinga Blog](https://www.icinga.org/blog/) for updates on this topic.
If you're looking for puppet manifests, chef cookbooks, ansible recipes, etc. -- we're happy
to integrate them upstream, so please get in touch with the [Icinga team](https://www.icinga.org/community/get-involved/).
These tools are currently in development and require feedback and tests:
* [Ansible Roles](https://github.com/Icinga/icinga2-ansible)
* [Puppet Module](https://github.com/Icinga/puppet-icinga2)
* [Chef Cookbook](https://github.com/Icinga/chef-icinga2)
## <a id="addon-integration-hints"></a> More Addon Integration Hints
### <a id="addons-graphing-pnp-action-url"></a> PNP Action Url
They work in a similar fashion for Icinga 2 and are used for 1.x web interfaces (Icinga Web 2 doesn't require
the action url attribute in its own module).
template Service "pnp-hst" {
action_url = "/pnp4nagios/graph?host=$HOSTNAME$"
}
template Service "pnp-svc" {
action_url = "/pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$"
}
### <a id="addons-graphing-pnp-custom-templates"></a> PNP Custom Templates with Icinga 2
PNP automatically determines the graph template from the check command name (or the argument's name).
This behavior changed in Icinga 2 compared to Icinga 1.x. Though there are certain possibilities to
fix this:
* Create a symlink for example from the `templates.dist/check_ping.php` template to the actual check name in Icinga 2 (`templates/ping4.php`)
* Pass the check command name inside the [format template configuration](14-features.md#writing-performance-data-files)
The latter becomes difficult with agent based checks like NRPE or SSH where the first command argument acts as
graph template identifier. There is the possibility to define the pnp template name as custom attribute
and use that inside the formatting templates as `SERVICECHECKCOMMAND` for instance.
Example for services:
# vim /etc/icinga2/features-enabled/perfdata.conf
service_format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.name$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.check_command$$pnp_check_arg1$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.state_type$"
# vim /etc/icinga2/conf.d/services.conf
template Service "pnp-svc" {
action_url = "/pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$"
vars.pnp_check_arg1 = ""
}
apply Service "nrpe-check" {
import "pnp-svc"
check_command = nrpe
vars.nrpe_command = "check_disk"
vars.pnp_check_arg1 = "!$nrpe_command$"
}
If there are warnings about unresolved macros, make sure to specify a default value for `vars.pnp_check_arg1` inside the
In PNP, the custom template for nrpe is then defined in `/etc/pnp4nagios/custom/nrpe.cfg`
and the additional command arg string will be seen in the xml too for other templates.

View File

@ -0,0 +1,697 @@
# <a id="icinga2-features"></a> Icinga 2 Features
## <a id="logging"></a> Logging
Icinga 2 supports three different types of logging:
* File logging
* Syslog (on *NIX-based operating systems)
* Console logging (`STDOUT` on tty)
You can enable additional loggers using the `icinga2 feature enable`
and `icinga2 feature disable` commands to configure loggers:
Feature | Description
---------|------------
debuglog | Debug log (path: `/var/log/icinga2/debug.log`, severity: `debug` or higher)
mainlog | Main log (path: `/var/log/icinga2/icinga2.log`, severity: `information` or higher)
syslog | Syslog (severity: `warning` or higher)
By default file the `mainlog` feature is enabled. When running Icinga 2
on a terminal log messages with severity `information` or higher are
written to the console.
## <a id="db-ido"></a> DB IDO
The IDO (Icinga Data Output) modules for Icinga 2 take care of exporting all
configuration and status information into a database. The IDO database is used
by a number of projects including Icinga Web 1.x and 2.
Details on the installation can be found in the [Configuring DB IDO](2-getting-started.md#configuring-db-ido-mysql)
chapter. Details on the configuration can be found in the
[IdoMysqlConnection](9-object-types.md#objecttype-idomysqlconnection) and
[IdoPgsqlConnection](9-object-types.md#objecttype-idopgsqlconnection)
object configuration documentation.
The DB IDO feature supports [High Availability](6-distributed-monitoring.md#distributed-monitoring-high-availability-db-ido) in
the Icinga 2 cluster.
The following example query checks the health of the current Icinga 2 instance
writing its current status to the DB IDO backend table `icinga_programstatus`
every 10 seconds. By default it checks 60 seconds into the past which is a reasonable
amount of time -- adjust it for your requirements. If the condition is not met,
the query returns an empty result.
> **Tip**
>
> Use [check plugins](5-service-monitoring.md#service-monitoring-plugins) to monitor the backend.
Replace the `default` string with your instance name if different.
Example for MySQL:
# mysql -u root -p icinga -e "SELECT status_update_time FROM icinga_programstatus ps
JOIN icinga_instances i ON ps.instance_id=i.instance_id
WHERE (UNIX_TIMESTAMP(ps.status_update_time) > UNIX_TIMESTAMP(NOW())-60)
AND i.instance_name='default';"
+---------------------+
| status_update_time |
+---------------------+
| 2014-05-29 14:29:56 |
+---------------------+
Example for PostgreSQL:
# export PGPASSWORD=icinga; psql -U icinga -d icinga -c "SELECT ps.status_update_time FROM icinga_programstatus AS ps
JOIN icinga_instances AS i ON ps.instance_id=i.instance_id
WHERE ((SELECT extract(epoch from status_update_time) FROM icinga_programstatus) > (SELECT extract(epoch from now())-60))
AND i.instance_name='default'";
status_update_time
------------------------
2014-05-29 15:11:38+02
(1 Zeile)
A detailed list on the available table attributes can be found in the [DB IDO Schema documentation](23-appendix.md#schema-db-ido).
## <a id="external-commands"></a> External Commands
Icinga 2 provides an external command pipe for processing commands
triggering specific actions (for example rescheduling a service check
through the web interface).
In order to enable the `ExternalCommandListener` configuration use the
following command and restart Icinga 2 afterwards:
# icinga2 feature enable command
Icinga 2 creates the command pipe file as `/var/run/icinga2/cmd/icinga2.cmd`
using the default configuration.
Web interfaces and other Icinga addons are able to send commands to
Icinga 2 through the external command pipe, for example for rescheduling
a forced service check:
# /bin/echo "[`date +%s`] SCHEDULE_FORCED_SVC_CHECK;localhost;ping4;`date +%s`" >> /var/run/icinga2/cmd/icinga2.cmd
# tail -f /var/log/messages
Oct 17 15:01:25 icinga-server icinga2: Executing external command: [1382014885] SCHEDULE_FORCED_SVC_CHECK;localhost;ping4;1382014885
Oct 17 15:01:25 icinga-server icinga2: Rescheduling next check for service 'ping4'
A list of currently supported external commands can be found [here](23-appendix.md#external-commands-list-detail).
Detailed information on the commands and their required parameters can be found
on the [Icinga 1.x documentation](http://docs.icinga.org/latest/en/extcommands2.html).
## <a id="performance-data"></a> Performance Data
When a host or service check is executed plugins should provide so-called
`performance data`. Next to that additional check performance data
can be fetched using Icinga 2 runtime macros such as the check latency
or the current service state (or additional custom attributes).
The performance data can be passed to external applications which aggregate and
store them in their backends. These tools usually generate graphs for historical
reporting and trending.
Well-known addons processing Icinga performance data are [PNP4Nagios](13-addons.md#addons-graphing-pnp),
[Graphite](13-addons.md#addons-graphing-graphite) or [OpenTSDB](14-features.md#opentsdb-writer).
### <a id="writing-performance-data-files"></a> Writing Performance Data Files
PNP4Nagios and Graphios use performance data collector daemons to fetch
the current performance files for their backend updates.
Therefore the Icinga 2 [PerfdataWriter](9-object-types.md#objecttype-perfdatawriter)
feature allows you to define the output template format for host and services helped
with Icinga 2 runtime vars.
host_format_template = "DATATYPE::HOSTPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tHOSTPERFDATA::$host.perfdata$\tHOSTCHECKCOMMAND::$host.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$"
service_format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.name$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.state_type$"
The default templates are already provided with the Icinga 2 feature configuration
which can be enabled using
# icinga2 feature enable perfdata
By default all performance data files are rotated in a 15 seconds interval into
the `/var/spool/icinga2/perfdata/` directory as `host-perfdata.<timestamp>` and
`service-perfdata.<timestamp>`.
External collectors need to parse the rotated performance data files and then
remove the processed files.
### <a id="graphite-carbon-cache-writer"></a> Graphite Carbon Cache Writer
While there are some [Graphite](13-addons.md#addons-graphing-graphite)
collector scripts and daemons like Graphios available for Icinga 1.x it's more
reasonable to directly process the check and plugin performance
in memory in Icinga 2. Once there are new metrics available, Icinga 2 will directly
write them to the defined Graphite Carbon daemon tcp socket.
You can enable the feature using
# icinga2 feature enable graphite
By default the [GraphiteWriter](9-object-types.md#objecttype-graphitewriter) feature
expects the Graphite Carbon Cache to listen at `127.0.0.1` on TCP port `2003`.
#### <a id="graphite-carbon-cache-writer-schema"></a> Current Graphite Schema
The current naming schema is defined as follows. The official Icinga Web 2 Graphite
module will use that schema too.
The default prefix for hosts and services is configured using
[runtime macros](3-monitoring-basics.md#runtime-macros)like this:
icinga2.$host.name$.host.$host.check_command$
icinga2.$host.name$.services.$service.name$.$service.check_command$
You can customize the prefix name by using the `host_name_template` and
`service_name_template` configuration attributes.
The additional levels will allow fine granular filters and also template
capabilities, e.g. by using the check command `disk` for specific
graph templates in web applications rendering the Graphite data.
The following characters are escaped in prefix labels:
Character | Escaped character
--------------|--------------------------
whitespace | _
. | _
\ | _
/ | _
Metric values are stored like this:
<prefix>.perfdata.<perfdata-label>.value
The following characters are escaped in perfdata labels:
Character | Escaped character
--------------|--------------------------
whitespace | _
\ | _
/ | _
:: | .
Note that perfdata labels may contain dots (`.`) allowing to
add more subsequent levels inside the Graphite tree.
`::` adds support for [multi performance labels](http://my-plugin.de/wiki/projects/check_multi/configuration/performance)
and is therefore replaced by `.`.
By enabling `enable_send_thresholds` Icinga 2 automatically adds the following threshold metrics:
<prefix>.perfdata.<perfdata-label>.min
<prefix>.perfdata.<perfdata-label>.max
<prefix>.perfdata.<perfdata-label>.warn
<prefix>.perfdata.<perfdata-label>.crit
By enabling `enable_send_metadata` Icinga 2 automatically adds the following metadata metrics:
<prefix>.metadata.current_attempt
<prefix>.metadata.downtime_depth
<prefix>.metadata.acknowledgement
<prefix>.metadata.execution_time
<prefix>.metadata.latency
<prefix>.metadata.max_check_attempts
<prefix>.metadata.reachable
<prefix>.metadata.state
<prefix>.metadata.state_type
Metadata metric overview:
metric | description
-------------------|------------------------------------------
current_attempt | current check attempt
max_check_attempts | maximum check attempts until the hard state is reached
reachable | checked object is reachable
downtime_depth | number of downtimes this object is in
acknowledgement | whether the object is acknowledged or not
execution_time | check execution time
latency | check latency
state | current state of the checked object
state_type | 0=SOFT, 1=HARD state
The following example illustrates how to configure the storage schemas for Graphite Carbon
Cache.
[icinga2_default]
# intervals like PNP4Nagios uses them per default
pattern = ^icinga2\.
retentions = 1m:2d,5m:10d,30m:90d,360m:4y
#### <a id="graphite-carbon-cache-writer-schema-legacy"></a> Graphite Schema < 2.4
In order to restore the old legacy schema, you'll need to adopt the `GraphiteWriter`
configuration:
object GraphiteWriter "graphite" {
enable_legacy_mode = true
host_name_template = "icinga.$host.name$"
service_name_template = "icinga.$host.name$.$service.name$"
}
The old legacy naming schema is
icinga.<hostname>.<metricname>
icinga.<hostname>.<servicename>.<metricname>
You can customize the metric prefix name by using the `host_name_template` and
`service_name_template` configuration attributes.
The example below uses [runtime macros](3-monitoring-basics.md#runtime-macros) and a
[global constant](17-language-reference.md#constants) named `GraphiteEnv`. The constant name
is freely definable and should be put in the [constants.conf](4-configuring-icinga-2.md#constants-conf) file.
const GraphiteEnv = "icinga.env1"
object GraphiteWriter "graphite" {
host_name_template = GraphiteEnv + ".$host.name$"
service_name_template = GraphiteEnv + ".$host.name$.$service.name$"
}
To make sure Icinga 2 writes a valid label into Graphite some characters are replaced
with `_` in the target name:
\/.- (and space)
The resulting name in Graphite might look like:
www-01 / http-cert / response time
icinga.www_01.http_cert.response_time
In addition to the performance data retrieved from the check plugin, Icinga 2 sends
internal check statistic data to Graphite:
metric | description
-------------------|------------------------------------------
current_attempt | current check attempt
max_check_attempts | maximum check attempts until the hard state is reached
reachable | checked object is reachable
downtime_depth | number of downtimes this object is in
acknowledgement | whether the object is acknowledged or not
execution_time | check execution time
latency | check latency
state | current state of the checked object
state_type | 0=SOFT, 1=HARD state
The following example illustrates how to configure the storage-schemas for Graphite Carbon
Cache. Please make sure that the order is correct because the first match wins.
[icinga_internals]
pattern = ^icinga\..*\.(max_check_attempts|reachable|current_attempt|execution_time|latency|state|state_type)
retentions = 5m:7d
[icinga_default]
# intervals like PNP4Nagios uses them per default
pattern = ^icinga\.
retentions = 1m:2d,5m:10d,30m:90d,360m:4y
### <a id="influxdb-writer"></a> InfluxDB Writer
Once there are new metrics available, Icinga 2 will directly write them to the
defined InfluxDB HTTP API.
You can enable the feature using
# icinga2 feature enable influxdb
By default the [InfluxdbWriter](9-object-types.md#objecttype-influxdbwriter) feature
expects the InfluxDB daemon to listen at `127.0.0.1` on port `8086`.
More configuration details can be found [here](9-object-types.md#objecttype-influxdbwriter).
### <a id="gelfwriter"></a> GELF Writer
The `Graylog Extended Log Format` (short: [GELF](http://www.graylog2.org/resources/gelf))
can be used to send application logs directly to a TCP socket.
While it has been specified by the [graylog2](http://www.graylog2.org/) project as their
[input resource standard](http://www.graylog2.org/resources/gelf), other tools such as
[Logstash](http://www.logstash.net) also support `GELF` as
[input type](http://logstash.net/docs/latest/inputs/gelf).
You can enable the feature using
# icinga2 feature enable gelf
By default the `GelfWriter` object expects the GELF receiver to listen at `127.0.0.1` on TCP port `12201`.
The default `source` attribute is set to `icinga2`. You can customize that for your needs if required.
Currently these events are processed:
* Check results
* State changes
* Notifications
### <a id="opentsdb-writer"></a> OpenTSDB Writer
While there are some OpenTSDB collector scripts and daemons like tcollector available for
Icinga 1.x it's more reasonable to directly process the check and plugin performance
in memory in Icinga 2. Once there are new metrics available, Icinga 2 will directly
write them to the defined TSDB TCP socket.
You can enable the feature using
# icinga2 feature enable opentsdb
By default the `OpenTsdbWriter` object expects the TSD to listen at
`127.0.0.1` on port `4242`.
The current naming schema is
icinga.host.<metricname>
icinga.service.<servicename>.<metricname>
for host and service checks. The tag host is always applied.
To make sure Icinga 2 writes a valid metric into OpenTSDB some characters are replaced
with `_` in the target name:
\ (and space)
The resulting name in OpenTSDB might look like:
www-01 / http-cert / response time
icinga.http_cert.response_time
In addition to the performance data retrieved from the check plugin, Icinga 2 sends
internal check statistic data to OpenTSDB:
metric | description
-------------------|------------------------------------------
current_attempt | current check attempt
max_check_attempts | maximum check attempts until the hard state is reached
reachable | checked object is reachable
downtime_depth | number of downtimes this object is in
acknowledgement | whether the object is acknowledged or not
execution_time | check execution time
latency | check latency
state | current state of the checked object
state_type | 0=SOFT, 1=HARD state
While reachable, state and state_type are metrics for the host or service the
other metrics follow the current naming schema
icinga.check.<metricname>
with the following tags
tag | description
--------|------------------------------------------
type | the check type, one of [host, service]
host | hostname, the check ran on
service | the service name (if type=service)
> **Note**
>
> You might want to set the tsd.core.auto_create_metrics setting to `true`
> in your opentsdb.conf configuration file.
## <a id="setting-up-livestatus"></a> Livestatus
The [MK Livestatus](http://mathias-kettner.de/checkmk_livestatus.html) project
implements a query protocol that lets users query their Icinga instance for
status information. It can also be used to send commands.
> **Tip**
>
> Only install the Livestatus feature if your web interface or addon requires
> you to do so (for example, [Icinga Web 2](2-getting-started.md#setting-up-icingaweb2)).
> Icinga Classic UI 1.x and Icinga Web 1.x do not use Livestatus as backend.
The Livestatus component that is distributed as part of Icinga 2 is a
re-implementation of the Livestatus protocol which is compatible with MK
Livestatus.
Details on the available tables and attributes with Icinga 2 can be found
in the [Livestatus Schema](23-appendix.md#schema-livestatus) section.
You can enable Livestatus using icinga2 feature enable:
# icinga2 feature enable livestatus
After that you will have to restart Icinga 2:
Debian/Ubuntu, RHEL/CentOS 6 and SUSE:
# service icinga2 restart
RHEL/CentOS 7 and Fedora:
# systemctl restart icinga2
By default the Livestatus socket is available in `/var/run/icinga2/cmd/livestatus`.
In order for queries and commands to work you will need to add your query user
(e.g. your web server) to the `icingacmd` group:
# usermod -a -G icingacmd www-data
The Debian packages use `nagios` as the user and group name. Make sure to change `icingacmd` to
`nagios` if you're using Debian.
Change `www-data` to the user you're using to run queries.
In order to use the historical tables provided by the livestatus feature (for example, the
`log` table) you need to have the `CompatLogger` feature enabled. By default these logs
are expected to be in `/var/log/icinga2/compat`. A different path can be set using the
`compat_log_path` configuration attribute.
# icinga2 feature enable compatlog
### <a id="livestatus-sockets"></a> Livestatus Sockets
Other to the Icinga 1.x Addon, Icinga 2 supports two socket types
* Unix socket (default)
* TCP socket
Details on the configuration can be found in the [LivestatusListener](9-object-types.md#objecttype-livestatuslistener)
object configuration.
### <a id="livestatus-get-queries"></a> Livestatus GET Queries
> **Note**
>
> All Livestatus queries require an additional empty line as query end identifier.
> The `nc` tool (`netcat`) provides the `-U` parameter to communicate using
> a unix socket.
There also is a Perl module available in CPAN for accessing the Livestatus socket
programmatically: [Monitoring::Livestatus](http://search.cpan.org/~nierlein/Monitoring-Livestatus-0.74/)
Example using the unix socket:
# echo -e "GET services\n" | /usr/bin/nc -U /var/run/icinga2/cmd/livestatus
Example using the tcp socket listening on port `6558`:
# echo -e 'GET services\n' | netcat 127.0.0.1 6558
# cat servicegroups <<EOF
GET servicegroups
EOF
(cat servicegroups; sleep 1) | netcat 127.0.0.1 6558
### <a id="livestatus-command-queries"></a> Livestatus COMMAND Queries
A list of available external commands and their parameters can be found [here](23-appendix.md#external-commands-list-detail)
$ echo -e 'COMMAND <externalcommandstring>' | netcat 127.0.0.1 6558
### <a id="livestatus-filters"></a> Livestatus Filters
and, or, negate
Operator | Negate | Description
----------|------------------------
= | != | Equality
~ | !~ | Regex match
=~ | !=~ | Equality ignoring case
~~ | !~~ | Regex ignoring case
< | | Less than
> | | Greater than
<= | | Less than or equal
>= | | Greater than or equal
### <a id="livestatus-stats"></a> Livestatus Stats
Schema: "Stats: aggregatefunction aggregateattribute"
Aggregate Function | Description
-------------------|--------------
sum | &nbsp;
min | &nbsp;
max | &nbsp;
avg | sum / count
std | standard deviation
suminv | sum (1 / value)
avginv | suminv / count
count | ordinary default for any stats query if not aggregate function defined
Example:
GET hosts
Filter: has_been_checked = 1
Filter: check_type = 0
Stats: sum execution_time
Stats: sum latency
Stats: sum percent_state_change
Stats: min execution_time
Stats: min latency
Stats: min percent_state_change
Stats: max execution_time
Stats: max latency
Stats: max percent_state_change
OutputFormat: json
ResponseHeader: fixed16
### <a id="livestatus-output"></a> Livestatus Output
* CSV
CSV output uses two levels of array separators: The members array separator
is a comma (1st level) while extra info and host|service relation separator
is a pipe (2nd level).
Separators can be set using ASCII codes like:
Separators: 10 59 44 124
* JSON
Default separators.
### <a id="livestatus-error-codes"></a> Livestatus Error Codes
Code | Description
----------|--------------
200 | OK
404 | Table does not exist
452 | Exception on query
### <a id="livestatus-tables"></a> Livestatus Tables
Table | Join |Description
--------------|-----------|----------------------------
hosts | &nbsp; | host config and status attributes, services counter
hostgroups | &nbsp; | hostgroup config, status attributes and host/service counters
services | hosts | service config and status attributes
servicegroups | &nbsp; | servicegroup config, status attributes and service counters
contacts | &nbsp; | contact config and status attributes
contactgroups | &nbsp; | contact config, members
commands | &nbsp; | command name and line
status | &nbsp; | programstatus, config and stats
comments | services | status attributes
downtimes | services | status attributes
timeperiods | &nbsp; | name and is inside flag
endpoints | &nbsp; | config and status attributes
log | services, hosts, contacts, commands | parses [compatlog](9-object-types.md#objecttype-compatlogger) and shows log attributes
statehist | hosts, services | parses [compatlog](9-object-types.md#objecttype-compatlogger) and aggregates state change attributes
hostsbygroup | hostgroups | host attributes grouped by hostgroup and its attributes
servicesbygroup | servicegroups | service attributes grouped by servicegroup and its attributes
servicesbyhostgroup | hostgroups | service attributes grouped by hostgroup and its attributes
The `commands` table is populated with `CheckCommand`, `EventCommand` and `NotificationCommand` objects.
A detailed list on the available table attributes can be found in the [Livestatus Schema documentation](23-appendix.md#schema-livestatus).
## <a id="status-data"></a> Status Data Files
Icinga 1.x writes object configuration data and status data in a cyclic
interval to its `objects.cache` and `status.dat` files. Icinga 2 provides
the `StatusDataWriter` object which dumps all configuration objects and
status updates in a regular interval.
# icinga2 feature enable statusdata
Icinga 1.x Classic UI requires this data set as part of its backend.
> **Note**
>
> If you are not using any web interface or addon which uses these files,
> you can safely disable this feature.
## <a id="compat-logging"></a> Compat Log Files
The Icinga 1.x log format is considered being the `Compat Log`
in Icinga 2 provided with the `CompatLogger` object.
These logs are not only used for informational representation in
external web interfaces parsing the logs, but also to generate
SLA reports and trends in Icinga 1.x Classic UI. Furthermore the
[Livestatus](14-features.md#setting-up-livestatus) feature uses these logs for answering queries to
historical tables.
The `CompatLogger` object can be enabled with
# icinga2 feature enable compatlog
By default, the Icinga 1.x log file called `icinga.log` is located
in `/var/log/icinga2/compat`. Rotated log files are moved into
`var/log/icinga2/compat/archives`.
The format cannot be changed without breaking compatibility to
existing log parsers.
# tail -f /var/log/icinga2/compat/icinga.log
[1382115688] LOG ROTATION: HOURLY
[1382115688] LOG VERSION: 2.0
[1382115688] HOST STATE: CURRENT;localhost;UP;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;disk;WARNING;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;http;OK;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;load;OK;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;ping4;OK;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;ping6;OK;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;processes;WARNING;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;ssh;OK;HARD;1;
[1382115688] SERVICE STATE: CURRENT;localhost;users;OK;HARD;1;
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;disk;1382115705
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;http;1382115705
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;load;1382115705
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;ping4;1382115705
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;ping6;1382115705
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;processes;1382115705
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;ssh;1382115705
[1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;users;1382115705
[1382115731] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;localhost;ping6;2;critical test|
[1382115731] SERVICE ALERT: localhost;ping6;CRITICAL;SOFT;2;critical test
## <a id="check-result-files"></a> Check Result Files
Icinga 1.x writes its check result files to a temporary spool directory
where they are processed in a regular interval.
While this is extremely inefficient in performance regards it has been
rendered useful for passing passive check results directly into Icinga 1.x
skipping the external command pipe.
Several clustered/distributed environments and check-aggregation addons
use that method. In order to support step-by-step migration of these
environments, Icinga 2 supports the `CheckResultReader` object.
There is no feature configuration available, but it must be defined
on-demand in your Icinga 2 objects configuration.
object CheckResultReader "reader" {
spool_dir = "/data/check-results"
}

View File

@ -0,0 +1,396 @@
# <a id="troubleshooting"></a> Icinga 2 Troubleshooting
## <a id="troubleshooting-information-required"></a> Which information is required
* Run `icinga2 troubleshoot` to collect required troubleshooting information
* Alternative, manual steps:
* `icinga2 --version`
* `icinga2 feature list`
* `icinga2 daemon --validate`
* Relevant output from your main and debug log ( `icinga2 object list --type='filelogger'` )
* The newest Icinga 2 crash log if relevant
* Your icinga2.conf and, if you run multiple Icinga 2 instances, your zones.conf
* How was Icinga 2 installed (and which repository in case) and which distribution are you using
* Provide complete configuration snippets explaining your problem in detail
* If the check command failed, what's the output of your manual plugin tests?
* In case of [debugging](20-development.md#development) Icinga 2, the full back traces and outputs
## <a id="troubleshooting-enable-debug-output"></a> Enable Debug Output
Enable the `debuglog` feature:
# icinga2 feature enable debuglog
# service icinga2 restart
You can find the debug log file in `/var/log/icinga2/debug.log`.
Alternatively you may run Icinga 2 in the foreground with debugging enabled. Specify the console
log severity as an additional parameter argument to `-x`.
# /usr/sbin/icinga2 daemon -x notice
The log level can be one of `critical`, `warning`, `information`, `notice`
and `debug`.
## <a id="list-configuration-objects"></a> List Configuration Objects
The `icinga2 object list` CLI command can be used to list all configuration objects and their
attributes. The tool also shows where each of the attributes was modified.
> **Tip**
>
> Use the Icinga 2 API to access [config objects at runtime](12-icinga2-api.md#icinga2-api-config-objects) directly.
That way you can also identify which objects have been created from your [apply rules](17-language-reference.md#apply).
# icinga2 object list
Object 'localhost!ssh' of type 'Service':
* __name = 'localhost!ssh'
* check_command = 'ssh'
% = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 5:3-5:23
* check_interval = 60
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 24:3-24:21
* host_name = 'localhost'
% = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 4:3-4:25
* max_check_attempts = 3
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 23:3-23:24
* name = 'ssh'
* retry_interval = 30
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 25:3-25:22
* templates = [ 'ssh', 'generic-service' ]
% += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 1:0-7:1
% += modified in '/etc/icinga2/conf.d/templates.conf', lines 22:1-26:1
* type = 'Service'
* vars
% += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
* sla = '24x7'
% = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
[...]
You can also filter by name and type:
# icinga2 object list --name *ssh* --type Service
Object 'localhost!ssh' of type 'Service':
* __name = 'localhost!ssh'
* check_command = 'ssh'
% = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 5:3-5:23
* check_interval = 60
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 24:3-24:21
* host_name = 'localhost'
% = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 4:3-4:25
* max_check_attempts = 3
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 23:3-23:24
* name = 'ssh'
* retry_interval = 30
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 25:3-25:22
* templates = [ 'ssh', 'generic-service' ]
% += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 1:0-7:1
% += modified in '/etc/icinga2/conf.d/templates.conf', lines 22:1-26:1
* type = 'Service'
* vars
% += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
* sla = '24x7'
% = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
Found 1 Service objects.
[2014-10-15 14:27:19 +0200] information/cli: Parsed 175 objects.
## <a id="check-command-definitions"></a> Where are the check command definitions?
Icinga 2 features a number of built-in [check command definitions](10-icinga-template-library.md#plugin-check-commands) which are
included using
include <itl>
include <plugins>
in the [icinga2.conf](4-configuring-icinga-2.md#icinga2-conf) configuration file. These files are not considered configuration files and will be overridden
on upgrade, so please send modifications as proposed patches upstream. The default include path is set to
`LocalStateDir + "/share/icinga2/includes"`.
You should add your own command definitions to a new file in `conf.d/` called `commands.conf`
or similar.
## <a id="troubleshooting-checks"></a> Checks
### <a id="checks-executed-command"></a> Executed Command for Checks
* Use the Icinga 2 API to [query](12-icinga2-api.md#icinga2-api-config-objects-query) host/service objects
for their check result containing the executed shell command.
* Use the Icinga 2 [console cli command](11-cli-commands.md#cli-command-console)
to fetch the checkable object, its check result and the executed shell command.
* Alternatively enable the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output) and look for the executed command.
### <a id="checks-not-executed"></a> Checks are not executed
* Check the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output) to see if the check command gets executed.
* Verify that failed depedencies do not prevent command execution.
* Make sure that the plugin is executable by the Icinga 2 user (run a manual test).
* Make sure the [checker](11-cli-commands.md#enable-features) feature is enabled.
* Use the Icinga 2 API [event streams](12-icinga2-api.md#icinga2-api-event-streams) to receive live check result streams.
Examples:
# sudo -u icinga /usr/lib/nagios/plugins/check_ping -4 -H 127.0.0.1 -c 5000,100% -w 3000,80%
# icinga2 feature enable checker
The feature 'checker' is already enabled.
Fetch all check result events matching the `event.service` name `random`:
$ curl -k -s -u root:icinga -X POST 'https://localhost:5665/v1/events?queue=debugchecks&types=CheckResult&filter=match%28%22random*%22,event.service%29'
## <a id="notifications-not-sent"></a> Notifications are not sent
* Check the debug log to see if a notification is triggered.
* If yes, verify that all conditions are satisfied.
* Are any errors on the notification command execution logged?
Verify the following configuration:
* Is the host/service `enable_notifications` attribute set, and if so, to which value?
* Do the notification attributes `states`, `types`, `period` match the notification conditions?
* Do the user attributes `states`, `types`, `period` match the notification conditions?
* Are there any notification `begin` and `end` times configured?
* Make sure the [notification](11-cli-commands.md#enable-features) feature is enabled.
* Does the referenced NotificationCommand work when executed as Icinga user on the shell?
If notifications are to be sent via mail, make sure that the mail program specified inside the
[NotificationCommand object](9-object-types.md#objecttype-notificationcommand) exists.
The name and location depends on the distribution so the preconfigured setting might have to be
changed on your system.
Examples:
# icinga2 feature enable notification
The feature 'notification' is already enabled.
You can use the Icinga 2 API [event streams](12-icinga2-api.md#icinga2-api-event-streams) to receive live notification streams:
$ curl -k -s -u root:icinga -X POST 'https://localhost:5665/v1/events?queue=debugnotifications&types=Notification'
## <a id="feature-not-working"></a> Feature is not working
* Make sure that the feature configuration is enabled by symlinking from `features-available/`
to `features-enabled` and that the latter is included in [icinga2.conf](4-configuring-icinga-2.md#icinga2-conf).
* Are the feature attributes set correctly according to the documentation?
* Any errors on the logs?
## <a id="configuration-ignored"></a> Configuration is ignored
* Make sure that the line(s) are not [commented out](17-language-reference.md#comments) (starting with `//` or `#`, or
encapsulated by `/* ... */`).
* Is the configuration file included in [icinga2.conf](4-configuring-icinga-2.md#icinga2-conf)?
## <a id="configuration-attribute-inheritance"></a> Configuration attributes are inherited from
Icinga 2 allows you to import templates using the [import](17-language-reference.md#template-imports) keyword. If these templates
contain additional attributes, your objects will automatically inherit them. You can override
or modify these attributes in the current object.
## <a id="configuration-value-dollar-sign"></a> Configuration Value with Single Dollar Sign
In case your configuration validation fails with a missing closing dollar sign error message, you
did not properly escape the single dollar sign preventing its usage as [runtime macro](3-monitoring-basics.md#runtime-macros).
critical/config: Error: Validation failed for Object 'ping4' (Type: 'Service') at /etc/icinga2/zones.d/global-templates/windows.conf:24: Closing $ not found in macro format string 'top-syntax=${list}'.
## <a id="troubleshooting-cluster"></a> Cluster and Clients Troubleshooting
This applies to any Icinga 2 node in a [distributed monitoring setup](6-distributed-monitoring.md#distributed-monitoring-scenarios).
You should configure the [cluster health checks](6-distributed-monitoring.md#distributed-monitoring-health-checks) if you haven't
done so already.
> **Note**
>
> Some problems just exist due to wrong file permissions or packet filters applied. Make
> sure to check these in the first place.
### <a id="troubleshooting-cluster-connection-errors"></a> Cluster Troubleshooting Connection Errors
General connection errors normally lead you to one of the following problems:
* Wrong network configuration
* Packet loss on the connection
* Firewall rules preventing traffic
Use tools like `netstat`, `tcpdump`, `nmap`, etc. to make sure that the cluster communication
happens (default port is `5665`).
# tcpdump -n port 5665 -i any
# netstat -tulpen | grep icinga
# nmap yourclusternode.localdomain
### <a id="troubleshooting-cluster-ssl-errors"></a> Cluster Troubleshooting SSL Errors
If the cluster communication fails with SSL error messages, make sure to check
the following
* File permissions on the SSL certificate files
* Does the used CA match for all cluster endpoints?
* Verify the `Issuer` being your trusted CA
* Verify the `Subject` containing your endpoint's common name (CN)
* Check the validity of the certificate itself
Steps on the client `icinga2-node2.localdomain`:
# ls -la /etc/icinga2/pki
# cd /etc/icinga2/pki/
# openssl x509 -in icinga2-node2.localdomain.crt -text
Certificate:
Data:
Version: 1 (0x0)
Serial Number: 2 (0x2)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=DE, ST=Bavaria, L=Nuremberg, O=NETWAYS GmbH, OU=Monitoring, CN=Icinga CA
Validity
Not Before: Jan 7 13:17:38 2014 GMT
Not After : Jan 5 13:17:38 2024 GMT
Subject: C=DE, ST=Bavaria, L=Nuremberg, O=NETWAYS GmbH, OU=Monitoring, CN=icinga2-node2.localdomain
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (4096 bit)
Modulus:
...
Try to manually connect from `icinga2-node2.localdomain` to the master node `icinga2-node1.localdomain`:
# openssl s_client -CAfile /etc/icinga2/pki/ca.crt -cert /etc/icinga2/pki/icinga2-node2.localdomain.crt -key /etc/icinga2/pki/icinga2-node2.localdomain.key -connect icinga2-node1.localdomain:5665
CONNECTED(00000003)
---
...
If the connection attempt fails or your CA does not match, [verify the master and client certificates](15-troubleshooting.md#troubleshooting-cluster-ssl-certificate-verification).
#### <a id="troubleshooting-cluster-unauthenticated-clients"></a> Cluster Troubleshooting Unauthenticated Clients
Unauthenticated nodes are able to connect. This is required for client setups.
Master:
[2015-07-13 18:29:25 +0200] information/ApiListener: New client connection for identity 'icinga-client' (unauthenticated)
Client as command execution bridge:
[2015-07-13 18:29:26 +1000] notice/ApiEvents: Discarding 'execute command' message from 'icinga-master': Invalid endpoint origin (client not allowed).
If these messages do not go away, make sure to [verify the master and client certificates](15-troubleshooting.md#troubleshooting-cluster-ssl-certificate-verification).
#### <a id="troubleshooting-cluster-ssl-certificate-verification"></a> Cluster Troubleshooting SSL Certificate Verification
Make sure to verify the client's certificate and its received `ca.crt` in `/etc/icinga2/pki` and ensure that
both instances are signed by the **same CA**.
# openssl verify -verbose -CAfile /etc/icinga2/pki/ca.crt /etc/icinga2/pki/icinga2-node1.localdomain.crt
icinga2-node1.localdomain.crt: OK
# openssl verify -verbose -CAfile /etc/icinga2/pki/ca.crt /etc/icinga2/pki/icinga2-node2.localdomain.crt
icinga2-node2.localdomain.crt: OK
Fetch the `ca.crt` file from the client node and compare it to your master's `ca.crt` file:
# scp icinga2-node2:/etc/icinga2/pki/ca.crt test-client-ca.crt
# diff -ur /etc/icinga2/pki/ca.crt test-client-ca.crt
On SLES11 you'll need to use the `openssl1` command instead of `openssl`.
### <a id="troubleshooting-cluster-message-errors"></a> Cluster Troubleshooting Message Errors
At some point, when the network connection is broken or gone, the Icinga 2 instances
will be disconnected. If the connection can't be re-established between endpoints in the same HA zone,
they remain in a Split-Brain-mode and history may differ.
Although the Icinga 2 cluster protocol stores historical events in a [replay log](15-troubleshooting.md#troubleshooting-cluster-replay-log)
for later synchronisation, you should make sure to check why the network connection failed.
### <a id="troubleshooting-cluster-command-endpoint-errors"></a> Cluster Troubleshooting Command Endpoint Errors
Command endpoints can be used [for clients](6-distributed-monitoring.md#distributed-monitoring-top-down-command-endpoint)
as well as inside an [High-Availability cluster](6-distributed-monitoring.md#distributed-monitoring-scenarios).
There is no cli command for manually executing the check, but you can verify
the following (e.g. by invoking a forced check from the web interface):
* `/var/log/icinga2/icinga2.log` contains connection and execution errors.
* The ApiListener is not enabled to [accept commands](6-distributed-monitoring.md#distributed-monitoring-top-down-command-endpoint).
* `CheckCommand` definition not found on the remote client.
* Referenced check plugin not found on the remote client.
* Runtime warnings and errors, e.g. unresolved runtime macros or configuration problems.
* Specific error messages are also populated into `UNKNOWN` check results including a detailed error message in their output.
* Verify the `check_source` object attribute. This is populated by the node executing the check.
* More verbose logs are found inside the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output).
* Use the Icinga 2 API [event streams](12-icinga2-api.md#icinga2-api-event-streams) to receive live check result streams.
Fetch all check result events matching the `event.service` name `remote-client`:
$ curl -k -s -u root:icinga -X POST 'https://localhost:5665/v1/events?queue=debugcommandendpoint&types=CheckResult&filter=match%28%22remote-client*%22,event.service%29'
### <a id="troubleshooting-cluster-config-sync"></a> Cluster Troubleshooting Config Sync
If the cluster zones do not sync their configuration, make sure to check the following:
* Within a config master zone, only one configuration master is allowed to have its config in `/etc/icinga2/zones.d`.
** The master syncs the configuration to `/var/lib/icinga2/api/zones/` during startup and only syncs valid configuration to the other nodes.
** The other nodes receive the configuration into `/var/lib/icinga2/api/zones/`.
* The `icinga2.log` log file in `/var/log/icinga2` will indicate whether this ApiListener
[accepts config](6-distributed-monitoring.md#distributed-monitoring-top-down-config-sync), or not.
Verify the object's [version](9-object-types.md#object-types) attribute on all nodes to
check whether the config update and reload was succesful or not.
### <a id="troubleshooting-cluster-check-results"></a> Cluster Troubleshooting Overdue Check Results
If your master does not receive check results (or any other events) from the child zones
(satellite, clients, etc.), make sure to check whether the client sending in events
is allowed to do so.
The [distributed monitoring conventions](6-distributed-monitoring.md#distributed-monitoring-conventions)
apply. So, if there's a mismatch between your client node's endpoint name and its provided
certificate's CN, the master will deny all events.
> **Tip**
>
> [Icinga Web 2](2-getting-started.md#setting-up-icingaweb2) provides a dashboard view
> for overdue check results.
Enable the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output) on the master
for more verbose insights.
If the client cannot authenticate, it's a more general [problem](15-troubleshooting.md#troubleshooting-cluster-unauthenticated-clients).
The client's endpoint is not configured on nor trusted by the master node:
Discarding 'check result' message from 'icinga2b': Invalid endpoint origin (client not allowed).
The check result message sent by the client does not belong to the zone the checkable object is
in on the master:
Discarding 'check result' message from 'icinga2b': Unauthorized access.
### <a id="troubleshooting-cluster-replay-log"></a> Cluster Troubleshooting Replay Log
If your `/var/lib/icinga2/api/log` directory grows, it generally means that your cluster
cannot replay the log on connection loss and re-establishment. A master node for example
will store all events for not connected endpoints in the same and child zones.
Check the following:
* All clients are connected? (e.g. [cluster health check](6-distributed-monitoring.md#distributed-monitoring-health-checks)).
* Check your [connection](15-troubleshooting.md#troubleshooting-cluster-connection-errors) in general.
* Does the log replay work, e.g. are all events processed and the directory gets cleared up over time?
* Decrease the `log_duration` attribute value for that specific [endpoint](9-object-types.md#objecttype-endpoint).

View File

@ -0,0 +1,56 @@
# <a id="upgrading-icinga-2"></a> Upgrading Icinga 2
Upgrading Icinga 2 is usually quite straightforward. Ordinarily the only manual steps involved
are scheme updates for the IDO database.
## <a id="upgrading-mysql-db"></a> Upgrading the MySQL database
If you're upgrading an existing Icinga 2 instance, you should check the
`/usr/share/icinga2-ido-mysql/schema/upgrade` directory for an incremental schema upgrade file.
> **Note**
>
> If there isn't an upgrade file for your current version available, there's nothing to do.
Apply all database schema upgrade files incrementally.
# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/<version>.sql
The Icinga 2 DB IDO module will check for the required database schema version on startup
and generate an error message if not satisfied.
**Example:** You are upgrading Icinga 2 from version `2.0.2` to `2.3.0`. Look into
the *upgrade* directory:
$ ls /usr/share/icinga2-ido-mysql/schema/upgrade/
2.0.2.sql 2.1.0.sql 2.2.0.sql 2.3.0.sql
There are two new upgrade files called `2.1.0.sql`, `2.2.0.sql` and `2.3.0.sql`
which must be applied incrementally to your IDO database.
## <a id="upgrading-postgresql-db"></a> Upgrading the PostgreSQL database
If you're updating an existing Icinga 2 instance, you should check the
`/usr/share/icinga2-ido-pgsql/schema/upgrade` directory for an incremental schema upgrade file.
> **Note**
>
> If there isn't an upgrade file for your current version available, there's nothing to do.
Apply all database schema upgrade files incrementally.
# export PGPASSWORD=icinga
# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/<version>.sql
The Icinga 2 DB IDO module will check for the required database schema version on startup
and generate an error message if not satisfied.
**Example:** You are upgrading Icinga 2 from version `2.0.2` to `2.3.0`. Look into
the *upgrade* directory:
$ ls /usr/share/icinga2-ido-pgsql/schema/upgrade/
2.0.2.sql 2.1.0.sql 2.2.0.sql 2.3.0.sql
There are two new upgrade files called `2.1.0.sql`, `2.2.0.sql` and `2.3.0.sql`
which must be applied incrementally to your IDO database.

View File

@ -0,0 +1,974 @@
# <a id="language-reference"></a> Language Reference
## <a id="object-definition"></a> Object Definition
Icinga 2 features an object-based configuration format. You can define new
objects using the `object` keyword:
object Host "host1.example.org" {
display_name = "host1"
address = "192.168.0.1"
address6 = "::1"
}
In general you need to write each statement on a new line. Expressions started
with `{`, `(` and `[` extend until the matching closing character and can be broken
up into multiple lines.
Alternatively you can write multiple statements on a single line by separating
them with a semicolon:
object Host "host1.example.org" {
display_name = "host1"
address = "192.168.0.1"; address6 = "::1"
}
Each object is uniquely identified by its type (`Host`) and name
(`host1.example.org`). Some types have composite names, e.g. the
`Service` type which uses the `host_name` attribute and the name
you specified to generate its object name.
Exclamation marks (!) are not permitted in object names.
Objects can contain a comma-separated list of property
declarations. Instead of commas semicolons may also be used.
The following data types are available for property values:
All objects have at least the following attributes:
Attribute | Description
---------------------|-----------------------------
name | The name of the object. This attribute can be modified in the object definition to override the name specified with the `object` directive.
type | The type of the object.
## <a id="expressions"></a> Expressions
The following expressions can be used on the right-hand side of assignments.
### <a id="numeric-literals"></a> Numeric Literals
A floating-point number.
Example:
27.3
### <a id="duration-literals"></a> Duration Literals
Similar to floating-point numbers except for the fact that they support
suffixes to help with specifying time durations.
Example:
2.5m
Supported suffixes include ms (milliseconds), s (seconds), m (minutes),
h (hours) and d (days).
Duration literals are converted to seconds by the config parser and
are treated like numeric literals.
### <a id="string-literals"></a> String Literals
A string.
Example:
"Hello World!"
Certain characters need to be escaped. The following escape sequences
are supported:
Character | Escape sequence
--------------------------|------------------------------------
" | \\"
\\ | \\\\
&lt;TAB&gt; | \\t
&lt;CARRIAGE-RETURN&gt; | \\r
&lt;LINE-FEED&gt; | \\n
&lt;BEL&gt; | \\b
&lt;FORM-FEED&gt; | \\f
In addition to these pre-defined escape sequences you can specify
arbitrary ASCII characters using the backslash character (\\) followed
by an ASCII character in octal encoding.
### <a id="multiline-string-literals"></a> Multi-line String Literals
Strings spanning multiple lines can be specified by enclosing them in
{{{ and }}}.
Example:
{{{This
is
a multi-line
string.}}}
Unlike in ordinary strings special characters do not have to be escaped
in multi-line string literals.
### <a id="boolean-literals"></a> Boolean Literals
The keywords `true` and `false` are used to denote truth values.
### <a id="null-value"></a> Null Value
The `null` keyword can be used to specify an empty value.
### <a id="dictionary"></a> Dictionary
An unordered list of key-value pairs. Keys must be unique and are
compared in a case-sensitive manner.
Individual key-value pairs must either be comma-separated or on separate lines.
The comma after the last key-value pair is optional.
Example:
{
address = "192.168.0.1"
port = 443
}
Identifiers may not contain certain characters (e.g. space) or start
with certain characters (e.g. digits). If you want to use a dictionary
key that is not a valid identifier, you can enclose the key in double
quotes.
### <a id="array"></a> Array
An ordered list of values.
Individual array elements must be comma-separated.
The comma after the last element is optional.
Example:
[ "hello", 42 ]
An array may simultaneously contain values of different types, such as
strings and numbers.
### <a id="expression-operators"></a> Operators
The following operators are supported in expressions. The operators are by descending precedence.
Operator | Precedence | Examples (Result) | Description
---------|------------|-----------------------------------------------|--------------------------------
() | 1 | (3 + 3) * 5 | Groups sub-expressions
() | 1 | Math.random() | Calls a function
[] | 1 | a[3] | Array subscript
. | 1 | a.b | Element access
! | 2 | !"Hello" (false), !false (true) | Logical negation of the operand
~ | 2 | ~true (false) | Bitwise negation of the operand
+ | 2 | +3 | Unary plus
- | 2 | -3 | Unary minus
* | 3 | 5m * 10 (3000) | Multiplies two numbers
/ | 3 | 5m / 5 (60) | Divides two numbers
% | 3 | 17 % 12 (5) | Remainder after division
+ | 4 | 1 + 3 (4), "hello " + "world" ("hello world") | Adds two numbers; concatenates strings
- | 4 | 3 - 1 (2) | Subtracts two numbers
<< | 5 | 4 << 8 (1024) | Left shift
>> | 5 | 1024 >> 4 (64) | Right shift
< | 6 | 3 < 5 (true) | Less than
> | 6 | 3 > 5 (false) | Greater than
<= | 6 | 3 <= 3 (true) | Less than or equal
>= | 6 | 3 >= 3 (true) | Greater than or equal
in | 7 | "foo" in [ "foo", "bar" ] (true) | Element contained in array
!in | 7 | "foo" !in [ "bar", "baz" ] (true) | Element not contained in array
== | 8 | "hello" == "hello" (true), 3 == 5 (false) | Equal to
!= | 8 | "hello" != "world" (true), 3 != 3 (false) | Not equal to
& | 9 | 7 & 3 (3) | Binary AND
^ | 10 | 17 ^ 12 (29) | Bitwise XOR
&#124; | 11 | 2 &#124; 3 (3) | Binary OR
&& | 13 | true && false (false), 3 && 7 (7), 0 && 7 (0) | Logical AND
&#124;&#124; | 14 | true &#124;&#124; false (true), 0 &#124;&#124; 7 (7)| Logical OR
= | 12 | a = 3 | Assignment
=> | 15 | x => x * x (function with arg x) | Lambda, for loop
### <a id="function-calls"></a> Function Calls
Functions can be called using the `()` operator:
const MyGroups = [ "test1", "test" ]
{
check_interval = len(MyGroups) * 1m
}
A list of available functions is available in the [Library Reference](18-library-reference.md#library-reference) chapter.
## <a id="dictionary-operators"></a> Assignments
In addition to the `=` operator shown above a number of other operators
to manipulate attributes are supported. Here's a list of all
available operators:
### <a id="operator-assignment"></a> Operator =
Sets an attribute to the specified value.
Example:
{
a = 5
a = 7
}
In this example `a` has the value `7` after both instructions are executed.
### <a id="operator-additive-assignment"></a> Operator +=
The += operator is a shortcut. The following expression:
{
a = [ "hello" ]
a += [ "world" ]
}
is equivalent to:
{
a = [ "hello" ]
a = a + [ "world" ]
}
### <a id="operator-substractive-assignment"></a> Operator -=
The -= operator is a shortcut. The following expression:
{
a = 10
a -= 5
}
is equivalent to:
{
a = 10
a = a - 5
}
### <a id="operator-multiply-assignment"></a> Operator \*=
The *= operator is a shortcut. The following expression:
{
a = 60
a *= 5
}
is equivalent to:
{
a = 60
a = a * 5
}
### <a id="operator-dividing-assignment"></a> Operator /=
The /= operator is a shortcut. The following expression:
{
a = 300
a /= 5
}
is equivalent to:
{
a = 300
a = a / 5
}
## <a id="indexer"></a> Indexer
The indexer syntax provides a convenient way to set dictionary elements.
Example:
{
hello.key = "world"
}
Example (alternative syntax):
{
hello["key"] = "world"
}
This is equivalent to writing:
{
hello += {
key = "world"
}
}
If the `hello` attribute does not already have a value, it is automatically initialized to an empty dictionary.
## <a id="template-imports"></a> Template Imports
Objects can import attributes from other objects.
Example:
template Host "default-host" {
vars.colour = "red"
}
template Host "test-host" {
import "default-host"
vars.colour = "blue"
}
object Host "localhost" {
import "test-host"
address = "127.0.0.1"
address6 = "::1"
}
The `default-host` and `test-host` objects are marked as templates
using the `template` keyword. Unlike ordinary objects templates are not
instantiated at run-time. Parent objects do not necessarily have to be
templates, however in general they are.
The `vars` dictionary for the `localhost` object contains all three
custom attributes and the custom attribute `colour` has the value `"blue"`.
Parent objects are resolved in the order they're specified using the
`import` keyword.
Default templates which are automatically imported into all object definitions
can be specified using the `default` keyword:
template CheckCommand "plugin-check-command" default {
// ...
}
Default templates are imported before any other user-specified statement in an
object definition is evaluated.
If there are multiple default templates the order in which they are imported
is unspecified.
## <a id="constants"></a> Constants
Global constants can be set using the `const` keyword:
const VarName = "some value"
Once defined a constant can be accessed from any file. Constants cannot be changed
once they are set.
Icinga 2 provides a number of special global constants. Some of them can be overridden using the `--define` command line parameter:
Variable |Description
--------------------|-------------------
PrefixDir |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to "/usr/local".
SysconfDir |**Read-only.** Contains the path of the sysconf directory. Defaults to PrefixDir + "/etc".
ZonesDir |**Read-only.** Contains the path of the zones.d directory. Defaults to SysconfDir + "/zones.d".
LocalStateDir |**Read-only.** Contains the path of the local state directory. Defaults to PrefixDir + "/var".
RunDir |**Read-only.** Contains the path of the run directory. Defaults to LocalStateDir + "/run".
PkgDataDir |**Read-only.** Contains the path of the package data directory. Defaults to PrefixDir + "/share/icinga2".
StatePath |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to LocalStateDir + "/lib/icinga2/icinga2.state".
ObjectsPath |**Read-write.** Contains the path of the Icinga 2 objects file. Defaults to LocalStateDir + "/cache/icinga2/icinga2.debug".
PidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to RunDir + "/icinga2/icinga2.pid".
Vars |**Read-write.** Contains a dictionary with global custom attributes. Not set by default.
NodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
UseVfork |**Read-write.** Whether to use vfork(). Only available on *NIX. Defaults to true.
EventEngine |**Read-write.** The name of the socket event engine, can be "poll" or "epoll". The epoll interface is only supported on Linux.
AttachDebugger |**Read-write.** Whether to attach a debugger when Icinga 2 crashes. Defaults to false.
RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
PlatformName |**Read-only.** The name of the operating system, e.g. "Ubuntu".
PlatformVersion |**Read-only.** The version of the operating system, e.g. "14.04.3 LTS".
PlatformKernel |**Read-only.** The name of the operating system kernel, e.g. "Linux".
PlatformKernelVersion|**Read-only.** The version of the operating system kernel, e.g. "3.13.0-63-generic".
BuildCompilerName |**Read-only.** The name of the compiler Icinga was built with, e.g. "Clang".
BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built with, e.g. "7.3.0.7030031".
BuildHostName |**Read-only.** The name of the host Icinga was built on, e.g. "acheron".
## <a id="apply"></a> Apply
The `apply` keyword can be used to create new objects which are associated with
another group of objects.
apply Service "ping" to Host {
import "generic-service"
check_command = "ping4"
assign where host.name == "localhost"
}
In this example the `assign where` condition is a boolean expression which is
evaluated for all objects of type `Host` and a new service with name "ping"
is created for each matching host. [Expression operators](17-language-reference.md#expression-operators)
may be used in `assign where` conditions.
The `to` keyword and the target type may be omitted if there is only one target
type, e.g. for the `Service` type.
Depending on the object type used in the `apply` expression additional local
variables may be available for use in the `where` condition:
Source Type | Target Type | Variables
------------------|-------------|--------------
Service | Host | host
Dependency | Host | host
Dependency | Service | host, service
Notification | Host | host
Notification | Service | host, service
ScheduledDowntime | Host | host
ScheduledDowntime | Service | host, service
Any valid config attribute can be accessed using the `host` and `service`
variables. For example, `host.address` would return the value of the host's
"address" attribute -- or null if that attribute isn't set.
More usage examples are documented in the [monitoring basics](3-monitoring-basics.md#using-apply-expressions)
chapter.
## <a id="apply-for"></a> Apply For
[Apply](17-language-reference.md#apply) rules can be extended with the
[for loop](17-language-reference.md#for-loops) keyword.
apply Service "prefix-" for (key => value in host.vars.dictionary) to Host {
import "generic-service"
check_command = "ping4"
vars.host_value = value
}
Any valid config attribute can be accessed using the `host` and `service`
variables. The attribute must be of the Array or Dictionary type. In this example
`host.vars.dictionary` is of the Dictionary type which needs a key-value-pair
as iterator.
In this example all generated service object names consist of `prefix-` and
the value of the `key` iterator. The prefix string can be omitted if not required.
The `key` and `value` variables can be used for object attribute assignment, e.g. for
setting the `check_command` attribute or custom attributes as command parameters.
`apply for` rules are first evaluated against all objects matching the `for loop` list
and afterwards the `assign where` and `ignore where` conditions are evaluated.
It is not necessary to check attributes referenced in the `for loop` expression
for their existance using an additional `assign where` condition.
More usage examples are documented in the [monitoring basics](3-monitoring-basics.md#using-apply-for)
chapter.
## <a id="group-assign"></a> Group Assign
Group objects can be assigned to specific member objects using the `assign where`
and `ignore where` conditions.
object HostGroup "linux-servers" {
display_name = "Linux Servers"
assign where host.vars.os == "Linux"
}
In this example the `assign where` condition is a boolean expression which is evaluated
for all objects of the type `Host`. Each matching host is added as member to the host group
with the name "linux-servers". Membership exclusion can be controlled using the `ignore where`
condition. [Expression operators](17-language-reference.md#expression-operators) may be used in `assign where` and
`ignore where` conditions.
Source Type | Variables
------------------|--------------
HostGroup | host
ServiceGroup | host, service
UserGroup | user
## <a id="boolean-values"></a> Boolean Values
The `assign where`, `ignore where`, `if` and `while` statements, the `!` operator as
well as the `bool()` function convert their arguments to a boolean value based on the
following rules:
Description | Example Value | Boolean Value
---------------------|-------------------|--------------
Empty value | null | false
Zero | 0 | false
Non-zero integer | -23945 | true
Empty string | "" | false
Non-empty string | "Hello" | true
Empty array | [] | false
Non-empty array | [ "Hello" ] | true
Empty dictionary | {} | false
Non-empty dictionary | { key = "value" } | true
For a list of supported expression operators for `assign where` and `ignore where`
statements, see [expression operators](17-language-reference.md#expression-operators).
## <a id="comments"></a> Comments
The Icinga 2 configuration format supports C/C++-style and shell-style comments.
Example:
/*
This is a comment.
*/
object Host "localhost" {
check_interval = 30 // this is also a comment.
retry_interval = 15 # yet another comment
}
## <a id="includes"></a> Includes
Other configuration files can be included using the `include` directive.
Paths must be relative to the configuration file that contains the
`include` directive.
Example:
include "some/other/file.conf"
include "conf.d/*.conf"
Wildcard includes are not recursive.
Icinga also supports include search paths similar to how they work in a
C/C++ compiler:
include <itl>
Note the use of angle brackets instead of double quotes. This causes the
config compiler to search the include search paths for the specified
file. By default $PREFIX/share/icinga2/include is included in the list of search
paths. Additional include search paths can be added using
[command-line options](11-cli-commands.md#config-include-path).
Wildcards are not permitted when using angle brackets.
## <a id="recursive-includes"></a> Recursive Includes
The `include_recursive` directive can be used to recursively include all
files in a directory which match a certain pattern.
Example:
include_recursive "conf.d", "*.conf"
include_recursive "templates"
The first parameter specifies the directory from which files should be
recursively included.
The file names need to match the pattern given in the second parameter.
When no pattern is specified the default pattern "*.conf" is used.
## <a id="zone-includes"></a> Zone Includes
The `include_zones` recursively includes all subdirectories for the
given path.
In addition to that it sets the `zone` attribute for all objects created
in these subdirectories to the name of the subdirectory.
Example:
include_zones "etc", "zones.d", "*.conf"
include_zones "puppet", "puppet-zones"
The first parameter specifies a tag name for this directive. Each `include_zones`
invocation should use a unique tag name. When copying the zones' configuration
files Icinga uses the tag name as the name for the destination directory in
`/var/lib/icinga2/api/config`.
The second parameter specifies the directory which contains the subdirectories.
The file names need to match the pattern given in the third parameter.
When no pattern is specified the default pattern "*.conf" is used.
## <a id="library"></a> Library directive
The `library` directive can be used to manually load additional
libraries. Libraries can be used to provide additional object types and
functions.
Example:
library "snmphelper"
## <a id="functions"></a> Functions
Functions can be defined using the `function` keyword.
Example:
function multiply(a, b) {
return a * b
}
When encountering the `return` keyword further execution of the function is terminated and
the specified value is supplied to the caller of the function:
log(multiply(3, 5))
In this example the `multiply` function we declared earlier is invoked with two arguments (3 and 5).
The function computes the product of those arguments and makes the result available to the
function's caller.
When no value is supplied for the `return` statement the function returns `null`.
Functions which do not have a `return` statement have their return value set to the value of the
last expression which was performed by the function. For example, we could have also written our
`multiply` function like this:
function multiply(a, b) {
a * b
}
Anonymous functions can be created by omitting the name in the function definition. The
resulting function object can be used like any other value:
var fn = function() { 3 }
fn() /* Returns 3 */
## <a id="lambdas"></a> Lambda Expressions
Functions can also be declared using the alternative lambda syntax.
Example:
f = (x) => x * x
Multiple statements can be used by putting the function body into braces:
f = (x) => {
log("Lambda called")
x * x
}
Just like with ordinary functions the return value is the value of the last statement.
For lambdas which take exactly one argument the braces around the arguments can be omitted:
f = x => x * x
## <a id="nullary-lambdas"></a> Abbreviated Lambda Syntax
Lambdas which take no arguments can also be written using the abbreviated lambda syntax.
Example:
f = {{ 3 }}
This creates a new function which returns the value 3.
## <a id="variable-scopes"></a> Variable Scopes
When setting a variable Icinga checks the following scopes in this order whether the variable
already exists there:
* Local Scope
* `this` Scope
* Global Scope
The local scope contains variables which only exist during the invocation of the current function,
object or apply statement. Local variables can be declared using the `var` keyword:
function multiply(a, b) {
var temp = a * b
return temp
}
Each time the `multiply` function is invoked a new `temp` variable is used which is in no way
related to previous invocations of the function.
When setting a variable which has not previously been declared as local using the `var` keyword
the `this` scope is used.
The `this` scope refers to the current object which the function or object/apply statement
operates on.
object Host "localhost" {
check_interval = 5m
}
In this example the `this` scope refers to the "localhost" object. The `check_interval` attribute
is set for this particular host.
You can explicitly access the `this` scope using the `this` keyword:
object Host "localhost" {
var check_interval = 5m
/* This explicitly specifies that the attribute should be set
* for the host, if we had omitted `this.` the (poorly named)
* local variable `check_interval` would have been modified instead.
*/
this.check_interval = 1m
}
Similarly the keywords `locals` and `globals` are available to access the local and global scope.
Functions also have a `this` scope. However unlike for object/apply statements the `this` scope for
a function is set to whichever object was used to invoke the function. Here's an example:
hm = {
h_word = null
function init(word) {
h_word = word
}
}
/* Let's invoke the init() function */
hm.init("hello")
We're using `hm.init` to invoke the function which causes the value of `hm` to become the `this`
scope for this function call.
## <a id="closures"></a> Closures
By default `function`s, `object`s and `apply` rules do not have access to variables declared
outside of their scope (except for global variables).
In order to access variables which are defined in the outer scope the `use` keyword can be used:
function MakeHelloFunction(name) {
return function() use(name) {
log("Hello, " + name)
}
}
In this case a new variable `name` is created inside the inner function's scope which has the
value of the `name` function argument.
Alternatively a different value for the inner variable can be specified:
function MakeHelloFunction(name) {
return function() use (greeting = "Hello, " + name) {
log(greeting)
}
}
## <a id="conditional-statements"></a> Conditional Statements
Sometimes it can be desirable to only evaluate statements when certain conditions are met. The if/else
construct can be used to accomplish this.
Example:
a = 3
if (a < 5) {
a *= 7
} else if (a > 10) {
a *= 5
} else {
a *= 2
}
An if/else construct can also be used in place of any other value. The value of an if/else statement
is the value of the last statement which was evaluated for the branch which was taken:
a = if (true) {
log("Taking the 'true' branch")
7 * 3
} else {
log("Taking the 'false' branch")
9
}
This example prints the log message "Taking the 'true' branch" and the `a` variable is set to 21 (7 * 3).
The value of an if/else construct is null if the condition evaluates to false and no else branch is given.
## <a id="while-loops"></a> While Loops
The `while` statement checks a condition and executes the loop body when the condition evaluates to `true`.
This is repeated until the condition is no longer true.
Example:
var num = 5
while (num > 5) {
log("Test")
num -= 1
}
The `continue` and `break` keywords can be used to control how the loop is executed: The `continue` keyword
skips over the remaining expressions for the loop body and begins the next loop evaluation. The `break` keyword
breaks out of the loop.
## <a id="for-loops"></a> For Loops
The `for` statement can be used to iterate over arrays and dictionaries.
Example:
var list = [ "a", "b", "c" ]
for (item in list) {
log("Item: " + item)
}
The loop body is evaluated once for each item in the array. The variable `item` is declared as a local
variable just as if the `var` keyword had been used.
Iterating over dictionaries can be accomplished in a similar manner:
var dict = { a = 3, b = 7 }
for (key => value in dict) {
log("Key: " + key + ", Value: " + value)
}
The `continue` and `break` keywords can be used to control how the loop is executed: The `continue` keyword
skips over the remaining expressions for the loop body and begins the next loop evaluation. The `break` keyword
breaks out of the loop.
## <a id="constructor"></a> Constructors
In order to create a new value of a specific type constructor calls may be used.
Example:
var pd = PerfdataValue()
pd.label = "test"
pd.value = 10
You can also try to convert an existing value to another type by specifying it as an argument for the constructor call.
Example:
var s = String(3) /* Sets s to "3". */
## <a id="throw"></a> Exceptions
Built-in commands may throw exceptions to signal errors such as invalid arguments. User scripts can throw exceptions
using the `throw` keyword.
Example:
throw "An error occurred."
There is currently no way for scripts to catch exceptions.
## <a id="breakpoints"></a> Breakpoints
The `debugger` keyword can be used to insert a breakpoint. It may be used at any place where an assignment would also be a valid expression.
By default breakpoints have no effect unless Icinga is started with the `--script-debugger` command-line option. When the script debugger is enabled Icinga stops execution of the script when it encounters a breakpoint and spawns a console which lets the user inspect the current state of the execution environment.
## <a id="types"></a> Types
All values have a static type. The `typeof` function can be used to determine the type of a value:
typeof(3) /* Returns an object which represents the type for numbers */
The following built-in types are available:
Type | Examples | Description
-----------|-------------------|------------------------
Number | 3.7 | A numerical value.
Boolean | true, false | A boolean value.
String | "hello" | A string.
Array | [ "a", "b" ] | An array.
Dictionary | { a = 3 } | A dictionary.
Depending on which libraries are loaded additional types may become available. The `icinga`
library implements a whole bunch of other [object types](9-object-types.md#object-types),
e.g. Host, Service, CheckCommand, etc.
Each type has an associated type object which describes the type's semantics. These
type objects are made available using global variables which match the type's name:
/* This logs 'true' */
log(typeof(3) == Number)
The type object's `prototype` property can be used to find out which methods a certain type
supports:
/* This returns: ["contains","find","len","lower","replace","reverse","split","substr","to_string","trim","upper"] */
keys(String.prototype)
Additional documentation on type methods is available in the
[library reference](18-library-reference.md#library-reference).
## <a id="location-information"></a> Location Information
The location of the currently executing script can be obtained using the
`current_filename` and `current_line` keywords.
Example:
log("Hello from '" + current_filename + "' in line " + current_line)
## <a id="reserved-keywords"></a> Reserved Keywords
These keywords are reserved and must not be used as constants or custom attributes.
object
template
include
include_recursive
ignore_on_error
library
null
true
false
const
var
this
use
apply
to
where
import
assign
ignore
function
return
for
if
else
in
current_filename
current_line
You can escape reserved keywords using the `@` character. The following example
tries to set `vars.include` which references a reserved keyword and generates
an error:
[2014-09-15 17:24:00 +0200] critical/config: Location:
/etc/icinga2/conf.d/hosts/localhost.conf(13): vars.sla = "24x7"
/etc/icinga2/conf.d/hosts/localhost.conf(14):
/etc/icinga2/conf.d/hosts/localhost.conf(15): vars.include = "some cmdb export field"
^^^^^^^
/etc/icinga2/conf.d/hosts/localhost.conf(16): }
/etc/icinga2/conf.d/hosts/localhost.conf(17):
Config error: in /etc/icinga2/conf.d/hosts/localhost.conf: 15:8-15:14: syntax error, unexpected include (T_INCLUDE), expecting T_IDENTIFIER
[2014-09-15 17:24:00 +0200] critical/config: 1 errors, 0 warnings.
You can escape the `include` keyword by prefixing it with an additional `@` character:
object Host "localhost" {
import "generic-host"
address = "127.0.0.1"
address6 = "::1"
vars.os = "Linux"
vars.sla = "24x7"
vars.@include = "some cmdb export field"
}

View File

@ -0,0 +1,904 @@
# <a id="library-reference"></a> Library Reference
## <a id="global-functions"></a> Global functions
Function | Description
--------------------------------|-----------------------
regex(pattern, text) | Returns true if the regex pattern matches the text, false otherwise.
match(pattern, text) | Returns true if the wildcard pattern matches the text, false otherwise.
cidr_match(pattern, ip) | Returns true if the CIDR pattern matches the IP address, false otherwise. IPv4 addresses are converted to IPv4-mapped IPv6 addresses before being matched against the pattern.
len(value) | Returns the length of the value, i.e. the number of elements for an array or dictionary, or the length of the string in bytes.
union(array, array, ...) | Returns an array containing all unique elements from the specified arrays.
intersection(array, array, ...) | Returns an array containing all unique elements which are common to all specified arrays.
keys(dict) | Returns an array containing the dictionary's keys.
string(value) | Converts the value to a string.
number(value) | Converts the value to a number.
bool(value) | Converts the value to a bool.
random() | Returns a random value between 0 and RAND_MAX (as defined in stdlib.h).
log(value) | Writes a message to the log. Non-string values are converted to a JSON string.
log(severity, facility, value) | Writes a message to the log. `severity` can be one of `LogDebug`, `LogNotice`, `LogInformation`, `LogWarning`, and `LogCritical`. Non-string values are converted to a JSON string.
typeof(value) | Returns the [Type](18-library-reference.md#type-type) object for a value.
get_time() | Returns the current UNIX timestamp.
parse_performance_data(pd) | Parses a performance data string and returns an array describing the values.
dirname(path) | Returns the directory portion of the specified path.
basename(path) | Returns the filename portion of the specified path.
escape\_shell\_arg(text) | Escapes a string for use as a single shell argument.
escape\_shell\_cmd(text) | Escapes shell meta characters in a string.
escape\_create\_process\_arg(text)| (Windows only) Escapes a string for use as an argument for CreateProcess().
exit(integer) | Terminates the application.
sleep(interval) | Sleeps for the specified amount of time (in seconds).
## <a id="object-accessor-functions"></a> Object Accessor Functions
These functions can be used to retrieve a reference to another object by name.
### <a id="objref-get_check_command"></a> get_check_command
Signature:
function get_check_command(name);
Returns the CheckCommand object with the specified name, or `null` if no such CheckCommand object exists.
### <a id="objref-get_event_command"></a> get_event_command
Signature:
function get_event_command(name);
Returns the EventCommand object with the specified name, or `null` if no such EventCommand object exists.
### <a id="objref-get_notification_command"></a> get_notification_command
Signature:
function get_notification_command(name);
Returns the NotificationCommand object with the specified name, or `null` if no such NotificationCommand object exists.
### <a id="objref-get_host"></a> get_host
Signature:
function get_host(host_name);
Returns the Host object with the specified name, or `null` if no such Host object exists.
### <a id="objref-get_service"></a> get_service
Signature:
function get_service(host_name, service_name);
Returns the Service object with the specified name, or `null` if no such Service object exists.
### <a id="objref-get_user"></a> get_user
Signature:
function get_user(name);
Returns the User object with the specified name, or `null` if no such User object exists.
### <a id="objref-get_host_group"></a> get_host_group
Signature:
function get_host_group(name);
Returns the HostGroup object with the specified name, or `null` if no such HostGroup object exists.
### <a id="objref-get_service_group"></a> get_service_group
Signature:
function get_service_group(name);
Returns the ServiceGroup object with the specified name, or `null` if no such ServiceGroup object exists.
### <a id="objref-get_user_group"></a> get_user_group
Signature:
function get_user_group(name);
Returns the UserGroup object with the specified name, or `null` if no such UserGroup object exists.
### <a id="objref-get_time_period"></a> get_time_period
Signature:
function get_time_period(name);
Returns the TimePeriod object with the specified name, or `null` if no such TimePeriod object exists.
### <a id="objref-get_object"></a> get_object
Signature:
function get_object(type, name);
Returns the object with the specified type and name, or `null` if no such object exists. `type` must refer
to a type object.
### <a id="objref-get_objects"></a> get_objects
Signature:
function get_objects(type);
Returns an array of objects whose type matches the specified type. `type` must refer
to a type object.
## <a id="math-object"></a> Math object
The global `Math` object can be used to access a number of mathematical constants
and functions.
### <a id="math-e"></a> Math.E
Euler's constant.
### <a id="math-ln2"></a> Math.LN2
Natural logarithm of 2.
### <a id="math-ln10"></a> Math.LN10
Natural logarithm of 10.
### <a id="math-log2e"></a> Math.LOG2E
Base 2 logarithm of E.
### <a id="math-pi"></a> Math.PI
The mathematical constant Pi.
### <a id="math-sqrt1_2"></a> Math.SQRT1_2
Square root of 1/2.
### <a id="math-sqrt2"></a> Math.SQRT2
Square root of 2.
### <a id="math-abs"></a> Math.abs
Signature:
function abs(x);
Returns the absolute value of `x`.
### <a id="math-acos"></a> Math.acos
Signature:
function acos(x);
Returns the arccosine of `x`.
### <a id="math-asin"></a> Math.asin
Signature:
function asin(x);
Returns the arcsine of `x`.
### <a id="math-atan"></a> Math.atan
Signature:
function atan(x);
Returns the arctangent of `x`.
### <a id="math-atan2"></a> Math.atan2
Signature:
function atan2(y, x);
Returns the arctangent of the quotient of `y` and `x`.
### <a id="math-ceil"></a> Math.ceil
Signature:
function ceil(x);
Returns the smallest integer value not less than `x`.
### <a id="math-cos"></a> Math.cos
Signature:
function cos(x);
Returns the cosine of `x`.
### <a id="math-exp"></a> Math.exp
Signature:
function exp(x);
Returns E raised to the `x`th power.
### <a id="math-floor"></a> Math.floor
Signature:
function floor(x);
Returns the largest integer value not greater than `x`.
### <a id="math-isinf"></a> Math.isinf
Signature:
function isinf(x);
Returns whether `x` is infinite.
### <a id="math-isnan"></a> Math.isnan
Signature:
function isnan(x);
Returns whether `x` is NaN (not-a-number).
### <a id="math-log"></a> Math.log
Signature:
function log(x);
Returns the natural logarithm of `x`.
### <a id="math-max"></a> Math.max
Signature:
function max(...);
Returns the largest argument. A variable number of arguments can be specified.
If no arguments are given, -Infinity is returned.
### <a id="math-min"></a> Math.min
Signature:
function min(...);
Returns the smallest argument. A variable number of arguments can be specified.
If no arguments are given, +Infinity is returned.
### <a id="math-pow"></a> Math.pow
Signature:
function pow(x, y);
Returns `x` raised to the `y`th power.
### <a id="math-random"></a> Math.random
Signature:
function random();
Returns a pseudo-random number between 0 and 1.
### <a id="math-round"></a> Math.round
Signature:
function round(x);
Returns `x` rounded to the nearest integer value.
### <a id="math-sign"></a> Math.sign
Signature:
function sign(x);
Returns -1 if `x` is negative, 1 if `x` is positive
and 0 if `x` is 0.
### <a id="math-sin"></a> Math.sin
Signature:
function sin(x);
Returns the sine of `x`.
### <a id="math-sqrt"></a> Math.sqrt
Signature:
function sqrt(x);
Returns the square root of `x`.
### <a id="math-tan"></a> Math.tan
Signature:
function tan(x);
Returns the tangent of `x`.
## <a id="json-object"></a> Json object
The global `Json` object can be used to encode and decode JSON.
### <a id="json-encode"></a> Json.encode
Signature:
function encode(x);
Encodes an arbitrary value into JSON.
### <a id="json-decode"></a> Json.decode
Signature:
function decode(x);
Decodes a JSON string.
## <a id="number-type"></a> Number type
### <a id="number-to_string"></a> Number#to_string
Signature:
function to_string();
The `to_string` method returns a string representation of the number.
Example:
var example = 7
example.to_string() /* Returns "7" */
## <a id="boolean-type"></a> Boolean type
### <a id="boolean-to_string"></a> Boolean#to_string
Signature:
function to_string();
The `to_string` method returns a string representation of the boolean value.
Example:
var example = true
example.to_string() /* Returns "true" */
## <a id="string-type"></a> String type
### <a id="string-find"></a> String#find
Signature:
function find(str, start);
Returns the zero-based index at which the string `str` was found in the string. If the string
was not found, -1 is returned. `start` specifies the zero-based index at which `find` should
start looking for the string (defaults to 0 when not specified).
Example:
"Hello World".find("World") /* Returns 6 */
### <a id="string-contains"></a> String#contains
Signature:
function contains(str);
Returns `true` if the string `str` was found in the string. If the string
was not found, `false` is returned. Use [find](18-library-reference.md#string-find)
for getting the index instead.
Example:
"Hello World".contains("World") /* Returns true */
### <a id="string-len"></a> String#len
Signature
function len();
Returns the length of the string in bytes. Note that depending on the encoding type of the string
this is not necessarily the number of characters.
Example:
"Hello World".len() /* Returns 11 */
### <a id="string-lower"></a> String#lower
Signature:
function lower();
Returns a copy of the string with all of its characters converted to lower-case.
Example:
"Hello World".lower() /* Returns "hello world" */
### <a id="string-upper"></a> String#upper
Signature:
function upper();
Returns a copy of the string with all of its characters converted to upper-case.
Example:
"Hello World".upper() /* Returns "HELLO WORLD" */
### <a id="string-replace"></a> String#replace
Signature:
function replace(search, replacement);
Returns a copy of the string with all occurences of the string specified in `search` replaced
with the string specified in `replacement`.
### <a id="string-split"></a> String#split
Signature:
function split(delimiters);
Splits a string into individual parts and returns them as an array. The `delimiters` argument
specifies the characters which should be used as delimiters between parts.
Example:
"x-7,y".split("-,") /* Returns [ "x", "7", "y" ] */
### <a id="string-substr"></a> String#substr
Signature:
function substr(start, len);
Returns a part of a string. The `start` argument specifies the zero-based index at which the part begins.
The optional `len` argument specifies the length of the part ("until the end of the string" if omitted).
Example:
"Hello World".substr(6) /* Returns "World" */
### <a id="string-to_string"></a> String#to_string
Signature:
function to_string();
Returns a copy of the string.
### <a id="string-reverse"></a> String#reverse
Signature:
function reverse();
Returns a copy of the string in reverse order.
### <a id="string-trim"></a> String#trim
Signature:
function trim();
Removes trailing whitespaces and returns the string.
## <a id="object-type"></a> Object type
This is the base type for all types in the Icinga application.
### <a id="object-clone"></a> Object#clone
Signature:
function clone();
Returns a copy of the object. Note that for object elements which are
reference values (e.g. objects such as arrays or dictionaries) the entire
object is recursively copied.
### <a id="object-to-string"></a> Object#to_string
Signature:
function to_string();
Returns a string representation for the object. Unless overridden this returns a string
of the format "Object of type '<typename>'" where <typename> is the name of the
object's type.
Example:
[ 3, true ].to_string() /* Returns "[ 3.000000, true ]" */
### <a id="object-type-field"></a> Object#type
Signature:
String type;
Returns the object's type name. This attribute is read-only.
Example:
get_host("localhost").type /* Returns "Host" */
## <a id="type-type"></a> Type type
Inherits methods from the [Object type](18-library-reference.md#object-type).
The `Type` type provides information about the underlying type of an object or scalar value.
All types are registered as global variables. For example, in order to obtain a reference to the `String` type the global variable `String` can be used.
### <a id="type-base"></a> Type#base
Signature:
Type base;
Returns a reference to the type's base type. This attribute is read-only.
Example:
Dictionary.base == Object /* Returns true, because the Dictionary type inherits directly from the Object type. */
### <a id="type-name"></a> Type#name
Signature:
String name;
Returns the name of the type.
### <a id="type-prototype"></a> Type#prototype
Signature:
Object prototype;
Returns the prototype object for the type. When an attribute is accessed on an object that doesn't exist the prototype object is checked to see if an attribute with the requested name exists. If it does, the attribute's value is returned.
The prototype functionality is used to implement methods.
Example:
3.to_string() /* Even though '3' does not have a to_string property the Number type's prototype object does. */
## <a id="array-type"></a> Array type
Inherits methods from the [Object type](18-library-reference.md#object-type).
### <a id="array-add"></a> Array#add
Signature:
function add(value);
Adds a new value after the last element in the array.
### <a id="array-clear"></a> Array#clear
Signature:
function clear();
Removes all elements from the array.
### <a id="array-shallow-clone"></a> Array#shallow_clone
function shallow_clone();
Returns a copy of the array. Note that for elements which are reference values (e.g. objects such
as arrays and dictionaries) only the references are copied.
### <a id="array-contains"></a> Array#contains
Signature:
function contains(value);
Returns true if the array contains the specified value, false otherwise.
### <a id="array-len"></a> Array#len
Signature:
function len();
Returns the number of elements contained in the array.
### <a id="array-remove"></a> Array#remove
Signature:
function remove(index);
Removes the element at the specified zero-based index.
### <a id="array-set"></a> Array#set
Signature:
function set(index, value);
Sets the element at the zero-based index to the specified value. The `index` must refer to an element
which already exists in the array.
### <a id="array-get"></a> Array#get
Signature:
function get(index);
Retrieves the element at the specified zero-based index.
### <a id="array-sort"></a> Array#sort
Signature:
function sort(less_cmp);
Returns a copy of the array where all items are sorted. The items are
compared using the `<` (less-than) operator. A custom comparator function
can be specified with the `less_cmp` argument.
### <a id="array-join"></a> Array#join
Signature:
function join(separator);
Joins all elements of the array using the specified separator.
### <a id="array-reverse"></a> Array#reverse
Signature:
function reverse();
Returns a new array with all elements of the current array in reverse order.
### <a id="array-map"></a> Array#map
Signature:
function map(func);
Calls `func(element)` for each of the elements in the array and returns
a new array containing the return values of these function calls.
### <a id="array-reduce"></a> Array#reduce
Signature:
function reduce(func);
Reduces the elements of the array into a single value by calling the provided
function `func` as `func(a, b)` repeatedly where `a` and `b` are elements of the array
or results from previous function calls.
### <a id="array-filter"></a> Array#filter
Signature:
function filter(func);
Returns a copy of the array containing only the elements for which `func(element)`
is true.
### <a id="array-unique"></a> Array#unique
Signature:
function unique();
Returns a copy of the array with all duplicate elements removed. The original order
of the array is not preserved.
## <a id="dictionary-type"></a> Dictionary type
Inherits methods from the [Object type](18-library-reference.md#object-type).
### <a id="dictionary-shallow-clone"></a> Dictionary#shallow_clone
Signature:
function shallow_clone();
Returns a copy of the dictionary. Note that for elements which are reference values (e.g. objects such
as arrays and dictionaries) only the references are copied.
### <a id="dictionary-contains"></a> Dictionary#contains
Signature:
function contains(key);
Returns true if a dictionary item with the specified `key` exists, false otherwise.
### <a id="dictionary-len"></a> Dictionary#len
Signature:
function len();
Returns the number of items contained in the dictionary.
### <a id="dictionary-remove"></a> Dictionary#remove
Signature:
function remove(key);
Removes the item with the specified `key`. Trying to remove an item which does not exist
is a no-op.
### <a id="dictionary-set"></a> Dictionary#set
Signature:
function set(key, value);
Creates or updates an item with the specified `key` and `value`.
### <a id="dictionary-get"></a> Dictionary#get
Signature:
function get(key);
Retrieves the value for the specified `key`. Returns `null` if they `key` does not exist
in the dictionary.
### <a id="dictionary-keys"></a> Dictionary#keys
Signature:
function keys();
Returns a list of keys for all items that are currently in the dictionary.
## <a id="scriptfunction-type"></a> Function type
Inherits methods from the [Object type](18-library-reference.md#object-type).
### <a id="scriptfunction-call"></a> Function#call
Signature:
function call(thisArg, ...);
Invokes the function using an alternative `this` scope. The `thisArg` argument specifies the `this`
scope for the function. All other arguments are passed directly to the function.
Example:
function set_x(val) {
this.x = val
}
dict = {}
set_x.call(dict, 7) /* Invokes set_x using `dict` as `this` */
### <a id="scriptfunction-callv"></a> Function#callv
Signature:
function callv(thisArg, args);
Invokes the function using an alternative `this` scope. The `thisArg` argument specifies the `this`
scope for the function. The items in the `args` array are passed to the function as individual arguments.
Example:
function set_x(val) {
this.x = val
}
var dict = {}
var args = [ 7 ]
set_x.callv(dict, args) /* Invokes set_x using `dict` as `this` */
## <a id="datetime-type"></a> DateTime type
Inherits methods from the [Object type](18-library-reference.md#object-type).
### <a id="datetime-ctor"></a> DateTime constructor
Signature:
function DateTime()
function DateTime(unixTimestamp)
function DateTime(year, month, day)
function DateTime(year, month, day, hours, minutes, seconds)
Constructs a new DateTime object. When no arguments are specified for the constructor a new
DateTime object representing the current time is created.
Example:
var d1 = DateTime() /* current time */
var d2 = DateTime(2016, 5, 21) /* midnight April 21st, 2016 (local time) */
### <a id="datetime-arithmetic"></a> DateTime arithmetic
Subtracting two DateTime objects yields the interval between them, in seconds.
Example:
var delta = DateTime() - DateTime(2016, 5, 21) /* seconds since midnight April 21st, 2016 */
Subtracting a number from a DateTime object yields a new DateTime object that is further in the past:
Example:
var dt = DateTime() - 2 * 60 * 60 /* Current time minus 2 hours */
Adding a number to a DateTime object yields a new DateTime object that is in the future:
Example:
var dt = DateTime() + 24 * 60 60 /* Current time plus 24 hours */
### <a id="datetime-format"></a> DateTime#format
Signature:
function format(fmt)
Returns a string representation for the DateTime object using the specified format string.
The format string may contain format conversion placeholders as specified in strftime(3).
Example:
var s = DateTime(2016, 4, 21).format("%A") /* Sets s to "Thursday". */
### <a id="datetime-tostring"></a> DateTime#to_string
Signature:
function to_string()
Returns a string representation for the DateTime object. Uses a suitable default format.
Example:
var s = DateTime(2016, 4, 21).to_string() /* Sets s to "2016-04-21 00:00:00 +0200". */

View File

@ -0,0 +1,105 @@
# <a id="script-debugger"></a> Script Debugger
You can run the Icinga 2 daemon with the `-X` (`--script-debugger`)
parameter to enable the script debugger:
# icinga2 daemon -X
When an exception occurs or the [debugger](17-language-reference.md#breakpoints)
keyword is encountered in a user script, Icinga 2 launches a console that
allows the user to debug the script.
Here is a list of common errors which can be diagnosed with the script debugger:
* Configuration errors (apply)
* Errors in user-defined functions
## <a id="script-debugger-config-errors"></a> Debugging Configuration Errors
The following example illustrates the problem of a service [apply rule](3-monitoring-basics.md#using-apply-for)
which expects a dictionary value for `config`, but the host custom attribute only
provides a string value:
object Host "script-debugger-host" {
check_command = "icinga"
vars.http_vhosts["example.org"] = "192.168.1.100" // a string value
}
apply Service for (http_vhost => config in host.vars.http_vhosts) {
import "generic-service"
vars += config // expects a dictionary
check_command = "http"
}
The error message on config validation will warn about the wrong value type,
but does not provide any context which objects are affected.
Enable the script debugger and run the config validation:
# icinga2 daemon -C -X
Breakpoint encountered in /etc/icinga2/conf.d/services.conf: 59:67-65:1
Exception: Error: Error while evaluating expression: Cannot convert value of type 'String' to an object.
Location:
/etc/icinga2/conf.d/services.conf(62): check_command = "http"
/etc/icinga2/conf.d/services.conf(63):
/etc/icinga2/conf.d/services.conf(64): vars += config
^^^^^^^^^^^^^^
/etc/icinga2/conf.d/services.conf(65): }
/etc/icinga2/conf.d/services.conf(66):
You can inspect expressions (such as variables) by entering them at the prompt.
To leave the debugger and continue the program use "$continue".
<1> =>
You can print the variables `vars` and `config` to get an idea about
their values:
<1> => vars
null
<2> => config
"192.168.1.100"
<3> =>
The `vars` attribute has to be a dictionary. Trying to set this attribute to a string caused
the error in our configuration example.
In order to determine the name of the host where the value of the `config` variable came from
you can inspect attributes of the service object:
<3> => host_name
"script-debugger-host-01"
<4> => name
"http"
Additionally you can view the service object attributes by printing the value of `this`.
## <a id="script-debugger-breakpoints"></a> Using Breakpoints
In order to halt execution in a script you can use the `debugger` keyword:
object Host "script-debugger-host-02" {
check_command = "dummy"
check_interval = 5s
vars.dummy_text = {{
var text = "Hello from " + macro("$name$")
debugger
return text
}}
}
Icinga 2 will spawn a debugger console every time the function is executed:
# icinga2 daemon -X
...
Breakpoint encountered in /etc/icinga2/tests/script-debugger.conf: 7:5-7:12
You can inspect expressions (such as variables) by entering them at the prompt.
To leave the debugger and continue the program use "$continue".
<1> => text
"Hello from script-debugger-host-02"
<2> => $continue

View File

@ -0,0 +1,775 @@
# <a id="getting-started"></a> Getting Started
This tutorial is a step-by-step introduction to installing [Icinga 2](2-getting-started.md#setting-up-icinga2)
and [Icinga Web 2](2-getting-started.md#setting-up-icingaweb2).
It assumes that you are familiar with the operating system you're using to install Icinga 2.
## <a id="setting-up-icinga2"></a> Setting up Icinga 2
First off you will have to install Icinga 2. The preferred way of doing this
is to use the official package repositories depending on which operating system
and distribution you are running.
Distribution | Repository
------------------------|---------------------------
Debian | [debmon](https://debmon.org/packages/debmon-jessie/icinga2), [Icinga Repository](http://packages.icinga.org/debian/)
Ubuntu | [Icinga PPA](https://launchpad.net/~formorer/+archive/ubuntu/icinga), [Icinga Repository](http://packages.icinga.org/ubuntu/)
RHEL/CentOS | [Icinga Repository](http://packages.icinga.org/epel/)
openSUSE | [Icinga Repository](http://packages.icinga.org/openSUSE/), [Server Monitoring Repository](https://build.opensuse.org/package/show/server:monitoring/icinga2)
SLES | [Icinga Repository](http://packages.icinga.org/SUSE/)
Gentoo | [Upstream](http://packages.gentoo.org/package/net-analyzer/icinga2)
FreeBSD | [Upstream](http://www.freshports.org/net-mgmt/icinga2)
ArchLinux | [Upstream](https://aur.archlinux.org/packages/icinga2)
Packages for distributions other than the ones listed above may also be
available. Please contact your distribution packagers.
### <a id="package-repositories"></a> Package Repositories
You need to add the Icinga repository to your package management configuration.
Below is a list with examples for the various distributions.
Debian (debmon):
# wget -O - https://debmon.org/debmon/repo.key 2>/dev/null | apt-key add -
# echo 'deb http://debmon.org/debmon debmon-jessie main' >/etc/apt/sources.list.d/debmon.list
# apt-get update
Ubuntu (PPA):
# add-apt-repository ppa:formorer/icinga
# apt-get update
RHEL/CentOS 7:
yum install https://packages.icinga.org/epel/7/release/noarch/icinga-rpm-release-7-1.el7.centos.noarch.rpm
RHEL/CentOS 6:
yum install https://packages.icinga.org/epel/6/release/noarch/icinga-rpm-release-6-1.el6.noarch.rpm
RHEL/CentOS 5:
rpm -i http://packages.icinga.org/epel/5/release/noarch/icinga-rpm-release-5-1.el5.centos.noarch.rpm
Fedora 23:
dnf install https://packages.icinga.org/fedora/23/release/noarch/icinga-rpm-release-23-1.fc23.noarch.rpm
Fedora 22:
dnf install https://packages.icinga.org/fedora/22/release/noarch/icinga-rpm-release-22-1.fc22.noarch.rpm
Fedora 21:
yum install http://packages.icinga.org/fedora/21/release/noarch/icinga-rpm-release-21-1.fc21.noarch.rpm
SLES 11:
# zypper ar http://packages.icinga.org/SUSE/ICINGA-release-11.repo
# zypper ref
SLES 12:
# zypper ar http://packages.icinga.org/SUSE/ICINGA-release.repo
# zypper ref
openSUSE:
# zypper ar http://packages.icinga.org/openSUSE/ICINGA-release.repo
# zypper ref
#### <a id="package-repositories-rhel-epel"></a> RHEL/CentOS EPEL Repository
The packages for RHEL/CentOS depend on other packages which are distributed
as part of the [EPEL repository](http://fedoraproject.org/wiki/EPEL).
CentOS 7/6/5:
yum install epel-release
If you are using RHEL you need enable the `optional` repository and then install
the [EPEL rpm package](http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F).
#### <a id="package-repositories-sles-security"></a> SLES Security Repository
The packages for SLES 11 depend on the `openssl1` package which is distributed
as part of the [SLES 11 Security Module](https://www.suse.com/communities/conversations/introducing-the-suse-linux-enterprise-11-security-module/).
### <a id="installing-icinga2"></a> Installing Icinga 2
You can install Icinga 2 by using your distribution's package manager
to install the `icinga2` package.
Debian/Ubuntu:
# apt-get install icinga2
RHEL/CentOS 5/6:
# yum install icinga2
# chkconfig icinga2 on
# service icinga2 start
RHEL/CentOS 7 and Fedora:
# yum install icinga2
# systemctl enable icinga2
# systemctl start icinga2
SLES/openSUSE:
# zypper install icinga2
FreeBSD:
# pkg install icinga2
### <a id="installation-enabled-features"></a> Enabled Features during Installation
The default installation will enable three features required for a basic
Icinga 2 installation:
* `checker` for executing checks
* `notification` for sending notifications
* `mainlog` for writing the `icinga2.log` file
You can verify that by calling `icinga2 feature list`
[CLI command](11-cli-commands.md#cli-command-feature) to see which features are
enabled and disabled.
# icinga2 feature list
Disabled features: api command compatlog debuglog graphite icingastatus ido-mysql ido-pgsql livestatus notification perfdata statusdata syslog
Enabled features: checker mainlog notification
### <a id="installation-paths"></a> Installation Paths
By default Icinga 2 uses the following files and directories:
Path | Description
------------------------------------|------------------------------------
/etc/icinga2 | Contains Icinga 2 configuration files.
/etc/init.d/icinga2 | The Icinga 2 init script.
/usr/sbin/icinga2 | The Icinga 2 binary.
/usr/share/doc/icinga2 | Documentation files that come with Icinga 2.
/usr/share/icinga2/include | The Icinga Template Library and plugin command configuration.
/var/run/icinga2 | PID file.
/var/run/icinga2/cmd | Command pipe and Livestatus socket.
/var/cache/icinga2 | status.dat/objects.cache, icinga2.debug files
/var/spool/icinga2 | Used for performance data spool files.
/var/lib/icinga2 | Icinga 2 state file, cluster log, local CA and configuration files.
/var/log/icinga2 | Log file location and compat/ directory for the CompatLogger feature.
FreeBSD uses slightly different paths:
By default Icinga 2 uses the following files and directories:
Path | Description
------------------------------------|------------------------------------
/usr/local/etc/icinga2 | Contains Icinga 2 configuration files.
/usr/local/etc/rc.d/icinga2 | The Icinga 2 init script.
/usr/local/sbin/icinga2 | The Icinga 2 binary.
/usr/local/share/doc/icinga2 | Documentation files that come with Icinga 2.
/usr/local/share/icinga2/include | The Icinga Template Library and plugin command configuration.
/var/run/icinga2 | PID file.
/var/run/icinga2/cmd | Command pipe and Livestatus socket.
/var/cache/icinga2 | status.dat/objects.cache, icinga2.debug files
/var/spool/icinga2 | Used for performance data spool files.
/var/lib/icinga2 | Icinga 2 state file, cluster log, local CA and configuration files.
/var/log/icinga2 | Log file location and compat/ directory for the CompatLogger feature.
## <a id="setting-up-check-plugins"></a> Setting up Check Plugins
Without plugins Icinga 2 does not know how to check external services. The
[Monitoring Plugins Project](https://www.monitoring-plugins.org/) provides
an extensive set of plugins which can be used with Icinga 2 to check whether
services are working properly.
These plugins are required to make the [example configuration](4-configuring-icinga-2.md#configuring-icinga2-overview)
work out-of-the-box.
For your convenience here is a list of package names for some of the more
popular operating systems/distributions:
OS/Distribution | Package Name | Repository | Installation Path
-----------------------|--------------------|---------------------------|----------------------------
RHEL/CentOS | nagios-plugins-all | [EPEL](http://fedoraproject.org/wiki/EPEL) | /usr/lib/nagios/plugins or /usr/lib64/nagios/plugins
SLES/OpenSUSE | monitoring-plugins | [server:monitoring](https://build.opensuse.org/project/repositories/server:monitoring) | /usr/lib/nagios/plugins
Debian/Ubuntu | nagios-plugins | - | /usr/lib/nagios/plugins
FreeBSD | monitoring-plugins | - | /usr/local/libexec/nagios
OS X | nagios-plugins | [MacPorts](http://www.macports.org), [Homebrew](http://brew.sh) | /opt/local/libexec or /usr/local/sbin
The recommended way of installing these standard plugins is to use your
distribution's package manager.
Debian/Ubuntu:
# apt-get install nagios-plugins
RHEL/CentOS:
# yum install nagios-plugins-all
The packages for RHEL/CentOS depend on other packages which are distributed
as part of the [EPEL repository](http://fedoraproject.org/wiki/EPEL). Please
make sure to enable this repository by following
[these instructions](http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F).
Fedora:
# dnf install nagios-plugins-all
SLES/openSUSE:
# zypper install monitoring-plugins
The packages for SLES/OpenSUSE depend on other packages which are distributed
as part of the [server:monitoring repository](https://build.opensuse.org/project/repositories/server:monitoring).
Please make sure to enable this repository beforehand.
FreeBSD:
# pkg install monitoring-plugins
Depending on which directory your plugins are installed into you may need to
update the global `PluginDir` constant in your [Icinga 2 configuration](4-configuring-icinga-2.md#constants-conf).
This constant is used by the check command definitions contained in the Icinga Template Library
to determine where to find the plugin binaries.
> **Note**
>
> Please refer to the [service monitoring](5-service-monitoring.md#service-monitoring-plugins) chapter for details about how to integrate
> additional check plugins into your Icinga 2 setup.
## <a id="running-icinga2"></a> Running Icinga 2
### <a id="init-script"></a> Init Script
Icinga 2's init script is installed in `/etc/init.d/icinga2` (`/usr/local/etc/rc.d/icinga2` on FreeBSD) by default:
# /etc/init.d/icinga2
Usage: /etc/init.d/icinga2 {start|stop|restart|reload|checkconfig|status}
The init script supports the following actions:
Command | Description
--------------------|------------------------
start | The `start` action starts the Icinga 2 daemon.
stop | The `stop` action stops the Icinga 2 daemon.
restart | The `restart` action is a shortcut for running the `stop` action followed by `start`.
reload | The `reload` action sends the `HUP` signal to Icinga 2 which causes it to restart. Unlike the `restart` action `reload` does not wait until Icinga 2 has restarted.
checkconfig | The `checkconfig` action checks if the `/etc/icinga2/icinga2.conf` configuration file contains any errors.
status | The `status` action checks if Icinga 2 is running.
By default the Icinga 2 daemon is running as `icinga` user and group
using the init script. Using Debian packages the user and group are set to
`nagios` for historical reasons.
### <a id="systemd-service"></a> systemd Service
Some distributions (e.g. Fedora, openSUSE and RHEL/CentOS 7) use systemd. The
Icinga 2 packages automatically install the necessary systemd unit files.
The Icinga 2 systemd service can be (re-)started, reloaded, stopped and also
queried for its current status.
# systemctl status icinga2
icinga2.service - Icinga host/service/network monitoring system
Loaded: loaded (/usr/lib/systemd/system/icinga2.service; disabled)
Active: active (running) since Mi 2014-07-23 13:39:38 CEST; 15s ago
Process: 21692 ExecStart=/usr/sbin/icinga2 -c ${ICINGA2_CONFIG_FILE} -d -e ${ICINGA2_ERROR_LOG} -u ${ICINGA2_USER} -g ${ICINGA2_GROUP} (code=exited, status=0/SUCCESS)
Process: 21674 ExecStartPre=/usr/sbin/icinga2-prepare-dirs /etc/sysconfig/icinga2 (code=exited, status=0/SUCCESS)
Main PID: 21727 (icinga2)
CGroup: /system.slice/icinga2.service
21727 /usr/sbin/icinga2 -c /etc/icinga2/icinga2.conf -d -e /var/log/icinga2/error.log -u icinga -g icinga --no-stack-rlimit
Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 309 Service(s).
Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 1 User(s).
Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 15 Notification(s).
Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 4 ScheduledDowntime(s).
Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 1 UserGroup(s).
Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 1 IcingaApplication(s).
Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 8 Dependency(s).
Jul 23 13:39:38 nbmif systemd[1]: Started Icinga host/service/network monitoring system.
The `systemctl` command supports the following actions:
Command | Description
--------------------|------------------------
start | The `start` action starts the Icinga 2 daemon.
stop | The `stop` action stops the Icinga 2 daemon.
restart | The `restart` action is a shortcut for running the `stop` action followed by `start`.
reload | The `reload` action sends the `HUP` signal to Icinga 2 which causes it to restart. Unlike the `restart` action `reload` does not wait until Icinga 2 has restarted.
status | The `status` action checks if Icinga 2 is running.
enable | The `enable` action enables the service being started at system boot time (similar to `chkconfig`)
Examples:
# systemctl enable icinga2
# systemctl restart icinga2
Job for icinga2.service failed. See 'systemctl status icinga2.service' and 'journalctl -xn' for details.
If you're stuck with configuration errors, you can manually invoke the
[configuration validation](11-cli-commands.md#config-validation).
### FreeBSD
On FreeBSD you need to enable icinga2 in your rc.conf
# sysrc icinga2_enable=yes
# service icinga2 restart
## <a id="configuration-syntax-highlighting"></a> Configuration Syntax Highlighting
Icinga 2 ships configuration examples for syntax highlighting using the `vim` and `nano` editors.
The RHEL and SUSE package `icinga2-common` installs these files into `/usr/share/doc/icinga2-common-[x.x.x]/syntax`
(where `[x.x.x]` is the version number, e.g. `2.4.3` or `2.4.4`). Sources provide these files in `tools/syntax`.
On Debian systems the `icinga2-common` package provides only the Nano configuration file (`/usr/share/nano/icinga2.nanorc`);
to obtain the Vim configuration, please install the extra package `vim-icinga2`. The files are located in `/usr/share/vim/addons`.
### <a id="configuration-syntax-highlighting-vim"></a> Configuration Syntax Highlighting using Vim
Install the package `vim-icinga2` with your distribution's package manager.
Debian/Ubuntu:
$ apt-get install vim-icinga2 vim-addon-manager
$ vim-addon-manager -w install icinga2
Info: installing removed addon 'icinga2' to /var/lib/vim/addons
RHEL/CentOS/Fedora:
$ yum install vim-icinga2
SLES/openSUSE:
$ zypper install vim-icinga2
Ensure that syntax highlighting is enabled e.g. by editing the user's `vimrc`
configuration file:
$ vim ~/.vimrc
syntax on
Test it:
$ vim /etc/icinga2/conf.d/templates.conf
![Vim with syntax highlighting](images/getting-started/vim-syntax.png "Vim with Icinga 2 syntax highlighting")
### <a id="configuration-syntax-highlighting-nano"></a> Configuration Syntax Highlighting using Nano
Install the package `nano-icinga2` with your distribution's package manager.
Debian/Ubuntu:
**Note:** The syntax files are installed with the `icinga2-common` package already.
RHEL/CentOS/Fedora:
$ yum install nano-icinga2
SLES/openSUSE:
$ zypper install nano-icinga2
Copy the `/etc/nanorc` sample file to your home directory.
$ cp /etc/nanorc ~/.nanorc
Include the `icinga2.nanorc` file.
$ vim ~/.nanorc
## Icinga 2
include "/usr/share/nano/icinga2.nanorc"
Test it:
$ nano /etc/icinga2/conf.d/templates.conf
![Nano with syntax highlighting](images/getting-started/nano-syntax.png "Nano with Icinga 2 syntax highlighting")
## <a id="setting-up-icingaweb2"></a> Setting up Icinga Web 2
Icinga 2 can be used with Icinga Web 2 and a number of other web interfaces.
This chapter explains how to set up Icinga Web 2.
The DB IDO (Database Icinga Data Output) modules for Icinga 2 take care of
exporting all configuration and status information into a database. The IDO
database is used by a number of projects including
[Icinga Web 2](2-getting-started.md#setting-up-icingaweb2), Icinga Reporting
or Icinga Web 1.x.
There is a separate module for each database backend. At present support for
both MySQL and PostgreSQL is implemented.
### <a id="configuring-db-ido-mysql"></a> Configuring DB IDO MySQL
#### <a id="installing-database-mysql-server"></a> Installing MySQL database server
Debian/Ubuntu:
# apt-get install mysql-server mysql-client
RHEL/CentOS 5/6:
# yum install mysql-server mysql
# chkconfig mysqld on
# service mysqld start
# mysql_secure_installation
RHEL/CentOS 7 and Fedora:
# yum install mariadb-server mariadb
# systemctl enable mariadb
# systemctl start mariadb
# mysql_secure_installation
SUSE:
# zypper install mysql mysql-client
# chkconfig mysqld on
# service mysqld start
FreeBSD:
# pkg install mysql56-server
# sysrc mysql_enable=yes
# service mysql-server restart
# mysql_secure_installation
#### <a id="installing-database-mysql-modules"></a> Installing the IDO modules for MySQL
The next step is to install the `icinga2-ido-mysql` package using your
distribution's package manager.
Debian/Ubuntu:
# apt-get install icinga2-ido-mysql
RHEL/CentOS:
# yum install icinga2-ido-mysql
SUSE:
# zypper install icinga2-ido-mysql
FreeBSD:
On FreeBSD the IDO modules for MySQL are included with the icinga2 package
and located at /usr/local/share/icinga2-ido-mysql/schema/mysql.sql
> **Note**
>
> The Debian/Ubuntu packages provide a database configuration wizard by
> default. You can skip the automated setup and install/upgrade the
> database manually if you prefer that.
#### <a id="setting-up-mysql-db"></a> Setting up the MySQL database
Set up a MySQL database for Icinga 2:
# mysql -u root -p
mysql> CREATE DATABASE icinga;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';
mysql> quit
![setting up the database on CentOS 7](images/getting-started/mariadb-centos7.png "Setting up the database on CentOS 7")
After creating the database you can import the Icinga 2 IDO schema using the
following command:
# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
#### <a id="enabling-ido-mysql"></a> Enabling the IDO MySQL module
The package provides a new configuration file that is installed in
`/etc/icinga2/features-available/ido-mysql.conf`. You will need to
update the database credentials in this file.
All available attributes are explained in the
[IdoMysqlConnection object](9-object-types.md#objecttype-idomysqlconnection)
chapter.
You can enable the `ido-mysql` feature configuration file using
`icinga2 feature enable`:
# icinga2 feature enable ido-mysql
Module 'ido-mysql' was enabled.
Make sure to restart Icinga 2 for these changes to take effect.
After enabling the ido-mysql feature you have to restart Icinga 2:
Debian/Ubuntu, RHEL/CentOS 6 and SUSE:
# service icinga2 restart
RHEL/CentOS 7 and Fedora:
# systemctl restart icinga2
FreeBSD:
# service icinga2 restart
### <a id="configuring-db-ido-postgresql"></a> Configuring DB IDO PostgreSQL
#### <a id="installing-database-postgresql-server"></a> Installing PostgreSQL database server
Debian/Ubuntu:
# apt-get install postgresql
RHEL/CentOS 5/6:
# yum install postgresql-server postgresql
# chkconfig postgresql on
# service postgresql start
RHEL/CentOS 7:
# yum install postgresql-server postgresql
# postgresql-setup initdb
# systemctl enable postgresql
# systemctl start postgresql
SUSE:
# zypper install postgresql postgresql-server
# chkconfig postgresql on
# service postgresql start
FreeBSD:
# pkg install postgresql93-server
# sysrc postgresql_enable=yes
# service postgresql start
#### <a id="installing-database-postgresql-modules"></a> Installing the IDO modules for PostgreSQL
The next step is to install the `icinga2-ido-pgsql` package using your
distribution's package manager.
Debian/Ubuntu:
# apt-get install icinga2-ido-pgsql
RHEL/CentOS:
# yum install icinga2-ido-pgsql
SUSE:
# zypper install icinga2-ido-pgsql
FreeBSD:
On FreeBSD the IDO modules for PostgreSQL are included with the icinga2 package
and located at /usr/local/share/icinga2-ido-pgsql/schema/pgsql.sql
> **Note**
>
> Upstream Debian packages provide a database configuration wizard by default.
> You can skip the automated setup and install/upgrade the database manually
> if you prefer that.
#### Setting up the PostgreSQL database
Set up a PostgreSQL database for Icinga 2:
# cd /tmp
# sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD 'icinga'"
# sudo -u postgres createdb -O icinga -E UTF8 icinga
# sudo -u postgres createlang plpgsql icinga
> **Note**
>
> When using PostgreSQL 9.x you can omit the `createlang` command.
> Also it is assumed here that your locale is set to utf-8, you may run into
> problems otherwise.
Locate your pg\_hba.conf (Debian: `/etc/postgresql/*/main/pg_hba.conf`,
RHEL/SUSE: `/var/lib/pgsql/data/pg_hba.conf`), add the icinga user with md5
authentication method and restart the postgresql server.
# icinga
local icinga icinga md5
host icinga icinga 127.0.0.1/32 md5
host icinga icinga ::1/128 md5
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# service postgresql restart
After creating the database and permissions you can import the Icinga 2 IDO
schema using the following command:
# export PGPASSWORD=icinga
# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql
![importing the Icinga 2 IDO schema](images/getting-started/postgr-import-ido.png "Importing the Icinga 2 IDO schema on Debian Jessie")
#### <a id="enabling-ido-postgresql"></a> Enabling the IDO PostgreSQL module
The package provides a new configuration file that is installed in
`/etc/icinga2/features-available/ido-pgsql.conf`. You will need to update
the database credentials in this file.
All available attributes are explained in the
[IdoPgsqlConnection object](9-object-types.md#objecttype-idopgsqlconnection)
chapter.
You can enable the `ido-pgsql` feature configuration file using
`icinga2 feature enable`:
# icinga2 feature enable ido-pgsql
Module 'ido-pgsql' was enabled.
Make sure to restart Icinga 2 for these changes to take effect.
After enabling the ido-pgsql feature you have to restart Icinga 2:
Debian/Ubuntu, RHEL/CentOS 6, SUSE and FreeBSD:
# service icinga2 restart
RHEL/CentOS 7 and Fedora:
# systemctl restart icinga2
### <a id="icinga2-user-interface-webserver"></a> Webserver
Debian/Ubuntu:
# apt-get install apache2
RHEL/CentOS 6:
# yum install httpd
# chkconfig httpd on
# service httpd start
RHEL/CentOS 7/Fedora:
# yum install httpd
# systemctl enable httpd
# systemctl start httpd
SUSE:
# zypper install apache2
# chkconfig on
# service apache2 start
FreeBSD (nginx, but you could also use the apache24 package):
# pkg install nginx php56-gettext php56-ldap php56-openssl php56-mysql php56-pdo_mysql php56-pgsql php56-pdo_pgsql php56-sockets php56-gd pecl-imagick pecl-intl
# sysrc php_fpm_enable=yes
# sysrc nginx_enable=yes
# sed -i '' "s/listen\ =\ 127.0.0.1:9000/listen\ =\ \/var\/run\/php5-fpm.sock/" /usr/local/etc/php-fpm.conf
# sed -i '' "s/;listen.owner/listen.owner/" /usr/local/etc/php-fpm.conf
# sed -i '' "s/;listen.group/listen.group/" /usr/local/etc/php-fpm.conf
# sed -i '' "s/;listen.mode/listen.mode/" /usr/local/etc/php-fpm.conf
# service php-fpm start
# service nginx start
### <a id="icinga2-user-interface-firewall-rules"></a> Firewall Rules
Example:
# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# service iptables save
RHEL/CentOS 7 specific:
# firewall-cmd --add-service=http
# firewall-cmd --permanent --add-service=http
FreeBSD:
Please consult the [FreeBSD Handbook](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/firewalls.html) how to configure one of FreeBSD's firewalls.
### <a id="setting-up-external-command-pipe"></a> Setting Up External Command Pipe
Web interfaces and other Icinga addons are able to send commands to
Icinga 2 through the external command pipe.
You can enable the External Command Pipe using the CLI:
# icinga2 feature enable command
After that you will have to restart Icinga 2:
Debian/Ubuntu, RHEL/CentOS 6 and SUSE:
# service icinga2 restart
RHEL/CentOS 7 and Fedora:
# systemctl restart icinga2
FreeBSD:
# service icinga2 restart
By default the command pipe file is owned by the group `icingacmd` with
read/write permissions. Add your webserver's user to the group `icingacmd` to
enable sending commands to Icinga 2 through your web interface:
# usermod -a -G icingacmd www-data
FreeBSD:
On FreeBSD the rw directory is owned by the group `www`. You do not need to add the
user `icinga` to the group `www`.
Debian packages use `nagios` as the default user and group name. Therefore
change `icingacmd` to `nagios`.
The webserver's user is different between distributions so you might have to
change `www-data` to `wwwrun`, `www`, or `apache`.
Change `www-data` to the user you're using to run queries.
You can verify that the user has been successfully added to the `icingacmd`
group using the `id` command:
$ id <your-webserver-user>
![id command on CentOS 7](images/getting-started/id-apache-centos7.png "Confirm that the webserver's user
(here: `apache` on a CentOS 7 system) is a member of the group `icingacmd`.")
### <a id="installing-icingaweb2"></a> Installing Icinga Web 2
Please consult the [installation documentation](https://github.com/Icinga/icingaweb2/blob/master/doc/02-Installation.md)
for further instructions on how to install Icinga Web 2.
## <a id="install-addons"></a> Addons
A number of additional features are available in the form of addons. A list of
popular addons is available in the
[Addons and Plugins](13-addons.md#addons) chapter.
## <a id="install-backup"></a> Backup
Ensure to include the following in your backups:
* Configuration files in `/etc/icinga2`
* Runtime files in `/var/lib/icinga2` (the master's CA is stored here as well)
* Optional: IDO database backup

View File

@ -0,0 +1,318 @@
# <a id="development"></a> Develop Icinga 2
This chapter provides hints on Icinga 2 development
especially for debugging purposes.
> **Note**
>
> If you are planning to build your own development environment,
> please consult the `INSTALL.md` file from the source tree.
## <a id="debug-requirements"></a> Debug Requirements
Make sure that the debug symbols are available for Icinga 2.
The Icinga 2 packages provide a debug package which must be
installed separately for all involved binaries, like `icinga2-bin`
or `icinga2-ido-mysql`.
Debian/Ubuntu:
# apt-get install icinga2-dbg
RHEL/CentOS:
# yum install icinga2-debuginfo
SLES/openSUSE:
# zypper install icinga2-bin-debuginfo icinga2-ido-mysql-debuginfo
Furthermore, you may also have to install debug symbols for Boost and your C library.
If you're building your own binaries, you should use the `-DCMAKE_BUILD_TYPE=Debug` cmake
build flag for debug builds.
## <a id="development-debug-gdb"></a> GDB
Install gdb:
Debian/Ubuntu:
# apt-get install gdb
RHEL/CentOS/Fedora:
# yum install gdb
SLES/openSUSE:
# zypper install gdb
Install the `boost`, `python` and `icinga2` pretty printers. Absolute paths are required,
so please make sure to update the installation paths accordingly (`pwd`).
$ mkdir -p ~/.gdb_printers && cd ~/.gdb_printers
Boost Pretty Printers compatible with Python 3:
$ git clone https://github.com/mateidavid/Boost-Pretty-Printer.git && cd Boost-Pretty-Printer
$ git checkout python-3
$ pwd
/home/michi/.gdb_printers/Boost-Pretty-Printer
Python Pretty Printers:
$ cd ~/.gdb_printers
$ svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
Icinga 2 Pretty Printers:
$ mkdir -p ~/.gdb_printers/icinga2 && cd ~/.gdb_printers/icinga2
$ wget https://raw.githubusercontent.com/Icinga/icinga2/master/tools/debug/gdb/icingadbg.py
Now you'll need to modify/setup your `~/.gdbinit` configuration file.
You can download the one from Icinga 2 and modify all paths.
Example on Fedora 22:
$ wget https://raw.githubusercontent.com/Icinga/icinga2/master/tools/debug/gdb/gdbinit -O ~/.gdbinit
$ vim ~/.gdbinit
set print pretty on
python
import sys
sys.path.insert(0, '/home/michi/.gdb_printers/icinga2')
from icingadbg import register_icinga_printers
register_icinga_printers()
end
python
import sys
sys.path.insert(0, '/home/michi/.gdb_printers/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
try:
register_libstdcxx_printers(None)
except:
pass
end
python
import sys
sys.path.insert(0, '/home/michi/.gdb_printers/Boost-Pretty-Printer')
import boost_print
boost_print.register_printers()
end
If you are getting the following error when running gdb, the `libstdcxx`
printers are already preloaded in your environment and you can remove
the duplicate import in your `~/.gdbinit` file.
RuntimeError: pretty-printer already registered: libstdc++-v6
### <a id="development-debug-gdb-run"></a> GDB Run
Call GDB with the binary (`/usr/sbin/icinga2` is a wrapper script calling
`/usr/lib64/icinga2/sbin/icinga2` since 2.4) and all arguments and run it in foreground.
If VFork causes trouble, disable it inside the gdb run.
# gdb --args /usr/lib64/icinga2/sbin/icinga2 daemon -x debug -DUseVfork=0 --no-stack-rlimit
The exact path to the Icinga 2 binary differs on each distribution. On Ubuntu
it is installed into `/usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2` on 64-bit systems
for example.
> **Note**
>
> If gdb tells you it's missing debug symbols, quit gdb and install
> them: `Missing separate debuginfos, use: debuginfo-install ...`
Run the application.
(gdb) r
Kill the running application.
(gdb) k
Continue after breakpoint.
(gdb) c
### <a id="development-debug-gdb-coredump"></a> GDB Core Dump
Either attach to the running process using `gdb -p PID` or start
a new gdb run.
(gdb) r
(gdb) generate-core-file
### <a id="development-debug-gdb-backtrace"></a> GDB Backtrace
If Icinga 2 aborted its operation abnormally, generate a backtrace.
(gdb) bt
(gdb) thread apply all bt full
If gdb stops at a SIGPIPE signal please disable the signal before
running Icinga 2.
(gdb) handle SIGPIPE nostop noprint pass
(gdb) r
If you're opening an issue at [https://dev.icinga.org], make sure
to attach as much detail as possible.
### <a id="development-debug-gdb-backtrace-running"></a> GDB Backtrace from Running Process
If Icinga 2 is still running, generate a full backtrace from the running
process and store it into a new file (e.g. for debugging dead locks):
# gdb -p $(pidof icinga2) -batch -ex "thread apply all bt full" -ex "detach" -ex "q" > gdb_bt.log
### <a id="development-debug-gdb-backtrace-stepping"></a> GDB Backtrace Stepping
Identifying the problem may require stepping into the backtrace, analysing
the current scope, attributes, and possible unmet requirements. `p` prints
the value of the selected variable or function call result.
(gdb) up
(gdb) down
(gdb) p checkable
(gdb) p checkable.px->m_Name
### <a id="development-debug-gdb-breakpoint"></a> GDB Breakpoints
To set a breakpoint to a specific function call, or file specific line.
(gdb) b checkable.cpp:125
(gdb) b icinga::Checkable::SetEnablePerfdata
GDB will ask about loading the required symbols later, select `yes` instead
of `no`.
Then run Icinga 2 until it reaches the first breakpoint. Continue with `c`
afterwards.
(gdb) run
(gdb) c
If you want to delete all breakpoints, use `d` and select `yes`.
(gdb) d
> **Tip**
>
> When debugging exceptions, set your breakpoint like this: `b __cxa_throw`.
Breakpoint Example:
(gdb) b __cxa_throw
(gdb) r
(gdb) up
....
(gdb) up
#11 0x00007ffff7cbf9ff in icinga::Utility::GlobRecursive(icinga::String const&, icinga::String const&, boost::function<void (icinga::String const&)> const&, int) (path=..., pattern=..., callback=..., type=1)
at /home/michi/coding/icinga/icinga2/lib/base/utility.cpp:609
609 callback(cpath);
(gdb) l
604
605 #endif /* _WIN32 */
606
607 std::sort(files.begin(), files.end());
608 BOOST_FOREACH(const String& cpath, files) {
609 callback(cpath);
610 }
611
612 std::sort(dirs.begin(), dirs.end());
613 BOOST_FOREACH(const String& cpath, dirs) {
(gdb) p files
$3 = std::vector of length 11, capacity 16 = {{static NPos = 18446744073709551615, m_Data = "/etc/icinga2/conf.d/agent.conf"}, {static NPos = 18446744073709551615,
m_Data = "/etc/icinga2/conf.d/commands.conf"}, {static NPos = 18446744073709551615, m_Data = "/etc/icinga2/conf.d/downtimes.conf"}, {static NPos = 18446744073709551615,
m_Data = "/etc/icinga2/conf.d/groups.conf"}, {static NPos = 18446744073709551615, m_Data = "/etc/icinga2/conf.d/notifications.conf"}, {static NPos = 18446744073709551615,
m_Data = "/etc/icinga2/conf.d/satellite.conf"}, {static NPos = 18446744073709551615, m_Data = "/etc/icinga2/conf.d/services.conf"}, {static NPos = 18446744073709551615,
m_Data = "/etc/icinga2/conf.d/templates.conf"}, {static NPos = 18446744073709551615, m_Data = "/etc/icinga2/conf.d/test.conf"}, {static NPos = 18446744073709551615,
m_Data = "/etc/icinga2/conf.d/timeperiods.conf"}, {static NPos = 18446744073709551615, m_Data = "/etc/icinga2/conf.d/users.conf"}}
## <a id="development-debug-core-dump"></a> Core Dump
When the Icinga 2 daemon crashes with a `SIGSEGV` signal
a core dump file should be written. This will help
developers to analyze and fix the problem.
### <a id="development-debug-core-dump-limit"></a> Core Dump File Size Limit
This requires setting the core dump file size to `unlimited`.
Example for Systemd:
vim /usr/lib/systemd/system/icinga2.service
[Service]
...
LimitCORE=infinity
systemctl daemon-reload
systemctl restart icinga2
Example for init script:
vim /etc/init.d/icinga2
...
ulimit -c unlimited
service icinga2 restart
Verify that the Icinga 2 process core file size limit is set to `unlimited`.
cat /proc/`pidof icinga2`/limits
...
Max core file size unlimited unlimited bytes
### <a id="development-debug-core-dump-format"></a> Core Dump Kernel Format
The Icinga 2 daemon runs with the SUID bit set. Therefore you need
to explicitly enable core dumps for SUID on Linux.
sysctl -w fs.suid_dumpable=1
Adjust the coredump kernel format and file location on Linux:
sysctl -w kernel.core_pattern=/var/lib/cores/core.%e.%p
install -m 1777 -d /var/lib/cores
MacOS:
sysctl -w kern.corefile=/cores/core.%P
chmod 777 /cores
### <a id="development-debug-core-dump-analysis"></a> Core Dump Analysis
Once Icinga 2 crashes again a new coredump file will be written. Please
attach this file to your bug report in addition to the general details.
Simple test case for a `SIGSEGV` simulation with `sleep`:
ulimit -c unlimited
sleep 1800&
[1] <PID>
kill -SEGV <PID>
gdb `which sleep` /var/lib/cores/core.sleep.<PID>
(gdb) bt
rm /var/lib/cores/core.sleep.*
Analyzing Icinga 2:
gdb /usr/lib64/icinga2/sbin/icinga2 core.icinga2.<PID>
(gdb) bt

View File

@ -0,0 +1,232 @@
# <a id="selinux"></a> SELinux
## <a id="selinux-introduction"></a> Introduction
SELinux is a mandatory access control (MAC) system on Linux which adds a fine granular permission system for access to all resources on the system such as files, devices, networks and inter-process communication.
The most important questions are answered briefly in the [FAQ of the SELinux Project](http://selinuxproject.org/page/FAQ). For more details on SELinux and how to actually use and administrate it on your systems have a look at [Red Hat Enterprise Linux 7 - SELinux User's and Administrator's Guide](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/SELinux_Users_and_Administrators_Guide/index.html). For an simplified (and funny) introduction download the [SELinux Coloring Book](https://github.com/mairin/selinux-coloring-book).
This documentation will use a similar format like the SELinux User's and Administrator's Guide.
### <a id="selinux-policy"></a> Policy
Icinga 2 is providing its own SELinux Policy. At the moment it is not upstreamed to the reference policy because it is under development. Target of the development is a policy package for Red Hat Enterprise Linux 7 and its derivates running the targeted policy which confines Icinga2 with all features and all checks executed. All other distributions will require some tweaks.
### <a id="selinux-policy-installation"></a> Installation
There are two ways to install the SELinux Policy for Icinga 2 on Enterprise Linux 7. Installing it from the provided package which is the preferred option and manual installation if you need some fixes not released yet or for development.
The policy package will run the daemon in a permissive domain so nothing will be denied also if the system runs in enforcing mode, so please make sure to run the system in this mode.
# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
You can change the configured mode by editing `/etc/selinux/config` and the current mode by executing `setenforce 0`.
#### <a id="selinux-policy-installation-package"></a> Package installation
The packages are provided with release version 2.4 onwards.
Simply add the selinux subpackage to your installation.
# yum install icinga2-selinux
After that restart Icinga 2 and verify it running in its own domain `icinga2_t`.
# systemctl restart icinga2.service
# ps -eZ | grep icinga2
system_u:system_r:icinga2_t:s0 2825 ? 00:00:00 icinga2
#### <a id="selinux-policy-installation-manual"></a> Manual installation
This section describes the installation to support development and testing. It assumes that Icinga 2 is already installed from packages and running on the system.
As a prerequisite install the `git`, `selinux-policy-devel` and `audit` package. Enable and start the audit daemon afterwards.
# yum install git selinux-policy-devel audit
# systemctl enable auditd.service
# systemctl start auditd.service
After that clone the icinga2 git repository.
# git clone git://git.icinga.org/icinga2.git
To create and install the policy package run the installation script which also labels the resources. (The script assumes Icinga 2 was started once after system startup, the labeling of the port will only happen once and fail later on.)
# cd tools/selinux/
# ./icinga.sh
After that restart Icinga 2 and verify it running in its own domain `icinga2_t`.
# systemctl restart icinga2.service
# ps -eZ | grep icinga2
system_u:system_r:icinga2_t:s0 2825 ? 00:00:00 icinga2
### <a id="selinux-policy-general"></a> General
When the SELinux policy package for Icinga 2 is installed, the Icinga 2 daemon (icinga2) runs in its own domain `icinga2_t` and is separated from other confined services.
Files have to be labeled correctly for allowing icinga2 access to it. For example it writes to its own log files labeled `icinga2_log_t`. Also the API port is labeled `icinga_port_t` and icinga2 is allowed to manage it. Furthermore icinga2 can open high ports and unix sockets to connect to databases and features like graphite. It executes the nagios plugins and transitions to their context if those are labeled for example `nagios_services_plugin_exec_t` or `nagios_system_plugin_exec_t`.
Additional the Apache webserver is allowed to connect to the Command pipe of Icinga 2 to allow web interfaces sending commands to icinga2. This will perhaps change later on while investigating Icinga Web 2 for SELinux!
### <a id="selinux-policy-types"></a> Types
The command pipe is labeled `icinga2_command_t` and other services can request access to it by using the interface `icinga2_send_commands`.
The nagios plugins use their own contexts and icinga2 will transition to it. This means plugins have to be labeled correctly for their required permissions. The plugins installed from package should have set their permissions by the corresponding policy module and you can restore them using `restorecon -R -v /usr/lib64/nagios/plugins/`. To label your own plugins use `chcon -t type /path/to/plugin`, for the type have a look at table below.
Type | Domain | Use case | Provided by policy package
----------------------------------|------------------------------|------------------------------------------------------------------|---------------------------
nagios_admin_plugin_exec_t | nagios_admin_plugin_t | Plugins which require require read access on all file attributes | nagios
nagios_checkdisk_plugin_exec_t | nagios_checkdisk_plugin_t | Plugins which require read access to all filesystem attributes | nagios
nagios_mail_plugin_exec_t | nagios_mail_plugin_t | Plugins which access the local mail service | nagios
nagios_services_plugin_exec_t | nagios_services_plugin_t | Plugins monitoring network services | nagios
nagios_system_plugin_exec_t | nagios_system_plugin_t | Plugins checking local system state | nagios
nagios_unconfined_plugin_exec_t | nagios_unconfined_plugin_t | Plugins running without confinement | nagios
nagios_eventhandler_plugin_exec_t | nagios_eventhandler_plugin_t | Eventhandler (actually running unconfined) | nagios
nagios_openshift_plugin_exec_t | nagios_openshift_plugin_t | Plugins monitoring openshift | nagios
nagios_notification_plugin_exec_t | nagios_notification_plugin_t | Notification commands | icinga (will be moved later)
If one of those plugin domains causes problems you can set it to permissive by executing `semanage permissive -a domain`.
The policy provides a role `icinga2adm_r` for confining an user which enables an administrative user managing only Icinga 2 on the system. This user will also execute the plugins in their domain instead of the users one, so you can verify their execution with the same restrictions like they have when executed by icinga2.
### <a id="selinux-policy-booleans"></a> Booleans
SELinux is based on the least level of access required for a service to run. Using booleans you can grant more access in a defined way. The Icinga 2 policy package provides the following booleans.
**icinga2_can_connect_all**
Having this boolean enabled allows icinga2 to connect to all ports. This can be neccesary if you use features which connect to unconfined services.
### <a id="selinux-policy-examples"></a> Configuration Examples
#### <a id="selinux-policy-examples-plugin"></a> Confining a plugin
Download and install a plugin, for example check_mysql_health.
# wget http://labs.consol.de/download/shinken-nagios-plugins/check_mysql_health-2.1.9.2.tar.gz
# tar xvzf check_mysql_health-2.1.9.2.tar.gz
# cd check_mysql_health-2.1.9.2/
# ./configure --libexecdir /usr/lib64/nagios/plugins
# make
# make install
It is labeled `nagios_unconfined_plugins_exec_t` by default, so it runs without restrictions.
# ls -lZ /usr/lib64/nagios/plugins/check_mysql_health
-rwxr-xr-x. root root system_u:object_r:nagios_unconfined_plugin_exec_t:s0 /usr/lib64/nagios/plugins/check_mysql_health
In this case the plugin is monitoring a service, so it should be labeled `nagios_services_plugin_exec_t` to restrict its permissions.
# chcon -t nagios_services_plugin_exec_t /usr/lib64/nagios/plugins/check_mysql_health
# ls -lZ /usr/lib64/nagios/plugins/check_mysql_health
-rwxr-xr-x. root root system_u:object_r:nagios_services_plugin_exec_t:s0 /usr/lib64/nagios/plugins/check_mysql_health
The plugin still runs fine but if someone changes the script to do weird stuff it will fail to do so.
#### <a id="selinux-policy-examples-connectall"></a> Allow icinga to connect to all ports.
You are running graphite on a different port than `2003` and want `icinga2` to connect to it.
Change the port value for the graphite feature according to your graphite installation before enabling it.
# cat /etc/icinga2/features-enabled/graphite.conf
/**
* The GraphiteWriter type writes check result metrics and
* performance data to a graphite tcp socket.
*/
library "perfdata"
object GraphiteWriter "graphite" {
//host = "127.0.0.1"
//port = 2003
port = 2004
}
# icinga2 feature enable graphite
Before you restart the icinga2 service allow it to connect to all ports by enabling the boolean ´icinga2_can_connect_all` (now and permanent).
# setsebool icinga2_can_connect_all true
# setsebool -P icinga2_can_connect_all true
If you restart the daemon now it will successfully connect to graphite.
#### <a id="selinux-policy-examples-user"></a> Confining a user
If you want to have an administrative account capable of only managing icinga2 and not the complete system, you can restrict the privileges by confining
this user. This is completly optional!
Start by adding the Icinga 2 administrator role `icinga2adm_r` to the administrative SELinux user `staff_u`.
# semanage user -m -R "staff_r sysadm_r system_r unconfined_r icinga2adm_r" staff_u
Confine your user login and create a sudo rule.
# semanage login -a dirk -s staff_u
# echo "dirk ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/dirk
Login to the system using ssh and verify your id.
$ id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023
Try to execute some commands as root using sudo.
$ sudo id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023
$ sudo vi /etc/icinga2/icinga2.conf
"/etc/icinga2/icinga2.conf" [Permission Denied]
$ sudo cat /var/log/icinga2/icinga2.log
cat: /var/log/icinga2/icinga2.log: Keine Berechtigung
$ sudo systemctl reload icinga2.service
Failed to get D-Bus connection: No connection to service manager.
Those commands fail because you only switch to root but do not change your SELinux role. Try again but tell sudo also to switch the SELinux role and type.
$ sudo -r icinga2adm_r -t icinga2adm_t id -Z
staff_u:icinga2adm_r:icinga2adm_t:s0-s0:c0.c1023
$ sudo -r icinga2adm_r -t icinga2adm_t vi /etc/icinga2/icinga2.conf
"/etc/icinga2/icinga2.conf"
$ sudo -r icinga2adm_r -t icinga2adm_t cat /var/log/icinga2/icinga2.log
[2015-03-26 20:48:14 +0000] information/DynamicObject: Dumping program state to file '/var/lib/icinga2/icinga2.state'
$ sudo -r icinga2adm_r -t icinga2adm_t systemctl reload icinga2.service
Now the commands will work, but you have always to remember to add the arguments, so change the sudo rule to set it by default.
# echo "dirk ALL=(ALL) ROLE=icinga2adm_r TYPE=icinga2adm_t NOPASSWD: ALL" > /etc/sudoers.d/dirk
Now try the commands again without providing the role and type and they will work, but if you try to read apache logs or restart apache for example it will still fail.
$ sudo cat /var/log/httpd/error_log
/bin/cat: /var/log/httpd/error_log: Keine Berechtigung
$ sudo systemctl reload httpd.service
Failed to issue method call: Access denied
## <a id="selinux-bugreports"></a> Bugreports
If you experience any problems while running in enforcing mode try to reproduce it in permissive mode. If the problem persists it is not related to SELinux because in permissive mode SELinux will not deny anything.
For now Icinga 2 is running in a permissive domain and adds also some rules for other necessary services so no problems should occure at all. But you can help to enhance the policy by testing Icinga 2 running confined by SELinux.
When filing a bug report please add the following information additionally to the [normal ones](https://www.icinga.org/icinga/faq/):
* Output of `semodule -l | grep -e icinga2 -e nagios -e apache`
* Output of `ps -eZ | grep icinga2`
* Output of `semanage port -l | grep icinga2`
* Output of `audit2allow -li /var/log/audit/audit.log`
If access to a file is blocked and you can tell which one please provided the output of `ls -lZ /path/to/file` (and perhaps the directory above).
If asked for full audit.log add `-w /etc/shadow -p w` to `/etc/audit/rules.d/audit.rules`, restart the audit daemon, reproduce the problem and add `/var/log/audit/audit.log` to the bug report. With the added audit rule it will include the path of files access was denied to.
If asked to provide full audit log with dontaudit rules disabled executed `semodule -DB` before reproducing the problem. After that enable the rules again to prevent auditd spamming your logfile by executing `semodule -B`.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,705 @@
# <a id="appendix"></a> Appendix
## <a id="external-commands-list-detail"></a> External Commands List
Additional details can be found in the [Icinga 1.x Documentation](http://docs.icinga.org/latest/en/extcommands2.html)
Command name | Parameters | Description
------------------------------------------|-----------------------------------|--------------------------
PROCESS_HOST_CHECK_RESULT | ;&lt;host_name&gt;;&lt;status_code&gt;;&lt;plugin_output&gt; (3) | -
PROCESS_SERVICE_CHECK_RESULT | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;return_code&gt;;&lt;plugin_output&gt; (4) | -
SCHEDULE_HOST_CHECK | ;&lt;host_name&gt;;&lt;check_time&gt; (2) | -
SCHEDULE_FORCED_HOST_CHECK | ;&lt;host_name&gt;;&lt;check_time&gt; (2) | -
SCHEDULE_SVC_CHECK | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;check_time&gt; (3) | -
SCHEDULE_FORCED_SVC_CHECK | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;check_time&gt; (3) | -
ENABLE_HOST_CHECK | ;&lt;host_name&gt; (1) | -
DISABLE_HOST_CHECK | ;&lt;host_name&gt; (1) | -
ENABLE_SVC_CHECK | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
DISABLE_SVC_CHECK | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
SHUTDOWN_PROCESS | - | -
RESTART_PROCESS | - | -
SCHEDULE_FORCED_HOST_SVC_CHECKS | ;&lt;host_name&gt;;&lt;check_time&gt; (2) | -
SCHEDULE_HOST_SVC_CHECKS | ;&lt;host_name&gt;;&lt;check_time&gt; (2) | -
ENABLE_HOST_SVC_CHECKS | ;&lt;host_name&gt; (1) | -
DISABLE_HOST_SVC_CHECKS | ;&lt;host_name&gt; (1) | -
ACKNOWLEDGE_SVC_PROBLEM | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;sticky&gt;;&lt;notify&gt;;&lt;persistent&gt;;&lt;author&gt;;&lt;comment&gt; (7) | Note: Icinga 2 treats all comments as persistent.
ACKNOWLEDGE_SVC_PROBLEM_EXPIRE | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;sticky&gt;;&lt;notify&gt;;&lt;persistent&gt;;&lt;timestamp&gt;;&lt;author&gt;;&lt;comment&gt; (8) | Note: Icinga 2 treats all comments as persistent.
REMOVE_SVC_ACKNOWLEDGEMENT | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
ACKNOWLEDGE_HOST_PROBLEM | ;&lt;host_name&gt;;&lt;sticky&gt;;&lt;notify&gt;;&lt;persistent&gt;;&lt;author&gt;;&lt;comment&gt; (6) | Note: Icinga 2 treats all comments as persistent.
ACKNOWLEDGE_HOST_PROBLEM_EXPIRE | ;&lt;host_name&gt;;&lt;sticky&gt;;&lt;notify&gt;;&lt;persistent&gt;;&lt;timestamp&gt;;&lt;author&gt;;&lt;comment&gt; (7) | Note: Icinga 2 treats all comments as persistent.
REMOVE_HOST_ACKNOWLEDGEMENT | ;&lt;host_name&gt; (1) | -
DISABLE_HOST_FLAP_DETECTION | ;&lt;host_name&gt; (1) | -
ENABLE_HOST_FLAP_DETECTION | ;&lt;host_name&gt; (1) | -
DISABLE_SVC_FLAP_DETECTION | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
ENABLE_SVC_FLAP_DETECTION | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
ENABLE_HOSTGROUP_SVC_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
DISABLE_HOSTGROUP_SVC_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
ENABLE_SERVICEGROUP_SVC_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
DISABLE_SERVICEGROUP_SVC_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
ENABLE_PASSIVE_HOST_CHECKS | ;&lt;host_name&gt; (1) | -
DISABLE_PASSIVE_HOST_CHECKS | ;&lt;host_name&gt; (1) | -
ENABLE_PASSIVE_SVC_CHECKS | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
DISABLE_PASSIVE_SVC_CHECKS | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
PROCESS_FILE | ;&lt;file_name&gt;;&lt;delete&gt; (2) | -
SCHEDULE_SVC_DOWNTIME | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt; (9) | -
DEL_SVC_DOWNTIME | ;&lt;downtime_id&gt; (1) | -
SCHEDULE_HOST_DOWNTIME | ;&lt;host_name&gt;;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt; (8) | -
DEL_HOST_DOWNTIME | ;&lt;downtime_id&gt; (1) | -
DEL_DOWNTIME_BY_HOST_NAME | ;&lt;host_name&gt;[;&lt;service_name;&gt;[;&lt;start_time;&gt;[;&lt;comment_text;&gt;]]] (1) | -
SCHEDULE_HOST_SVC_DOWNTIME | ;&lt;host_name&gt;;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt; (8) | -
SCHEDULE_HOSTGROUP_HOST_DOWNTIME | ;&lt;hostgroup_name&gt;;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt; (8) | -
SCHEDULE_HOSTGROUP_SVC_DOWNTIME | ;&lt;hostgroup_name&gt;;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt; (8) | -
SCHEDULE_SERVICEGROUP_HOST_DOWNTIME | ;&lt;servicegroup_name&gt;;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt; (8) | -
SCHEDULE_SERVICEGROUP_SVC_DOWNTIME | ;&lt;servicegroup_name&gt;;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt; (8) | -
ADD_HOST_COMMENT | ;&lt;host_name&gt;;&lt;persistent&gt;;&lt;author&gt;;&lt;comment&gt; (4) | Note: Icinga 2 treats all comments as persistent.
DEL_HOST_COMMENT | ;&lt;comment_id&gt; (1) | -
ADD_SVC_COMMENT | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;persistent&gt;;&lt;author&gt;;&lt;comment&gt; (5) | Note: Icinga 2 treats all comments as persistent.
DEL_SVC_COMMENT | ;&lt;comment_id&gt; (1) | -
DEL_ALL_HOST_COMMENTS | ;&lt;host_name&gt; (1) | -
DEL_ALL_SVC_COMMENTS | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
SEND_CUSTOM_HOST_NOTIFICATION | ;&lt;host_name&gt;;&lt;options&gt;;&lt;author&gt;;&lt;comment&gt; (4) | -
SEND_CUSTOM_SVC_NOTIFICATION | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;options&gt;;&lt;author&gt;;&lt;comment&gt; (5) | -
DELAY_HOST_NOTIFICATION | ;&lt;host_name&gt;;&lt;notification_time&gt; (2) | -
DELAY_SVC_NOTIFICATION | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;notification_time&gt; (3) | -
ENABLE_HOST_NOTIFICATIONS | ;&lt;host_name&gt; (1) | -
DISABLE_HOST_NOTIFICATIONS | ;&lt;host_name&gt; (1) | -
ENABLE_SVC_NOTIFICATIONS | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
DISABLE_SVC_NOTIFICATIONS | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
ENABLE_HOST_SVC_NOTIFICATIONS | ;&lt;host_name&gt; (1) | -
DISABLE_HOST_SVC_NOTIFICATIONS | ;&lt;host_name&gt; (1) | -
DISABLE_HOSTGROUP_HOST_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
DISABLE_SERVICEGROUP_HOST_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
ENABLE_HOSTGROUP_HOST_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS | ;&lt;hostgroup_name&gt; (1) | -
ENABLE_SERVICEGROUP_HOST_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS | ;&lt;servicegroup_name&gt; (1) | -
ENABLE_NOTIFICATIONS | - | -
DISABLE_NOTIFICATIONS | - | -
ENABLE_FLAP_DETECTION | - | -
DISABLE_FLAP_DETECTION | - | -
ENABLE_EVENT_HANDLERS | - | -
DISABLE_EVENT_HANDLERS | - | -
ENABLE_PERFORMANCE_DATA | - | -
DISABLE_PERFORMANCE_DATA | - | -
START_EXECUTING_HOST_CHECKS | - | -
STOP_EXECUTING_HOST_CHECKS | - | -
START_EXECUTING_SVC_CHECKS | - | -
STOP_EXECUTING_SVC_CHECKS | - | -
CHANGE_NORMAL_SVC_CHECK_INTERVAL | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;check_interval&gt; (3) | -
CHANGE_NORMAL_HOST_CHECK_INTERVAL | ;&lt;host_name&gt;;&lt;check_interval&gt; (2) | -
CHANGE_RETRY_SVC_CHECK_INTERVAL | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;check_interval&gt; (3) | -
CHANGE_RETRY_HOST_CHECK_INTERVAL | ;&lt;host_name&gt;;&lt;check_interval&gt; (2) | -
ENABLE_HOST_EVENT_HANDLER | ;&lt;host_name&gt; (1) | -
DISABLE_HOST_EVENT_HANDLER | ;&lt;host_name&gt; (1) | -
ENABLE_SVC_EVENT_HANDLER | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
DISABLE_SVC_EVENT_HANDLER | ;&lt;host_name&gt;;&lt;service_name&gt; (2) | -
CHANGE_HOST_EVENT_HANDLER | ;&lt;host_name&gt;;&lt;event_command_name&gt; (2) | -
CHANGE_SVC_EVENT_HANDLER | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;event_command_name&gt; (3) | -
CHANGE_HOST_CHECK_COMMAND | ;&lt;host_name&gt;;&lt;check_command_name&gt; (2) | -
CHANGE_SVC_CHECK_COMMAND | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;check_command_name&gt; (3) | -
CHANGE_MAX_HOST_CHECK_ATTEMPTS | ;&lt;host_name&gt;;&lt;check_attempts&gt; (2) | -
CHANGE_MAX_SVC_CHECK_ATTEMPTS | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;check_attempts&gt; (3) | -
CHANGE_HOST_CHECK_TIMEPERIOD | ;&lt;host_name&gt;;&lt;timeperiod_name&gt; (2) | -
CHANGE_SVC_CHECK_TIMEPERIOD | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;timeperiod_name&gt; | -
CHANGE_CUSTOM_HOST_VAR | ;&lt;host_name&gt;;&lt;var_name&gt;;&lt;var_value&gt; (3) | -
CHANGE_CUSTOM_SVC_VAR | ;&lt;host_name&gt;;&lt;service_name&gt;;&lt;var_name&gt;;&lt;var_value&gt; (4) | -
CHANGE_CUSTOM_USER_VAR | ;&lt;user_name&gt;;&lt;var_name&gt;;&lt;var_value&gt; (3) | -
CHANGE_CUSTOM_CHECKCOMMAND_VAR | ;&lt;check_command_name&gt;;&lt;var_name&gt;;&lt;var_value&gt; (3) | -
CHANGE_CUSTOM_EVENTCOMMAND_VAR | ;&lt;event_command_name&gt;;&lt;var_name&gt;;&lt;var_value&gt; (3) | -
CHANGE_CUSTOM_NOTIFICATIONCOMMAND_VAR | ;&lt;notification_command_name&gt;;&lt;var_name&gt;;&lt;var_value&gt; (3) | -
ENABLE_HOSTGROUP_HOST_NOTIFICATIONS | ;&lt;hostgroup_name&gt; (1) | -
ENABLE_HOSTGROUP_SVC_NOTIFICATIONS | ;&lt;hostgroup_name&gt; (1) | -
DISABLE_HOSTGROUP_HOST_NOTIFICATIONS | ;&lt;hostgroup_name&gt; (1) | -
DISABLE_HOSTGROUP_SVC_NOTIFICATIONS | ;&lt;hostgroup_name&gt; (1) | -
ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS | ;&lt;servicegroup_name&gt; (1) | -
DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS | ;&lt;servicegroup_name&gt; (1) | -
ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS | ;&lt;servicegroup_name&gt; (1) | -
DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS | ;&lt;servicegroup_name&gt; (1) | -
## <a id="schemas"></a> Schemas
By convention `CheckCommand`, `EventCommand`, and `NotificationCommand` objects
are exported using a prefix. This is mandatory for unique objects in the
command tables.
Object | Prefix
------------------------|------------------------
CheckCommand | check_
EventCommand | event_
NotificationCommand | notification_
### <a id="schema-status-files"></a> Status Files
Status files used by Icinga 1.x Classic UI: `status.dat`, `objects.cache`.
Icinga 2 specific extensions:
* host and service objects support 'check_source' (added in Classic UI 1.10.0)
* command objects support custom variables (added in Classic UI 1.11.2)
* host and service objects support 'is_reachable' (added in Classic UI 1.11.3)
* 2.2 adds custom attributes with arrays and dictionaries. They are dumped as JSON encoded string and `_is_json`
is set as additional custom variable in `objects.cache`.
### <a id="schema-db-ido"></a> DB IDO Schema
There is a detailed documentation for the Icinga IDOUtils 1.x
database schema available on [http://docs.icinga.org/latest/en/db_model.html]
#### <a id="schema-db-ido-extensions"></a> DB IDO Schema Extensions
Icinga 2 specific extensions are shown below:
New table: `endpointstatus`
Table | Column | Type | Default | Description
--------------------|--------------------|----------|---------|-------------
endpoints | endpoint_object_id | bigint | NULL | FK: objects table
endpoints | identity | TEXT | NULL | endpoint name
endpoints | node | TEXT | NULL | local node name
endpoints | zone_object_id | bigint | NULL | zone object where this endpoint is a member of
New table: `endpointstatus`
Table | Column | Type | Default | Description
--------------------|--------------------|----------|---------|-------------
endpointstatus | endpoint_object_id | bigint | NULL | FK: objects table
endpointstatus | identity | TEXT | NULL | endpoint name
endpointstatus | node | TEXT | NULL | local node name
endpointstatus | is_connected | smallint | 0 | update on endpoint connect/disconnect
endpointstatus | zone_object_id | bigint | NULL | zone object where this endpoint is a member of
New tables: `zones` and `zonestatus`:
Table | Column | Type | Default | Description
--------------------|--------------------|----------|---------|-------------
zones | zone_object_id | bigint | NULL | FK: objects table
zones | parent_zone_object_id | bigint | NULL | FK: zones table
zones | is_global | smallint | 0 | zone is global
New columns:
Table | Column | Type | Default | Description
--------------------|-------------------------|----------|---------|-------------
all status/history | endpoint_object_id | bigint | NULL | FK: objects table
servicestatus | check_source | TEXT | NULL | node name where check was executed
hoststatus | check_source | TEXT | NULL | node name where check was executed
statehistory | check_source | TEXT | NULL | node name where check was executed
servicestatus | is_reachable | integer | NULL | object reachability
hoststatus | is_reachable | integer | NULL | object reachability
logentries | object_id | bigint | NULL | FK: objects table (service associated with column)
{host,service}group | notes | TEXT | NULL | -
{host,service}group | notes_url | TEXT | NULL | -
{host,service}group | action_url | TEXT | NULL | -
customvariable* | is_json | integer | 0 | Defines whether `varvalue` is a json encoded string from custom attributes, or not
servicestatus | original_attributes | TEXT | NULL | JSON encoded dictionary of original attributes if modified at runtime.
hoststatus | original_attributes | TEXT | NULL | JSON encoded dictionary of original attributes if modified at runtime.
Additional command custom variables populated from 'vars' dictionary.
Additional global custom variables populated from 'Vars' constant (object_id is NULL).
### <a id="schema-livestatus"></a> Livestatus Schema
#### <a id="schema-livestatus-extensions"></a> Livestatus Schema Extensions
Icinga 2 specific extensions are shown below:
New table: `endpoints`:
Table | Column
----------|--------------
endpoints | name
endpoints | identity
endpoints | node
endpoints | is_connected
endpoints | zone
New table: `zones`:
Table | Column
----------|--------------
zone | name
zone | endpoints
zone | parent
zone | global
New columns:
Table | Column
----------|--------------
hosts | is_reachable
services | is_reachable
hosts | cv_is_json
services | cv_is_json
contacts | cv_is_json
hosts | check_source
services | check_source
downtimes | triggers
downtimes | trigger_time
commands | custom_variable_names
commands | custom_variable_values
commands | custom_variables
commands | modified_attributes
commands | modified_attributes_list
status | custom_variable_names
status | custom_variable_values
status | custom_variables
hosts | original_attributes
services | original_attributes
Command custom variables reflect the local 'vars' dictionary.
Status custom variables reflect the global 'Vars' constant.
#### <a id="schema-livestatus-hosts-table-attributes"></a> Livestatus Hosts Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
name | string | .
display_name | string | .
alias | string | same as display_name.
address | string | .
address6 | string | NEW in Icinga.
check_command | string | .
check_command_expanded | string | .
event_handler | string | .
notification_period | string | host with notifications: period.
check_period | string | .
notes | string | .
notes_expanded | string | .
notes_url | string | .
notes_url_expanded | string | .
action_url | string | .
action_url_expanded | string | .
plugin_output | string | .
perf_data | string | .
icon_image | string | .
icon_image_expanded | string | .
icon_image_alt | stirng | .
statusmap_image | string | .
long_plugin_output | string | .
max_check_attempts | int | .
flap_detection_enabled | int | .
check_freshness | int | .
process_performance_data | int | .
accept_passive_checks | int | .
event_handler_enabled | int | .
acknowledgement_type | int | Only 0 or 1.
check_type | int | .
last_state | int | .
last_hard_state | int | .
current_attempt | int | .
last_notification | int | host with notifications: last notification.
next_notification | int | host with notifications: next notification.
next_check | int | .
last_hard_state_change | int | .
has_been_checked | int | .
current_notification_number | int | host with notifications: number.
total_services | int | .
checks_enabled | int | .
notifications_enabled | int | .
acknowledged | int | .
state | int | .
state_type | int | .
no_more_notifications | int | notification_interval == 0 && volatile == false.
last_check | int | .
last_state_change | int | .
last_time_up | int | .
last_time_down | int | .
last_time_unreachable | int | .
is_flapping | int | .
scheduled_downtime_depth | int | .
active_checks_enabled | int | .
modified_attributes | array | .
modified_attributes_list | array | .
check_interval | double | .
retry_interval | double | .
notification_interval | double | host with notifications: smallest interval.
low_flap_threshold | double | flapping_threshold
high_flap_threshold | double | flapping_threshold
latency | double | .
execution_time | double | .
percent_state_change | double | flapping.
in_notification_period | int | host with notifications: matching period.
in_check_period | int | .
contacts | array | host with notifications, users and user groups.
downtimes | array | id.
downtimes_with_info | array | id+author+comment.
comments | array | id.
comments_with_info | array | id+author+comment.
comments_with_extra_info | array | id+author+comment+entry_type+entry_time.
custom_variable_names | array | .
custom_variable_values | array | .
custom_variables | array | Array of custom variable array pair.
parents | array | Direct host parents.
childs | array | Direct host children (Note: `childs` is inherited from the origin MK_Livestatus protocol).
num_services | int | .
worst_service_state | int | All services and their worst state.
num_services_ok | int | All services with Ok state.
num_services_warn | int | All services with Warning state.
num_services_crit | int | All services with Critical state.
num_services_unknown | int | All services with Unknown state.
worst_service_hard_state | int | All services and their worst hard state.
num_services_hard_ok | int | All services in a hard state with Ok state.
num_services_hard_warn | int | All services in a hard state with Warning state.
num_services_hard_crit | int | All services in a hard state with Critical state.
num_services_hard_unknown | int | All services in a hard state with Unknown state.
hard_state | int | Returns OK if state is OK. Returns current state if now a hard state type. Returns last hard state otherwise.
staleness | int | Indicates time since last check normalized onto the check_interval.
groups | array | All hostgroups this host is a member of.
contact_groups | array | All usergroups associated with this host through notifications.
services | array | All services associated with this host.
services_with_state | array | All services associated with this host with state and hasbeenchecked.
services_with_info | array | All services associated with this host with state, hasbeenchecked and output.
Not supported: `initial_state`, `pending_flex_downtime`, `check_flapping_recovery_notification`,
`is_executing`, `check_options`, `obsess_over_host`, `first_notification_delay`, `x_3d`, `y_3d`, `z_3d`,
`x_2d`, `y_2d`, `filename`, `pnpgraph_present`.
#### <a id="schema-livestatus-hostgroups-table-attributes"></a> Livestatus Hostgroups Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
name | string | .
alias | string | `display_name` attribute.
notes | string | .
notes_url | string | .
action_url | string | .
members | array | .
members_with_state | array | Host name and state.
worst_host_state | int | Of all group members.
num_hosts | int | In this group.
num_hosts_pending | int | .
num_hosts_up | int | .
num_hosts_down | int | .
num_hosts_unreach | int | .
num_services | int | Number of services associated with hosts in this hostgroup.
worst_services_state | int | .
num_services_pending | int | .
num_services_ok | int | .
num_services_warn | int | .
num_services_crit | int | .
num_services_unknown | int | .
worst_service_hard_state | int | .
num_services_hard_ok | int | .
num_services_hard_warn | int | .
num_services_hard_crit | int | .
num_services_hard_unknown | int | .
#### <a id="schema-livestatus-services-table-attributes"></a> Livestatus Services Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
description | string | .
display_name | string | .
alias | string | same as display_name.
check_command | string | .
check_command_expanded | string | .
event_handler | string | .
notification_period | string | host with notifications: period.
check_period | string | .
notes | string | .
notes_expanded | string | .
notes_url | string | .
notes_url_expanded | string | .
action_url | string | .
action_url_expanded | string | .
plugin_output | string | .
perf_data | string | .
icon_image | string | .
icon_image_expanded | string | .
icon_image_alt | stirng | .
statusmap_image | string | .
long_plugin_output | string | .
max_check_attempts | int | .
flap_detection_enabled | int | .
check_freshness | int | .
process_performance_data | int | .
accept_passive_checks | int | .
event_handler_enabled | int | .
acknowledgement_type | int | Only 0 or 1.
check_type | int | .
last_state | int | .
last_hard_state | int | .
current_attempt | int | .
last_notification | int | service with notifications: last notification.
next_notification | int | service with notifications: next notification.
next_check | int | .
last_hard_state_change | int | .
has_been_checked | int | .
current_notification_number | int | service with notifications: number.
checks_enabled | int | .
notifications_enabled | int | .
acknowledged | int | .
state | int | .
state_type | int | .
no_more_notifications | int | notification_interval == 0 && volatile == false.
last_check | int | .
last_state_change | int | .
last_time_ok | int | .
last_time_warning | int | .
last_time_critical | int | .
last_time_unknown | int | .
is_flapping | int | .
scheduled_downtime_depth | int | .
active_checks_enabled | int | .
modified_attributes | array | .
modified_attributes_list | array | .
check_interval | double | .
retry_interval | double | .
notification_interval | double | service with notifications: smallest interval.
low_flap_threshold | double | flapping_threshold
high_flap_threshold | double | flapping_threshold
latency | double | .
execution_time | double | .
percent_state_change | double | flapping.
in_notification_period | int | service with notifications: matching period.
in_check_period | int | .
contacts | array | service with notifications, users and user groups.
downtimes | array | id.
downtimes_with_info | array | id+author+comment.
comments | array | id.
comments_with_info | array | id+author+comment.
comments_with_extra_info | array | id+author+comment+entry_type+entry_time.
custom_variable_names | array | .
custom_variable_values | array | .
custom_variables | array | Array of custom variable array pair.
hard_state | int | Returns OK if state is OK. Returns current state if now a hard state type. Returns last hard state otherwise.
staleness | int | Indicates time since last check normalized onto the check_interval.
groups | array | All hostgroups this host is a member of.
contact_groups | array | All usergroups associated with this host through notifications.
host_ | join | Prefix for attributes from implicit join with hosts table.
Not supported: `initial_state`, `is_executing`, `check_options`, `obsess_over_service`, `first_notification_delay`,
`pnpgraph_present`.
#### <a id="schema-livestatus-servicegroups-table-attributes"></a> Livestatus Servicegroups Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
name | string | .
alias | string | `display_name` attribute.
notes | string | .
notes_url | string | .
action_url | string | .
members | array | CSV format uses `host|service` syntax.
members_with_state | array | Host, service, hoststate, servicestate.
worst_service_state | int | .
num_services | int | .
num_services_pending | int | .
num_services_ok | int | .
num_services_warn | int | .
num_services_crit | int | .
num_services_unknown | int | .
num_services_hard_ok | int | .
num_services_hard_warn | int | .
num_services_hard_crit | int | .
num_services_hard_unknown | int | .
#### <a id="schema-livestatus-contacts-table-attributes"></a> Livestatus Contacts Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
name | string | .
alias | string | `display_name` attribute.
email | string | .
pager | string | .
host_notification_period | string | .
service_notification_period | string | .
host_notifications_enabled | int | .
service_notifications_enabled | int | .
in_host_notification_period | int | .
in_service_notification_period | int | .
custom_variable_names | array | .
custom_variable_values | array | .
custom_variables | array | Array of customvariable array pairs.
modified_attributes | array | .
modified_attributes_list | array | .
Not supported: `can_submit_commands`.
#### <a id="schema-livestatus-contactgroups-table-attributes"></a> Livestatus Contactgroups Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
name | string | .
alias | string | `display_name` attribute.
members | array | .
#### <a id="schema-livestatus-commands-table-attributes"></a> Livestatus Commands Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
name | string | 3 types of commands in Icinga 2.
line | string | .
#### <a id="schema-livestatus-status-table-attributes"></a> Livestatus Status Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
connections | int | Since application start.
connections_rate | double | .
service_checks | int | Since application start.
service_checks_rate | double | .
host_checks | int | Since application start.
host_checks_rate | double | .
external_commands | int | Since application start.
external_commands_rate | double | .
nagios_pid | string | Application PID.
enable_notifications | int | .
execute_service_checks | int | .
accept_passive_service_checks | int | .
execute_host_checks | int | .
accept_passive_host_checks | int | .
enable_event_handlers | int | .
check_service_freshness | int | .
check_host_freshness | int | .
enable_flap_detection | int | .
process_performance_data | int | .
check_external_commands | int | Always enabled.
program_start | int | In seconds.
last_command_check | int | Always.
interval_length | int | Compatibility mode: 60.
num_hosts | int | .
num_services | int | .
program_version | string | 2.0.
livestatus_active_connections | string | .
Not supported: `neb_callbacks`, `neb_callbacks_rate`, `requests`, `requests_rate`, `forks`, `forks_rate`,
`log_messages`, `log_messages_rate`, `livechecks`, `livechecks_rate`, `livecheck_overflows`,
`livecheck_overflows_rate`, `obsess_over_services`, `obsess_over_hosts`, `last_log_rotation`,
`external_command_buffer_slots`, `external_command_buffer_usage`, `external_command_buffer_max`,
`cached_log_messages`, `livestatus_queued_connections`, `livestatus_threads`.
#### <a id="schema-livestatus-comments-table-attributes"></a> Livestatus Comments Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
author | string | .
comment | string | .
id | int | legacy_id.
entry_time | string | Seconds.
type | int | 1=host, 2=service.
is_service | int | .
persistent | int | Always.
source | string | Always external (1).
entry_type | int | .
expires | int | .
expire_time | string | Seconds.
service_ | join | Prefix for attributes from implicit join with services table.
host_ | join | Prefix for attributes from implicit join with hosts table.
#### <a id="schema-livestatus-downtimes-table-attributes"></a> Livestatus Downtimes Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
author | string | .
comment | string | .
id | int | legacy_id.
entry_time | string | Seconds.
type | int | 1=active, 0=pending.
is_service | int | .
start_time | string | Seconds.
end_time | string | Seconds.
fixed | int | 0=flexible, 1=fixed.
duration | int | .
triggered_by | int | legacy_id.
triggers | int | NEW in Icinga 2.
trigger_time | string | NEW in Icinga 2.
service_ | join | Prefix for attributes from implicit join with services table.
host_ | join | Prefix for attributes from implicit join with hosts table.
#### <a id="schema-livestatus-timeperiod-table-attributes"></a> Livestatus Timeperiod Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
name | string | .
alias | string | `display_name` attribute.
in | int | Current time is in timeperiod or not.
#### <a id="schema-livestatus-log-table-attributes"></a> Livestatus Log Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
time | int | Time of log event (unix timestamp).
lineno | int | Line number in `CompatLogger` log file.
class | int | Log message class: 0=info, 1=state, 2=program, 3=notification, 4=passive, 5=command.
message | string | Complete message line.
type | string | Text before the colon `:`.
options | string | Text after the colon `:`.
comment | string | Comment if available.
plugin_output | string | Check output if available.
state | int | Host or service state.
state_type | int | State type if available.
attempt | int | Current check attempt.
service_description | string | .
host_name | string | .
contact_name | string | .
command_name | string | .
current_service_ | join | Prefix for attributes from implicit join with services table.
current_host_ | join | Prefix for attributes from implicit join with hosts table.
current_contact_ | join | Prefix for attributes from implicit join with contacts table.
current_command_ | join | Prefix for attributes from implicit join with commands table.
#### <a id="schema-livestatus-statehist-table-attributes"></a> Livestatus Statehist Table Attributes
Key | Type | Note
----------------------|-----------|-------------------------
time | int | Time of log event (unix timestamp).
lineno | int | Line number in `CompatLogger` log file.
from | int | Start timestamp (unix timestamp).
until | int | End timestamp (unix timestamp).
duration | int | until-from.
duration_part | double | duration / query_part.
state | int | State: 0=ok, 1=warn, 2=crit, 3=unknown, -1=notmonitored.
host_down | int | Host associated with the service is down or not.
in_downtime | int | Host/service is in downtime.
in_host_downtime | int | Host associated with the service is in a downtime or not.
is_flapping | int | Host/service is flapping.
in_notification_period | int | Host/service notification periods match or not.
notification_period | string | Host/service notification period.
host_name | string | .
service_description | string | .
log_output | string | Log file output for this state.
duration_ok | int | until-from for OK state.
duration_part_ok | double | .
duration_warning | int | until-from for Warning state.
duration_part_warning | double | .
duration_critical | int | until-from for Critical state.
duration_part_critical | double | .
duration_unknown | int | until-from for Unknown state.
duration_part_unknown | double | .
duration_unmonitored | int | until-from for Not-Monitored state.
duration_part_unmonitored | double | .
current_service_ | join | Prefix for attributes from implicit join with services table.
current_host_ | join | Prefix for attributes from implicit join with hosts table.
Not supported: `debug_info`.
#### <a id="schema-livestatus-hostsbygroup-table-attributes"></a> Livestatus Hostsbygroup Table Attributes
All (hosts)[19-appendix.md#schema-livestatus-hosts-table-attributes] table attributes grouped with
the (hostgroups)[19-appendix.md#schema-livestatus-hostgroups-table-attributes] table prefixed with `hostgroup_`.
#### <a id="schema-livestatus-servicesbygroup-table-attributes"></a> Livestatus Servicesbygroup Table Attributes
All (services)[19-appendix.md#schema-livestatus-services-table-attributes] table attributes grouped with
the (servicegroups)[19-appendix.md#schema-livestatus-servicegroups-table-attributes] table prefixed with `servicegroup_`.
#### <a id="schema-livestatus-servicesbyhostgroup-table-attributes"></a> Livestatus Servicesbyhostgroup Table Attributes
All (services)[19-appendix.md#schema-livestatus-services-table-attributes] table attributes grouped with
the (hostgroups)[19-appendix.md#schema-livestatus-hostgroups-table-attributes] table prefixed with `hostgroup_`.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,680 @@
# <a id="configuring-icinga2-first-steps"></a> Configuring Icinga 2: First Steps
This chapter provides an introduction into best practices with your Icinga 2 configuration.
The configuration files which are automatically created when installing the Icinga 2 packages
are a good way to start with Icinga 2.
If you're interested in a detailed explanation of each language feature used in those
configuration files, you can find more information in the [Language Reference](17-language-reference.md#language-reference)
chapter.
## <a id="configuration-best-practice"></a> Configuration Best Practice
If you are ready to configure additional hosts, services, notifications,
dependencies, etc., you should think about the requirements first and then
decide for a possible strategy.
There are many ways of creating Icinga 2 configuration objects:
* Manually with your preferred editor, for example vi(m), nano, notepad, etc.
* Generated by a [configuration management tool](13-addons.md#configuration-tools) such as Puppet, Chef, Ansible, etc.
* A configuration addon for Icinga 2 ([Icinga Director](https://github.com/Icinga/icingaweb2-module-director))
* A custom exporter script from your CMDB or inventory tool
* your own.
In order to find the best strategy for your own configuration, ask yourself the following questions:
* Do your hosts share a common group of services (for example linux hosts with disk, load, etc. checks)?
* Only a small set of users receives notifications and escalations for all hosts/services?
If you can at least answer one of these questions with yes, look for the
[apply rules](3-monitoring-basics.md#using-apply) logic instead of defining objects on a per
host and service basis.
* You are required to define specific configuration for each host/service?
* Does your configuration generation tool already know about the host-service-relationship?
Then you should look for the object specific configuration setting `host_name` etc. accordingly.
Finding the best files and directory tree for your configuration is up to you. Make sure that
the [icinga2.conf](4-configuring-icinga-2.md#icinga2-conf) configuration file includes them,
and then think about:
* tree-based on locations, hostgroups, specific host attributes with sub levels of directories.
* flat `hosts.conf`, `services.conf`, etc. files for rule based configuration.
* generated configuration with one file per host and a global configuration for groups, users, etc.
* one big file generated from an external application (probably a bad idea for maintaining changes).
* your own.
In either way of choosing the right strategy you should additionally check the following:
* Are there any specific attributes describing the host/service you could set as `vars` custom attributes?
You can later use them for applying assign/ignore rules, or export them into external interfaces.
* Put hosts into hostgroups, services into servicegroups and use these attributes for your apply rules.
* Use templates to store generic attributes for your objects and apply rules making your configuration more readable.
Details can be found in the [using templates](3-monitoring-basics.md#object-inheritance-using-templates) chapter.
* Apply rules may overlap. Keep a central place (for example, [services.conf](4-configuring-icinga-2.md#services-conf) or [notifications.conf](4-configuring-icinga-2.md#notifications-conf)) storing
the configuration instead of defining apply rules deep in your configuration tree.
* Every plugin used as check, notification or event command requires a `Command` definition.
Further details can be looked up in the [check commands](3-monitoring-basics.md#check-commands) chapter.
If you are planning to use a distributed monitoring setup with master, satellite and client installations
take the configuration location into account too. Everything configured on the master, synced to all other
nodes? Or any specific local configuration (e.g. health checks)?
TODO
If you happen to have further questions, do not hesitate to join the
[community support channels](https://support.icinga.org)
and ask community members for their experience and best practices.
## <a id="configuring-icinga2-overview"></a> Configuration Overview
### <a id="icinga2-conf"></a> icinga2.conf
An example configuration file is installed for you in `/etc/icinga2/icinga2.conf`.
Here's a brief description of the example configuration:
/**
* Icinga 2 configuration file
* -- this is where you define settings for the Icinga application including
* which hosts/services to check.
*
* For an overview of all available configuration options please refer
* to the documentation that is distributed as part of Icinga 2.
*/
Icinga 2 supports [C/C++-style comments](17-language-reference.md#comments).
/**
* The constants.conf defines global constants.
*/
include "constants.conf"
The `include` directive can be used to include other files.
/**
* The zones.conf defines zones for a cluster setup.
* Not required for single instance setups.
*/
include "zones.conf"
The [Icinga Template Library](10-icinga-template-library.md#icinga-template-library) provides a set of common templates
and [CheckCommand](3-monitoring-basics.md#check-commands) definitions.
/**
* The Icinga Template Library (ITL) provides a number of useful templates
* and command definitions.
* Common monitoring plugin command definitions are included separately.
*/
include <itl>
include <plugins>
include <plugins-contrib>
include <manubulon>
/**
* This includes the Icinga 2 Windows plugins. These command definitions
* are required on a master node when a client is used as command endpoint.
*/
include <windows-plugins>
/**
* This includes the NSClient++ check commands. These command definitions
* are required on a master node when a client is used as command endpoint.
*/
include <nscp>
/**
* The features-available directory contains a number of configuration
* files for features which can be enabled and disabled using the
* icinga2 feature enable / icinga2 feature disable CLI commands.
* These commands work by creating and removing symbolic links in
* the features-enabled directory.
*/
include "features-enabled/*.conf"
This `include` directive takes care of including the configuration files for all
the features which have been enabled with `icinga2 feature enable`. See
[Enabling/Disabling Features](11-cli-commands.md#enable-features) for more details.
/**
* The repository.d directory contains all configuration objects
* managed by the 'icinga2 repository' CLI commands.
*/
include_recursive "repository.d"
This `include_recursive` directive is used for discovery of services on remote clients
and their generated configuration described in
[this chapter](6-distributed-monitoring.md#distributed-monitoring-bottom-up).
/**
* Although in theory you could define all your objects in this file
* the preferred way is to create separate directories and files in the conf.d
* directory. Each of these files must have the file extension ".conf".
*/
include_recursive "conf.d"
You can put your own configuration files in the [conf.d](4-configuring-icinga-2.md#conf-d) directory. This
directive makes sure that all of your own configuration files are included.
### <a id="constants-conf"></a> constants.conf
The `constants.conf` configuration file can be used to define global constants.
By default, you need to make sure to set these constants:
* The `PluginDir` constant must be set to the path where the [Monitoring Project plugins](2-getting-started.md#setting-up-check-plugins) are installed.
This constant is used by a number of
[built-in check command definitions](10-icinga-template-library.md#plugin-check-commands).
* The `NodeName` constant defines your local node name. Should be set to FQDN which is the default
if not set. This constant is required for local host configuration, monitoring remote clients and
cluster setup.
Example:
/* The directory which contains the plugins from the Monitoring Plugins project. */
const PluginDir = "/usr/lib64/nagios/plugins"
/* The directory which contains the Manubulon plugins.
* Check the documentation, chapter "SNMP Manubulon Plugin Check Commands", for details.
*/
const ManubulonPluginDir = "/usr/lib64/nagios/plugins"
/* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`.
* This should be the common name from the API certificate.
*/
//const NodeName = "localhost"
/* Our local zone name. */
const ZoneName = NodeName
/* Secret key for remote node tickets */
const TicketSalt = ""
The `ZoneName` and `TicketSalt` constants are required for remote client
and distributed setups only.
### <a id="conf-d"></a> The conf.d Directory
This directory contains example configuration which should help you get started
with monitoring the local host and its services. It is included in the
[icinga2.conf](4-configuring-icinga-2.md#icinga2-conf) configuration file by default.
It can be used as reference example for your own configuration strategy.
Just keep in mind to include the main directories in the
[icinga2.conf](4-configuring-icinga-2.md#icinga2-conf) file.
You are certainly not bound to it. Remove it if you prefer your own
way of deploying Icinga 2 configuration.
Further details on configuration best practice and how to build your
own strategy is described in [this chapter](4-configuring-icinga-2.md#configuration-best-practice).
Available configuration files which are installed by default:
* [hosts.conf](4-configuring-icinga-2.md#hosts-conf)
* [services.conf](4-configuring-icinga-2.md#services-conf)
* [users.conf](4-configuring-icinga-2.md#users-conf)
* [notifications.conf](4-configuring-icinga-2.md#notifications-conf)
* [commands.conf](4-configuring-icinga-2.md#commands-conf)
* [groups.conf](4-configuring-icinga-2.md#groups-conf)
* [templates.conf](4-configuring-icinga-2.md#templates-conf)
* [downtimes.conf](4-configuring-icinga-2.md#downtimes-conf)
* [timeperiods.conf](4-configuring-icinga-2.md#timeperiods-conf)
* [satellite.conf](4-configuring-icinga-2.md#satellite-conf)
* [api-users.conf](4-configuring-icinga-2.md#api-users-conf)
* [app.conf](4-configuring-icinga-2.md#app-conf)
#### <a id="hosts-conf"></a> hosts.conf
The `hosts.conf` file contains an example host based on your
`NodeName` setting in [constants.conf](4-configuring-icinga-2.md#constants-conf). You
can use global constants for your object names instead of string
values.
The `import` keyword is used to import the `generic-host` template which
takes care of setting up the host check command to `hostalive`. If you
require a different check command, you can override it in the object definition.
The `vars` attribute can be used to define custom attributes which are available
for check and notification commands. Most of the [Plugin Check Commands](10-icinga-template-library.md#plugin-check-commands)
in the Icinga Template Library require an `address` attribute.
The custom attribute `os` is evaluated by the `linux-servers` group in
[groups.conf](4-configuring-icinga-2.md#groups-conf) making the local host a member.
The example host will show you how to
* define http vhost attributes for the `http` service apply rule defined
in [services.conf](4-configuring-icinga-2.md#services-conf).
* define disks (all, specific `/`) and their attributes for the `disk`
service apply rule defined in [services.conf](4-configuring-icinga-2.md#services-conf).
* define notification types (`mail`) and set the groups attribute. This
will be used by notification apply rules in [notifications.conf](notifications-conf).
If you've installed [Icinga Web 2](2-getting-started.md#setting-up-icingaweb2), you can
uncomment the http vhost attributes and reload Icinga 2. The apply
rules in [services.conf](4-configuring-icinga-2.md#services-conf) will automatically
generate a new service checking the `/icingaweb2` URI using the `http`
check.
/*
* Host definitions with object attributes
* used for apply rules for Service, Notification,
* Dependency and ScheduledDowntime objects.
*
* Tip: Use `icinga2 object list --type Host` to
* list all host objects after running
* configuration validation (`icinga2 daemon -C`).
*/
/*
* This is an example host based on your
* local host's FQDN. Specify the NodeName
* constant in `constants.conf` or use your
* own description, e.g. "db-host-1".
*/
object Host NodeName {
/* Import the default host template defined in `templates.conf`. */
import "generic-host"
/* Specify the address attributes for checks e.g. `ssh` or `http`. */
address = "127.0.0.1"
address6 = "::1"
/* Set custom attribute `os` for hostgroup assignment in `groups.conf`. */
vars.os = "Linux"
/* Define http vhost attributes for service apply rules in `services.conf`. */
vars.http_vhosts["http"] = {
http_uri = "/"
}
/* Uncomment if you've sucessfully installed Icinga Web 2. */
//vars.http_vhosts["Icinga Web 2"] = {
// http_uri = "/icingaweb2"
//}
/* Define disks and attributes for service apply rules in `services.conf`. */
vars.disks["disk"] = {
/* No parameters. */
}
vars.disks["disk /"] = {
disk_partitions = "/"
}
/* Define notification mail attributes for notification apply rules in `notifications.conf`. */
vars.notification["mail"] = {
/* The UserGroup `icingaadmins` is defined in `users.conf`. */
groups = [ "icingaadmins" ]
}
}
This is only the host object definition. Now we'll need to make sure that this
host and your additional hosts are getting [services](4-configuring-icinga-2.md#services-conf) applied.
> **Tip**
>
> If you don't understand all the attributes and how to use [apply rules](17-language-reference.md#apply),
> don't worry -- the [monitoring basics](3-monitoring-basics.md#monitoring-basics) chapter will explain
> that in detail.
#### <a id="services-conf"></a> services.conf
These service [apply rules](17-language-reference.md#apply) will show you how to monitor
the local host, but also allow you to re-use or modify them for
your own requirements.
You should define all your service apply rules in `services.conf`
or any other central location keeping them organized.
By default, the local host will be monitored by the following services
Service(s) | Applied on host(s)
--------------------------------------------|------------------------
`load`, `procs`, `swap`, `users`, `icinga` | The `NodeName` host only
`ping4`, `ping6` | All hosts with `address` resp. `address6` attribute
`ssh` | All hosts with `address` and `vars.os` set to `Linux`
`http`, optional: `Icinga Web 2` | All hosts with custom attribute `http_vhosts` defined as dictionary
`disk`, `disk /` | All hosts with custom attribute `disks` defined as dictionary
The Debian packages also include an additional `apt` service check applied to the local host.
The command object `icinga` for the embedded health check is provided by the
[Icinga Template Library (ITL)](10-icinga-template-library.md#icinga-template-library) while `http_ip`, `ssh`, `load`, `processes`,
`users` and `disk` are all provided by the [Plugin Check Commands](10-icinga-template-library.md#plugin-check-commands)
which we enabled earlier by including the `itl` and `plugins` configuration file.
Example `load` service apply rule:
apply Service "load" {
import "generic-service"
check_command = "load"
/* Used by the ScheduledDowntime apply rule in `downtimes.conf`. */
vars.backup_downtime = "02:00-03:00"
assign where host.name == NodeName
}
The `apply` keyword can be used to create new objects which are associated with
another group of objects. You can `import` existing templates, define (custom)
attributes.
The custom attribe `backup_downtime` is defined to a specific timerange string.
This variable value will be used for applying a `ScheduledDowntime` object to
these services in [downtimes.conf](4-configuring-icinga-2.md#downtimes-conf).
In this example the `assign where` condition is a boolean expression which is
evaluated for all objects of type `Host` and a new service with name "load"
is created for each matching host. [Expression operators](17-language-reference.md#expression-operators)
may be used in `assign where` conditions.
Multiple `assign where` condition can be combined with `AND` using the `&&` operator
as shown in the `ssh` example:
apply Service "ssh" {
import "generic-service"
check_command = "ssh"
assign where host.address && host.vars.os == "Linux"
}
In this example, the service `ssh` is applied to all hosts having the `address`
attribute defined `AND` having the custom attribute `os` set to the string
`Linux`.
You can modify this condition to match multiple expressions by combinding `AND`
and `OR` using `&&` and `||` [operators](17-language-reference.md#expression-operators), for example
`assign where host.address && (vars.os == "Linux" || vars.os == "Windows")`.
A more advanced example is shown by the `http` and `disk` service apply
rules. While one `apply` rule for `ssh` will only create a service for matching
hosts, you can go one step further: Generate apply rules based on array items
or dictionary key-value pairs.
The idea is simple: Your host in [hosts.conf](4-configuring-icinga-2.md#hosts-conf) defines the
`disks` dictionary as custom attribute in `vars`.
Remember the example from [hosts.conf](4-configuring-icinga-2.md#hosts-conf):
...
/* Define disks and attributes for service apply rules in `services.conf`. */
vars.disks["disk"] = {
/* No parameters. */
}
vars.disks["disk /"] = {
disk_partition = "/"
}
...
This dictionary contains multiple service names we want to monitor. `disk`
should just check all available disks, while `disk /` will pass an additional
parameter `disk_partition` to the check command.
You'll recognize that the naming is important -- that's the very same name
as it is passed from a service to a check command argument. Read about services
and passing check commands in [this chapter](3-monitoring-basics.md#command-passing-parameters).
Using `apply Service for` omits the service name, it will take the key stored in
the `disk` variable in `key => config` as new service object name.
The `for` keyword expects a loop definition, for example `key => value in dictionary`
as known from Perl and other scripting languages.
Once defined like this, the `apply` rule defined below will do the following:
* only match hosts with `host.vars.disks` defined through the `assign where` condition
* loop through all entries in the `host.vars.disks` dictionary. That's `disk` and `disk /` as keys.
* call `apply` on each, and set the service object name from the provided key
* inside apply, the `generic-service` template is imported
* defining the [disk](10-icinga-template-library.md#plugin-check-command-disk) check command requiring command arguments like `disk_partition`
* adding the `config` dictionary items to `vars`. Simply said, there's now `vars.disk_partition` defined for the
generated service
Configuration example:
apply Service for (disk => config in host.vars.disks) {
import "generic-service"
check_command = "disk"
vars += config
}
A similar example is used for the `http` services. That way you can make your
host the information provider for all apply rules. Define them once, and only
manage your hosts.
Look into [notifications.conf](4-configuring-icinga-2.md#notifications-conf) how this technique is used
for applying notifications to hosts and services using their type and user
attributes.
Don't forget to install the [check plugins](2-getting-started.md#setting-up-check-plugins) required by
the hosts and services and their check commands.
Further details on the monitoring configuration can be found in the
[monitoring basics](3-monitoring-basics.md#monitoring-basics) chapter.
#### <a id="users-conf"></a> users.conf
Defines the `icingaadmin` User and the `icingaadmins` UserGroup. The latter is used in
[hosts.conf](4-configuring-icinga-2.md#hosts-conf) for defining a custom host attribute later used in
[notifications.conf](4-configuring-icinga-2.md#notifications-conf) for notification apply rules.
object User "icingaadmin" {
import "generic-user"
display_name = "Icinga 2 Admin"
groups = [ "icingaadmins" ]
email = "icinga@localhost"
}
object UserGroup "icingaadmins" {
display_name = "Icinga 2 Admin Group"
}
#### <a id="notifications-conf"></a> notifications.conf
Notifications for check alerts are an integral part or your
Icinga 2 monitoring stack.
The examples in this file define two notification apply rules for hosts and services.
Both `apply` rules match on the same condition: They are only applied if the
nested dictionary attribute `notification.mail` is set.
Please note that the `to` keyword is important in [notification apply rules](3-monitoring-basics.md#using-apply-notifications)
defining whether these notifications are applies to hosts or services.
The `import` keyword imports the specific mail templates defined in [templates.conf](4-configuring-icinga-2.md#templates-conf).
The `interval` attribute is not explicitly set -- it [defaults to 30 minutes](9-object-types.md#objecttype-notification).
By setting the `user_groups` to the value provided by the
respective [host.vars.notification.mail](4-configuring-icinga-2.md#hosts-conf) attribute we'll
implicitely use the `icingaadmins` UserGroup defined in [users.conf](4-configuring-icinga-2.md#users-conf).
apply Notification "mail-icingaadmin" to Host {
import "mail-host-notification"
user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users
assign where host.vars.notification.mail
}
apply Notification "mail-icingaadmin" to Service {
import "mail-service-notification"
user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users
assign where host.vars.notification.mail
}
More details on defining notifications and their additional attributes such as
filters can be read in [this chapter](3-monitoring-basics.md#notifications).
### <a id="commands-conf"></a> commands.conf
This is the place where your own command configuration can be defined. By default
only the notification commands used by the notification templates defined in [templates.conf](4-configuring-icinga-2.md#templates-conf).
You can freely customize these notification commands, and adapt them for your needs.
Read more on that topic [here](3-monitoring-basics.md#notification-commands).
### <a id="groups-conf"></a> groups.conf
The example host defined in [hosts.conf](hosts-conf) already has the
custom attribute `os` set to `Linux` and is therefore automatically
a member of the host group `linux-servers`.
This is done by using the [group assign](17-language-reference.md#group-assign) expressions similar
to previously seen [apply rules](3-monitoring-basics.md#using-apply).
object HostGroup "linux-servers" {
display_name = "Linux Servers"
assign where host.vars.os == "Linux"
}
object HostGroup "windows-servers" {
display_name = "Windows Servers"
assign where host.vars.os == "Windows"
}
Service groups can be grouped together by similar pattern matches.
The [match() function](17-language-reference.md#function-calls) expects a wildcard match string
and the attribute string to match with.
object ServiceGroup "ping" {
display_name = "Ping Checks"
assign where match("ping*", service.name)
}
object ServiceGroup "http" {
display_name = "HTTP Checks"
assign where match("http*", service.check_command)
}
object ServiceGroup "disk" {
display_name = "Disk Checks"
assign where match("disk*", service.check_command)
}
#### <a id="templates-conf"></a> templates.conf
Most of the example configuration objects use generic global templates by
default:
template Host "generic-host" {
max_check_attempts = 5
check_interval = 1m
retry_interval = 30s
check_command = "hostalive"
}
template Service "generic-service" {
max_check_attempts = 3
check_interval = 1m
retry_interval = 30s
}
The `hostalive` check command is part of the
[Plugin Check Commands](10-icinga-template-library.md#plugin-check-commands).
template Notification "mail-host-notification" {
command = "mail-host-notification"
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
period = "24x7"
}
template Notification "mail-service-notification" {
command = "mail-service-notification"
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
period = "24x7"
}
More details on `Notification` object attributes can be found [here](9-object-types.md#objecttype-notification).
#### <a id="downtimes-conf"></a> downtimes.conf
The `load` service apply rule defined in [services.conf](4-configuring-icinga-2.md#services-conf) defines
the `backup_downtime` custom attribute.
The [ScheduledDowntime](9-object-types.md#objecttype-scheduleddowntime) apply rule uses this attribute
to define the default value for the time ranges required for recurring downtime slots.
apply ScheduledDowntime "backup-downtime" to Service {
author = "icingaadmin"
comment = "Scheduled downtime for backup"
ranges = {
monday = service.vars.backup_downtime
tuesday = service.vars.backup_downtime
wednesday = service.vars.backup_downtime
thursday = service.vars.backup_downtime
friday = service.vars.backup_downtime
saturday = service.vars.backup_downtime
sunday = service.vars.backup_downtime
}
assign where service.vars.backup_downtime != ""
}
#### <a id="timeperiods-conf"></a> timeperiods.conf
This file contains the default timeperiod definitions for `24x7`, `9to5`
and `never`. TimePeriod objects are referenced by `*period`
objects such as hosts, services or notifications.
#### <a id="satellite-conf"></a> satellite.conf
Includes default templates and dependencies for
[monitoring remote clients](6-distributed-monitoring.md#distributed-monitoring)
using service discovery and
[config generation](6-distributed-monitoring.md#distributed-monitoring-bottom-up)
on the master. Can be ignored/removed on setups not using this feature.
Further details on the monitoring configuration can be found in the
[monitoring basics](3-monitoring-basics.md#monitoring-basics) chapter.
#### <a id="api-users-conf"></a> api-users.conf
Provides the default [ApiUser](9-object-types.md#objecttype-apiuser) object
named "root" for the [API authentication](12-icinga2-api.md#icinga2-api-authentication).
#### <a id="app-conf"></a> app.conf
Provides the default [IcingaApplication](9-object-types.md#objecttype-icingaapplication)
object named "app" for additional settings such as disabling notifications
globally, etc.

View File

@ -0,0 +1,283 @@
# <a id="service-monitoring"></a> Service Monitoring
The power of Icinga 2 lies in its modularity. There are thousands of
community plugins available next to the standard plugins provided by
the [Monitoring Plugins project](https://www.monitoring-plugins.org).
## <a id="service-monitoring-requirements"></a> Requirements
### <a id="service-monitoring-plugins"></a> Plugins
All existing Nagios or Icinga 1.x plugins work with Icinga 2. Here's a
list of popular community sites which host check plugins:
* [Icinga Exchange](https://exchange.icinga.org)
* [Icinga Wiki](https://wiki.icinga.org)
The recommended way of setting up these plugins is to copy them to a common directory
and create a new global constant, e.g. `CustomPluginDir` in your [constants.conf](4-configuring-icinga-2.md#constants-conf)
configuration file:
# cp check_snmp_int.pl /opt/monitoring/plugins
# chmod +x /opt/plugins/check_snmp_int.pl
# cat /etc/icinga2/constants.conf
/**
* This file defines global constants which can be used in
* the other configuration files. At a minimum the
* PluginDir constant should be defined.
*/
const PluginDir = "/usr/lib/nagios/plugins"
const CustomPluginDir = "/opt/monitoring/plugins"
Prior to using the check plugin with Icinga 2 you should ensure that it is working properly
by trying to run it on the console using whichever user Icinga 2 is running as:
# su - icinga -s /bin/bash
$ /opt/monitoring/plugins/check_snmp_int.pl --help
Additional libraries may be required for some plugins. Please consult the plugin
documentation and/or the included README file for installation instructions.
Sometimes plugins contain hard-coded paths to other components. Instead of changing
the plugin it might be easier to create a symbolic link to make sure it doesn't get overwritten during the next update.
Sometimes there are plugins which do not exactly fit your requirements.
In that case you can modify an existing plugin or just write your own.
### <a id="service-monitoring-plugin-checkcommand"></a> CheckCommand Definition
Each plugin requires a [CheckCommand](9-object-types.md#objecttype-checkcommand) object in your
configuration which can be used in the [Service](9-object-types.md#objecttype-service) or
[Host](9-object-types.md#objecttype-host) object definition.
Please check if the Icinga 2 package already provides an
[existing CheckCommand definition](10-icinga-template-library.md#plugin-check-commands).
If that's the case, throroughly check the required parameters and integrate the check command
into your host and service objects.
Please make sure to follow these conventions when adding a new command object definition:
* Use [command arguments](3-monitoring-basics.md#command-arguments) whenever possible. The `command` attribute
must be an array in `[ ... ]` for shell escaping.
* Define a unique `prefix` for the command's specific arguments. That way you can safely
set them on host/service level and you'll always know which command they control.
* Use command argument default values, e.g. for thresholds.
* Use [advanced conditions](9-object-types.md#objecttype-checkcommand) like `set_if` definitions.
This is an example for a custom `my-snmp-int` check command:
object CheckCommand "my-snmp-int" {
command = [ CustomPluginDir + "/check_snmp_int.pl" ]
arguments = {
"-H" = "$snmp_address$"
"-C" = "$snmp_community$"
"-p" = "$snmp_port$"
"-2" = {
set_if = "$snmp_v2$"
}
"-n" = "$snmp_interface$"
"-f" = {
set_if = "$snmp_perf$"
}
"-w" = "$snmp_warn$"
"-c" = "$snmp_crit$"
}
vars.snmp_v2 = true
vars.snmp_perf = true
vars.snmp_warn = "300,400"
vars.snmp_crit = "0,600"
}
For further information on your monitoring configuration read the
[Monitoring Basics](3-monitoring-basics.md#monitoring-basics) chapter.
If you have created your own `CheckCommand` definition, please kindly
[send it upstream](https://wiki.icinga.org/display/community/Contribute+Icinga+2+ITL+Plugin+Check+Command+Definitions).
### <a id="service-monitoring-plugin-api"></a> Plugin API
Currently Icinga 2 supports the native plugin API specification from the Monitoring Plugins project. It is defined in the [Monitoring Plugins Development Guidelines](https://www.monitoring-plugins.org/doc/guidelines.html).
### <a id="service-monitoring-plugin-new"></a> Create a new Plugin
Sometimes an existing plugin does not satisfy your requirements. You
can either kindly contact the original author about plans to add changes
and/or create a patch.
If you just want to format the output and state of an existing plugin
it might also be helpful to write a wrapper script. This script
could pass all configured parameters, call the plugin script, parse
its output/exit code and return your specified output/exit code.
On the other hand plugins for specific services and hardware might not yet
exist.
Common best practices when creating a new plugin are for example:
* Choose the pragramming language wisely
* Scripting languages (Bash, Python, Perl, Ruby, PHP, etc.) are easier to write and setup but their check execution might take longer (invoking the script interpreter as overhead, etc.).
* Plugins written in C/C++, Go, etc. improve check execution time but may generate an overhead with installation and packaging.
* Use a modern VCS such as Git for developing the plugin (e.g. share your plugin on GitHub).
* Add parameters with key-value pairs to your plugin. They should allow long names (e.g. `--host localhost`) and also short parameters (e.g. `-H localhost`)
* `-h|--help` should print the version and all details about parameters and runtime invocation.
* Add a verbose/debug output functionality for detailed on-demand logging.
* Respect the exit codes required by the [Plugin API](5-service-monitoring.md#service-monitoring-plugin-api).
* Always add performance data to your plugin output
Example skeleton:
# 1. include optional libraries
# 2. global variables
# 3. helper functions and/or classes
# 4. define timeout condition
if (<timeout_reached>) then
print "UNKNOWN - Timeout (...) reached | 'time'=30.0
endif
# 5. main method
<execute and fetch data>
if (<threshold_critical_condition>) then
print "CRITICAL - ... | 'time'=0.1 'myperfdatavalue'=5.0
exit(2)
else if (<threshold_warning_condition>) then
print "WARNING - ... | 'time'=0.1 'myperfdatavalue'=3.0
exit(1)
else
print "OK - ... | 'time'=0.2 'myperfdatavalue'=1.0
endif
There are various plugin libraries available which will help
with plugin execution and output formatting too, for example
[nagiosplugin from Python](https://pypi.python.org/pypi/nagiosplugin/).
> **Note**
>
> Ensure to test your plugin properly with special cases before putting it
> into production!
Once you've finished your plugin please upload/sync it to [Icinga Exchange](https://exchange.icinga.org/new).
Thanks in advance!
## <a id="service-monitoring-overview"></a> Service Monitoring Overview
The following examples should help you to start implementing your own ideas.
There is a variety of plugins available. This collection is not complete --
if you have any updates, please send a documentation patch upstream.
### <a id="service-monitoring-general"></a> General Monitoring
If the remote service is available (via a network protocol and port),
and if a check plugin is also available, you don't necessarily need a local client.
Instead, choose a plugin and configure its parameters and thresholds. The following examples are included in the [Icinga 2 Template Library](10-icinga-template-library.md#icinga-template-library):
* [ping4](10-icinga-template-library.md#plugin-check-command-ping4), [ping6](10-icinga-template-library.md#plugin-check-command-ping6),
[fping4](10-icinga-template-library.md#plugin-check-command-fping4), [fping6](10-icinga-template-library.md#plugin-check-command-fping6), [hostalive](10-icinga-template-library.md#plugin-check-command-hostalive)
* [tcp](10-icinga-template-library.md#plugin-check-command-tcp), [udp](10-icinga-template-library.md#plugin-check-command-udp), [ssl](10-icinga-template-library.md#plugin-check-command-ssl)
* [ntp_time](10-icinga-template-library.md#plugin-check-command-ntp-time)
### <a id="service-monitoring-linux"></a> Linux Monitoring
* [disk](10-icinga-template-library.md#plugin-check-command-disk)
* [mem](10-icinga-template-library.md#plugin-contrib-command-mem), [swap](10-icinga-template-library.md#plugin-check-command-swap)
* [running_kernel](10-icinga-template-library.md#plugin-contrib-command-running_kernel)
* package management: [apt](10-icinga-template-library.md#plugin-check-command-apt), [yum](10-icinga-template-library.md#plugin-contrib-command-yum), etc.
* [ssh](10-icinga-template-library.md#plugin-check-command-ssh)
* performance: [iostat](10-icinga-template-library.md#plugin-contrib-command-iostat), [check_sar_perf](https://github.com/dnsmichi/icinga-plugins/blob/master/scripts/check_sar_perf.py)
### <a id="service-monitoring-windows"></a> Windows Monitoring
* [check_wmi_plus](http://www.edcint.co.nz/checkwmiplus/)
* [NSClient++](https://www.nsclient.org) (in combination with the Icinga 2 client as [nscp-local](10-icinga-template-library.md#nscp-plugin-check-commands) check commands)
* [Icinga 2 Windows Plugins](10-icinga-template-library.md#windows-plugins) (disk, load, memory, network, performance counters, ping, procs, service, swap, updates, uptime, users
* vbs and Powershell scripts
### <a id="service-monitoring-database"></a> Database Monitoring
* MySQL/MariaDB: [mysql_health](10-icinga-template-library.md#plugin-contrib-command-mysql_health), [mysql](10-icinga-template-library.md#plugin-check-command-mysql), [mysql_query](10-icinga-template-library.md#plugin-check-command-mysql-query)
* PostgreSQL: [postgres](10-icinga-template-library.md#plugin-contrib-command-postgres)
* Oracle: [oracle_health](10-icinga-template-library.md#plugin-contrib-command-oracle_health)
* MSSQL: [mssql_health](10-icinga-template-library.md#plugin-contrib-command-mssql_health)
* DB2: [db2_health](10-icinga-template-library.md#plugin-contrib-command-db2_health)
* MongoDB: [mongodb](10-icinga-template-library.md#plugin-contrib-command-mongodb)
* Elasticsearch: [elasticsearch](10-icinga-template-library.md#plugin-contrib-command-elasticsearch)
* Redis: [redis](10-icinga-template-library.md#plugin-contrib-command-redis)
### <a id="service-monitoring-snmp"></a> SNMP Monitoring
* [Manubulon plugins](10-icinga-template-library.md#snmp-manubulon-plugin-check-commands) (interface, storage, load, memory, process)
* [snmp](10-icinga-template-library.md#plugin-check-command-snmp), [snmpv3](10-icinga-template-library.md#plugin-check-command-snmpv3)
### <a id="service-monitoring-network"></a> Network Monitoring
* [nwc_health](10-icinga-template-library.md#plugin-contrib-command-nwc_health)
* [interfaces](10-icinga-template-library.md#plugin-contrib-command-interfaces)
* [interfacetable](10-icinga-template-library.md#plugin-contrib-command-interfacetable)
* [iftraffic](10-icinga-template-library.md#plugin-contrib-command-iftraffic), [iftraffic64](10-icinga-template-library.md#plugin-contrib-command-iftraffic64)
### <a id="service-monitoring-web"></a> Web Monitoring
* [http](10-icinga-template-library.md#plugin-check-command-http)
* [ftp](10-icinga-template-library.md#plugin-check-command-ftp)
* [webinject](10-icinga-template-library.md#plugin-contrib-command-webinject)
* [squid](10-icinga-template-library.md#plugin-contrib-command-squid)
* [apache_status](10-icinga-template-library.md#plugin-contrib-command-apache_status)
* [nginx_status](10-icinga-template-library.md#plugin-contrib-command-nginx_status)
* [kdc](10-icinga-template-library.md#plugin-contrib-command-kdc)
* [rbl](10-icinga-template-library.md#plugin-contrib-command-rbl)
### <a id="service-monitoring-java"></a> Java Monitoring
* [jmx4perl](10-icinga-template-library.md#plugin-contrib-command-jmx4perl)
### <a id="service-monitoring-dns"></a> DNS Monitoring
* [dns](10-icinga-template-library.md#plugin-check-command-dns)
* [dig](10-icinga-template-library.md#plugin-check-command-dig)
* [dhcp](10-icinga-template-library.md#plugin-check-command-dhcp)
### <a id="service-monitoring-backup"></a> Backup Monitoring
* [check_bareos](https://github.com/widhalmt/check_bareos)
### <a id="service-monitoring-log"></a> Log Monitoring
* [check_logfiles](https://labs.consol.de/nagios/check_logfiles/)
* [check_logstash](https://github.com/widhalmt/check_logstash)
* [check_graylog2_stream](https://github.com/Graylog2/check-graylog2-stream)
### <a id="service-monitoring-virtualization"></a> Virtualization Monitoring
### <a id="service-monitoring-virtualization-vmware"></a> VMware Monitoring
* [esxi_hardware](10-icinga-template-library.md#plugin-contrib-command-esxi-hardware)
* [VMware](10-icinga-template-library.md#plugin-contrib-vmware)
**Tip**: If you are encountering timeouts using the VMware Perl SDK,
check [this blog entry](http://www.claudiokuenzler.com/blog/650/slow-vmware-perl-sdk-soap-request-error-libwww-version).
### <a id="service-monitoring-sap"></a> SAP Monitoring
* [check_sap_health](https://labs.consol.de/nagios/check_sap_health/index.html)
* [SAP CCMS](https://sourceforge.net/projects/nagios-sap-ccms/)
### <a id="service-monitoring-mail"></a> Mail Monitoring
* [smtp](10-icinga-template-library.md#plugin-check-command-smtp), [ssmtp](10-icinga-template-library.md#plugin-check-command-ssmtp)
* [imap](10-icinga-template-library.md#plugin-check-command-imap), [simap](10-icinga-template-library.md#plugin-check-command-simap)
* [pop](10-icinga-template-library.md#plugin-check-command-pop), [spop](10-icinga-template-library.md#plugin-check-command-spop)
### <a id="service-monitoring-hardware"></a> Hardware Monitoring
* [hpasm](10-icinga-template-library.md#plugin-contrib-command-hpasm)
* [ipmi-sensor](10-icinga-template-library.md#plugin-contrib-command-ipmi-sensor)
### <a id="service-monitoring-metrics"></a> Metrics Monitoring
* [graphite](10-icinga-template-library.md#plugin-contrib-command-graphite)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,359 @@
# <a id="agent-based-checks-addon"></a> Additional Agent-based Checks
If the remote services are not directly accessible through the network, a
local agent installation exposing the results to check queries can
become handy.
## <a id="agent-based-checks-snmp"></a> SNMP
The SNMP daemon runs on the remote system and answers SNMP queries by plugin
binaries. The [Monitoring Plugins package](2-getting-started.md#setting-up-check-plugins) ships
the `check_snmp` plugin binary, but there are plenty of [existing plugins](5-service-monitoring.md#service-monitoring-plugins)
for specific use cases already around, for example monitoring Cisco routers.
The following example uses the [SNMP ITL](10-icinga-template-library.md#plugin-check-command-snmp) `CheckCommand` and just
overrides the `snmp_oid` custom attribute. A service is created for all hosts which
have the `snmp-community` custom attribute.
apply Service "uptime" {
import "generic-service"
check_command = "snmp"
vars.snmp_oid = "1.3.6.1.2.1.1.3.0"
vars.snmp_miblist = "DISMAN-EVENT-MIB"
assign where host.vars.snmp_community != ""
}
Additional SNMP plugins are available using the [Manubulon SNMP Plugins](10-icinga-template-library.md#snmp-manubulon-plugin-check-commands).
If no `snmp_miblist` is specified, the plugin will default to `ALL`. As the number of available MIB files
on the system increases so will the load generated by this plugin if no `MIB` is specified.
As such, it is recommended to always specify at least one `MIB`.
## <a id="agent-based-checks-ssh"></a> SSH
Calling a plugin using the SSH protocol to execute a plugin on the remote server fetching
its return code and output. The `by_ssh` command object is part of the built-in templates and
requires the `check_by_ssh` check plugin which is available in the [Monitoring Plugins package](2-getting-started.md#setting-up-check-plugins).
object CheckCommand "by_ssh_swap" {
import "by_ssh"
vars.by_ssh_command = "/usr/lib/nagios/plugins/check_swap -w $by_ssh_swap_warn$ -c $by_ssh_swap_crit$"
vars.by_ssh_swap_warn = "75%"
vars.by_ssh_swap_crit = "50%"
}
object Service "swap" {
import "generic-service"
host_name = "remote-ssh-host"
check_command = "by_ssh_swap"
vars.by_ssh_logname = "icinga"
}
## <a id="agent-based-checks-nsclient"></a> NSClient++
[NSClient++](http://nsclient.org) works on both Windows and Linux platforms and is well
known for its magnificent Windows support. There are alternatives like the WMI interface,
but using `NSClient++` will allow you to run local scripts similar to check plugins fetching
the required output and performance counters.
You can use the `check_nt` plugin from the Monitoring Plugins project to query NSClient++.
Icinga 2 provides the [nscp check command](10-icinga-template-library.md#plugin-check-command-nscp) for this:
Example:
object Service "disk" {
import "generic-service"
host_name = "remote-windows-host"
check_command = "nscp"
vars.nscp_variable = "USEDDISKSPACE"
vars.nscp_params = "c"
vars.nscp_warn = 70
vars.nscp_crit = 80
}
For details on the `NSClient++` configuration please refer to the [official documentation](http://www.nsclient.org/nscp/wiki/doc/configuration/0.4.x).
## <a id="agent-based-checks-nsca-ng"></a> NSCA-NG
[NSCA-ng](http://www.nsca-ng.org) provides a client-server pair that allows the
remote sender to push check results into the Icinga 2 `ExternalCommandListener`
feature.
> **Note**
>
> This addon works in a similar fashion like the Icinga 1.x distributed model. If you
> are looking for a real distributed architecture with Icinga 2, scroll down.
## <a id="agent-based-checks-nrpe"></a> NRPE
[NRPE](http://docs.icinga.org/latest/en/nrpe.html) runs as daemon on the remote client including
the required plugins and command definitions.
Icinga 2 calls the `check_nrpe` plugin binary in order to query the configured command on the
remote client.
> **Note**
>
> The NRPE protocol is considered insecure and has multiple flaws in its
> design. Upstream is not willing to fix these issues.
>
> In order to stay safe, please use the native [Icinga 2 client](6-distributed-monitoring.md#distributed-monitoring)
> instead.
The NRPE daemon uses its own configuration format in nrpe.cfg while `check_nrpe`
can be embedded into the Icinga 2 `CheckCommand` configuration syntax.
You can use the `check_nrpe` plugin from the NRPE project to query the NRPE daemon.
Icinga 2 provides the [nrpe check command](10-icinga-template-library.md#plugin-check-command-nrpe) for this:
Example:
object Service "users" {
import "generic-service"
host_name = "remote-nrpe-host"
check_command = "nrpe"
vars.nrpe_command = "check_users"
}
nrpe.cfg:
command[check_users]=/usr/local/icinga/libexec/check_users -w 5 -c 10
If you are planning to pass arguments to NRPE using the `-a`
command line parameter, make sure that your NRPE daemon has them
supported and enabled.
> **Note**
>
> Enabling command arguments in NRPE is considered harmful
> and exposes a security risk allowing attackers to execute
> commands remotely. Details at [seclists.org](http://seclists.org/fulldisclosure/2014/Apr/240).
The plugin check command `nrpe` provides the `nrpe_arguments` custom
attribute which expects either a single value or an array of values.
Example:
object Service "nrpe-disk-/" {
import "generic-service"
host_name = "remote-nrpe-host"
check_command = "nrpe"
vars.nrpe_command = "check_disk"
vars.nrpe_arguments = [ "20%", "10%", "/" ]
}
Icinga 2 will execute the nrpe plugin like this:
/usr/lib/nagios/plugins/check_nrpe -H <remote-nrpe-host> -c 'check_disk' -a '20%' '10%' '/'
NRPE expects all additional arguments in an ordered fashion
and interprets the first value as `$ARG1$` macro, the second
value as `$ARG2$`, and so on.
nrpe.cfg:
command[check_disk]=/usr/local/icinga/libexec/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
Using the above example with `nrpe_arguments` the command
executed by the NRPE daemon looks similar to that:
/usr/local/icinga/libexec/check_disk -w 20% -c 10% -p /
You can pass arguments in a similar manner to [NSClient++](7-agent-based-monitoring.md#agent-based-checks-nsclient)
when using its NRPE supported check method.
## <a id="agent-based-checks-snmp-traps"></a> Passive Check Results and SNMP Traps
SNMP Traps can be received and filtered by using [SNMPTT](http://snmptt.sourceforge.net/)
and specific trap handlers passing the check results to Icinga 2.
Following the SNMPTT [Format](http://snmptt.sourceforge.net/docs/snmptt.shtml#SNMPTT.CONF-FORMAT)
documentation and the Icinga external command syntax found [here](23-appendix.md#external-commands-list-detail)
we can create generic services that can accommodate any number of hosts for a given scenario.
### <a id="simple-traps"></a> Simple SNMP Traps
A simple example might be monitoring host reboots indicated by an SNMP agent reset.
Building the event to auto reset after dispatching a notification is important.
Setup the manual check parameters to reset the event from an initial unhandled
state or from a missed reset event.
Add a directive in `snmptt.conf`
EVENT coldStart .1.3.6.1.6.3.1.1.5.1 "Status Events" Normal
FORMAT Device reinitialized (coldStart)
EXEC echo "[$@] PROCESS_SERVICE_CHECK_RESULT;$A;Coldstart;2;The snmp agent has reinitialized." >> /var/run/icinga2/cmd/icinga2.cmd
SDESC
A coldStart trap signifies that the SNMPv2 entity, acting
in an agent role, is reinitializing itself and that its
configuration may have been altered.
EDESC
1. Define the `EVENT` as per your need.
2. Construct the `EXEC` statement with the service name matching your template
applied to your _n_ hosts. The host address inferred by SNMPTT will be the
correlating factor. You can have snmptt provide host names or ip addresses to
match your Icinga convention.
Add an `EventCommand` configuration object for the passive service auto reset event.
object EventCommand "coldstart-reset-event" {
command = [ SysconfDir + "/icinga2/conf.d/custom/scripts/coldstart_reset_event.sh" ]
arguments = {
"-i" = "$service.state_id$"
"-n" = "$host.name$"
"-s" = "$service.name$"
}
}
Create the `coldstart_reset_event.sh` shell script to pass the expanded variable
data in. The `$service.state_id$` is important in order to prevent an endless loop
of event firing after the service has been reset.
#!/bin/bash
SERVICE_STATE_ID=""
HOST_NAME=""
SERVICE_NAME=""
show_help()
{
cat <<-EOF
Usage: ${0##*/} [-h] -n HOST_NAME -s SERVICE_NAME
Writes a coldstart reset event to the Icinga command pipe.
-h Display this help and exit.
-i SERVICE_STATE_ID The associated service state id.
-n HOST_NAME The associated host name.
-s SERVICE_NAME The associated service name.
EOF
}
while getopts "hi:n:s:" opt; do
case "$opt" in
h)
show_help
exit 0
;;
i)
SERVICE_STATE_ID=$OPTARG
;;
n)
HOST_NAME=$OPTARG
;;
s)
SERVICE_NAME=$OPTARG
;;
'?')
show_help
exit 0
;;
esac
done
if [ -z "$SERVICE_STATE_ID" ]; then
show_help
printf "\n Error: -i required.\n"
exit 1
fi
if [ -z "$HOST_NAME" ]; then
show_help
printf "\n Error: -n required.\n"
exit 1
fi
if [ -z "$SERVICE_NAME" ]; then
show_help
printf "\n Error: -s required.\n"
exit 1
fi
if [ "$SERVICE_STATE_ID" -gt 0 ]; then
echo "[`date +%s`] PROCESS_SERVICE_CHECK_RESULT;$HOST_NAME;$SERVICE_NAME;0;Auto-reset (`date +"%m-%d-%Y %T"`)." >> /var/run/icinga2/cmd/icinga2.cmd
fi
Finally create the `Service` and assign it:
apply Service "Coldstart" {
import "generic-service-custom"
check_command = "dummy"
event_command = "coldstart-reset-event"
enable_notifications = 1
enable_active_checks = 0
enable_passive_checks = 1
enable_flapping = 0
volatile = 1
enable_perfdata = 0
vars.dummy_state = 0
vars.dummy_text = "Manual reset."
vars.sla = "24x7"
assign where (host.vars.os == "Linux" || host.vars.os == "Windows")
}
### <a id="complex-traps"></a> Complex SNMP Traps
A more complex example might be passing dynamic data from a traps varbind list
for a backup scenario where the backup software dispatches status updates. By
utilizing active and passive checks, the older freshness concept can be leveraged.
By defining the active check as a hard failed state, a missed backup can be reported.
As long as the most recent passive update has occurred, the active check is bypassed.
Add a directive in `snmptt.conf`
EVENT enterpriseSpecific <YOUR OID> "Status Events" Normal
FORMAT Enterprise specific trap
EXEC echo "[$@] PROCESS_SERVICE_CHECK_RESULT;$A;$1;$2;$3" >> /var/run/icinga2/cmd/icinga2.cmd
SDESC
An enterprise specific trap.
The varbinds in order denote the Icinga service name, state and text.
EDESC
1. Define the `EVENT` as per your need using your actual oid.
2. The service name, state and text are extracted from the first three varbinds.
This has the advantage of accommodating an unlimited set of use cases.
Create a `Service` for the specific use case associated to the host. If the host
matches and the first varbind value is `Backup`, SNMPTT will submit the corresponding
passive update with the state and text from the second and third varbind:
object Service "Backup" {
import "generic-service-custom"
host_name = "host.domain.com"
check_command = "dummy"
enable_notifications = 1
enable_active_checks = 1
enable_passive_checks = 1
enable_flapping = 0
volatile = 1
max_check_attempts = 1
check_interval = 87000
enable_perfdata = 0
vars.sla = "24x7"
vars.dummy_state = 2
vars.dummy_text = "No passive check result received."
}

View File

@ -0,0 +1,685 @@
# <a id="advanced-topics"></a> Advanced Topics
This chapter covers a number of advanced topics. If you're new to Icinga, you
can safely skip over things you're not interested in.
## <a id="downtimes"></a> Downtimes
Downtimes can be scheduled for planned server maintenance or
any other targeted service outage you are aware of in advance.
Downtimes will suppress any notifications, and may trigger other
downtimes too. If the downtime was set by accident, or the duration
exceeds the maintenance, you can manually cancel the downtime.
Planned downtimes will also be taken into account for SLA reporting
tools calculating the SLAs based on the state and downtime history.
Multiple downtimes for a single object may overlap. This is useful
when you want to extend your maintenance window taking longer than expected.
If there are multiple downtimes triggered for one object, the overall downtime depth
will be greater than `1`.
If the downtime was scheduled after the problem changed to a critical hard
state triggering a problem notification, and the service recovers during
the downtime window, the recovery notification won't be suppressed.
### <a id="fixed-flexible-downtimes"></a> Fixed and Flexible Downtimes
A `fixed` downtime will be activated at the defined start time, and
removed at the end time. During this time window the service state
will change to `NOT-OK` and then actually trigger the downtime.
Notifications are suppressed and the downtime depth is incremented.
Common scenarios are a planned distribution upgrade on your linux
servers, or database updates in your warehouse. The customer knows
about a fixed downtime window between 23:00 and 24:00. After 24:00
all problems should be alerted again. Solution is simple -
schedule a `fixed` downtime starting at 23:00 and ending at 24:00.
Unlike a `fixed` downtime, a `flexible` downtime will be triggered
by the state change in the time span defined by start and end time,
and then last for the specified duration in minutes.
Imagine the following scenario: Your service is frequently polled
by users trying to grab free deleted domains for immediate registration.
Between 07:30 and 08:00 the impact will hit for 15 minutes and generate
a network outage visible to the monitoring. The service is still alive,
but answering too slow to Icinga 2 service checks.
For that reason, you may want to schedule a downtime between 07:30 and
08:00 with a duration of 15 minutes. The downtime will then last from
its trigger time until the duration is over. After that, the downtime
is removed (may happen before or after the actual end time!).
### <a id="scheduling-downtime"></a> Scheduling a downtime
This can either happen through a web interface or by sending an [external command](14-features.md#external-commands)
to the external command pipe provided by the `ExternalCommandListener` configuration.
Fixed downtimes require a start and end time (a duration will be ignored).
Flexible downtimes need a start and end time for the time span, and a duration
independent from that time span.
### <a id="triggered-downtimes"></a> Triggered Downtimes
This is optional when scheduling a downtime. If there is already a downtime
scheduled for a future maintenance, the current downtime can be triggered by
that downtime. This renders useful if you have scheduled a host downtime and
are now scheduling a child host's downtime getting triggered by the parent
downtime on `NOT-OK` state change.
### <a id="recurring-downtimes"></a> Recurring Downtimes
[ScheduledDowntime objects](9-object-types.md#objecttype-scheduleddowntime) can be used to set up
recurring downtimes for services.
Example:
apply ScheduledDowntime "backup-downtime" to Service {
author = "icingaadmin"
comment = "Scheduled downtime for backup"
ranges = {
monday = "02:00-03:00"
tuesday = "02:00-03:00"
wednesday = "02:00-03:00"
thursday = "02:00-03:00"
friday = "02:00-03:00"
saturday = "02:00-03:00"
sunday = "02:00-03:00"
}
assign where "backup" in service.groups
}
## <a id="comments-intro"></a> Comments
Comments can be added at runtime and are persistent over restarts. You can
add useful information for others on repeating incidents (for example
"last time syslog at 100% cpu on 17.10.2013 due to stale nfs mount") which
is primarily accessible using web interfaces.
Adding and deleting comment actions are possible through the external command pipe
provided with the `ExternalCommandListener` configuration. The caller must
pass the comment id in case of manipulating an existing comment.
## <a id="acknowledgements"></a> Acknowledgements
If a problem is alerted and notified, you may signal the other notification
recipients that you are aware of the problem and will handle it.
By sending an acknowledgement to Icinga 2 (using the external command pipe
provided with `ExternalCommandListener` configuration) all future notifications
are suppressed, a new comment is added with the provided description and
a notification with the type `NotificationFilterAcknowledgement` is sent
to all notified users.
### <a id="expiring-acknowledgements"></a> Expiring Acknowledgements
Once a problem is acknowledged it may disappear from your `handled problems`
dashboard and no-one ever looks at it again since it will suppress
notifications too.
This `fire-and-forget` action is quite common. If you're sure that a
current problem should be resolved in the future at a defined time,
you can define an expiration time when acknowledging the problem.
Icinga 2 will clear the acknowledgement when expired and start to
re-notify, if the problem persists.
## <a id="timeperiods"></a> Time Periods
[Time Periods](9-object-types.md#objecttype-timeperiod) define
time ranges in Icinga where event actions are triggered, for
example whether a service check is executed or not within
the `check_period` attribute. Or a notification should be sent to
users or not, filtered by the `period` and `notification_period`
configuration attributes for `Notification` and `User` objects.
> **Note**
>
> If you are familiar with Icinga 1.x, these time period definitions
> are called `legacy timeperiods` in Icinga 2.
>
> An Icinga 2 legacy timeperiod requires the `ITL` provided template
>`legacy-timeperiod`.
The `TimePeriod` attribute `ranges` may contain multiple directives,
including weekdays, days of the month, and calendar dates.
These types may overlap/override other types in your ranges dictionary.
The descending order of precedence is as follows:
* Calendar date (2008-01-01)
* Specific month date (January 1st)
* Generic month date (Day 15)
* Offset weekday of specific month (2nd Tuesday in December)
* Offset weekday (3rd Monday)
* Normal weekday (Tuesday)
If you don't set any `check_period` or `notification_period` attribute
on your configuration objects, Icinga 2 assumes `24x7` as time period
as shown below.
object TimePeriod "24x7" {
import "legacy-timeperiod"
display_name = "Icinga 2 24x7 TimePeriod"
ranges = {
"monday" = "00:00-24:00"
"tuesday" = "00:00-24:00"
"wednesday" = "00:00-24:00"
"thursday" = "00:00-24:00"
"friday" = "00:00-24:00"
"saturday" = "00:00-24:00"
"sunday" = "00:00-24:00"
}
}
If your operation staff should only be notified during workhours,
create a new timeperiod named `workhours` defining a work day from
09:00 to 17:00.
object TimePeriod "workhours" {
import "legacy-timeperiod"
display_name = "Icinga 2 8x5 TimePeriod"
ranges = {
"monday" = "09:00-17:00"
"tuesday" = "09:00-17:00"
"wednesday" = "09:00-17:00"
"thursday" = "09:00-17:00"
"friday" = "09:00-17:00"
}
}
Use the `period` attribute to assign time periods to
`Notification` and `Dependency` objects:
object Notification "mail" {
import "generic-notification"
host_name = "localhost"
command = "mail-notification"
users = [ "icingaadmin" ]
period = "workhours"
}
### <a id="timeperiods-includes-excludes"></a> Time Periods Inclusion and Exclusion
Sometimes it is necessary to exclude certain time ranges from
your default time period definitions, for example, if you don't
want to send out any notification during the holiday season,
or if you only want to allow small time windows for executed checks.
The [TimePeriod object](9-object-types.md#objecttype-timeperiod)
provides the `includes` and `excludes` attributes to solve this issue.
`prefer_includes` defines whether included or excluded time periods are
preferred.
The following example defines a time period called `holidays` where
notifications should be supressed:
object TimePeriod "holidays" {
import "legacy-timeperiod"
ranges = {
"january 1" = "00:00-24:00" //new year's day
"july 4" = "00:00-24:00" //independence day
"december 25" = "00:00-24:00" //christmas
"december 31" = "18:00-24:00" //new year's eve (6pm+)
"2017-04-16" = "00:00-24:00" //easter 2017
"monday -1 may" = "00:00-24:00" //memorial day (last monday in may)
"monday 1 september" = "00:00-24:00" //labor day (1st monday in september)
"thursday 4 november" = "00:00-24:00" //thanksgiving (4th thursday in november)
}
}
In addition to that the time period `weekends` defines an additional
time window which should be excluded from notifications:
object TimePeriod "weekends-excluded" {
import "legacy-timeperiod"
ranges = {
"saturday" = "00:00-09:00,18:00-24:00"
"sunday" = "00:00-09:00,18:00-24:00"
}
}
The time period `prod-notification` defines the default time ranges
and adds the excluded time period names as an array.
object TimePeriod "prod-notification" {
import "legacy-timeperiod"
excludes = [ "holidays", "weekends-excluded" ]
ranges = {
"monday" = "00:00-24:00"
"tuesday" = "00:00-24:00"
"wednesday" = "00:00-24:00"
"thursday" = "00:00-24:00"
"friday" = "00:00-24:00"
"saturday" = "00:00-24:00"
"sunday" = "00:00-24:00"
}
}
## <a id="use-functions-object-config"></a> Use Functions in Object Configuration
There is a limited scope where functions can be used as object attributes such as:
* As value for [Custom Attributes](3-monitoring-basics.md#custom-attributes-functions)
* Returning boolean expressions for [set_if](8-advanced-topics.md#use-functions-command-arguments-setif) inside command arguments
* Returning a [command](8-advanced-topics.md#use-functions-command-attribute) array inside command objects
The other way around you can create objects dynamically using your own global functions.
> **Note**
>
> Functions called inside command objects share the same global scope as runtime macros.
> Therefore you can access host custom attributes like `host.vars.os`, or any other
> object attribute from inside the function definition used for [set_if](8-advanced-topics.md#use-functions-command-arguments-setif) or [command](8-advanced-topics.md#use-functions-command-attribute).
Tips when implementing functions:
* Use [log()](18-library-reference.md#global-functions) to dump variables. You can see the output
inside the `icinga2.log` file depending in your log severity
* Use the `icinga2 console` to test basic functionality (e.g. iterating over a dictionary)
* Build them step-by-step. You can always refactor your code later on.
### <a id="use-functions-command-arguments-setif"></a> Use Functions in Command Arguments set_if
The `set_if` attribute inside the command arguments definition in the
[CheckCommand object definition](9-object-types.md#objecttype-checkcommand) is primarily used to
evaluate whether the command parameter should be set or not.
By default you can evaluate runtime macros for their existence. If the result is not an empty
string, the command parameter is passed. This becomes fairly complicated when want to evaluate
multiple conditions and attributes.
The following example was found on the community support channels. The user had defined a host
dictionary named `compellent` with the key `disks`. This was then used inside service apply for rules.
object Host "dict-host" {
check_command = "check_compellent"
vars.compellent["disks"] = {
file = "/var/lib/check_compellent/san_disks.0.json",
checks = ["disks"]
}
}
The more significant problem was to only add the command parameter `--disk` to the plugin call
when the dictionary `compellent` contains the key `disks`, and omit it if not found.
By defining `set_if` as [abbreviated lambda function](17-language-reference.md#nullary-lambdas)
and evaluating the host custom attribute `compellent` containing the `disks` this problem was
solved like this:
object CheckCommand "check_compellent" {
command = [ "/usr/bin/check_compellent" ]
arguments = {
"--disks" = {
set_if = {{
var host_vars = host.vars
log(host_vars)
var compel = host_vars.compellent
log(compel)
compel.contains("disks")
}}
}
}
}
This implementation uses the dictionary type method [contains](18-library-reference.md#dictionary-contains)
and will fail if `host.vars.compellent` is not of the type `Dictionary`.
Therefore you can extend the checks using the [typeof](17-language-reference.md#types) function.
You can test the types using the `icinga2 console`:
# icinga2 console
Icinga (version: v2.3.0-193-g3eb55ad)
<1> => srv_vars.compellent["check_a"] = { file="outfile_a.json", checks = [ "disks", "fans" ] }
null
<2> => srv_vars.compellent["check_b"] = { file="outfile_b.json", checks = [ "power", "voltages" ] }
null
<3> => typeof(srv_vars.compellent)
type 'Dictionary'
<4> =>
The more programmatic approach for `set_if` could look like this:
"--disks" = {
set_if = {{
var srv_vars = service.vars
if(len(srv_vars) > 0) {
if (typeof(srv_vars.compellent) == Dictionary) {
return srv_vars.compellent.contains("disks")
} else {
log(LogInformationen, "checkcommand set_if", "custom attribute compellent_checks is not a dictionary, ignoring it.")
return false
}
} else {
log(LogWarning, "checkcommand set_if", "empty custom attributes")
return false
}
}}
}
### <a id="use-functions-command-attribute"></a> Use Functions as Command Attribute
This comes in handy for [NotificationCommands](9-object-types.md#objecttype-notificationcommand)
or [EventCommands](9-object-types.md#objecttype-eventcommand) which does not require
a returned checkresult including state/output.
The following example was taken from the community support channels. The requirement was to
specify a custom attribute inside the notification apply rule and decide which notification
script to call based on that.
object User "short-dummy" {
}
object UserGroup "short-dummy-group" {
assign where user.name == "short-dummy"
}
apply Notification "mail-admins-short" to Host {
import "mail-host-notification"
command = "mail-host-notification-test"
user_groups = [ "short-dummy-group" ]
vars.short = true
assign where host.vars.notification.mail
}
The solution is fairly simple: The `command` attribute is implemented as function returning
an array required by the caller Icinga 2.
The local variable `mailscript` sets the default value for the notification scrip location.
If the notification custom attribute `short` is set, it will override the local variable `mailscript`
with a new value.
The `mailscript` variable is then used to compute the final notification command array being
returned.
You can omit the `log()` calls, they only help debugging.
object NotificationCommand "mail-host-notification-test" {
command = {{
log("command as function")
var mailscript = "mail-host-notification-long.sh"
if (notification.vars.short) {
mailscript = "mail-host-notification-short.sh"
}
log("Running command")
log(mailscript)
var cmd = [ SysconfDir + "/icinga2/scripts/" + mailscript ]
log(LogCritical, "me", cmd)
return cmd
}}
env = {
}
}
### <a id="custom-functions-as-attribute"></a> Use Custom Functions as Attribute
To use custom functions as attributes, the function must be defined in a
slightly unexpected way. The following example shows how to assign values
depending on group membership. All hosts in the `slow-lan` host group use 300
as value for `ping_wrta`, all other hosts use 100.
globals.group_specific_value = function(group, group_value, non_group_value) {
return function() use (group, group_value, non_group_value) {
if (group in host.groups) {
return group_value
} else {
return non_group_value
}
}
}
apply Service "ping4" {
import "generic-service"
check_command = "ping4"
vars.ping_wrta = group_specific_value("slow-lan", 300, 100)
vars.ping_crta = group_specific_value("slow-lan", 500, 200)
assign where true
}
### <a id="use-functions-assign-where"></a> Use Functions in Assign Where Expressions
If a simple expression for matching a name or checking if an item
exists in an array or dictionary does not fit, you should consider
writing your own global [functions](17-language-reference.md#functions).
You can call them inside `assign where` and `ignore where` expressions
for [apply rules](3-monitoring-basics.md#using-apply-expressions) or
[group assignments](3-monitoring-basics.md#group-assign-intro) just like
any other global functions for example [match](18-library-reference.md#global-functions).
The following example requires the host `myprinter` being added
to the host group `printers-lexmark` but only if the host uses
a template matching the name `lexmark*`.
template Host "lexmark-printer-host" {
vars.printer_type = "Lexmark"
}
object Host "myprinter" {
import "generic-host"
import "lexmark-printer-host"
address = "192.168.1.1"
}
/* register a global function for the assign where call */
globals.check_host_templates = function(host, search) {
/* iterate over all host templates and check if the search matches */
for (tmpl in host.templates) {
if (match(search, tmpl)) {
return true
}
}
/* nothing matched */
return false
}
object HostGroup "printers-lexmark" {
display_name = "Lexmark Printers"
/* call the global function and pass the arguments */
assign where check_host_templates(host, "lexmark*")
}
Take a different more complex example: All hosts with the
custom attribute `vars_app` as nested dictionary should be
added to the host group `ABAP-app-server`. But only if the
`app_type` for all entries is set to `ABAP`.
It could read as wildcard match for nested dictionaries:
where host.vars.vars_app["*"].app_type == "ABAP"
The solution for this problem is to register a global
function which checks the `app_type` for all hosts
with the `vars_app` dictionary.
object Host "appserver01" {
check_command = "dummy"
vars.vars_app["ABC"] = { app_type = "ABAP" }
}
object Host "appserver02" {
check_command = "dummy"
vars.vars_app["DEF"] = { app_type = "ABAP" }
}
globals.check_app_type = function(host, type) {
/* ensure that other hosts without the custom attribute do not match */
if (typeof(host.vars.vars_app) != Dictionary) {
return false
}
/* iterate over the vars_app dictionary */
for (key => val in host.vars.vars_app) {
/* if the value is a dictionary and if contains the app_type being the requested type */
if (typeof(val) == Dictionary && val.app_type == type) {
return true
}
}
/* nothing matched */
return false
}
object HostGroup "ABAP-app-server" {
assign where check_app_type(host, "ABAP")
}
## <a id="access-object-attributes-at-runtime"></a> Access Object Attributes at Runtime
The [Object Accessor Functions](18-library-reference.md#object-accessor-functions)
can be used to retrieve references to other objects by name.
This allows you to access configuration and runtime object attributes. A detailed
list can be found [here](9-object-types.md#object-types).
Simple cluster example for accessing two host object states and calculating a virtual
cluster state and output:
object Host "cluster-host-01" {
check_command = "dummy"
vars.dummy_state = 2
vars.dummy_text = "This host is down."
}
object Host "cluster-host-02" {
check_command = "dummy"
vars.dummy_state = 0
vars.dummy_text = "This host is up."
}
object Host "cluster" {
check_command = "dummy"
vars.cluster_nodes = [ "cluster-host-01", "cluster-host-02" ]
vars.dummy_state = {{
var up_count = 0
var down_count = 0
var cluster_nodes = macro("$cluster_nodes$")
for (node in cluster_nodes) {
if (get_host(node).state > 0) {
down_count += 1
} else {
up_count += 1
}
}
if (up_count >= down_count) {
return 0 //same up as down -> UP
} else {
return 2 //something is broken
}
}}
vars.dummy_text = {{
var output = "Cluster hosts:\n"
var cluster_nodes = macro("$cluster_nodes$")
for (node in cluster_nodes) {
output += node + ": " + get_host(node).last_check_result.output + "\n"
}
return output
}}
}
The following example sets time dependent thresholds for the load check based on the current
time of the day compared to the defined time period.
object TimePeriod "backup" {
import "legacy-timeperiod"
ranges = {
monday = "02:00-03:00"
tuesday = "02:00-03:00"
wednesday = "02:00-03:00"
thursday = "02:00-03:00"
friday = "02:00-03:00"
saturday = "02:00-03:00"
sunday = "02:00-03:00"
}
}
object Host "webserver-with-backup" {
check_command = "hostalive"
address = "127.0.0.1"
}
object Service "webserver-backup-load" {
check_command = "load"
host_name = "webserver-with-backup"
vars.load_wload1 = {{
if (get_time_period("backup").is_inside) {
return 20
} else {
return 5
}
}}
vars.load_cload1 = {{
if (get_time_period("backup").is_inside) {
return 40
} else {
return 10
}
}}
}
## <a id="check-result-freshness"></a> Check Result Freshness
In Icinga 2 active check freshness is enabled by default. It is determined by the
`check_interval` attribute and no incoming check results in that period of time.
threshold = last check execution time + check interval
Passive check freshness is calculated from the `check_interval` attribute if set.
threshold = last check result time + check interval
If the freshness checks are invalid, a new check is executed defined by the
`check_command` attribute.
## <a id="check-flapping"></a> Check Flapping
The flapping algorithm used in Icinga 2 does not store the past states but
calculates the flapping threshold from a single value based on counters and
half-life values. Icinga 2 compares the value with a single flapping threshold
configuration attribute named `flapping_threshold`.
Flapping detection can be enabled or disabled using the `enable_flapping` attribute.
## <a id="volatile-services"></a> Volatile Services
By default all services remain in a non-volatile state. When a problem
occurs, the `SOFT` state applies and once `max_check_attempts` attribute
is reached with the check counter, a `HARD` state transition happens.
Notifications are only triggered by `HARD` state changes and are then
re-sent defined by the `interval` attribute.
It may be reasonable to have a volatile service which stays in a `HARD`
state type if the service stays in a `NOT-OK` state. That way each
service recheck will automatically trigger a notification unless the
service is acknowledged or in a scheduled downtime.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
# Icinga 2
# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
file(GLOB DOCSRCS "*.md")
if(UNIX OR CYGWIN)
install(
FILES icinga2.8
DESTINATION ${CMAKE_INSTALL_MANDIR}/man8
)
endif()
install(
FILES ${DOCSRCS}
DESTINATION ${CMAKE_INSTALL_DOCDIR}/markdown
)

View File

@ -0,0 +1,99 @@
.TH ICINGA2 "8" "October 2015" "icinga2 - The Icinga 2 network monitoring daemon"
.SH NAME
icinga2 \- The Icinga 2 network monitoring daemon
.SH SYNOPSIS
.B icinga2
.I command
[
.I command options
][
.I global options
]
.I command
:= [
.B api | console | daemon | feature | node | object | pki | repository | troubleshoot | variable
]
.B --help
.SH DESCRIPTION
Icinga 2 is an open source monitoring system which checks the availability of your network resources, notifies users of outages, and generates performance data for reporting.
Scalable and extensible, Icinga 2 can monitor large, complex environments across multiple locations.
.SH OPTIONS
Details for specific command options can be viewed by invoking the command name with
.B --help
parameter.
.SS Global options
.TP
.B -h,--help
Show this help message.
.TP
.B -V,--version
Show version information.
.TP
.B --color
Use VT100 color codes even when stdout is not a terminal.
.TP
.BI "-D, --define" " arg"
Define a constant.
.TP
.BI "-l, --library" " arg"
Load a library.
.TP
.BI "-I, --include" " arg"
Add include search directory.
.TP
.BI "-x, --log-level" " [ debug | notice | information | warning | critical ]"
Specify the log level for the console log, default is
.B information.
.TP
.BI "-X, --script-debugger"
Enables the script debugger. When an exception occurs or the 'debugger' keyword
is encountered in a user script Icinga 2 launches the script debugger that
allows the user to debug the script.
.SS daemon options
The CLI command daemon provides the functionality to start/stop Icinga 2.
Furthermore it provides the configuration validation.
.TP
.BI "-c, --config" " arg"
Using this option you can specify one or more configuration files.
Config files are processed in the order they are specified on the command-line.
When no configuration file is specified and the
.B --no-config
is not used, Icinga 2 automatically falls back to using the configuration file
.B SysconfDir + "/icinga2/icinga2.conf"
(where SysconfDir is usually
.BI "/etc" ")."
.TP
.B "-z, --noconfig"
Start without a configuration file.
.TP
.B "-C, --validate"
This option can be used to check if your configuration files contain errors.
If any errors are found the exit status is 1, otherwise 0 is returned.
.TP
.BI "-e, --errorlog" " arg"
Log fatal errors to the specified log file (only works in combination with
.BR "--daemonize" ")."
.TP
.B "-d, --daemonize"
Detach from the controlling terminal.
.SH "REPORTING BUGS"
Report bugs at <https://dev.icinga.org/>
.br
Icinga home page: <https://www.icinga.org/>
.SH COPYRIGHT
Copyright \(co 2012\-2014 Icinga Development Team (http://www.icinga.org)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
.br
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Some files were not shown because too many files have changed in this diff Show More