wp-server-stats icon indicating copy to clipboard operation
wp-server-stats copied to clipboard

fix `arithmetic expression: division by zero`

Open takano32 opened this issue 11 months ago • 7 comments

Count cpu cores with getconf _NPROCESSORS_ONLN

takano32 avatar Mar 03 '24 21:03 takano32

Have you tested these changes on a general shared server? Cause a lot of things are not allowed in shared servers. Also what problem is it solving? According to this: https://stackoverflow.com/a/23569003/2308992 it might not work globally across all servers (considering many different hosts are using many different Linux OS and configs).

isaumya avatar Mar 04 '24 10:03 isaumya

Amazon ECS or Google CloudRun containers has no grep cores /proc/cpuinfo lines.

Sorry for might not work globally.

takano32 avatar Mar 05 '24 12:03 takano32

This is my /proc/cpuinfo

root@ip-10-0-102-138:/var/www/html# cat /proc/cpuinfo
processor	: 0
BogoMIPS	: 243.75
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x3
CPU part	: 0xd0c
CPU revision	: 1

processor	: 1
BogoMIPS	: 243.75
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x3
CPU part	: 0xd0c
CPU revision	: 1

root@ip-10-0-102-138:/var/www/html#

This is ECS container deployed with Fargate.

https://github.com/takano32/wordpress-on-aws

They have no cores line.

takano32 avatar Mar 07 '24 13:03 takano32

Using cat /proc/cpuinfo | grep '^processor' | wc -l is better way ?

takano32 avatar Mar 07 '24 13:03 takano32

I'm adding commit using cat /proc/cpuinfo | grep '^processor' | wc -l, But I can't make sense of grep -o '[0-9]' | uniq, sorry.

takano32 avatar Mar 07 '24 14:03 takano32

I need to test this on shared servers and see how they work. Will let you know when I test it. Will let you know.

isaumya avatar Mar 07 '24 14:03 isaumya

I got it. I would be waiting forward your test result.

Thank you.

takano32 avatar Mar 07 '24 14:03 takano32