# Using check\_disk with custom partition thresholds

**URL:** <https://community.icinga.com/t/using-check-disk-with-custom-partition-thresholds/14029>\
**Category:** Icinga 2\
**Created:** [August 26, 2024, 10:01am UTC](https://community.icinga.com/t/using-check-disk-with-custom-partition-thresholds/14029 "2024-08-26T10:01:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brenard](https://community.icinga.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@brenard](https://community.icinga.com/u/brenard)\
**Post date:** [August 26, 2024, 10:01am UTC](https://community.icinga.com/t/using-check-disk-with-custom-partition-thresholds/14029/1 "2024-08-26T10:01:48Z")

</div>

I’m trying to use the `check_disk` command with custom partition thresholds in a single service. To do this, I need Icinga to run the following check command:

```auto
/usr/lib/nagios/plugins/check_disk -w 5% -c 2% -p /srv/archives -w 10% -c 5%

```

In this example, the `/srv/archives` partition will be checked with 5% and 2% as warning/critical thresholds, and all other partitions will be checked with 10% and 5% as warning/critical thresholds.

To achieve this, and since I need to control the relative position of the arguments, I’m trying to add some arguments manually to the `command`:

```auto
object CheckCommand "ee-disk" {
  import "disk"
  command = [PluginDir + "/check_disk"]

  if (vars.disk_custom_partitions_thresholds) {
    for (var item in vars.disk_custom_partitions_thresholds) {
      if(item.warning_threshold) {
       command += ["-w", item.warning_threshold]
      }
      if(item.critical_threshold) {
       command += ["-c", item.critical_threshold]
      }
      command += ["-p", item.partition]
    }
  }
  vars.disk_wfree = "10%"
  vars.disk_cfree = "5%"
}

```

In my host definition:

```auto
object Host "test" {
  vars.disk_custom_partitions_thresholds = [
    {
      partition = "/srv/archives"
      warning_threshold = "5%"
      critical_threshold = "2%"
    }
  ]
}

```

However, this does not work, and Icinga still runs the command without my extra arguments. I know that this is not a traditional way to manage command arguments, but I don’t see another way to control the relative order of the arguments.

**Note:** My previous workaround for this issue was to define multiple services, but I hope to find a solution to achieve the same check with a single service.

---

<div class="post-metadata">

**Author:** ![lorenz](https://community.icinga.com/user_avatar/community.icinga.com/lorenz/32/7666_2.png) [@lorenz](https://community.icinga.com/u/lorenz)\
**Post date:** [August 26, 2024, 1:44pm UTC](https://community.icinga.com/t/using-check-disk-with-custom-partition-thresholds/14029/2 "2024-08-26T13:44:45Z")

</div>

It am not totally sure here, but I think your fancy logic in the `CheckCommand` is evaluated **before** an assignment to a host/service takes places, therefore `vars.disk_custom_partitions_thresholds` is non-existent.

I think you could put this in the the service and address your data with `host.vars.` instead of `vars.`
