Add docker actions, arr profile enforcer, monitor caching, and web file symlink
Web files now served via symlink to the git repo so git pull changes survive reboots without rebuilding the txz. Also includes: docker pull/rebuild/restart with live log streaming, arr_profile_enforcer for Sonarr/Radarr quality profiles, monitor page cache fix (background writer now in cron), and ARR_KIDS/SONARR/RADARR profile name vars in master.conf.
This commit is contained in:
@@ -19,15 +19,14 @@ function vv_system_info(): array {
|
||||
$os = $api['info']['os'] ?? [];
|
||||
$cpu = $api['info']['cpu'] ?? [];
|
||||
|
||||
// uptime is a String in this schema — try numeric (seconds) first, else display as-is
|
||||
// uptime is a String in this schema — try numeric (seconds) first, else fall back to /proc/uptime
|
||||
$uptimeRaw = $os['uptime'] ?? '';
|
||||
if (is_numeric($uptimeRaw)) {
|
||||
$uptimeSec = (int)$uptimeRaw;
|
||||
$uptime = vv_format_uptime($uptimeSec);
|
||||
} else {
|
||||
$uptimeSec = 0;
|
||||
$uptime = $uptimeRaw ?: '—';
|
||||
$uptimeSec = (int)explode(' ', @file_get_contents('/proc/uptime') ?: '0')[0];
|
||||
}
|
||||
$uptime = vv_format_uptime($uptimeSec);
|
||||
|
||||
$load = sys_getloadavg();
|
||||
return [
|
||||
|
||||
@@ -233,6 +233,11 @@ function vv_watchdog_summary(): array {
|
||||
|
||||
$zombies = (int)trim(shell_exec("ps -eo stat 2>/dev/null | grep -c '^Z'") ?: '0');
|
||||
|
||||
$fileNr = explode("\t", trim(@file_get_contents('/proc/sys/fs/file-nr') ?: '0 0 1'));
|
||||
$fdOpen = max(0, (int)($fileNr[0] ?? 0) - (int)($fileNr[1] ?? 0));
|
||||
$fdMax = max(1, (int)($fileNr[2] ?? 1));
|
||||
$fdPct = round($fdOpen / $fdMax * 100, 1);
|
||||
|
||||
$nic = trim(shell_exec("ip route show default 2>/dev/null | awk 'NR==1{print \$5}'") ?: 'eth0') ?: 'eth0';
|
||||
$nicState = trim(@file_get_contents("/sys/class/net/$nic/operstate") ?: 'unknown');
|
||||
$sshdOk = (int)trim(shell_exec('pgrep -c sshd 2>/dev/null') ?: '0') > 0;
|
||||
@@ -260,6 +265,9 @@ function vv_watchdog_summary(): array {
|
||||
'load_1min' => $load1,
|
||||
'cpu_temp' => $cpuTemp,
|
||||
'zombies' => $zombies,
|
||||
'fd_open' => $fdOpen,
|
||||
'fd_max' => $fdMax,
|
||||
'fd_pct' => $fdPct,
|
||||
'nic' => $nic,
|
||||
'nic_state' => $nicState,
|
||||
'sshd_ok' => $sshdOk,
|
||||
@@ -330,6 +338,7 @@ function vv_rsync_status(): array {
|
||||
'daily' => ($vars['DAILY_RSYNC_ENABLED'] ?? 'false') !== 'false',
|
||||
'intermediate' => ($vars['INTERMEDIATE_RSYNC_ENABLED'] ?? 'true') !== 'false',
|
||||
'weekly' => ($vars['WEEKLY_RSYNC_ENABLED'] ?? 'false') !== 'false',
|
||||
'monthly' => ($vars['MONTHLY_RSYNC_ENABLED'] ?? 'true') !== 'false',
|
||||
];
|
||||
|
||||
// Active rsync profiles — from lock files
|
||||
@@ -353,10 +362,11 @@ function vv_rsync_status(): array {
|
||||
'daily' => 'daily_sync_maintenance',
|
||||
'intermediate' => 'intermediate_sync_maintenance',
|
||||
'weekly' => 'weekly_sync_maintenance',
|
||||
'monthly' => 'monthly_maintenance',
|
||||
];
|
||||
$lastSync = [];
|
||||
foreach ($scriptMap as $key => $scriptName) {
|
||||
$logFile = LOG_DIR . "/$scriptName.json";
|
||||
$logFile = LOG_DIR . "/Orchestrators/$scriptName.json";
|
||||
if (!file_exists($logFile)) continue;
|
||||
$stat = json_decode(@file_get_contents($logFile) ?: '{}', true) ?: [];
|
||||
$lastSync[$key] = [
|
||||
@@ -376,7 +386,7 @@ function vv_rsync_status(): array {
|
||||
$p = explode('|', $line);
|
||||
if (count($p) < 4 || ($p[0] ?? '') < $cutoff7) continue;
|
||||
$name = $p[2] ?? '';
|
||||
if (!$name) continue;
|
||||
if (!$name || str_ends_with($name, '-fallback')) continue;
|
||||
if (!isset($profiles[$name])) $profiles[$name] = ['runs' => 0, 'dur' => 0, 'bytes' => 0];
|
||||
$profiles[$name]['runs']++;
|
||||
$profiles[$name]['dur'] += (int)($p[3] ?? 0);
|
||||
|
||||
@@ -121,6 +121,17 @@ function vv_cron_rebuild(array $schedule): bool {
|
||||
}
|
||||
$lines[] = "";
|
||||
|
||||
// Background writers — always injected, never user-configurable (excluded from scheduler UI).
|
||||
$toolsDir = SCRIPTS_DIR . '/Plugin/unraid/Tools';
|
||||
foreach ([
|
||||
['* * * * *', 'api_cache_writer.sh'],
|
||||
['0 */2 * * *', 'remote_arr_cache_writer.sh'],
|
||||
] as [$cron, $script]) {
|
||||
$path = "$toolsDir/$script";
|
||||
if (file_exists($path)) $lines[] = "$cron bash \"$runner\" \"Plugin/unraid/Tools/$script\" \"$path\"";
|
||||
}
|
||||
$lines[] = "";
|
||||
|
||||
// Write to the plugin cron file; update_cron merges all plugin *.cron files into /etc/cron.d/root.
|
||||
if (file_put_contents(CRON_FILE, implode("\n", $lines)) === false) return false;
|
||||
exec('/usr/local/sbin/update_cron');
|
||||
@@ -483,7 +494,7 @@ function vv_conf_script_map(): array {
|
||||
// Read a boolean flag value (e.g. INTERMEDIATE_RSYNC_ENABLED) from master.conf.
|
||||
function vv_conf_flag_value(string $name): bool {
|
||||
$conf = file_get_contents(CONF_DIR . '/master.conf') ?: '';
|
||||
if (preg_match('/^\s*' . preg_quote($name, '/') . '\s*=\s*(true|false)\s*$/m', $conf, $m)) {
|
||||
if (preg_match('/^\s*' . preg_quote($name, '/') . '\s*=\s*(true|false)\s*(?:#.*)?$/m', $conf, $m)) {
|
||||
return $m[1] === 'true';
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user