Cacti / plugin_thold

Thold Plugin for Cacti
GNU General Public License v2.0
68 stars 63 forks source link

Plugin Thold shows the current value as 0 after executing CDEF #583

Closed igomezBaitic closed 1 year ago

igomezBaitic commented 1 year ago

Describe the bug After upgrading the CACTI version to 1.2.24, we have noticed an issue when creating a new Thold template. The SNMP-extracted voltage value from a device is not correctly captured after applying the CDEF logic of dividing it by 100.

Analyzing the CACTI logs, we have found the following error lines:

01-Jun-2023 12:55:52 - THOLD: Checking Threshold: Name: HOST - TEMPLATE', Graph: '9347' 01-Jun-2023 12:55:52 - THOLD WARNING: Value for Data ID 7240 is not numeric:'CURRENT_DATA_SOURCE', Previous Value was:'CURRENT_DATA_SOURCE' 01-Jun-2023 12:55:52 - THOLD WARNING: Erroneous CDEF logic, the first value should be numeric, but is 'CURRENT_DATA_SOURCE' 01-Jun-2023 12:55:52 - ERROR PHP WARNING in Plugin 'thold': A non-numeric value encountered in file: /cacti/plugins/thold/thold_functions.php on line: 4117

It seems that when applying the logic, the function encounters a non-numeric value. Analyzing the Thold database tables, we can see that the value of the last reading is stored as varchar2, which may be the cause of the issue.

On the other hand, we have tried updating the Thold plugin to its latest version, but the problem persists. We have also tested performing the CDEF operation with byte-to-bit conversion, and in this case, it seems to work correctly. Therefore, the error only occurs with non-traffic data.

If we collect the value as an exact value, it captures the current value correctly. The issue seems to be specifically related to the CDEF function.

Could you please review what might be happening?

Thank you very much in advance.

Best regards.

To Reproduce Steps I show in the description

Expected behavior Explanation I show in the description

Plugin (please complete the following information):

Desktop (please complete the following information):

TheWitness commented 1 year ago

Okay, I think I have this figured. You should test, but not on productions. We are in heavy development of Thold 2.0 right now. So, though this is fixed, you should tread lightly towards production.

TheWitness commented 1 year ago

You might be able to cherry pick this single commit though.

TheWitness commented 1 year ago

I've tested this and it's working fine. So, I'll close for now.