Skip to content
Snippets Groups Projects
Commit 13d8bc86 authored by Thibault Debatty's avatar Thibault Debatty
Browse files

fix cpu vcores parsing

parent 8028b37c
No related branches found
No related tags found
No related merge requests found
Pipeline #19842 failed
......@@ -27,7 +27,7 @@ test:php74:
- cp env.test .env
- php artisan migrate
script:
- vendor/bin/phpunit --coverage-text --colors=never
- vendor/bin/phpunit --coverage-text --colors=never --testdox
- vendor/bin/phpcs
- vendor/bin/phpstan analyze --memory-limit=512M
- vendor/bin/unused_scanner unused-scanner.php
......@@ -98,4 +98,4 @@ deploy:
# docker login and restart services
- ssh monitoring@$SERVER "cd /home/monitoring;
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY;
docker compose up -d --scale queue=4"
\ No newline at end of file
docker compose up -d --scale queue=4"
......@@ -24,7 +24,7 @@ class ServerInfoFreeBSDCPU extends ServerInfoParser
preg_match_all($REGEX, $string, $matches);
foreach ($matches[1] as $match) {
$count += $match[0];
$count += $match;
}
// if regex does not match, or dmi info is empty...
......
......@@ -34,7 +34,7 @@ class ServerinfoTest extends TestCase
* @group cpu
* @group freebsd-cpu
*/
public function testThreadsFreeBSD()
public function testThreadsFreebsd()
{
$string = file_get_contents(__DIR__ . "/freebsd-dmi-cpu");
$sensor = new ServerInfoFreeBSDCPU();
......@@ -42,4 +42,18 @@ class ServerinfoTest extends TestCase
$sensor->analyzeString($string, $info);
$this->assertEquals(4, $info->vCores());
}
/**
* Test CPU cores extraction for a system with multiple processors and many threads
*
* @group cpu
*/
public function testThreadsMulti()
{
$string = file_get_contents(__DIR__ . "/dmi-cpu");
$sensor = new ServerInfoFreeBSDCPU();
$info = new ServerInfo();
$sensor->analyzeString($string, $info);
$this->assertEquals(64, $info->vCores());
}
}
# dmidecode 3.6
# SMBIOS entry point at 0x75cc4000
Found SMBIOS entry point in EFI, reading table from /dev/mem.
SMBIOS 3.5 present.
Handle 0x004A, DMI type 4, 48 bytes
Processor Information
Socket Designation: U3E1
Type: Central Processor
Family: Other
Manufacturer: Intel(R) Corporation
ID: E0 06 0B 00 FF FB EB BF
Version: Intel(R) N100
Voltage: 1.0 V
External Clock: 100 MHz
Max Speed: 3400 MHz
Current Speed: 2871 MHz
Status: Populated, Enabled
Upgrade: Other
L1 Cache Handle: 0x0047
L2 Cache Handle: 0x0048
L3 Cache Handle: 0x0049
Serial Number: To Be Filled By O.E.M.
Asset Tag: To Be Filled By O.E.M.
Part Number: To Be Filled By O.E.M.
Core Count: 16
Core Enabled: 16
Thread Count: 32
Characteristics:
64-bit capable
Multi-Core
Execute Protection
Enhanced Virtualization
Power/Performance Control
Handle 0x004A, DMI type 4, 48 bytes
Processor Information
Socket Designation: U3E1
Type: Central Processor
Family: Other
Manufacturer: Intel(R) Corporation
ID: E0 06 0B 00 FF FB EB BF
Version: Intel(R) N100
Voltage: 1.0 V
External Clock: 100 MHz
Max Speed: 3400 MHz
Current Speed: 2871 MHz
Status: Populated, Enabled
Upgrade: Other
L1 Cache Handle: 0x0047
L2 Cache Handle: 0x0048
L3 Cache Handle: 0x0049
Serial Number: To Be Filled By O.E.M.
Asset Tag: To Be Filled By O.E.M.
Part Number: To Be Filled By O.E.M.
Core Count: 16
Core Enabled: 16
Thread Count: 32
Characteristics:
64-bit capable
Multi-Core
Execute Protection
Enhanced Virtualization
Power/Performance Control
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment