I would like that $config$ is an array.
I need to enter for example the array (value1;value2;value3) on the host on which service apply is applied.
is it possible to defice the Service Apply Rule as:
Field1: $config$[0]
Field2: $config$[1]
Field3: $config$[2]
?
So
Field1=vaule1
Field2=vaule2
Field3=vaule3
Is it possible?
Thanks a lot
Mario
icinga2 - The Icinga 2 network monitoring daemon (version: r2.13.1-1)
Icinga Web 2 Version
2.9.3
Git commit
c757a17530c326c7d6daebd6171486cb8167a8a1
PHP Version
7.2.24-0ubuntu0.18.04.8
Git commit date
2021-08-10
Modules:
businessprocess 2.3.1
director master
fileshipper 1.1.0
monitoring 2.9.3
It is possible, but not with the Director.
At least I’m not sure how that would be done. Apply For is definitely not usable for that.
You will have to do that via some config file in /etc/icinga2/zones.d or /etc/icinga2/conf.d
# icinga2 console
Icinga 2 (version: r2.12.5-1)
Type $help to view available commands.
<1> => var a = ["hi", "hello"]
null
<2> => a
[ "hi", "hello" ]
<3> => var b = a[0]
null
<4> => b
"hi"
<5> => var c = a[1]
null
<6> => c
"hello"
side note for the future:
I would suggest not using the master but the latest version tag as checkout.
I would check what options are available with the plugin by running -h or /?, etc. It may be possible for specific thresholds, or you could add two services (one for C: with thresholds x and one for D: with thresholds y) to the host.
Yes, I know the option available and they work fromo the command line.
But Idon’t like to create a service for every disk.
I preferred to create a “Service Template” and an “Apply rule” for that service instead of create a single service one to one to disks
Well, you keep us quite in the dark on what check you want to use and how you currently have configured it
For this scenario my first idea is to create an apply rule for each disk check and configure the values there.
Then create a new data field of type array for the disk-partitions add it to the respective hosts and set what partitions they have.
After that you can configure assign where host.vars.disk_partitions_list contains C/D/E/what ever in the apply rule assignment logic.
An apply for would basically work similar to this, you need an array data field at the host and the apply for rule would then create a service for each entry in the array. But this would be the same service config(e.g. thresholds) for all of them expect for the name of the service and partition variable.
You could realize different threshold variables inside the apply for with multiple if clauses when using the config files instead of the Director
I would suggest you to separate in diff service checks using same service template. From this template then you can create service check for dedicated drive and requered thresholds. For example you can add in service template filed “disk_drive”, “disk_warn” and “disk_crit”. Then you need to create apply rules, where you will specify what kind of parametrs/thresholds you want to have for each drive. It should be apply rule per drive.
So that means if you have 4 drives you will need to know the list of servers which has 4 drives and create from 1 service template 4 service checks. You can put those 4 service checks in set of services and put apply rule on set of service. In this apply rule must be machines on what you want to implement those service checks.
If you are new to icinga2 please check in docu about service template, service objects and apply rules and try to figure it out correlation.
My opinion is that director is good and bad. Bad is cause you cannot use “fancy programing style icinga2 conf” and you cannot do crazy combination of conditions and be like “ninja”. Good thing it will force you to use it on right way to have clean environment.