update diagnostics

- make use of "publish" function
- force bash commands to run with UTF8 encoding
This commit is contained in:
bergware
2025-04-24 12:07:34 +02:00
parent ebbc6b9a23
commit b4542d9d2a

View File

@@ -26,7 +26,7 @@ $cli = empty($zip);
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/webGui/include/publish.php";
if (is_file('/boot/syslinux/syslinux.cfg')) {
$bootenv = '/boot/syslinux';
@@ -45,18 +45,7 @@ $pools = pools_filter($disks);
require_once "$docroot/webGui/include/CustomMerge.php";
function write(...$messages){
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/diagnostics?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
}
curl_close($com);
foreach ($messages as $message) publish('diagnostics', $message);
}
function run($cmd, &$save=null, $timeout=30) {
@@ -64,7 +53,7 @@ function run($cmd, &$save=null, $timeout=30) {
// output command for display
write($cmd);
// execute command with timeout of 30s
exec("timeout -s9 $timeout $cmd", $save);
exec("LC_ALL=en_US.UTF-8 timeout -s9 $timeout $cmd", $save);
return implode("\n",$save);
}
@@ -470,7 +459,7 @@ foreach ($ports as $port) {
file_put_contents("/$diag/system/ethtool.txt", "--------------------------------\r\n", FILE_APPEND);
}
run("ip -br a|todos >".escapeshellarg("/$diag/system/ifconfig.txt"));
if (!$all) maskIP("/$diag/system/ifconfig.txt");
maskIP("/$diag/system/ifconfig.txt");
// create system information (suppress errors)
run("find /sys/kernel/iommu_groups/ -type l 2>/dev/null|sort -V|todos >".escapeshellarg("/$diag/system/iommu_groups.txt"));