small issue with apply disk service

This forum was archived to /woltlab and is now in read-only mode.
  • Hey!
    my current apply rule for service "disk" looks like that:


    Code
    1. apply Service "disk" {
    2. import "generic-service"
    3. check_command = "disk"
    4. vars.disk_wfree = "2%"
    5. vars.disk_cfree = "1%"
    6. assign where host.vars.os == "Linux"
    7. }

    That works absolutely fine.


    However, I do have some linux hosts that need specific disk checks, for example I have to exclude some partitions.


    So I tried the following:

    But that doesn't work for me. The disk check disappeared on every linux host, although there is still the assign argument.

    What am I doing wrong?

  • ignore where is evaluated first, then assign where. In this case it does not apply the service to linuxhost1/2/3, as defined.


    There's nothing wrong with it, you probably want to define a specific service apply rule which checks for certain partitions, or excludes some using the disk's custom attributes for the command.

  • mmh..there are 20 linux hosts in total, and with the apply rule of code1, every linux hosts get the disk service applied.


    When I'm using code2, none of the 20 linux hosts get the disk service applied.

  • Ah. I need more coffee.


    The ignore where expression is wrong, this always evaluates to "true". Why?


    Code
    1. ignore where host.name == "linuxhost1" || "linuxhost2" || "linuxhost3"

    converted to logical expressions:


    Code
    1. ignore where (attribute equals string - either true or false) || (a string, always true) || (a string, always true)

    which in term means the following:


    Code
    1. ignore where (true/false) || true || true


    If you want to check if a host name is in a given list, you need to do it with comparison "pairs". Or you keep using the in operator for lists.


    Code
    1. ignore where host.name == "linuxhost1" || host.name == "linuxhost2" || host.name == "linuxhost3"


    Best practice and shorter


    Code
    1. ignore where host.name in [ "linuxhost1", "linuxhost2", "linuxhost3" ]


    Since this moves the exclusion logic into the service apply rule and requires future changes over there, I would solve it differently.


    Define a host attribute, which excludes the disk check on demand.


  • Hi,


    maybe an other thought, you can set the vars.disk_partitions_excluded and/or vars.disk_partitions attributes to your host object. You set the attribute on the specific hosts and can control which partitions should be monitored. Now you don't need the ignore where statement and/or additional service apply rule.