Cacti / plugin_thold

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

Thold Current Value is incorrect in 1.8.1 #674

Open JasonRaptor opened 5 months ago

JasonRaptor commented 5 months ago

Describe the bug Thold Current Value is incorrect in 1.8.1

Hello Sir,

As I have upgraded from v0.8.8h to v1.2.27, and now the Thold Plugin is able to send alert email out, but the current value (Mbytes) can't match with the data showing in Graph (Mbits), even I made self calculation.

Cacti Version: v1.2.27 PHP 8.3.7 MySQL 5.7.43 Thold 1.8.1 NET-SNMP version: 5.5 cmd.php Concurrent Processes Name: Main Poller, Procs: 40 Max Threads Name: Main Poller, Threads: 60 PHP Servers 10 Minimum Connections: Main Server: Current: 3000, Min Required: 2900

May I know if anyone can help to provide some solution for me ?

To Reproduce Steps to reproduce the behavior:

  1. Click on "Thold" Plugin Page
  2. Select any Threshold record and click "Edit Threshold"
  3. The "traffic_in / traffic_out"'s Last value cannot match with the Graph (the current value (Mbytes) can't match with the data showing in Graph (Mbits), even I made self calculation)

Expected behavior The "traffic_in / traffic_out"'s Last value should be match with the Graph

Screenshots Thold Current Incorrect

Plugin (please complete the following information):

Server (please complete the following information):

Additional context Add any other context about the problem here.

xmacan commented 5 months ago

It is from forums. User reported php error too: 2024-06-04 19:18:02 - CMDPHP PHP ERROR Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[99]:perform_thold_processes(), D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[154]:thold_check_all_thresholds(), D:\Inetpub\wwwroot\cacti\plugins\thold\includes\polling.php[332]:thold_check_threshold(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[2219]:get_thold_emails(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[7596]:CactiErrorHandler()) 2024-06-04 19:18:02 - ERROR PHP DEPRECATED: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file: D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php on line: 7596 2024-06-04 19:18:02 - CMDPHP PHP ERROR Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[99]:perform_thold_processes(), D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[154]:thold_check_all_thresholds(), D:\Inetpub\wwwroot\cacti\plugins\thold\includes\polling.php[332]:thold_check_threshold(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[2219]:get_thold_emails(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[7596]:CactiErrorHandler()) 2024-06-04 19:18:02 - ERROR PHP DEPRECATED: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file: D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php on line: 7596 2024-06-04 19:18:02 - CMDPHP PHP ERROR Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[99]:perform_thold_processes(), D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[154]:thold_check_all_thresholds(), D:\Inetpub\wwwroot\cacti\plugins\thold\includes\polling.php[332]:thold_check_threshold(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[2219]:get_thold_emails(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[7596]:CactiErrorHandler()) 2024-06-04 19:18:02 - ERROR PHP DEPRECATED: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file: D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php on line: 7596 2024-06-04 19:18:02 - CMDPHP PHP ERROR Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[99]:perform_thold_processes(), D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[154]:thold_check_all_thresholds(), D:\Inetpub\wwwroot\cacti\plugins\thold\includes\polling.php[332]:thold_check_threshold(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[2219]:get_thold_emails(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[7596]:CactiErrorHandler()) 2024-06-04 19:18:02 - ERROR PHP DEPRECATED: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file: D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php on line: 7596 2024-06-04 19:18:02 - CMDPHP PHP ERROR Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[99]:perform_thold_processes(), D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[154]:thold_check_all_thresholds(), D:\Inetpub\wwwroot\cacti\plugins\thold\includes\polling.php[332]:thold_check_threshold(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[2219]:get_thold_emails(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[7596]:CactiErrorHandler()) 2024-06-04 19:18:02 - ERROR PHP DEPRECATED: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file: D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php on line: 7596 2024-06-04 19:18:02 - CMDPHP PHP ERROR Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[99]:perform_thold_processes(), D:\Inetpub\wwwroot\cacti\plugins\thold\poller_thold.php[154]:thold_check_all_thresholds(), D:\Inetpub\wwwroot\cacti\plugins\thold\includes\polling.php[332]:thold_check_threshold(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[2219]:get_thold_emails(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php[7596]:CactiErrorHandler()) 2024-06-04 19:18:02 - ERROR PHP DEPRECATED: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file: D:\Inetpub\wwwroot\cacti\plugins\thold\thold_functions.php on line: 7596

Problem is int thold_functions.php on line 7593-7596. Notify_warning_extra can be null. So strlen(null) causes this.

@TheWitness why we have diferent settings for notify_warning_extra and notify_extra (first can be null, second not)?

TheWitness commented 5 months ago

This is fixed now, you may grab a fresh copy of thold_functions.php and report back.

JasonRaptor commented 5 months ago

Thank you @TheWitness , let me have a try on it :)

JasonRaptor commented 5 months ago

@TheWitness I just tried to stop the Apache, renamed the old php as "thold_functions.php", and place the new php file in there, and start the Apache. But the Cacti Plugin page is being with this error as below.

Sorry, we could not process your last action. Error: 500 plugin_thold/thold_functions.php at develop · Cacti/plugin_thold Reason: We read every piece of feedback, and take your input very seriously.

TheWitness commented 5 months ago

That sounds more like a configuration issue than anything else. Run the following on the file:

php -l -d display_errors=on thold_functions.php

If that does not work, restart the Apache service.

JasonRaptor commented 5 months ago

@TheWitness I discover that the new "thold_functions.php" is being with different ROWs, may need to upload again

TheWitness commented 5 months ago

This is the only change. There are not many different rows.

image

You may have a line ending issue with the file. Edit it and make sure you actually have the right file.

JasonRaptor commented 5 months ago

I have made use of my original php file, and modified with the code, and now it is able to access now.

And now the Current Data should be able to match with the Graph Data, but there is slightly different, is that normal? Is it related to different polling time ?

Thold Current

JasonRaptor commented 5 months ago

Hello @TheWitness ,

Thanks for your help. And now the Threshold Status cannot be updated, even the current value is being dropped, it still keep in triggered status as below.

Thold Status Freeze

And also failed to trigger alert when I modified with a super small threshold, and there is no email alert as well.

Failed to trigger

And the below is the current Cacti Log. 11_05PM Log

Thanks a lot for your help.

bmfmancini commented 5 months ago

@JasonRaptor when you moved the new thold_functions.php file over did you set the same permissions ? The Thold plugin its self would crash but not deny you access to the main cacti UI so that's strange

JasonRaptor commented 5 months ago

Hello @bmfmancini I have replaced the coding in the original file, and I can confirm with the same permission as before. But now being with another issue that I mentioned.

Thank you.

JasonRaptor commented 5 months ago

Hello,

I have reapply the "thold_functions.php" again, and reboot the server. Now the situation is same as before. The current value that cannot be matched with the Graph as below, but the alert email trigger is normal as previous.

Below is the same Interface on One Network Device Wrong Threshold Current

And the below is the Cacti Log 12_15PM Log

Thank you.

JasonRaptor commented 5 months ago

Hello @TheWitness ,

May I know if you can help to provide some solution for me, please?

Thank you.

TheWitness commented 5 months ago

So even though you're plotting bits per second you have to enter the data as it appears in the rrdfile which is in bytes per second. So if you reduce your value to bytes per second I think it should work correctly. Let me know if that works out.

JasonRaptor commented 5 months ago

Hello @TheWitness ,

Thanks for your follow up with my case. Please take a look at below for my case.

For Example: The Link Bandwidth ==> 3Gbit Threshold Setting ==> 3Gbit (90%) = 2700 Megabits (Mb)

Convert Mb to B > 2700 Megabits (Mb) = 337500000 Bytes (B)

Then I have the below Setting in Thold

Warning - High / Low Settings High Threshold = 'I leave it blank' Low Threshold = 'I leave it blank' Breach Duration = 5 mins

Alert - High / Low Settings High Threshold = 337500000 Low Threshold = 300000000 Breach Duration = 15 mins

Then Press "Save" Button

After that, I can see the amount I entered, it changed to below automatically Alert - High / Low Settings High Threshold = 337.5M Low Threshold = 300M Breach Duration = 15 mins

After few times polling (~15 mins), and I check with the current graph data

Graph: Inbound (Current) = 1.43 Gbit Outbound (Current) = 16.61 Mbit

Thold (Traffic_in) (Last: 304.03346 M) Thold (Traffic_out) (Last: 3.595518 M)

Thank you.

TheWitness commented 5 months ago

Upload a screenshot of the Threshold > Edit page. Redact anything private.

JasonRaptor commented 5 months ago

Hello @TheWitness

Thanks for that. Please take a look at the below PrintScreen for your reference. Thank you.

Screenshot001

Screenshot002

Screenshot003

TheWitness commented 5 months ago

Okay. I'll have to find some time. I'm working on some things for 1.8.2. Maybe by the end of next week I can have this one pinned down.

JasonRaptor commented 4 months ago

Okay. I'll have to find some time. I'm working on some things for 1.8.2. Maybe by the end of next week I can have this one pinned down.

Thanks a lot @TheWitness

JasonRaptor commented 4 months ago

Here is the Latest ScreenShot after being using with the Latest THOLD in Github.

Snipaste_2024-06-26_14-26-40 Snipaste_2024-06-26_14-28-24

And seem that the Data Polling Time for the "THOLD's Current Value" and "Graph Value" is not at the same Time.

JasonRaptor commented 4 months ago

During the time I edit the "High Threshold" value, I can see the below Cacti Log.

2024-06-26 19:51:31 - CMDPHP PHP ERROR WARNING Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[144]:thold_edit(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[2266]:draw_edit_form(), D:\Inetpub\wwwroot\cacti\lib\html_form.php[57]:CactiErrorHandler()) 2024-06-26 19:51:31 - ERROR PHP WARNING: Undefined array key "default" in file: D:\Inetpub\wwwroot\cacti\lib\html_form.php on line: 57 2024-06-26 19:51:31 - CMDPHP form_edit Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[144]:thold_edit(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[2266]:draw_edit_form(), D:\Inetpub\wwwroot\cacti\lib\html_form.php[56]:cacti_debug_backtrace()) 2024-06-26 19:51:31 - CMDPHP WARNING: Cacti Form field 'syslog_settings' does not include a 'value' Column. Using default 2024-06-26 19:51:19 - CMDPHP PHP ERROR WARNING Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[144]:thold_edit(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[2266]:draw_edit_form(), D:\Inetpub\wwwroot\cacti\lib\html_form.php[57]:CactiErrorHandler()) 2024-06-26 19:51:19 - ERROR PHP WARNING: Undefined array key "default" in file: D:\Inetpub\wwwroot\cacti\lib\html_form.php on line: 57 2024-06-26 19:51:19 - CMDPHP form_edit Backtrace: (D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[144]:thold_edit(), D:\Inetpub\wwwroot\cacti\plugins\thold\thold.php[2266]:draw_edit_form(), D:\Inetpub\wwwroot\cacti\lib\html_form.php[56]:cacti_debug_backtrace()) 2024-06-26 19:51:19 - CMDPHP WARNING: Cacti Form field 'syslog_settings' does not include a 'value' Column. Using default