Solved

Modbus strange behavior

  • 16 May 2023
  • 1 reply
  • 51 views

Userlevel 1
Badge +11

Hi,

 

I want to manipulate the data with modbus monitoring.

 

Here is my json

{
  "selection":{
        "FC3_key_erasing_information":{
            "address": 7,
            "quantity": 1,
            "type": "holding",
            "display": false
      }
    },
  "virtualcurve":{
    "FC3_key_erasing_information":{
      "aggregation": "avg",
      "pattern": "FC3_key_erasing_information",
      "critical": "0",
      "formatting": {
        "printf_msg": "key_erasing sensor is %.f",
        "printf_var": "$self->{result_values}->{instance}, $self->{result_values}->{value}"
      }
  }
}
}
 

With my simulator i’ve set the value to 1 but here is the result:

-bash-4.2$ /usr/lib/centreon/plugins/centreon_protocol_modbus.pl --plugin=apps::protocols::modbus::plugin --mode=numeric-value --tcp-host=X.X.X.X --config=/usr/lib/centreon/plugins/intrusion.json  --verbose
Argument "FC3_key_erasing_information" isn't numeric in sprintf at /usr/lib/centreon/plugins/centreon_protocol_modbus.pl line 100.
OK: key_erasing sensor is 0 | 'FC3_key_erasing_information'=1;;0:1;;
key_erasing sensor is 0
 

Why i get this sprintf message and also, why the value returned is 0 while the value is 1?

icon

Best answer by coco163 22 May 2023, 14:44

View original

1 reply

Userlevel 1
Badge +11

As seen, "printf_var": "$self->{result_values}->{instance}, $self->{result_values}->{value}" correspond to the manipulation of %s and then %.f.

My mistake.

Thanks for the clarification.

Reply