Skip to content

[bug]: Dashboard statistics widget crashes in LXC on FreePBX 17 / PHP 8.2 due to non-numeric cpufreq value #1038

@Vadim73755

Description

@Vadim73755

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:

  1. TypeError->() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.Linux.inc.php:323
  2. Linux->_cpuinfo() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.Linux.inc.php:953
  3. Linux->build() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/os/class.OS.inc.php:81
  4. OS->getSys() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/xml/class.XML.inc.php:514
  5. XML->_buildXml() /var/www/html/admin/modules/dashboard/classes/phpsysinfo/includes/xml/class.XML.inc.php:535
  6. XML->getXml() /var/www/html/admin/modules/dashboard/classes/SysInfo.class.php:52
  7. SysInfo->getSysInfo() /var/www/html/admin/modules/dashboard/Dashboard.class.php:227
  8. Dashboard->genSysInfo() /var/www/html/admin/modules/dashboard/Dashboard.class.php:261
  9. Dashboard->getSysInfo() /var/www/html/admin/modules/dashboard/Dashboard.class.php:209
  10. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageTriage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions