Sql-server – Nagios – host inherit from multiple templates

nagiossql server

Is it possible to have a host in Nagios use multiple templates?

I'm trying to monitor some MSSQL servers. Some of these are standalone single servers with a single instance, and others are using MSCS to form 2-node HA clusters.

The things I want to monitor on a particular server are different to the things I want to monitor for a particular SQL instance. e.g. I want to use a template windows-server to tell me generic things about windows for a given server. Similarly, I'd want to use a specific SQL template called sql-instance to monitor SQL-specific things, like connected users, batch requests etc.

For my 2 node clusters, this is quite easy – I have three host definitions: a windows-server for each specific node and a sql-instance pointing at the cluster dns name.

For single instances, I'd like to be able to have a single host, which uses both the windows-server and sql-instance templates together, because they both should point at the same hostname. However, any attempts to do:

define host {
    use windows-server, sql-instance
}

or

define host {
    use windows-server
    use sql-instance
}

results in nagios only picking up one of the templates and ignoring the other.

So how best can I do multiple template inheritance in Nagios?

Best Answer

I solved this by using a workaround. Instead of having a particular host inherit from multiple templates, I attached my services to various hostgroups and just placed each host in more than one hostgroup:

define host {
    use             generic-host
    hostgroups      sql-servers,sql-instances
 }