Update example config.

Refs #5878
This commit is contained in:
Gunnar Beutner 2014-03-28 16:32:15 +01:00
parent 0e79abb8f2
commit fa11e5a97e
6 changed files with 101 additions and 124 deletions

View File

@ -1,59 +1,44 @@
/** /**
* Provides default settings for hosts. By convention * Provides default settings for hosts. By convention
* all hosts should inherit from this template. * all hosts should import this template.
*/ */
template Host "generic-host" { template Host "generic-host" {
check = "ping4"
}
apply Service "ping4" {
import "generic-service",
check_command = "ping4",
assign where "generic-host" in host.templates
}
apply Service "ping6" {
import "generic-service",
check_command = "ping6",
assign where "generic-host" in host.templates,
ignore where !host.macros.address6
} }
template Host "linux-server" { template Host "linux-server" {
import "generic-host", import "generic-host",
groups += [ "linux-servers" ], groups += [ "linux-servers" ],
services["ping4"] = {
templates = [ "generic-service" ],
check_command = "ping4"
},
check = "ping4"
} }
template Host "windows-server" { template Host "windows-server" {
import "generic-host", import "generic-host",
groups += [ "windows-servers" ], groups += [ "windows-servers" ],
services["ping4"] = {
templates = [ "generic-service" ],
check_command = "ping4"
},
check = "ping4"
} }
template Host "generic-printer" { template Host "generic-printer" {
import "generic-host", import "generic-host",
services["ping4"] = {
templates = [ "generic-service" ],
check_command = "ping4"
},
check = "ping4"
} }
template Host "generic-switch" { template Host "generic-switch" {
import "generic-host", import "generic-host",
services["ping4"] = {
templates = [ "generic-service" ],
check_command = "ping4"
},
check = "ping4"
} }

View File

@ -1,15 +1,18 @@
/** /**
* Provides default settings for services. By convention * Provides default settings for services. By convention
* all services should inherit from this template. * all services should import this template.
*/ */
template Service "generic-service" { template Service "generic-service" {
max_check_attempts = 3, max_check_attempts = 3,
check_interval = 5m, check_interval = 5m,
retry_interval = 1m, retry_interval = 1m,
enable_perfdata = true, enable_perfdata = true
}
notifications["mail-icingaadmin"] = {
templates = [ "mail-notification" ], apply Notification "mail-icingaadmin" {
user_groups = [ "icingaadmins" ] import "mail-notification",
}
user_groups = [ "icingaadmins"],
assign where "generic-service" in service.templates
} }

View File

@ -4,19 +4,5 @@
*/ */
template User "generic-user" { template User "generic-user" {
enable_notifications = true,
notification_period = "24x7",
notification_state_filter = StateFilterWarning |
StateFilterCritical |
StateFilterUnknown,
notification_type_filter = NotificationFilterProblem |
NotificationFilterAcknowledgement |
NotificationFilterRecovery |
NotificationFilterCustom |
NotificationFilterFlappingStart |
NotificationFilterFlappingEnd |
NotificationFilterDowntimeStart |
NotificationFilterDowntimeEnd |
NotificationFilterDowntimeRemoved
} }

View File

