Skip to main content
Solved

Modbus strange behavior

  • May 16, 2023
  • 1 reply
  • 86 views

coco163
Forum|alt.badge.img+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?

Best answer by coco163

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.

1 reply

coco163
Forum|alt.badge.img+11
  • Author
  • Steward ***
  • Answer
  • May 22, 2023

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.