Skip to content

Migrate all threshold parameters from type=int to Nagios range support #1067

@markuslf

Description

@markuslf

Goal

Migrate all --warning and --critical parameters from type=int (or type=float) to type=str with _operator='range' in lib.base.get_state(), enabling full Nagios range expressions like 10:, ~:50, @10:20.

Background

The CONTRIBUTING and the example plugin now define Nagios range support as the standard for new plugins. Existing plugins still use type=int with the default _operator='ge', which only supports simple "greater or equal" thresholds.

What needs to change per plugin

  1. Remove type=int (or type=float) from --warning and --critical add_argument() calls (defaults to type=str).
  2. Change lib.base.get_state(value, args.WARN, args.CRIT) to lib.base.get_state(value, args.WARN, args.CRIT, _operator='range').
  3. Update the help text Default from Default: >= %(default)s to Default: %(default)s (the range interpretation handles the direction).
  4. Update unit tests if they assert on specific threshold behavior.

Backward compatibility

Simple numeric values like --critical 90 continue to work identically: 90 as a Nagios range means "alert if outside 0..90", which is equivalent to the current "alert if >= 90" behavior for values between 0 and 100. No admin-visible breaking change for standard usage.

Scope

All plugins that currently use type=int or type=float for --warning/--critical parameters with lib.base.get_state().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions