Hi all,

In the below mail, I was talking about an enhance "service generator" for switches. After a huge battle with regexp (I hate regexp :( ), it's done :)

So what is it?

With the last service generator thing, if you have a switch with 6 units (a stack of switches) and each one with 48 ports, you should add in your host switch definition :

define host {
   host_name   SuperSwitch
   _ports     Unit 1 Port 1,Unit 1 Port 2, ... , Unit 6 Port 48

with the service :
define service {
  host_name SuperSwitch
  service_description    Port $KEY$ Usage
  check_command       check_snmp!$KEY$!$VALUE$
  duplicate_foreach      _ports
  default_value            70%!80%

So you must wrote each 6*48 string... quite long (more than 4k characters...) when the only thing that change on it are just .. 2 ints!

Now with the last commit, you can have a sort of key generator :
define host {
   host_name   SuperSwitch
   _ports     Unit [1-6] Port [1-48]


And that's all :)

Quite cool isn't it? :)

I think the only part of IT where this is useful is for this port thing of switches/routers. But it will save quite a lot of configuration lines I think :)


On Wed, Oct 27, 2010 at 11:40 AM, nap <naparuba@gmail.com> wrote:
Hi all,

There two new features in the core since few days about configuration
capabilities, and in fact how we create services for hosts. The main
idea is to have all 'informations' about how to check an host ... in
the host definition :)

* First the service template apply on host template. It's inspired by
Centreon capability that allow the users to make such a link and
generate services if an host use a template that is linked with a
service template. In Shinken, such link is now possible.

All you need is to add a host_name and a service description to a
service template and put in host_name where you want for it to apply.
And here, it will be the name of host template that will be lookup.
And all hosts that use this host template will have the service

>From now there is no "exception" way for this like we've got for
service based on hostgroup, so Centreon user should not use this
feature and keep their classic way. for all others, it's an
enhancement :)

* The second is based on a Andreas Ericsson's idea about services
generated from host properties. The main idea is to "generate" a
service for each host properties, with specific
parameters if the user want it. So you can have all information in the
host definition. It's more easy to see for new users.

An example maybe? Ok :)

Here we want to generate a service for each disk of a server :

define host {
   host_name   Windowsbox
   _disk     C$(80%!90%)$,D,E$(98%!99%)$,F$(98%!99%)$

And now the "generator" service :
define service {
  host_name Windowsbox
  service_description    Disk $KEY$
  check_command       check_disk!$KEY$!$VALUE$
  duplicate_foreach      _disks
  default_value            70%!80%

It will generate the following services for the Windowsbox server:
"Disk C" with command : check_disk!C!80%!90%
"Disk D" with command : check_disk!D!70%!80%
"Disk E" with command : check_disk!E!98%!99%
"Disk F" with command : check_disk!F!98%!99%

It can be useful for disks, windows services and switchs ports :)

for this last one, I'm working on a enhanced way for "_ports" so we an
have in few characters all 48 ports of a switchs, and so got easily 48
services :)

>From now the service generator is tag experimental because it's a new
syntax, and maybe some other projects will use another one, so we must
look what is the better way for it :)

Good configuration shrink :)