Replace $plugindir$ macro with a constant.

Fixes #5877
This commit is contained in:
Gunnar Beutner 2014-03-31 13:11:36 +02:00
parent da86cb4cc3
commit 036fd3303f
7 changed files with 52 additions and 31 deletions

View File

@ -79,11 +79,18 @@ Here's a brief description of the example configuration:
Icinga 2 supports [C/C++-style comments](#comments).
include <itl/itl.conf>
/**
* The constants.conf defines global constants.
*/
include "constants.conf"
The `include` directive can be used to include other files. The `itl/itl.conf`
file is distributed as part of Icinga 2 and provides a number of useful templates
and constants you can use to configure your services.
The `include` directive can be used to include other files.
/**
* The Icinga Template Library (ITL) provides a number of useful templates
* and command definitions.
*/
include <itl/itl.conf>
/**
* The features-available directory contains a number of configuration

View File

@ -20,13 +20,13 @@ include(InstallConfig)
configure_file(icinga/icinga-classic-apache.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga/icinga-classic-apache.conf)
install_if_not_exists(icinga2/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(icinga2/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(icinga2/conf.d/downtimes.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/generic-host.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/generic-service.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/generic-user.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/groups.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/localhost.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/macros.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/notifications.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/timeperiods.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)

View File

@ -1,7 +0,0 @@
/**
* Global macros
*/
const IcingaMacros = {
plugindir = "/usr/lib/nagios/plugins"
}

View File

@ -0,0 +1,7 @@
/**
* 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"

View File

@ -7,6 +7,15 @@
* to the documentation that is distributed as part of Icinga 2.
*/
/**
* The constants.conf defines global constants.
*/
include "constants.conf"
/**
* The Icinga Template Library (ITL) provides a number of useful templates
* and command definitions.
*/
include <itl/itl.conf>
/**

View File

@ -21,7 +21,7 @@ object CheckCommand "ping4" {
import "plugin-check-command",
command = [
"$plugindir$/check_ping",
PluginDir + "/check_ping",
"-4",
"-H", "$HOSTADDRESS$",
"-w", "$wrta$,$wpl$%",
@ -46,7 +46,7 @@ object CheckCommand "ping6" {
import "plugin-check-command",
command = [
"$plugindir$/check_ping",
PluginDir + "/check_ping",
"-6",
"-H", "$HOSTADDRESS6$",
"-w", "$wrta$,$wpl$%",
@ -71,7 +71,7 @@ object CheckCommand "dummy" {
import "plugin-check-command",
command = [
"$plugindir$/check_dummy",
PluginDir + "/check_dummy",
"$state$",
"$text$"
],
@ -95,7 +95,7 @@ object CheckCommand "tcp" {
import "plugin-check-command",
command = [
"$plugindir$/check_tcp",
PluginDir + "/check_tcp",
"-H", "$HOSTADDRESS$",
"-p", "$port$"
]
@ -105,7 +105,7 @@ object CheckCommand "udp" {
import "plugin-check-command",
command = [
"$plugindir$/check_udp",
PluginDir + "/check_udp",
"-H", "$HOSTADDRESS$",
"-p", "$port$"
]
@ -115,7 +115,7 @@ object CheckCommand "http_vhost" {
import "plugin-check-command",
command = [
"$plugindir$/check_http",
PluginDir + "/check_http",
"-H", "$vhost$"
]
}
@ -124,7 +124,7 @@ object CheckCommand "http_ip" {
import "plugin-check-command",
command = [
"$plugindir$/check_http",
PluginDir + "/check_http",
"-H", "$HOSTADDRESS$"
]
}
@ -133,7 +133,7 @@ object CheckCommand "https_vhost" {
import "plugin-check-command",
command = [
"$plugindir$/check_http",
PluginDir + "/check_http",
"-H", "$vhost$", "-S"
]
}
@ -142,7 +142,7 @@ object CheckCommand "https_ip" {
import "plugin-check-command",
command = [
"$plugindir$/check_http",
PluginDir + "/check_http",
"-I", "$HOSTADDRESS$", "-S"
]
}
@ -151,7 +151,7 @@ object CheckCommand "smtp" {
import "plugin-check-command",
command = [
"$plugindir$/check_smtp",
PluginDir + "/check_smtp",
"-H", "$HOSTADDRESS$"
]
}
@ -160,7 +160,7 @@ object CheckCommand "ssmtp" {
import "plugin-check-command",
command = [
"$plugindir$/check_ssmtp",
PluginDir + "/check_ssmtp",
"-H", "$HOSTADDRESS$",
"-p", "$port$"
],
@ -172,7 +172,7 @@ object CheckCommand "ntp_time" {
import "plugin-check-command",
command = [
"$plugindir$/check_ntp_time",
PluginDir + "/check_ntp_time",
"-H", "$HOSTADDRESS$"
]
}
@ -181,7 +181,7 @@ object CheckCommand "ssh" {
import "plugin-check-command",
command = [
"$plugindir$/check_ssh",
PluginDir + "/check_ssh",
"$HOSTADDRESS$"
]
}
@ -190,7 +190,7 @@ object CheckCommand "disk" {
import "plugin-check-command",
command = [
"$plugindir$/check_disk",
PluginDir + "/check_disk",
"-w", "$wfree$%",
"-c", "$cfree$%"
],
@ -205,7 +205,7 @@ object CheckCommand "users"{
import "plugin-check-command",
command = [
"$plugindir$/check_users",
PluginDir + "/check_users",
"-w", "$wgreater$",
"-c", "$cgreater$"
],
@ -220,7 +220,7 @@ object CheckCommand "processes"{
import "plugin-check-command",
command = [
"$plugindir$/check_procs",
PluginDir + "/check_procs",
"-w", "$wgreater$",
"-c", "$cgreater$"
],
@ -235,7 +235,7 @@ object CheckCommand "load"{
import "plugin-check-command",
command = [
"$plugindir$/check_load",
PluginDir + "/check_load",
"-w", "$wload1$,$wload5$,$wload15$",
"-c", "$cload1$,$cload5$,$cload15$"
],
@ -255,7 +255,7 @@ object CheckCommand "snmp"{
import "plugin-check-command",
command = [
"$plugindir$/check_snmp",
PluginDir + "/check_snmp",
"-H", "$HOSTADDRESS$",
"-o", "$oid$",
"-C", "$community$"

View File

@ -118,7 +118,12 @@ IcingaApplication::Ptr IcingaApplication::GetInstance(void)
Dictionary::Ptr IcingaApplication::GetMacros(void) const
{
return ScriptVariable::Get("IcingaMacros");
ScriptVariable::Ptr sv = ScriptVariable::GetByName("IcingaMacros");
if (!sv)
return Dictionary::Ptr();
return sv->GetData();
}
String IcingaApplication::GetNodeName(void) const