Skip to content

Commit 4ef4285

Browse files
authored
Merge pull request #15 from LucidityCrash/multi_cpu
multi-cpu try 1
2 parents b2c8ba9 + 4d22ba7 commit 4ef4285

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ipmi-server/rootfs/app/src/Controller/IpmiController.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,13 @@ private function extractFromSensorCommand(array $cmd, string $interface, array &
397397
return $ret !== false;
398398
}
399399

400+
private function preg_array_key_exists($pattern, $array): array
401+
{
402+
$keys = array_keys($array);
403+
return preg_grep($pattern,$keys);
404+
}
405+
406+
400407
private function extractFromSdrCommand(array $cmd, string $interface, array &$sensorData, array &$states): bool
401408
{
402409
$ret = $this->runCommand(array_merge($cmd, ['-I', $interface, 'sdr', 'list', 'full']), true);
@@ -417,6 +424,14 @@ private function extractFromSdrCommand(array $cmd, string $interface, array &$se
417424
foreach($this->unitsOfMeasure as $uom => $type) {
418425
if (str_contains($value, $uom)) {
419426
$value = trim(str_replace($uom, '', $value));
427+
428+
$id_pattern = "/^".$id."/";
429+
$id_count = count($this->preg_array_key_exists($id_pattern, $sensorData[$type]));
430+
if ($id_count > 0) {
431+
$description .= ' ' . $id_count+1;
432+
$id = $this->generateId($description);
433+
}
434+
420435
$sensorData[$type][$id] = $description;
421436
$states[$id] = $value;
422437
}
@@ -521,4 +536,4 @@ private function getSensorsByType(Request $request, string $type, string $unit):
521536
}
522537

523538

524-
}
539+
}

0 commit comments

Comments
 (0)