Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PHP 8.1 support when adding devices #5483

Closed
asd0109 opened this issue Sep 8, 2023 · 13 comments
Closed

Improve PHP 8.1 support when adding devices #5483

asd0109 opened this issue Sep 8, 2023 · 13 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@asd0109
Copy link

asd0109 commented Sep 8, 2023

2023-09-08 09 02 53

add new device very very slow

2023-09-08 09 00 35

After adding, it was found device status is unknown.

2023-09-08 09 01 17

logpage show error message.

i test cacti in ubuntu 20.04.6 php7.4 is ok no this error .

@asd0109 asd0109 added bug Undesired behaviour unverified Some days we don't have a clue labels Sep 8, 2023
@TheWitness
Copy link
Member

Good catch. What happens if you edit lib/snmp.php and add the following after global $banned_snmp_strings;?

    global $banned_snmp_strings;

    if ($string === null) {
        return '';
    }

@TheWitness
Copy link
Member

PHP8 deprecations drive me nuts.

@TheWitness TheWitness added this to the 1.2.26 milestone Sep 8, 2023
@asd0109
Copy link
Author

asd0109 commented Sep 8, 2023

2023-09-08 13 15 56

2023-09-08 13 16 31

i try , but fail :(

Good catch. What happens if you edit lib/snmp.php and add the following after global $banned_snmp_strings;?

    global $banned_snmp_strings;

    if ($string === null) {
        return '';
    }

i try it ,but failed .

@asd0109
Copy link
Author

asd0109 commented Sep 8, 2023

2023-09-08 13:13:43 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler())

2023-09-08 13:13:43 - ERROR PHP ERROR: Uncaught TypeError: dechex(): Argument #1 ($num) must be of type int, string given in /var/www/html/cacti/lib/data_query.php:1378 Stack trace: #0 /var/www/html/cacti/lib/data_query.php(1378): dechex() #1 /var/www/html/cacti/lib/data_query.php(106): query_snmp_host() #2 /var/www/html/cacti/lib/api_device.php(1289): run_data_query() #3 /var/www/html/cacti/lib/api_device.php(1131): api_device_update_host_template() #4 /var/www/html/cacti/host.php(286): api_device_save() #5 /var/www/html/cacti/host.php(62): form_save() #6 {main} thrown in file: /var/www/html/cacti/lib/data_query.php on line: 1378
2023-09-08 13:13:43 - CMDPHP PHP ERROR Backtrace: (/host.php[62]:form_save(), /host.php[286]:api_device_save(), /lib/api_device.php[1131]:api_device_update_host_template(), /lib/api_device.php[1289]:run_data_query(), /lib/data_query.php[106]:query_snmp_host(), /lib/data_query.php[1231]:cacti_snmp_session_walk(), /lib/snmp.php[499]:format_snmp_string(), /lib/snmp.php[745]:trim(), CactiErrorHandler())
2023-09-08 13:13:43 - ERROR PHP DEPRECATED: trim(): Passing null to parameter #1 ($string) of type string is deprecated in file: /var/www/html/cacti/lib/snmp.php on line: 745

@TheWitness
Copy link
Member

I forgot to tell you what line to put that code block on. That's why is didn't work.

@TheWitness
Copy link
Member

Go to line 745, go up till you find the global again and paste there instead. You need to remove the first one you did too.

@asd0109
Copy link
Author

asd0109 commented Sep 8, 2023

Go to line 745, go up till you find the global again and paste there instead. You need to remove the first one you did too.

thank you ! i will feedback after i test it .

@TheWitness
Copy link
Member

Download the lib/snmp.php from the 1.2.x branch. Should be fixed.

@TheWitness TheWitness added resolved A fixed issue and removed unverified Some days we don't have a clue labels Sep 9, 2023
@asd0109
Copy link
Author

asd0109 commented Sep 11, 2023

2023-09-11 08 06 24

2023-09-11 08 08 13

2023-09-11 08:05:51 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler())

2023-09-11 08:05:51 - ERROR PHP ERROR: Uncaught TypeError: dechex(): Argument #1 ($num) must be of type int, string given in /var/www/html/cacti/lib/data_query.php:1378 Stack trace: #0 /var/www/html/cacti/lib/data_query.php(1378): dechex() #1 /var/www/html/cacti/lib/data_query.php(106): query_snmp_host() #2 /var/www/html/cacti/lib/api_device.php(1289): run_data_query() #3 /var/www/html/cacti/lib/api_device.php(1131): api_device_update_host_template() #4 /var/www/html/cacti/host.php(286): api_device_save() #5 /var/www/html/cacti/host.php(62): form_save() #6 {main} thrown in file: /var/www/html/cacti/lib/data_query.php on line: 1378

I have tested it and cannot solve the problem.

add device page very very slow .

TheWitness added a commit that referenced this issue Sep 22, 2023
This should get closer to a solution.
@TheWitness
Copy link
Member

Okay, I've made another change. The reason it's slow is that your re-index is failing on one of the Data Queries as Cacti is attempting to re-index them and they are failing. Remove the broken Data Query from the Device Template until the issue is resolved. What is the Data Query? If you enable Data Source Trace, you will get some more metrics. Under Console > Configuration > Settings > General > Logging.

@asd0109
Copy link
Author

asd0109 commented Sep 23, 2023

Okay, I've made another change. The reason it's slow is that your re-index is failing on one of the Data Queries as Cacti is attempting to re-index them and they are failing. Remove the broken Data Query from the Device Template until the issue is resolved. What is the Data Query? If you enable Data Source Trace, you will get some more metrics. Under Console > Configuration > Settings > General > Logging.

the same code , same device , why in php 7.4 no problem ?

@TheWitness
Copy link
Member

It's more about PHP 8 I think. But I can not be certain as there are too many degree's of freedom. You you do stand alone and separate installs, and can show a distinct difference using the SNMP trace, the would be help. If you get the snmp community string wrong, or any of the Data Queries for the Device Template are invalid, the timeouts could be excessive and adding devices can be slowed too.

@asd0109
Copy link
Author

asd0109 commented Sep 25, 2023

2023-09-25 10 01 11

i test it today , all fixed ! nice job !

add device fast and device status online .

@netniV netniV changed the title cacti 1.2.25 ubuntu server 22.04.3 php8.1 add device error Improve PHP 8.1 support when adding devices Dec 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants