diff --git a/check-plugins/dir-size/.windows b/check-plugins/dir-size/.windows new file mode 100644 index 000000000..e69de29bb diff --git a/check-plugins/dir-size/README.md b/check-plugins/dir-size/README.md new file mode 100644 index 000000000..de36719b8 --- /dev/null +++ b/check-plugins/dir-size/README.md @@ -0,0 +1,150 @@ +# Check dir-size + +## Overview + +Checks directory sizes against configurable thresholds using human-readable units (e.g. 25M, 1G). Supports glob patterns and SMB shares. Alerts when any directory exceeds the configured size thresholds. Requires root or sudo. + +**Important Notes:** + +- SMB share access requires the optional `PySmbClient` and `smbprotocol` Python modules +- Recursive globs (`**`) can cause high memory usage on large directory trees +- The `--dirname` and `--url` parameters are mutually exclusive +- Thresholds accept human-readable units (base 1024). Valid qualifiers: `b`, `k`/`kb`/`kib`, `m`/`mb`/`mib`, `g`/`gb`/`gib`, etc. Nagios ranges are supported (e.g. `:1G` alerts if size exceeds 1 GiB, `6 KiB:10k` alerts outside the 6-10 KiB range) +- Returns UNKNOWN if no directories are found + +**Data Collection:** + +- Uses Python's `glob.iglob()` for local directories and `lib.smb` for SMB shares +- Follows symbolic links +- Reads `st_size` from `os.stat()` for each matched directory +- Only directories are checked + +## Fact Sheet + +| Fact | Value | +| -------------------------------- | ------------------------------------------------------------------------------------ | +| Check Plugin Download | | +| Nagios/Icinga Check Name | `check_dir_size` | +| Check Interval Recommendation | Every 15 minutes | +| Can be called without parameters | Yes | +| Runs on | Cross-platform | +| Compiled for Windows | Yes | +| 3rd Party Python modules | optional: `PySmbClient`, `smbprotocol` | + +## Help + +```text +usage: dir-size [-h] [-V] [--always-ok] [-c CRIT] [--dirname DIRNAME] + [--pattern PATTERN] [--password PASSWORD] [--timeout TIMEOUT] + [-u URL] [--username USERNAME] [-w WARN] + +Checks directory sizes against configurable thresholds using human-readable units +(e.g. 25M, 1G). Supports glob patterns and SMB shares. Alerts when any directory +exceeds the configured size thresholds. Requires root or sudo. + +options: + -h, --help show this help message and exit + -V, --version show program's version number and exit + --always-ok Always returns OK. + -c, --critical CRIT CRIT threshold for the directory size in human-readable + format (base is always 1024; valid qualifiers are b, + k/kb/kib, m/mb/mib, g/gb/gib etc.). Supports Nagios + ranges. Example: `:1G` alerts if size is greater than 1 + GiB. Default: 1G + --dirname DIRNAME Path of the directory to check. Supports glob patterns + according to + https://docs.python.org/3/library/glob.html. Recursive + globs can cause high memory usage. Mutually exclusive + with `-u` / `--url`. Example: `--dirname /tmp/*`. + --pattern PATTERN Search string to match against SMB directory names. Use + `*` as a wildcard for multiple characters and `?` for a + single character. Does not support regex patterns. + Default: * + --password PASSWORD Password for SMB authentication. + --timeout TIMEOUT Network timeout in seconds. Default: 3 (seconds) + -u, --url URL URL of the directory to check, starting with `smb://`. + Mutually exclusive with `--dirname`. Example: `--url + smb://server/share/path`. + --username USERNAME Username for SMB authentication. + -w, --warning WARN WARN threshold for the directory size in human-readable + format (base is always 1024; valid qualifiers are b, + k/kb/kib, m/mb/mib, g/gb/gib etc.). Supports Nagios + ranges. Example: `:1G` alerts if size is greater than 1 + GiB. Default: 25M +``` + +## Usage Examples + +Warn if directory is greater than 25M, crit if it is greater than 1G: + +```bash +./dir-size --dirname=/var/log/ --warning=25M --critical=1G +``` + +Output: + +```text +1 file checked. 1 is outside the given size thresholds (25M/1G). Checked /var/log/: 5.1GiB [CRITICAL] +``` + +Warn if directory are larger than 150 MiB, crit if files are larger than 300 +MiB (plus showing the various formats): + +```bash +./dir-size --dirname '/usr/*' --warning ':150MiB' --critical ':300MiB' +``` + +Output: + +```text +11 files checked. 6 are outside the given size thresholds (:150MiB/:300MiB). + +Directory ! Size ! State +-------------+----------+----------- +/usr/bin ! 479.6MiB ! [CRITICAL] +/usr/games ! 0.0B ! [OK] +/usr/include ! 19.8MiB ! [OK] +/usr/lib ! 2.6GiB ! [CRITICAL] +/usr/lib64 ! 1.1GiB ! [CRITICAL] +/usr/libexec ! 692.5MiB ! [CRITICAL] +/usr/local ! 12.9MiB ! [OK] +/usr/sbin ! 267.7MiB ! [WARNING] +/usr/share ! 535.6MiB ! [CRITICAL] +/usr/src ! 952.4KiB ! [OK] +/usr/tmp ! 0.0B ! [OK] +``` + +The same as above, but recursive (might use a lot of memory): + +```bash +./file-size --dirname '/usr/**/*bin' --warning ':100KiB' --critical ':3MiB' +``` + +Output: + +```text +3 files checked. 1 is outside the given size thresholds (:1MiB/:3MiB). + +Directory ! Size ! State +-----------------+----------+----------- +/usr/local/bin ! 12.9MiB ! [CRITICAL] +/usr/local/sbin ! 0.0B ! [OK] +/usr/src/annobin ! 952.4KiB ! [WARNING] +``` + +## States + +- OK if all found directories are within the given size thresholds (default: 25M/1G). +- WARN if any directory exceeds `--warning` (default: 25M). +- CRIT if any directory exceeds `--critical` (default: 1G). +- UNKNOWN if no directories are found. +- `--always-ok` suppresses all alerts and always returns OK. + +## Perfdata / Metrics + +There is no perfdata. + +## Credits, License + +- Authors: [Linuxfabrik GmbH, Zurich](https://www.linuxfabrik.ch) +- License: The Unlicense, see [LICENSE file](https://unlicense.org/). diff --git a/check-plugins/dir-size/dir-size b/check-plugins/dir-size/dir-size new file mode 100755 index 000000000..69e062499 --- /dev/null +++ b/check-plugins/dir-size/dir-size @@ -0,0 +1,294 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8; py-indent-offset: 4 -*- +# +# Author: Linuxfabrik GmbH, Zurich, Switzerland +# Contact: info (at) linuxfabrik (dot) ch +# https://www.linuxfabrik.ch/ +# License: The Unlicense, see LICENSE file. + +# https://github.com/Linuxfabrik/monitoring-plugins/blob/main/CONTRIBUTING.md + +"""See the check's README for more details.""" + +import argparse +import glob +import os +import sys + +import lib.args +import lib.base +import lib.human +import lib.lftest +import lib.txt +from lib.globals import STATE_OK, STATE_UNKNOWN + +PYTHON_MOD = None +try: + import lib.smb + + HAVE_SMB = True +except ModuleNotFoundError as e: + HAVE_SMB = False + PYTHON_MOD = e.name + +__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland' +__version__ = '2026041001' + +DESCRIPTION = """Checks directory sizes against configurable thresholds using human-readable units (e.g. +25M, 1G). Supports glob patterns and SMB shares. +Alerts when any directory exceeds the configured size thresholds. +Requires root or sudo.""" + + +DEFAULT_CRIT = '1G' +DEFAULT_PATTERN = '*' +DEFAULT_TIMEOUT = 3 +DEFAULT_WARN = '25M' + + +def parse_args(): + """Parse command line arguments using argparse.""" + parser = argparse.ArgumentParser(description=DESCRIPTION) + + parser.add_argument( + '-V', + '--version', + action='version', + version=f'%(prog)s: v{__version__} by {__author__}', + ) + + parser.add_argument( + '--always-ok', + help=lib.args.help('--always-ok'), + dest='ALWAYS_OK', + action='store_true', + default=False, + ) + + parser.add_argument( + '-c', + '--critical', + help='CRIT threshold for the directory size in human-readable format ' + '(base is always 1024; valid qualifiers are ' + 'b, k/kb/kib, m/mb/mib, g/gb/gib etc.). ' + 'Supports Nagios ranges. ' + 'Example: `:1G` alerts if size is greater than 1 GiB. ' + 'Default: %(default)s', + dest='CRIT', + default=DEFAULT_CRIT, + ) + + parser.add_argument( + '--dirname', + help='Path of the directory to check. ' + 'Supports glob patterns according to https://docs.python.org/3/library/glob.html. ' + 'Recursive globs can cause high memory usage. ' + 'Mutually exclusive with `-u` / `--url`. ' + 'Example: `--dirname /tmp/*`.', + dest='DIRNAME', + ) + + parser.add_argument( + '--pattern', + help='Search string to match against SMB directory or directory names. ' + 'Use `*` as a wildcard for multiple characters and `?` for a single character. ' + 'Does not support regex patterns. ' + 'Default: %(default)s', + dest='PATTERN', + default=DEFAULT_PATTERN, + ) + + parser.add_argument( + '--password', + help='Password for SMB authentication.', + dest='PASSWORD', + ) + + parser.add_argument( + '--timeout', + help=lib.args.help('--timeout') + ' Default: %(default)s (seconds)', + dest='TIMEOUT', + type=int, + default=DEFAULT_TIMEOUT, + ) + + parser.add_argument( + '-u', + '--url', + help='URL of the directory to check, starting with `smb://`. ' + 'Mutually exclusive with `--dirname`. ' + 'Example: `--url smb://server/share/path`.', + dest='URL', + type=str, + ) + + parser.add_argument( + '--username', + help='Username for SMB authentication.', + dest='USERNAME', + ) + + parser.add_argument( + '-w', + '--warning', + help='WARN threshold for the directory size in human-readable format ' + '(base is always 1024; valid qualifiers are ' + 'b, k/kb/kib, m/mb/mib, g/gb/gib etc.). ' + 'Supports Nagios ranges. ' + 'Example: `:1G` alerts if size is greater than 1 GiB. ' + 'Default: %(default)s', + dest='WARN', + default=DEFAULT_WARN, + ) + + args, _ = parser.parse_known_args() + return args + + +def get_dir_size(path): + """Return total size of files in directory recursively.""" + total = 0 + for dirpath, dirnames, filenames in os.walk(path): + for f in filenames: + fp = os.path.join(dirpath, f) + try: + total += os.path.getsize(fp) + except OSError: + pass + return total + + +def main(): + """The main function. This is where the magic happens.""" + + # parse the command line, exit with UNKNOWN if it fails + try: + args = parse_args() + except SystemExit: + sys.exit(STATE_UNKNOWN) + + if args.DIRNAME and args.URL: + lib.base.cu( + 'The `--dirname` and `-u` / `--url` parameters are mutually exclusive. Please use only one.' + ) + + # init some vars + state = STATE_OK + msg = '' + table_data = [] + alert_count = 0 + + # convert human readable nagios ranges to something that the Linuxfabrik libraries + # can understand + CRIT = lib.human.humanrange2bytes(args.CRIT) + WARN = lib.human.humanrange2bytes(args.WARN) + + # fetch data from local + if args.DIRNAME: + for item in sorted(glob.iglob(args.DIRNAME)): + if not os.path.isdir(item): + continue + table_data.append( + { + 'dirname': item, + 'size': get_dir_size(item), + } + ) + + # or fetch data from remote + if args.URL: + split_url = args.URL.split('://') + if len(split_url) != 2: + lib.base.cu(f'Could not parse the protocol of the url "{args.URL}".') + proto, url = split_url + if proto == 'smb': + if not HAVE_SMB: + lib.base.cu(f'Python module "{PYTHON_MOD}" is not installed.') + for item in lib.base.coe( + lib.smb.glob( + url, + args.USERNAME, + args.PASSWORD, + args.TIMEOUT, + pattern=args.PATTERN, + ) + ): + if item.is_dir(): + continue + table_data.append( + { + 'dirname': item, + 'size': item.stat().st_size, + } + ) + else: + lib.base.cu(f'The protocol "{proto}" is not supported.') + + if len(table_data) == 0: + msg = 'No directories found.' + lib.base.oao(msg, STATE_UNKNOWN, always_ok=args.ALWAYS_OK) + + # analyze data + for i, item in enumerate(table_data): + table_data[i]['size_hr'] = lib.human.bytes2human(table_data[i]['size']) + table_data[i]['state'] = lib.base.get_state( + item['size'], + WARN, + CRIT, + _operator='range', + ) + table_data[i]['state_hr'] = lib.base.state2str( + table_data[i]['state'], empty_ok=False + ) + if table_data[i]['state']: + alert_count += 1 + state = lib.base.get_worst(state, table_data[i]['state']) + + # build the message + msg += ( + f'{len(table_data)} {lib.txt.pluralize("directory", len(table_data))} checked. ' + ) + if state == STATE_OK: + msg += ( + f'{lib.txt.pluralize("", len(table_data), "It is,All are")}' + f' within the given size thresholds' + f' ({args.WARN}/{args.CRIT}).' + ) + else: + msg += ( + f'{alert_count}' + f' {lib.txt.pluralize("", alert_count, "is,are")}' + f' outside the given size thresholds' + f' ({args.WARN}/{args.CRIT}).' + ) + if len(table_data) == 1: + # show info on first line when there is only one hit + msg += ( + f' Checked {table_data[0]["dirname"]}:' + f' {table_data[0]["size_hr"]}' + f'{lib.base.state2str(table_data[0]["state"], prefix=" ")}' + ) + else: + msg += '\n\n' + lib.base.get_table( + table_data, + [ + 'dirname', + 'size_hr', + 'state_hr', + ], + header=[ + 'Directory', + 'Size', + 'State', + ], + ) + + # over and out + lib.base.oao(msg, state, always_ok=args.ALWAYS_OK) + + +if __name__ == '__main__': + try: + main() + except Exception: + lib.base.cu() diff --git a/check-plugins/dir-size/icingaweb2-module-director/dir-size.json b/check-plugins/dir-size/icingaweb2-module-director/dir-size.json new file mode 100644 index 000000000..6ab05d0d2 --- /dev/null +++ b/check-plugins/dir-size/icingaweb2-module-director/dir-size.json @@ -0,0 +1,559 @@ +{ + "Command": { + "cmd-check-dir-size": { + "arguments": { + "--always-ok": { + "set_if": "$dir_size_always_ok$" + }, + "--critical": { + "value": "$dir_size_critical$" + }, + "--dirname": { + "value": "$dir_size_dirname$" + }, + "--pattern": { + "value": "$dir_size_pattern$" + }, + "--password": { + "value": "$dir_size_password$" + }, + "--timeout": { + "value": "$dir_size_timeout$" + }, + "--url": { + "value": "$dir_size_url$" + }, + "--username": { + "value": "$dir_size_username$" + }, + "--warning": { + "value": "$dir_size_warning$" + } + }, + "command": "/usr/lib64/nagios/plugins/dir-size", + "disabled": false, + "fields": [ + { + "datafield_id": 1, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 2, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 3, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 4, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 5, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 6, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 7, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 8, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 9, + "is_required": "n", + "var_filter": null + } + ], + "imports": [], + "is_string": null, + "methods_execute": "PluginCheck", + "object_name": "cmd-check-dir-size", + "object_type": "object", + "timeout": "10", + "vars": {}, + "zone": null, + "uuid": "503e82b1-4560-41be-abec-76b86afce211" + }, + "cmd-check-dir-size-sudo": { + "arguments": {}, + "command": "/usr/bin/sudo /usr/lib64/nagios/plugins/dir-size", + "disabled": false, + "fields": [], + "imports": [ + "cmd-check-dir-size" + ], + "is_string": null, + "methods_execute": null, + "object_name": "cmd-check-dir-size-sudo", + "object_type": "object", + "timeout": null, + "vars": {}, + "zone": null, + "uuid": "7c18525b-ac1b-4fc8-9cf6-e2b24b82f263" + }, + "cmd-check-dir-size-windows": { + "arguments": { + "--always-ok": { + "set_if": "$dir_size_windows_always_ok$" + }, + "--critical": { + "value": "$dir_size_windows_critical$" + }, + "--dirname": { + "value": "$dir_size_windows_dirname$" + }, + "--pattern": { + "value": "$dir_size_windows_pattern$" + }, + "--password": { + "value": "$dir_size_windows_password$" + }, + "--timeout": { + "value": "$dir_size_windows_timeout$" + }, + "--url": { + "value": "$dir_size_windows_url$" + }, + "--username": { + "value": "$dir_size_windows_username$" + }, + "--warning": { + "value": "$dir_size_windows_warning$" + } + }, + "command": "C:\\Program Files\\icinga2\\sbin\\linuxfabrik\\dir-size.exe", + "disabled": false, + "fields": [ + { + "datafield_id": 10, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 11, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 12, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 13, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 14, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 15, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 16, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 17, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 18, + "is_required": "n", + "var_filter": null + } + ], + "imports": [], + "is_string": null, + "methods_execute": "PluginCheck", + "object_name": "cmd-check-dir-size-windows", + "object_type": "object", + "timeout": "10", + "vars": {}, + "zone": null, + "uuid": "a07b033f-42c1-4513-9b86-941aebac31e5" + }, + "cmd-check-dir-size-windows-python": { + "arguments": {}, + "command": "C:\\Windows\\py C:\\Program Files\\icinga2\\sbin\\linuxfabrik\\dir-size.py", + "disabled": false, + "fields": [], + "imports": [ + "cmd-check-dir-size-windows" + ], + "is_string": null, + "methods_execute": null, + "object_name": "cmd-check-dir-size-windows-python", + "object_type": "object", + "timeout": null, + "vars": {}, + "zone": null, + "uuid": "b2c6ca42-2f59-4d83-84e2-5c9979f86170" + } + }, + "ServiceTemplate": { + "tpl-service-dir-size": { + "action_url": null, + "apply_for": null, + "assign_filter": null, + "check_command": "cmd-check-dir-size", + "check_interval": 900, + "check_period": null, + "check_timeout": null, + "command_endpoint": null, + "disabled": false, + "display_name": null, + "enable_active_checks": null, + "enable_event_handler": null, + "enable_flapping": null, + "enable_notifications": true, + "enable_passive_checks": null, + "enable_perfdata": null, + "event_command": null, + "fields": [], + "flapping_threshold_high": null, + "flapping_threshold_low": null, + "groups": [], + "host": null, + "icon_image": "dir-size.svg", + "icon_image_alt": null, + "imports": [ + "tpl-service-generic" + ], + "max_check_attempts": 5, + "notes": "Checks directory sizes against configurable thresholds using human-readable units (e.g. 25M, 1G). Supports glob patterns and SMB shares. Alerts when any directory exceeds the configured size thresholds. Requires root or sudo.", + "notes_url": "https://linuxfabrik.github.io/monitoring-plugins/check-plugins/dir-size/", + "object_name": "tpl-service-dir-size", + "object_type": "template", + "retry_interval": 15, + "service_set": null, + "template_choice": null, + "use_agent": null, + "use_var_overrides": null, + "vars": { + "criticality": "C", + "dir_size_always_ok": false, + "dir_size_critical": "1G", + "dir_size_pattern": "*", + "dir_size_timeout": 3, + "dir_size_warning": "25M" + }, + "volatile": null, + "zone": null, + "uuid": "5f5bdd51-f98e-44de-993d-8c615fecdc02" + }, + "tpl-service-dir-size-sudo": { + "action_url": null, + "apply_for": null, + "assign_filter": null, + "check_command": "cmd-check-dir-size-sudo", + "check_interval": null, + "check_period": null, + "check_timeout": null, + "command_endpoint": null, + "disabled": false, + "display_name": null, + "enable_active_checks": null, + "enable_event_handler": null, + "enable_flapping": null, + "enable_notifications": true, + "enable_passive_checks": null, + "enable_perfdata": null, + "event_command": null, + "fields": [], + "flapping_threshold_high": null, + "flapping_threshold_low": null, + "groups": [], + "host": null, + "icon_image": null, + "icon_image_alt": null, + "imports": [ + "tpl-service-dir-size" + ], + "max_check_attempts": null, + "notes": null, + "notes_url": null, + "object_name": "tpl-service-dir-size-sudo", + "object_type": "template", + "retry_interval": null, + "service_set": null, + "template_choice": null, + "use_agent": null, + "use_var_overrides": null, + "vars": { + "criticality": "C" + }, + "volatile": null, + "zone": null, + "uuid": "b2eba5c5-cff8-4f7a-8fa6-1cd197ff27cb" + }, + "tpl-service-dir-size-windows": { + "action_url": null, + "apply_for": null, + "assign_filter": null, + "check_command": "cmd-check-dir-size-windows", + "check_interval": 60, + "check_period": null, + "check_timeout": null, + "command_endpoint": null, + "disabled": false, + "display_name": null, + "enable_active_checks": null, + "enable_event_handler": null, + "enable_flapping": null, + "enable_notifications": true, + "enable_passive_checks": null, + "enable_perfdata": null, + "event_command": null, + "fields": [], + "flapping_threshold_high": null, + "flapping_threshold_low": null, + "groups": [], + "host": null, + "icon_image": "dir-size.svg", + "icon_image_alt": null, + "imports": [ + "tpl-service-generic" + ], + "max_check_attempts": 5, + "notes": "Checks directory sizes against configurable thresholds using human-readable units (e.g. 25M, 1G). Supports glob patterns and SMB shares. Alerts when any directory exceeds the configured size thresholds. Requires root or sudo.", + "notes_url": "https://linuxfabrik.github.io/monitoring-plugins/check-plugins/dir-size/", + "object_name": "tpl-service-dir-size-windows", + "object_type": "template", + "retry_interval": 15, + "service_set": null, + "template_choice": null, + "use_agent": null, + "use_var_overrides": null, + "vars": { + "criticality": "C", + "dir_size_windows_always_ok": false, + "dir_size_windows_critical": "1G", + "dir_size_windows_pattern": "*", + "dir_size_windows_timeout": 3, + "dir_size_windows_warning": "25M" + }, + "volatile": null, + "zone": null, + "uuid": "d0d44d9a-f496-450a-8218-4f65eb70f034" + } + }, + "Datafield": { + "1": { + "varname": "dir_size_always_ok", + "caption": "Directory Size: Always OK?", + "description": "Always returns OK.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean", + "format": null, + "settings": {}, + "uuid": "bb4ea574-768b-4a22-a889-0e638a6a080f" + }, + "2": { + "varname": "dir_size_critical", + "caption": "Directory Size: Critical", + "description": "CRIT threshold for the directory size in human-readable format (base is always 1024; valid qualifiers are b, k/kb/kib, m/mb/mib, g/gb/gib etc.). Supports Nagios ranges. Example: `:1G` alerts if size is greater than 1 GiB.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "e8ad3768-b4da-4a0e-896e-663a765cd56d" + }, + "3": { + "varname": "dir_size_dirname", + "caption": "Directory Size: Directory Name", + "description": "Path of the directory to check. Supports glob patterns according to https://docs.python.org/3/library/glob.html. Recursive globs can cause high memory usage. Mutually exclusive with `-u` / `--url`. Example: `--dirname /tmp/*`.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "93f605f9-8192-4fd1-acde-61075364b83c" + }, + "4": { + "varname": "dir_size_pattern", + "caption": "Directory Size: Pattern", + "description": "Search string to match against SMB directory names. Use `*` as a wildcard for multiple characters and `?` for a single character. Does not support regex patterns.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "5b028499-0953-4fc4-9f35-1e6282a76486" + }, + "5": { + "varname": "dir_size_password", + "caption": "Directory Size: Password", + "description": "Password for SMB authentication.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "hidden" + }, + "uuid": "6fda7fa6-b04a-4190-8360-393008362e62" + }, + "6": { + "varname": "dir_size_timeout", + "caption": "Directory Size: Timeout", + "description": "Network timeout in seconds.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "1ecb3316-e7dc-4b16-ae2a-b49edeeda976" + }, + "7": { + "varname": "dir_size_url", + "caption": "Directory Size: URL", + "description": "URL of the directory to check, starting with `smb://`. Mutually exclusive with `--dirname`. Example: `--url smb://server/share/path`.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "697a0079-4297-41b1-9159-9a89126c0928" + }, + "8": { + "varname": "dir_size_username", + "caption": "Directory Size: Username", + "description": "Username for SMB authentication.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "f2fca516-7655-46ab-bbf0-9f03825f7e71" + }, + "9": { + "varname": "dir_size_warning", + "caption": "Directory Size: Warning", + "description": "WARN threshold for the directory size in human-readable format (base is always 1024; valid qualifiers are b, k/kb/kib, m/mb/mib, g/gb/gib etc.). Supports Nagios ranges. Example: `:1G` alerts if size is greater than 1 GiB.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "81630705-7df2-4ad3-9498-51fa3e5d7788" + }, + "10": { + "varname": "dir_size_windows_always_ok", + "caption": "Directory Size: Always OK?", + "description": "Always returns OK.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean", + "format": null, + "settings": {}, + "uuid": "38360153-ddcf-44c4-8aa9-e879826e05f9" + }, + "11": { + "varname": "dir_size_windows_critical", + "caption": "Directory Size: Critical", + "description": "CRIT threshold for the directory size in human-readable format (base is always 1024; valid qualifiers are b, k/kb/kib, m/mb/mib, g/gb/gib etc.). Supports Nagios ranges. Example: `:1G` alerts if size is greater than 1 GiB.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "dcaf9e8e-599d-4391-84ae-3850e1c8cc5f" + }, + "12": { + "varname": "dir_size_windows_dirname", + "caption": "Directory Size: Directory Name", + "description": "Path of the directory to check. Supports glob patterns according to https://docs.python.org/3/library/glob.html. Recursive globs can cause high memory usage. Mutually exclusive with `-u` / `--url`. Example: `--dirname C:\\Temp\\*`.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "cf224109-87ce-430a-8a39-9007fce38be0" + }, + "13": { + "varname": "dir_size_windows_pattern", + "caption": "Directory Size: Pattern", + "description": "Search string to match against SMB directory names. Use `*` as a wildcard for multiple characters and `?` for a single character. Does not support regex patterns.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "edd8c7a9-0096-4d0e-a36d-ed4cf0d65190" + }, + "14": { + "varname": "dir_size_windows_password", + "caption": "Directory Size: Password", + "description": "Password for SMB authentication.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "hidden" + }, + "uuid": "0fc3c701-dffe-49d7-931d-e63fffb393df" + }, + "15": { + "varname": "dir_size_windows_timeout", + "caption": "Directory Size: Timeout", + "description": "Network timeout in seconds.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "0e65a7fb-4675-4c96-b151-cc7f28379628" + }, + "16": { + "varname": "dir_size_windows_url", + "caption": "Directory Size: URL", + "description": "URL of the directory to check, starting with `smb://`. Mutually exclusive with `--dirname`. Example: `--url smb://server/share/path`.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "2fa58ba2-ce87-4a8c-9850-606c6959e010" + }, + "17": { + "varname": "dir_size_windows_username", + "caption": "Directory Size: Username", + "description": "Username for SMB authentication.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "a1ec99b7-7b39-4016-b705-a63715d8d34d" + }, + "18": { + "varname": "dir_size_windows_warning", + "caption": "Directory Size: Warning", + "description": "WARN threshold for the directory size in human-readable format (base is always 1024; valid qualifiers are b, k/kb/kib, m/mb/mib, g/gb/gib etc.). Supports Nagios ranges. Example: `:1G` alerts if size is greater than 1 GiB.", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "settings": { + "visibility": "visible" + }, + "uuid": "f509bfd4-62bc-4bd0-bb3c-f8c5ba4af4a0" + } + } +} diff --git a/check-plugins/dir-size/icingaweb2-module-director/dir-size.yml b/check-plugins/dir-size/icingaweb2-module-director/dir-size.yml new file mode 100644 index 000000000..eff2def88 --- /dev/null +++ b/check-plugins/dir-size/icingaweb2-module-director/dir-size.yml @@ -0,0 +1,8 @@ +--- +variants: + - linux + - sudo + - windows + +overwrites: + '["ServiceTemplate"]["tpl-service-dir-size"]["check_interval"]': 900 diff --git a/check-plugins/dir-size/icon/dir-size.svg b/check-plugins/dir-size/icon/dir-size.svg new file mode 100644 index 000000000..a5d7b5ad9 --- /dev/null +++ b/check-plugins/dir-size/icon/dir-size.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/check-plugins/dir-size/lib b/check-plugins/dir-size/lib new file mode 120000 index 000000000..58677ddb4 --- /dev/null +++ b/check-plugins/dir-size/lib @@ -0,0 +1 @@ +../../lib \ No newline at end of file