2.2 KiB
Groups
Groups are used for combining hosts, services and users into accessible configuration attributes and views in external (web) interfaces.
Group membership is defined at the respective object itself. If
you have a hostgroup name windows
for example, and want to assign
specific hosts to this group for later viewing the group on your
alert dashboard, first create the hostgroup:
object HostGroup "windows" {
display_name = "Windows Servers"
}
Then add your hosts to this hostgroup
object Host "mssql-srv1" {
groups = [ "windows" ],
macros = {
"mssql_port" = 1433
}
}
object Host "mssql-srv2" {
groups = [ "windows" ],
macros = {
"mssql_port" = 1433
}
}
Best Practice
Add the hostgroup membership into generic templates combined with other attributes and let all windows hosts inherit from that template. You can also define multiple group memberships.
template Host "windows-mssql-template" {
groups = [ "windows" ],
macros = {
"mssql_port" = 1433
}
}
object Host "mssql-srv1" {
templates = [ "windows-mssql-template" ]
}
object Host "mssql-srv2" {
templates = [ "windows-mssql-template" ]
}
This can be done for service and user groups the same way. Additionally
the user groups are associated as attributes in Notification
objects.
object UserGroup "windows-mssql-admins" {
display_name = "Windows MSSQL Admins"
}
template User "generic-windows-mssql-users" {
groups = [ "windows-mssql-admins" ]
}
object User "win-mssql-noc" inherits "generic-windows-mssql-users" {
macros = {
"email" = "noc@company.com"
}
}
object User "win-mssql-ops" inherits "generic-windows-mssql-users" {
macros = {
"email" = "ops@company.com"
}
}
object Host "localhost" {
services["ping4"] = {
notifications["mail"] = {
templates = [ "generic-notification" ],
notification_command = "mail-notification",
user_groups = [ "windows-admins" ],
}
}
}