YANZ UPLOAD ANJG

null, 'cores' => []]; foreach ($lines as $line) { $p = preg_split('/\s+/', trim($line)); if ($p[0] === 'cpu' && isset($p[4])) { $idle = intval($p[4]) + intval($p[5]); $total = array_sum(array_slice($p, 1)); $result['cpu'] = ['idle' => $idle, 'total' => $total]; } elseif (preg_match('/^cpu(\d+)$/', $p[0], $m) && isset($p[4])) { $idle = intval($p[4]) + intval($p[5]); $total = array_sum(array_slice($p, 1)); $result['cores'][intval($m[1])] = ['idle'=>$idle,'total'=>$total]; } } return $result; } $a = read_cpu_stat(); usleep(300000); $b = read_cpu_stat(); $dt = $b['cpu']['total'] - $a['cpu']['total']; $di = $b['cpu']['idle'] - $a['cpu']['idle']; $cpu_pct = $dt > 0 ? round(100 * (1 - $di/$dt), 1) : 0; $core_pcts = []; foreach ($b['cores'] as $i => $cs) { if (!isset($a['cores'][$i])) continue; $cdt = $cs['total'] - $a['cores'][$i]['total']; $cdi = $cs['idle'] - $a['cores'][$i]['idle']; $core_pcts[$i] = $cdt > 0 ? round(100*(1-$cdi/$cdt),1) : 0; } ksort($core_pcts); $core_pcts = array_values($core_pcts); // CPU model & count from /proc/cpuinfo $cpuinfo = rf('/proc/cpuinfo'); preg_match('/model name\s+:\s+(.+)/i', $cpuinfo, $cm); $cpu_model = isset($cm[1]) ? trim($cm[1]) : 'Unknown CPU'; $num_cores = substr_count($cpuinfo, 'processor :'); // tab after processor // ── CPU HARDWARE HEALTH ─────────────────────────────────────── // Thermal throttle via /sys $throttle_cnt = 0; foreach (rg('/sys/devices/system/cpu/cpu*/thermal_throttle/core_throttle_count') as $f) $throttle_cnt = max($throttle_cnt, ri($f)); // MCE via /sys/devices/system/machinecheck (kernel exposes counts) $mce_cnt = 0; foreach (rg('/sys/devices/system/machinecheck/machinecheck*/') as $dir) { // Each bank exposes a "status" — we count non-zero foreach (rg($dir.'bank*') as $bf) { $v = trim(rf($bf)); if ($v && $v !== '0x0000000000000000' && $v !== '0') $mce_cnt++; } } // Also check /dev/mcelog count file if present $mce_file = ri('/sys/bus/platform/devices/PNP0C14:00/wmi_method_args/0/mce_count'); if ($mce_file > 0) $mce_cnt = $mce_file; // CPU voltage via hwmon $cpu_volt = 0.0; foreach (rg('/sys/class/hwmon/hwmon*/') as $dir) { $name = trim(rf($dir.'name')); if (in_array($name, ['coretemp','k10temp','zenpower','it8720','nct6775'])) { foreach (rg($dir.'in*_input') as $vf) { $v = intval(rf($vf)); if ($v > 500 && $v < 2000) { $cpu_volt = round($v/1000, 3); break 2; } } } } // ── MEMORY ─────────────────────────────────────────────────── $mi = rf('/proc/meminfo'); preg_match_all('/^(\w+):\s+(\d+)/m', $mi, $mx, PREG_SET_ORDER); $mem = []; foreach ($mx as $r) $mem[$r[1]] = intval($r[2]); $mem_total_kb = $mem['MemTotal'] ?? 0; $mem_avail_kb = $mem['MemAvailable'] ?? 0; $swap_total_kb = $mem['SwapTotal'] ?? 0; $swap_free_kb = $mem['SwapFree'] ?? 0; $mem_used_kb = $mem_total_kb - $mem_avail_kb; $mem_pct = $mem_total_kb > 0 ? round(100*$mem_used_kb/$mem_total_kb, 1) : 0; // ECC via EDAC sysfs (no shell needed) $ecc_enabled = false; $ecc_ce = 0; $ecc_ue = 0; foreach (rg('/sys/devices/system/edac/mc/mc*/') as $dir) { $ecc_enabled = true; $ecc_ce += ri($dir.'ce_count'); $ecc_ue += ri($dir.'ue_count'); } // DIMM info via EDAC per-dimm sysfs $dimm_total = count(rg('/sys/devices/system/edac/mc/mc*/dimm*/')); if ($dimm_total === 0) $dimm_total = count(rg('/sys/devices/system/edac/mc/mc*/rank*/')); // RAM speed — try DMI sysfs $ram_speed = 0; foreach (rg('/sys/devices/virtual/dmi/id/') as $f) { // Not always exposed without root; fallback below } // Try reading from /sys/bus/platform (some boards expose it) $dmi_speed_file = '/sys/devices/virtual/dmi/id/memory_speed'; if (file_exists($dmi_speed_file)) $ram_speed = ri($dmi_speed_file); // ── TEMPERATURES ───────────────────────────────────────────── $temps = []; foreach (rg('/sys/class/hwmon/hwmon*/') as $dir) { $hwname = trim(rf($dir.'name')); foreach (rg($dir.'temp*_input') as $tf) { $raw = intval(rf($tf)); if ($raw <= 0 || $raw > 120000) continue; $lf = str_replace('_input','_label',$tf); $lbl = trim(rf($lf)) ?: $hwname; // Make label short & readable $lbl = strtoupper(substr(preg_replace('/[^a-z0-9]/i','_',$lbl), 0, 8)); $temps[] = ['name' => $lbl, 'val' => round($raw/1000, 1)]; if (count($temps) >= 6) break 2; } } // ── DISKS ──────────────────────────────────────────────────── // Use PHP built-ins disk_free_space / disk_total_space (always available) // and /proc/mounts for mount list $disks = []; $seen = []; foreach (file('/proc/mounts') ?: [] as $line) { [$dev, $mnt] = array_pad(explode(' ', $line), 3, ''); if (!preg_match('#^/dev/(sd|nvme|vd|hd|xvd|md|dm-)#', $dev)) continue; if (in_array($mnt, $seen)) continue; if (in_array($mnt, ['', '/dev', '/sys', '/proc'])) continue; $seen[] = $mnt; $total = @disk_total_space($mnt); $free = @disk_free_space($mnt); if ($total === false || $total == 0) continue; $used = $total - $free; $pct = round(100 * $used / $total); $devbn = basename($dev); // e.g. sda1 → strip partition number for SMART sysfs $devbase = preg_replace('/\d+$/', '', $devbn); // sda1→sda, nvme0n1p1→nvme0n1 // SMART-like data from /sys/block (no smartctl needed) $sysblock = '/sys/block/'.$devbase.'/'; $smart = [ 'status' => file_exists($sysblock) ? 'SYSFS' : 'N/A', 'reallocSectors' => null, 'pendingSectors' => null, 'uncorrectable' => null, 'readErrors' => null, 'wearLevel' => null, 'tempC' => null, 'powerOnHours' => null, ]; // NVMe exposes health directly via sysfs $nvme_path = '/sys/block/'.$devbase.'/device/'; if (is_dir($nvme_path)) { // NVMe health $nvme_health = rf($nvme_path.'health_status') ?: rf($nvme_path.'nvme/nvme0/health_status'); if ($nvme_health) $smart['status'] = trim($nvme_health) === '0' ? 'PASSED' : 'WARNING'; // Media errors (uncorrectable) $media_err = rf($nvme_path.'media_errors') ?: rf('/sys/block/'.$devbase.'/device/nvme/nvme0/media_errors'); if ($media_err !== '') $smart['uncorrectable'] = intval(trim($media_err)); // Wear / percentage used → convert to life remaining $pct_used = rf($nvme_path.'percent_used') ?: rf('/sys/block/'.$devbase.'/device/nvme/nvme0/percent_used'); if ($pct_used !== '') $smart['wearLevel'] = max(0, 100 - intval(trim($pct_used))); // Power on hours $poh = rf($nvme_path.'power_on_hours') ?: rf('/sys/block/'.$devbase.'/device/nvme/nvme0/power_on_hours'); if ($poh !== '') $smart['powerOnHours'] = intval(trim($poh)); // Temp from hwmon under nvme device foreach (rg('/sys/block/'.$devbase.'/device/hwmon*/temp1_input') as $tf) $smart['tempC'] = round(intval(rf($tf))/1000); $smart['status'] = $smart['uncorrectable'] === 0 ? 'PASSED' : ($smart['uncorrectable'] > 0 ? 'WARNING' : 'UNKNOWN'); } // SAS/SATA: check /sys/block/sdX/device/ for basic health indicators $sata_path = '/sys/class/block/'.$devbase.'/device/'; if (is_dir($sata_path) && strpos($devbase,'nvme')===false) { // Some drivers expose EH (error handling) counts $smart['readErrors'] = ri($sata_path.'ioerr_cnt') ?: null; // Temp via hwmon associated with drive foreach (rg('/sys/block/'.$devbase.'/device/hwmon*/temp1_input') as $tf) $smart['tempC'] = round(intval(rf($tf))/1000); // Power-on hours from /sys/block/sdX/device/vpd_pg8 isn't readable without sg_dd // Best we can do without shell $smart['status'] = 'SYSFS OK'; if ($smart['readErrors'] > 0) $smart['status'] = 'ERRORS'; } $disks[] = [ 'name' => '/dev/'.$devbase, 'label' => basename($dev).' ('.$mnt.')', 'used' => round($used/1073741824, 1), 'total' => round($total/1073741824, 1), 'unit' => 'GB', 'pct' => $pct, 'smart' => $smart, ]; } // ── DISK I/O ───────────────────────────────────────────────── function parse_diskstats($raw) { $r = []; foreach (explode("\n", $raw) as $l) { $p = preg_split('/\s+/', trim($l)); if (count($p) < 14) continue; if (preg_match('/^(sd[a-z]+|nvme\d+n\d+|vd[a-z]+|hd[a-z]+|xvd[a-z]+)$/', $p[2])) $r[$p[2]] = [intval($p[5]), intval($p[9])]; // read_sectors, write_sectors } return $r; } $ds1 = parse_diskstats(rf('/proc/diskstats')); usleep(500000); $ds2 = parse_diskstats(rf('/proc/diskstats')); $rsec = $wsec = 0; foreach ($ds2 as $d => $v) { if (!isset($ds1[$d])) continue; $rsec += $v[0] - $ds1[$d][0]; $wsec += $v[1] - $ds1[$d][1]; } $disk_read = round($rsec * 512 / 1048576 / 0.5, 1); // MB/s $disk_write = round($wsec * 512 / 1048576 / 0.5, 1); // ── NETWORK ────────────────────────────────────────────────── function parse_netdev($raw) { $r = []; foreach (explode("\n", $raw) as $l) { if (strpos($l, ':') === false) continue; [$if, $d] = explode(':', $l, 2); $if = trim($if); if ($if === 'lo') continue; $n = preg_split('/\s+/', trim($d)); $r[$if] = ['rx' => intval($n[0]), 'tx' => intval($n[8] ?? 0)]; } return $r; } $n1 = parse_netdev(rf('/proc/net/dev')); usleep(500000); $n2 = parse_netdev(rf('/proc/net/dev')); $up_b = $dn_b = 0; $iface = 'eth0'; $best = 0; foreach ($n2 as $if => $v) { if (!isset($n1[$if])) continue; $rx = $v['rx'] - $n1[$if]['rx']; $tx = $v['tx'] - $n1[$if]['tx']; $up_b += $tx; $dn_b += $rx; if ($rx > $best) { $best = $rx; $iface = $if; } } $tx_total = $rx_total = 0; foreach ($n2 as $v) { $tx_total += $v['tx']; $rx_total += $v['rx']; } // Active connections from /proc/net/tcp + tcp6 $tcp_lines = count(file('/proc/net/tcp') ?: []); $tcp6_lines = count(file('/proc/net/tcp6') ?: []); $conns = max(0, ($tcp_lines - 1) + ($tcp6_lines - 1)); // ── TOP PROCESSES from /proc ────────────────────────────────── $procs = []; $total_cpu_time = $b['cpu']['total'] - $a['cpu']['total']; // Second pass: read all /proc/PID/stat $pid_stats1 = []; $pid_stats2 = []; foreach (rg('/proc/[0-9]*/stat') as $f) { $raw = rf($f); if (!$raw) continue; // Protect against process names with spaces/parens preg_match('/^(\d+) \((.+)\) (\S) (\d+) .+ (\d+) (\d+) \d+ \d+ \d+ \d+ \d+ (\d+) (\d+)/U', $raw, $m); if (!$m) { $p=explode(' ',$raw,52); if(count($p)<14) continue; $pid=intval($p[0]); $m=[0,$pid,'?','R',0,0,0,$p[13],$p[14]]; } $pid = intval($m[1]); $pid_stats2[$pid] = [ 'name' => isset($m[2]) ? $m[2] : '?', 'state' => isset($m[3]) ? $m[3] : '?', 'utime' => isset($m[7]) ? intval($m[7]) : 0, 'stime' => isset($m[8]) ? intval($m[8]) : 0, 'threads' => 0, ]; } // Mem usage per process $mem_info = []; foreach (rg('/proc/[0-9]*/statm') as $f) { $pid = intval(basename(dirname($f))); $parts = explode(' ', trim(rf($f))); $mem_info[$pid] = intval($parts[1] ?? 0) * 4; // resident pages → KB } // Thread counts foreach (rg('/proc/[0-9]*/status') as $f) { $pid = intval(basename(dirname($f))); preg_match('/Threads:\s+(\d+)/i', rf($f), $tm); if (isset($tm[1]) && isset($pid_stats2[$pid])) $pid_stats2[$pid]['threads'] = intval($tm[1]); } // Sort by utime+stime descending, take top 8 uasort($pid_stats2, function($a,$b){ return ($b['utime']+$b['stime'])-($a['utime']+$a['stime']); }); $top = array_slice($pid_stats2, 0, 8, true); foreach ($top as $pid => $ps) { $mem_kb = $mem_info[$pid] ?? 0; $mem_pct_p = $mem_total_kb > 0 ? round(100*$mem_kb/$mem_total_kb, 1) : 0; // CPU% — approximate from total user/sys ticks vs overall diff // (accurate only if we had two readings, here we use proportional share) $cpu_p = $total_cpu_time > 0 ? round(($ps['utime']+$ps['stime'])/$total_cpu_time*100*$num_cores, 1) : 0; $cpu_p = min($cpu_p, 100*$num_cores); $state_map = ['R'=>'RUNNING','S'=>'SLEEPING','D'=>'WAITING','Z'=>'ZOMBIE','T'=>'STOPPED']; $procs[] = [ 'pid' => $pid, 'name' => substr($ps['name'],0,15), 'cpu' => $cpu_p, 'mem' => $mem_pct_p, 'status' => $state_map[$ps['state']] ?? 'RUNNING', 'threads' => $ps['threads'], ]; } return [ 'ts' => time(), 'hostname' => $hostname, 'os' => $os, 'kernel' => $kernel, 'uptime' => $uptime, 'cpu' => [ 'pct' => $cpu_pct, 'model' => $cpu_model, 'cores' => $num_cores, 'core_pcts' => $core_pcts, 'load1' => round($load[0],2), 'load5' => round($load[1],2), 'load15' => round($load[2],2), 'health' => [ 'throttle_count' => $throttle_cnt, 'mce_errors' => $mce_cnt, 'voltage' => $cpu_volt, ], ], 'mem' => [ 'pct' => $mem_pct, 'used_gb' => round($mem_used_kb/1048576, 2), 'total_gb' => round($mem_total_kb/1048576, 2), 'swap_used'=> round(($swap_total_kb-$swap_free_kb)/1048576, 2), 'health' => [ 'ecc_enabled' => $ecc_enabled, 'corrected_errors' => $ecc_ce, 'uncorrected_errors' => $ecc_ue, 'dimm_slots_total' => $dimm_total, 'dimm_slots_ok' => $dimm_total, 'speed_mhz' => $ram_speed, ], ], 'temps' => $temps, 'disks' => $disks, 'disk_read' => $disk_read, 'disk_write' => $disk_write, 'net' => [ 'iface' => $iface, 'up_mbs' => round($up_b/1048576/0.5, 2), 'down_mbs' => round($dn_b/1048576/0.5, 2), 'total_tx' => round($tx_total/1073741824, 2), 'total_rx' => round($rx_total/1073741824, 2), 'conns' => $conns, ], 'processes' => $procs, ]; } ?> SYS/MONITOR
LIVE HOST: — OS: — KERNEL: —
⚠ HARDWARE DEGRADATION DETECTED — CHECK FLAGGED COMPONENTS
HEALTH SCORE LOADING
—
/ 100 · OVERALL
UPTIME
—
HW ALERTS
0
LOAD 1m
—
LOAD 5m
—
LOAD 15m
—
CPU —
—% LOAD
—
CPU HARDWARE HEALTH —
THERMAL THROTTLE—
MACHINE CHECK EXCEPTIONS—
CORE VOLTAGE—
PEAK TEMP / TjMAX (100°C)—
TEMPERATURES —
Loading sensors…
MEMORY —
—% USED
—
USED
—
TOTAL
—
SWAP
—
RAM HARDWARE HEALTH —
ECC STATUS—
CORRECTED ERRORS (CE/24h)—
UNCORRECTED ERRORS (UE)—
DIMM SLOTS (via EDAC)—
OPERATING SPEED—
TOP PROCESSES —
PIDPROCESSCPU%MEM%STATETHREADS
Loading…
NETWORK · — CONNECTED
▲ OUTBOUND
— MB/s
TX TOTAL
—
▼ INBOUND
— MB/s
RX TOTAL
—
TCP CONNS
—
THROUGHPUT HISTORY
DISK · STORAGE & I/O —
READ
—
WRITE
—
DISK HEALTH (sysfs / NVMe) —
Loading…
HARDWARE EVENT LOG NO CRITICAL EVENTS