diff --git a/Plugin/unraid/include/common.php b/Plugin/unraid/include/common.php index 1caf7a0..8984535 100644 --- a/Plugin/unraid/include/common.php +++ b/Plugin/unraid/include/common.php @@ -748,9 +748,23 @@ function vv_transcode_sessions(): array { $flipCount = (int)($raw['flip_count_hour'] ?? 0); $isRamdisk = str_contains($target, 'ramdisk'); - // Count active session dirs in both known locations + // Count active sessions: subdirs (legacy transcode) + unique hex prefixes (Live TV / Direct Stream HLS) $ramdiskPath = '/mnt/ramdisk_transcodes/transcoding-temp'; $ramSessions = count(glob("$ramdiskPath/*/", GLOB_ONLYDIR) ?: []); + $maxAge = (int)(vv_conf_vars()['TRANSCODE_MAX_AGE'] ?? 20); + $activeFiles = 0; + $cutoff = time() - $maxAge * 60; + $flatPrefixes = []; + if (is_dir($ramdiskPath)) { + foreach (new DirectoryIterator($ramdiskPath) as $f) { + if (!$f->isFile()) continue; + if (preg_match('/^([0-9a-f]{16,})/', $f->getFilename(), $m)) { + $flatPrefixes[$m[1]] = true; + } + if ($f->getMTime() >= $cutoff) $activeFiles++; + } + } + $ramSessions += count($flatPrefixes); // SSD path: first transcoding-temp mount that is not a RAM filesystem (tmpfs/ramfs) $ssdPath = ''; @@ -800,6 +814,7 @@ function vv_transcode_sessions(): array { 'last_flip_ago' => $lastFlip > 0 ? time() - $lastFlip : null, 'ram_sessions' => $ramSessions, 'ssd_sessions' => $ssdSessions, + 'active_files' => $activeFiles, 'ramdisk' => $rd, 'ssd' => $ssd, 'last_rd_freed' => $lastRdFreed, diff --git a/Plugin/unraid/pages/monitor.php b/Plugin/unraid/pages/monitor.php index 47ba3ad..91110d1 100644 --- a/Plugin/unraid/pages/monitor.php +++ b/Plugin/unraid/pages/monitor.php @@ -1518,6 +1518,15 @@ function vvPollMonitor() { // Active sessions from shared streams data const activeSessions = vvLastSessions.filter(s => s.is_tc); const typeLabel = t => ({ LiveTvProgram:'Live TV', Movie:'Movie', Episode:'TV', Audio:'Music' }[t] ?? t); + const activeFiles = tc.active_files ?? 0; + + let activeSegHtml = ''; + if (activeFiles > 0) { + activeSegHtml = `
+ Active segments + ${activeFiles}Live TV / Direct Stream +
`; + } let sessHtml = ''; if (activeSessions.length) { @@ -1576,7 +1585,7 @@ function vvPollMonitor() {
- ${sessHtml}`; + ${activeSegHtml}${sessHtml}`; } // ── Containers and VMs ──────────────────────────────────────────────────