@ -6,70 +6,69 @@
object Host "localhost" { object Host "localhost" {
import "linux-server", import "linux-server",
display_name = "localhost", macros.address = "127.0.0.1",
macros.address6 = "::1"
services["icinga"] = {
templates = [ "generic-service" ],
check_command = "icinga"
},
services["ping4"] = {
templates = [ "generic-service" ],
check_command = "ping4"
},
services["ping6"] = {
templates = [ "generic-service" ],
check_command = "ping6"
},
services["http"] = {
templates = [ "generic-service" ],
check_command = "http_ip"
},
services["ssh"] = {
templates = [ "generic-service" ],
check_command = "ssh"
},
services["load"] = {
templates = [ "generic-service" ],
check_command = "load",
scheduled_downtimes["backup"] = {
templates = [ "backup-downtime" ]
}
},
services["processes"] = {
templates = [ "generic-service" ],
check_command = "processes"
},
services["users"] = {
templates = [ "generic-service" ],
check_command = "users"
},
services["disk"] = {
templates = [ "generic-service" ],
check_command = "disk"
},
macros = {
address = "127.0.0.1",
address6 = "::1",
},
check = "ping4",
} }
apply Service "icinga" {
import "generic-service",
check_command = "icinga",
assign where host.name == "localhost"
}
apply Service "http" {
import "generic-service",
check_command = "http_ip",
assign where host.name == "localhost"
}
apply Service "ssh" {
import "generic-service",
check_command = "ssh",
assign where host.name == "localhost"
}
apply Service "load" {
import "generic-service",
check_command = "load",
assign where host.name == "localhost"
}
apply ScheduledDowntime "backup-downtime" {
import "backup-downtime",
assign where service.host == "localhost" && service.short_name == "load"
}
apply Service "processes" {
import "generic-service",
check_command = "processes",
assign where host.name == "localhost"
}
apply Service "users" {
import "generic-service",
check_command = "users",
assign where host.name == "localhost"
}
apply Service "disk" {
import "generic-service",
check_command = "disk",
assign where host.name == "localhost"
}

View File

@ -420,6 +420,8 @@ Value AExpression::OpIndexer(const AExpression *expr, const Dictionary::Ptr& loc
BOOST_THROW_EXCEPTION(ConfigError("Tried to access invalid property '" + index + "'")); BOOST_THROW_EXCEPTION(ConfigError("Tried to access invalid property '" + index + "'"));
return object->GetField(field); return object->GetField(field);
} else if (value.IsEmpty()) {
return Empty;
} else { } else {
BOOST_THROW_EXCEPTION(ConfigError("Dot operator cannot be applied to type '" + value.GetTypeName() + "'")); BOOST_THROW_EXCEPTION(ConfigError("Dot operator cannot be applied to type '" + value.GetTypeName() + "'"));
} }

View File

@ -146,6 +146,7 @@ using namespace icinga;
%token T_IMPORT "import (T_IMPORT)" %token T_IMPORT "import (T_IMPORT)"
%token T_ASSIGN "assign (T_ASSIGN)" %token T_ASSIGN "assign (T_ASSIGN)"
%token T_IGNORE "ignore (T_IGNORE)" %token T_IGNORE "ignore (T_IGNORE)"
%type <text> identifier %type <text> identifier
%type <array> rterm_items %type <array> rterm_items
%type <array> rterm_items_inner %type <array> rterm_items_inner
@ -160,19 +161,20 @@ using namespace icinga;
%type <variant> rterm_scope %type <variant> rterm_scope
%type <variant> lterm %type <variant> lterm
%type <num> variable_decl %type <num> variable_decl
%left T_LOGICAL_OR %left T_LOGICAL_OR
%left T_LOGICAL_AND %left T_LOGICAL_AND
%left T_IN
%left T_NOT_IN
%nonassoc T_EQUAL %nonassoc T_EQUAL
%nonassoc T_NOT_EQUAL %nonassoc T_NOT_EQUAL
%nonassoc T_IN
%nonassoc T_NOT_IN
%left T_PLUS T_MINUS %left T_PLUS T_MINUS
%left T_MULTIPLY T_DIVIDE_OP %left T_MULTIPLY T_DIVIDE_OP
%left T_BINARY_AND %left T_BINARY_AND
%left T_BINARY_OR %left T_BINARY_OR
%left '.'
%right '~' %right '~'
%right '!' %right '!'
%left '.'
%{ %{
int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner); int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
@ -731,7 +733,7 @@ apply:
String name = aname->Evaluate(m_ModuleScope); String name = aname->Evaluate(m_ModuleScope);
if (!ApplyRule::IsValidType(type)) if (!ApplyRule::IsValidType(type))
BOOST_THROW_EXCEPTION(ConfigError("'apply' cannot be used with type '" + type + "'") << errinfo_debuginfo(@2)); BOOST_THROW_EXCEPTION(ConfigError("'apply' cannot be used with type '" + type + "'") << errinfo_debuginfo(DebugInfoRange(@2, @3)));
AExpression::Ptr exprl = static_cast<AExpression::Ptr>(*$5); AExpression::Ptr exprl = static_cast<AExpression::Ptr>(*$5);
delete $5; delete $5;