# Folder Size Check Not Working

**URL:** <https://community.icinga.com/t/folder-size-check-not-working/14158>\
**Category:** Icinga 2\
**Tags:** icinga2\
**Created:** [October 2, 2024, 7:54am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158 "2024-10-02T07:54:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![RetroPuma](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@RetroPuma](https://community.icinga.com/u/RetroPuma)\
**Post date:** [October 2, 2024, 7:54am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/1 "2024-10-02T07:54:46Z")

</div>

Hello everyone,

I’m having trouble setting up a folder size check in Icinga2. I’ve already taken several steps to ensure everything is configured correctly, but I’m encountering various issues.

#### Problem Description:

I want to monitor a folder on a Windows client and retrieve the total size of the folder. I created a batch script that works with the command `dir "C:\Path\To\Folder" /s /a` and correctly returns the total size when I run it manually. The script is located in the `C:\Program Files\ICINGA2\scripts` directory.

#### Error Messages:

When attempting to execute the script through Icinga2, I receive the following error message:

```auto
execvpe(cmd) failed: No such file or directory

```

and

```auto
execvpe(C:\Windows\System32\cmd.exe) failed: No such file or directory

```

#### Steps I’ve Taken:

1. **Defined CheckCommand:** I created a `CheckCommand` for the folder size and linked it to the batch file.
2. **Defined Service:** I set up a service for the folder size that is associated with the relevant host.
3. **Checked Permissions:** Icinga runs under the “Local System Account,” and I verified the permissions of the target folder to ensure the `SYSTEM` user has access.
4. **Tested Batch Script:** The script outputs the correct folder size when executed directly in the command prompt.
5. **Validated Configuration:** I ran `icinga2 daemon -C` and checked the configuration for errors, but everything seems to be in order.

#### Question:

Does anyone have any ideas on how I can resolve the issue with executing the script through Icinga2? Are there specific configurations that I might have overlooked? I would appreciate any help!

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 2, 2024, 8:05am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/2 "2024-10-02T08:05:28Z")

</div>

did you tell icinga to run it on an agent:

> [@Run on agent without using director](https://community.icinga.com/t/run-on-agent-without-using-director/13088):
>
> Hi All, I am trying to monitor cpu, drives etc of a windows host where i have installed the icinga agent & PS framework. I am testing a few things without using director. So with the Icinga API i have put the windows host for monitoring. Now i have configured a command for Invoke check cpu , created a service as well for the same but i am getting - execvpe(C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) failed: No such file or directory. I know if do it via the director i have an opt…

---

<div class="post-metadata">

**Author:** ![RetroPuma](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@RetroPuma](https://community.icinga.com/u/RetroPuma)\
**Post date:** [October 2, 2024, 8:17am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/3 "2024-10-02T08:17:21Z")

</div>

the agent runs on the client and already sends back service data such as hard disc size, cpu etc.

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 2, 2024, 8:37am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/4 "2024-10-02T08:37:23Z")

</div>

please post the config of:

- service template
- service apply rule
- host template
- host

---

<div class="post-metadata">

**Author:** ![RetroPuma](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@RetroPuma](https://community.icinga.com/u/RetroPuma)\
**Post date:** [October 2, 2024, 8:54am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/5 "2024-10-02T08:54:12Z")

</div>

I’m a bit further along. I found the service Invoke-‘IcingaCheckDirectory’. according to the website, there is the argument ‘CriticalTotalSize’. I don’t have this argument in my service. what could be the reason?

> The Icinga 2 network monitoring daemon (version: r2.14.2-1)

in the preview you can also see that there is no line that defines the total size

```auto
IcingaCheckDirectory' "
        }
        "-ChangeOlderThan" = {
            order = 8
            value = "$IcingaCheckDirectory_String_ChangeOlderThan$"
        }
        "-ChangeTimeEqual" = {
            order = 6
            value = "$IcingaCheckDirectory_String_ChangeTimeEqual$"
        }
        "-ChangeYoungerThan" = {
            order = 7
            value = "$IcingaCheckDirectory_String_ChangeYoungerThan$"
        }
        "-CreationOlderThan" = {
            order = 10
            value = "$IcingaCheckDirectory_String_CreationOlderThan$"
        }
        "-CreationTimeEqual" = {
            order = 9
            value = "$IcingaCheckDirectory_String_CreationTimeEqual$"
        }
        "-CreationYoungerThan" = {
            order = 11
            value = "$IcingaCheckDirectory_String_CreationYoungerThan$"
        }
        "-Critical" = {
            order = 4
            value = "$IcingaCheckDirectory_Object_Critical$"
        }
        "-FileNames" = {
            order = 3
            value = {{
                var arr = macro("$IcingaCheckDirectory_Array_FileNames$");
                if (len(arr) == 0) {
                    return "@()";
                }
                return arr.map(
                    x => if (typeof(x) == String) {
                        var argLen = len(x);
                        if (argLen != 0 && x.substr(0,1) == "'" && x.substr(argLen - 1, argLen) == "'") {
                            x;
                        } else {
                            "'" + x + "'";
                        }
                    } else {
                        x;
                    }
                ).join(",");
            }}
        }
        "-FileSizeGreaterThan" = {
            order = 12
            value = "$IcingaCheckDirectory_String_FileSizeGreaterThan$"
        }
        "-FileSizeSmallerThan" = {
            order = 13
            value = "$IcingaCheckDirectory_String_FileSizeSmallerThan$"
        }
        "-NoPerfData" = {
            order = 99
            set_if = "$IcingaCheckDirectory_Switchparameter_NoPerfData$"
        }
        "-Path" = {
            order = 2
            value = "$IcingaCheckDirectory_String_Path$"
        }
        "-Recurse" = {
            order = 99
            set_if = "$IcingaCheckDirectory_Switchparameter_Recurse$"
        }
        "-ThresholdInterval" = {
            order = 100
            value = "$IcingaCheckDirectory_String_ThresholdInterval$"
        }
        "-Verbosity" = {
            order = 14
            value = "$IcingaCheckDirectory_Int32_Verbosity$"
        }
        "-Warning" = {
            order = 5
            value = "$IcingaCheckDirectory_Object_Warning$"
        }
    }

```

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 2, 2024, 9:17am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/6 "2024-10-02T09:17:50Z")

</div>

> [@RetroPuma](#):
>
> CriticalTotalSize

looks like you definition or/and plugin (v1.7) is not the most recent one:

> <https://github.com/Icinga/icinga-powershell-plugins/blob/support/1.7/plugins/Invoke-IcingaCheckDirectory.psm1>

CriticalTotalSize was introduced in 1.8

---

<div class="post-metadata">

**Author:** ![RetroPuma](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@RetroPuma](https://community.icinga.com/u/RetroPuma)\
**Post date:** [October 2, 2024, 9:37am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/8 "2024-10-02T09:37:25Z")

</div>

Oh wow! But how do I update the plugin version? It doesn’t seem to be tied to the Icinga version, or am I mistaken? I regularly update the Icinga version itself.

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 2, 2024, 10:33am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/9 "2024-10-02T10:33:24Z")

</div>

do you use icingadirector?

---

<div class="post-metadata">

**Author:** ![RetroPuma](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@RetroPuma](https://community.icinga.com/u/RetroPuma)\
**Post date:** [October 2, 2024, 11:26am UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/10 "2024-10-02T11:26:58Z")

</div>

yes i use the director

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 2, 2024, 1:05pm UTC](https://community.icinga.com/t/folder-size-check-not-working/14158/11 "2024-10-02T13:05:28Z")

</div>

then you have to check which version of icinga-powershell-plugins you have installed and use the basket for that specific version
