Revert WARN n CRITIC values

I have an oid that gives me battery percentage, I can alter warn and critic values, but I need them to work recursevely meaning, when I get 20 percent left, give me a warning, if 5% is remaining, CRITIC

Module’s conf:
commands.conf:

object CheckCommand "checkUPS" {
          command = [ PluginDir + "/check_snmp"]

          arguments = {
            "-H" = "$snmp_address$"
            "-o" = "$snmp_oid$"
            "-P" = "$snmp_version$"
            "-C" = "$snmp_community$"
            "-w" = "$snmp_warn$"
            "-c" = "$snmp_crit$"
            "-u" = "$snmp_units$"
          }

          vars.snmp_address = "$address$"
 }

services.conf:

            apply Service "BatteryPercentage" {
                  import "generic-service"

              check_command = "checkUPS"
              vars.snmp_oid = "1.3.6.1.2.1.33.1.2.4.0"
              vars.snmp_warn = "20"
              vars.snmp_crit = "5"
              vars.snmp_units = "%"
              assign where host.vars.os == "ups"
            }

Hi,

first you don’t need to redefine the snmp check. There is already a build in snmp check and you can remove your checkUPS CheckCommand object.
To your problem, change the warning and critical values to 20: and 5: - so if the value is < 20 warn and if the value is < 5 critical:

apply Service "BatteryPercentage" {
    import "generic-service"

    check_command = "snmp"
    vars.snmp_oid = "1.3.6.1.2.1.33.1.2.4.0"
    vars.snmp_warn = "20:"
    vars.snmp_crit = "5:"
    vars.snmp_units = "%"
    
    assign where host.vars.os == "ups"
}

More informations about available thresholds can be found at the monitoring guidelines.

Greetz

2 Likes

@fluxX Just for future reference, we’ve created our own plugin API spec with enhanced examples and guidelines. The old html format is obsolete by now.

https://icinga.com/docs/icinga2/latest/doc/05-service-monitoring/#plugin-api

2 Likes

Hi,

@mfriedrich thx for the info! :slight_smile:

Greetz

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)