i want use oid return value on --format-critical

Badge +2

$CENTREONPLUGINS$/ --plugin=apps::protocols::snmp::plugin --mode=string-value --hostname=$HOSTADDRESS$ --snmp-community='$_HOSTSNMPCOMMUNITY$' --snmp-version=$_HOSTSNMPVERSION$ $_HOSTSNMPEXTRAOPTIONS$ --oid='$_SERVICEOID$'  --map-values='$_HOSTATTENDU$=>$_HOSTATTENDU$' --map-value-other='Critical' --critical-regexp='Critical' --format-ok='%{details_ok}'  --format-critical='%{details_ok} non ok : $_HOSTATTENDU$ attendu' --snmp-autoreduce

if it’s ok --format-ok='%{details_ok}' returne the good value to oid check 
but if it’s critical -format-critical='%{details_ok} non ok’   %{details_ok} is empty

they are other way to do this ? 



Best answer by vcoum 3 April 2024, 12:06

View original

11 replies

Userlevel 5
Badge +11

Hello @anthonys 

If i refer to the code of the plugin, for each status you need to change the syntax

  • If ok, you used the correct syntax => %{details_ok}
  • If warning, use %{details_warning}
  • If critical, %{details_critical}
  • If unknown, %{details_unknown}

The details will be placed in one of these variables according to the service status

So you parameters should be  --format-critical='%{details_critical}

Hope it helps

Badge +2

hello if i use %{details_critical} : is not the same value of %{details_ok}

i want the result return by the snmp extend check.

my check if a script who return number : for instance 5
if ok  map value 5  %{details_ok} = 5 

i want use print in critical : number is : 5  no good 

thk for your help 

Userlevel 4
Badge +12

I don’t understand what you are trying to obtain.

Can you explain what values the OID is returning and what output message you want to get out of it ?

Badge +2

I want this : 

  1. Successful Check (OK): If the SNMP check returns the expected version number (e.g., 10.5), the output message should indicate that the check is OK, along with the current version number.

    Output message: OK: Current version 10.5

  2. Failed Check (Critical): If the SNMP check returns a version number different from the expected one (e.g., 10.4 instead of 10.5), the output message should indicate that the check is critical, along with both the current and expected version numbers.

    Output message: Critical: Current version 10.4, Expected version 10.5

But I am unable to retrieve the version, for example 10.4, returned by the script in the output of the critical message.

This way, the output message clearly indicates whether the check is successful or not, along with the necessary version information for further analysis.


Userlevel 5
Badge +11

Can you try you command without the mapping, and with this arguments?

./ --plugin=apps::protocols::snmp::plugin --mode=string-value --hostname=$HOSTADDRESS$ --snmp-community='$_HOSTSNMPCOMMUNITY$' --snmp-version=$_HOSTSNMPVERSION$ $_HOSTSNMPEXTRAOPTIONS$ --oid='$_SERVICEOID$' --format-ok='Current version %{details_ok}' --format-critical='Current version %{details_critical}, Expected version VALEURATTENDU' --critical-regexp='(?!VALEURATTENDU)'

The argument  critical-regexp will turn the status to Critical if the regex expression match

In your case, i put a negative match, so if the value returned doesn’t match your pattern, the status will be critical



Badge +2

yep it’s work fine :) thank you.

Badge +2

hmm isn't really good because when the version is okay "VALEURATTENDU" is the correct version, it still shows as critical because it's the critical regex.

Status: CRITICAL: Current version 10.0.14, Expected version : 10.0.14



Userlevel 5
Badge +11

Try to escape the dots in the regex , like this



Badge +2

i can’t it’s variable  :


Userlevel 5
Badge +11

Okay try with this syntax


#Or in the command


Badge +2

well done. it’s ok 
thank you.