FreePBX Version
FreePBX 17
Issue Description
The FreePBX Dashboard statistics widget fails in an LXC container because the bundled phpsysinfo code attempts to divide a non-
numeric cpufreq value by 1000.
This breaks the dashboard scheduler job and prevents fresh statistics from being collected.
Reproduction:
fwconsole job --run=9 -vvv
Actual result:
TypeError: Unsupported operand types: string / int in file /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/
class.Linux.inc.php on line 323
Relevant stack trace:
- TypeError->() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.Linux.inc.php:323
- Linux->_cpuinfo() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.Linux.inc.php:953
- Linux->build() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.OS.inc.php:81
- OS->getSys() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/xml/class.XML.inc.php:514
- XML->_buildXml() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/xml/class.XML.inc.php:535
- XML->getXml() /var/www/html/admin/modules/dashboard/classes/SysInfo.class.php:52
- SysInfo->getSysInfo() /var/www/html/admin/modules/dashboard/Dashboard.class.php:227
- Dashboard->genSysInfo() /var/www/html/admin/modules/dashboard/Dashboard.class.php:261
- Dashboard->getSysInfo() /var/www/html/admin/modules/dashboard/Dashboard.class.php:209
- Dashboard->runTrigger() /var/www/html/admin/modules/dashboard/Job.php:18
Suspected cause:
In:
/var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.Linux.inc.php
around line 323:
$dev->setCpuSpeed($buf / 1000);
The value read from:
/sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq
or:
/sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
can be non-numeric in LXC/containerized environments. PHP 8 raises a TypeError when dividing a string by an integer.
Expected result:
Dashboard statistics collection should not crash if cpufreq data is missing or non-numeric. The value should be checked with
is_numeric() before division, or skipped when invalid.
Suggested fix:
Guard cpufreq values before division, for example:
if (is_numeric(trim($buf))) {
$dev->setCpuSpeed(((float) trim($buf)) / 1000);
}
Same for cpuinfo_max_freq and cpuinfo_min_freq.
Operating Environment
FreePBX: 17
Dashboard module: 17.0.5
Framework module: 17.0.28
Asterisk: 22.8.2
PHP: 8.2.31
OS: Debian 12
Environment: LXC container
Architecture: x86_64
Relevant log output
FreePBX Version
FreePBX 17
Issue Description
The FreePBX Dashboard statistics widget fails in an LXC container because the bundled phpsysinfo code attempts to divide a non-
numeric cpufreq value by 1000.
This breaks the dashboard scheduler job and prevents fresh statistics from being collected.
Reproduction:
fwconsole job --run=9 -vvv
Actual result:
TypeError: Unsupported operand types: string / int in file /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/
class.Linux.inc.php on line 323
Relevant stack trace:
Suspected cause:
In:
/var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.Linux.inc.php
around line 323:
$dev->setCpuSpeed($buf / 1000);
The value read from:
/sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq
or:
/sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
can be non-numeric in LXC/containerized environments. PHP 8 raises a TypeError when dividing a string by an integer.
Expected result:
Dashboard statistics collection should not crash if cpufreq data is missing or non-numeric. The value should be checked with
is_numeric() before division, or skipped when invalid.
Suggested fix:
Guard cpufreq values before division, for example:
if (is_numeric(trim($buf))) {
$dev->setCpuSpeed(((float) trim($buf)) / 1000);
}
Same for cpuinfo_max_freq and cpuinfo_min_freq.
Operating Environment
FreePBX: 17
Dashboard module: 17.0.5
Framework module: 17.0.28
Asterisk: 22.8.2
PHP: 8.2.31
OS: Debian 12
Environment: LXC container
Architecture: x86_64
Relevant log output