diff --git a/README.md b/README.md index bd9aa37..16f10f4 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ Ollama · Open WebUI · ComfyUI를 한 곳에서 설치하고 운영하는 관 | `jj_ollama_manager.ps1` | Windows 11 (PowerShell 5.1) — 설정 + `src/platform/windows/*.ps1` 불러오기 + 시작 | | `RUN.cmd` | Windows 실행용 (실행 정책과 상관없이 더블클릭으로 실행) | | `jj_ollama_manager.sh` | macOS (Intel Mac, 기본 bash 3.2) — 설정 + `src/platform/mac/*.sh` 불러오기 + 시작 | -| `src/platform/windows/` | Windows 기능 소스 16개 (파일당 약 300~400줄, 번호 순서대로 불러옴) | -| `src/platform/mac/` | Mac 기능 소스 16개 (파일당 약 300~400줄, 번호 순서대로 불러옴) | +| `src/platform/windows/` | Windows 기능 소스 17개 (파일당 약 300~400줄, 번호 순서대로 불러옴) | +| `src/platform/mac/` | Mac 기능 소스 17개 (파일당 약 300~400줄, 번호 순서대로 불러옴) | > 실행 파일 하나만 복사하면 동작하지 않습니다. `src/` 폴더까지 저장소 전체를 받아 주세요 (`git pull`). diff --git a/jj_ollama_manager.ps1 b/jj_ollama_manager.ps1 index 5a04a9c..7afb21c 100644 --- a/jj_ollama_manager.ps1 +++ b/jj_ollama_manager.ps1 @@ -229,7 +229,8 @@ foreach ($__src in @( '13_comfy_stack_storage.ps1', '14_storage_quickopen.ps1', '15_webui_image_sync.ps1', - '16_factory_reset.ps1' + '16_factory_reset.ps1', + '17_podman_monitor.ps1' )) { $__path = Join-Path $SrcDir $__src if (-not (Test-Path -LiteralPath $__path)) { diff --git a/jj_ollama_manager.sh b/jj_ollama_manager.sh index 1293b97..49cb54c 100755 --- a/jj_ollama_manager.sh +++ b/jj_ollama_manager.sh @@ -191,7 +191,8 @@ for __src in \ 13_storage_paths.sh \ 14_setup.sh \ 15_continue.sh \ - 16_factory_reset.sh; do + 16_factory_reset.sh \ + 17_podman_monitor.sh; do if [ ! -f "$SRC_DIR/$__src" ]; then echo "${RED}❌ 소스 파일이 없습니다: $SRC_DIR/$__src (저장소를 다시 받아 주세요: git pull)${RESET}" >&2 exit 1 diff --git a/src/platform/mac/03_monitor_preview.sh b/src/platform/mac/03_monitor_preview.sh index 64cd6e9..51a0eb2 100644 --- a/src/platform/mac/03_monitor_preview.sh +++ b/src/platform/mac/03_monitor_preview.sh @@ -168,6 +168,8 @@ list_active_clients() { # 모니터링 출력: monitor_print [full] monitor_print() { local full="$1" ver up ctx line + # Podman 가상 머신 (맨 위, 17_podman_monitor.sh) + podman_monitor_print # 서버 if is_server_running; then server_info diff --git a/src/platform/mac/09_webui_menu_comfy.sh b/src/platform/mac/09_webui_menu_comfy.sh index a989e17..3dc93a0 100644 --- a/src/platform/mac/09_webui_menu_comfy.sh +++ b/src/platform/mac/09_webui_menu_comfy.sh @@ -30,7 +30,7 @@ webui_monitor_print() { *) echo -e "${BOLD}WebUI${RESET} ${RED}● 중지됨${RESET} ${GRAY}${WU_STATUS:-$WU_STATE}${RESET}" ;; esac - echo -e " Podman v${pver} · 가상 머신 ${MC_NAME} 실행 중 (CPU ${MC_CPUS} · 메모리 ${MC_MEM}) · 데이터 ${dsize:-0} (${WEBUI_DIR})" + echo -e " 데이터 ${dsize:-0} (${WEBUI_DIR}) ${GRAY}(Podman·가상 머신 정보는 맨 위 Podman 줄)${RESET}" if [ "$full" = "full" ] && [ "$WU_STATE" = "running" ]; then local stats cpu mem net blk pids code stats=$(podman stats --no-stream --format '{{.CPUPerc}}|{{.MemUsage}}|{{.NetIO}}|{{.BlockIO}}|{{.PIDs}}' "$WEBUI_NAME" 2>/dev/null | head -n 1) diff --git a/src/platform/mac/17_podman_monitor.sh b/src/platform/mac/17_podman_monitor.sh new file mode 100644 index 0000000..0792d5e --- /dev/null +++ b/src/platform/mac/17_podman_monitor.sh @@ -0,0 +1,66 @@ +# JJ Ollama Manager (Mac) — src/platform/mac/17_podman_monitor.sh : 상태 화면 맨 위 Podman 줄 +# jj_ollama_manager.sh 가 순서대로 불러옵니다 (직접 실행하지 않음). 2026-11-05 추가 +# +# 매번 새로 읽음 (메뉴를 그릴 때마다). 명령 5개를 동시에 돌려 약 0.6초 (Podman 5.8.5에서 하나씩 0.2~0.6초 확인) +# podman info → 가상 머신 메모리 전체·여유 +# podman stats → 컨테이너 현재 CPU·메모리 (합계) +# podman system df → 이미지·컨테이너·볼륨 크기 (합계) +# podman ps -a → 실행 중 / 전체 컨테이너 수 +# podman machine list → 가상 머신 디스크 크기 + +# "666.4MB" "8.308GB" "0B" "1.2GiB" → GB 숫자 +pm_to_gb() { + awk -v s="$1" 'BEGIN { + n = s + 0; u = s; sub(/^[0-9.]+ */, "", u); u = toupper(u) + f = 1e-9 + if (u ~ /^KIB/) f = 1024 / 1e9; else if (u ~ /^KB/) f = 1e-6 + else if (u ~ /^MIB/) f = 1048576 / 1e9; else if (u ~ /^MB/) f = 1e-3 + else if (u ~ /^GIB/) f = 1073741824 / 1e9; else if (u ~ /^GB/) f = 1 + else if (u ~ /^TIB/) f = 1099511627776 / 1e9; else if (u ~ /^TB/) f = 1000 + printf "%.3f", n * f }' +} + +podman_monitor_print() { + if ! has_podman; then + echo -e "${BOLD}Podman${RESET} ${GRAY}미설치 ('Open WebUI (Podman)' 메뉴에서 기동하면 설치합니다)${RESET}" + return + fi + local ver + ver=$(podman --version 2>/dev/null | awk '{print $NF}') + machine_info + case "$MC_STATE" in + none) echo -e "${BOLD}Podman${RESET} ${GRAY}● 가상 머신 없음 v${ver} (WebUI를 기동하면 만듭니다)${RESET}"; return ;; + stopped) echo -e "${BOLD}Podman${RESET} ${RED}● 가상 머신 중지됨${RESET} v${ver} · ${MC_NAME} (CPU ${MC_CPUS} · 메모리 ${MC_MEM})"; return ;; + starting) echo -e "${BOLD}Podman${RESET} ${YELLOW}● 가상 머신 켜는 중${RESET} v${ver} · ${MC_NAME}"; return ;; + esac + + local t p1 p2 p3 p4 p5 + t=$(mktemp -d "${TMPDIR:-/tmp}/jjpm.XXXXXX") || return + podman info --format '{{.Host.MemTotal}}|{{.Host.MemFree}}' > "$t/i" 2>/dev/null & p1=$! + podman stats --no-stream --format '{{.CPUPerc}}|{{.MemUsage}}' > "$t/s" 2>/dev/null & p2=$! + podman system df --format '{{.Size}}' > "$t/d" 2>/dev/null & p3=$! + podman ps -a --format '{{.State}}' > "$t/p" 2>/dev/null & p4=$! + podman machine list --format '{{.Name}}|{{.DiskSize}}' > "$t/m" 2>/dev/null & p5=$! + wait $p1 $p2 $p3 $p4 $p5 2>/dev/null + + local mt mf cpu cmem dsk run all msize line u + IFS='|' read -r mt mf < "$t/i" + cpu=$(awk -F'|' '{ v = $1; gsub(/%/, "", v); s += v } END { printf "%.1f", s }' "$t/s") + cmem=0 + while IFS='|' read -r _ u; do + [ -z "$u" ] && continue + cmem=$(awk -v a="$cmem" -v b="$(pm_to_gb "${u%% /*}")" 'BEGIN { printf "%.3f", a + b }') + done < "$t/s" + dsk=0 + while read -r u; do + [ -z "$u" ] && continue + dsk=$(awk -v a="$dsk" -v b="$(pm_to_gb "$u")" 'BEGIN { printf "%.3f", a + b }') + done < "$t/d" + run=$(grep -c '^running' "$t/p"); all=$(grep -c . "$t/p") + msize=$(awk -F'|' -v n="$MC_NAME" '{ x = $1; sub(/\*$/, "", x) } x == n { print $2; exit }' "$t/m") + rm -rf "$t" + + echo -e "${BOLD}Podman${RESET} ${GREEN}● 실행 중${RESET} v${ver} · ${MC_NAME} (CPU ${MC_CPUS} · 메모리 ${MC_MEM} · 디스크 ${msize:-?}) · 컨테이너 실행 ${run}/${all}" + line=$(awk -v t="$mt" -v f="$mf" 'BEGIN { if (t > 0) printf "%.1f/%.1fGB (%d%%)", (t - f) / 1e9, t / 1e9, (t - f) * 100 / t; else printf "?" }') + echo -e " CPU ${cpu}% ${GRAY}(컨테이너 합계)${RESET} · 메모리 컨테이너 $(awk -v c="$cmem" 'BEGIN { printf "%.1f", c }')GB · 가상 머신 사용 ${line} ${GRAY}(캐시 포함)${RESET} · 디스크 사용 $(awk -v d="$dsk" 'BEGIN { printf "%.1f", d }')GB" +} diff --git a/src/platform/windows/04_server.ps1 b/src/platform/windows/04_server.ps1 index 3d67235..16683da 100644 --- a/src/platform/windows/04_server.ps1 +++ b/src/platform/windows/04_server.ps1 @@ -106,6 +106,9 @@ function Get-StatusBlock { function Get-MonitorText([switch]$Full) { $L = New-Object System.Collections.Generic.List[string] + # Podman 가상 머신 (맨 위, 17_podman_monitor.ps1) + foreach ($pl in @(Get-PodmanMonitorLines)) { $L.Add($pl) } + # 서버 if (Test-Server) { $si = Get-ServerInfo diff --git a/src/platform/windows/09_webui.ps1 b/src/platform/windows/09_webui.ps1 index e4ea24f..115af61 100644 --- a/src/platform/windows/09_webui.ps1 +++ b/src/platform/windows/09_webui.ps1 @@ -369,7 +369,7 @@ function Get-WebuiMonitorLines([switch]$Full) { $L.Add("${BOLD}WebUI${RESET} ${RED}● 중지됨${RESET} ${GRAY}$s${RESET}") } } - $L.Add(" Podman v$pver · 가상 머신 $($mi.Name) 실행 중 (CPU $($mi.Cpus) · 메모리 $($mi.Mem))$dsize ($WebuiDir)") + $L.Add(" $dsize ($WebuiDir) ${GRAY}(Podman·가상 머신 정보는 맨 위 Podman 줄)${RESET}") if ($Full -and $wi.State -eq 'running') { $stats = "$(& $script:PodmanExe stats --no-stream --format '{{.CPUPerc}}|{{.MemUsage}}|{{.NetIO}}|{{.BlockIO}}|{{.PIDs}}' $WebuiName 2>$null | Select-Object -First 1)" if ($stats.Trim()) { diff --git a/src/platform/windows/17_podman_monitor.ps1 b/src/platform/windows/17_podman_monitor.ps1 new file mode 100644 index 0000000..5f01968 --- /dev/null +++ b/src/platform/windows/17_podman_monitor.ps1 @@ -0,0 +1,88 @@ +# JJ Ollama Manager (Windows) — src/platform/windows/17_podman_monitor.ps1 : 상태 화면 맨 위 Podman 줄 +# jj_ollama_manager.ps1 가 순서대로 불러옵니다 (직접 실행하지 않음). 2026-11-05 추가 +# +# 매번 새로 읽음 (메뉴를 그릴 때마다). podman 명령 4개를 동시에 실행 +# podman info → 가상 머신 메모리 전체·여유 +# podman stats → 컨테이너 현재 CPU·메모리 (합계) +# podman system df → 이미지·컨테이너·볼륨 크기 (합계) +# podman ps -a → 실행 중 / 전체 컨테이너 수 +# (가상 머신 이름·CPU·메모리·디스크 크기는 podman machine list) + +# "666.4MB" "8.308GB" "0B" "1.2GiB" → GB 숫자 +function ConvertTo-PmGB([string]$Text) { + if ("$Text".Trim() -notmatch '^([0-9.]+)\s*([A-Za-z]*)') { return 0.0 } + $n = [double]::Parse($Matches[1], [Globalization.CultureInfo]::InvariantCulture) + $u = $Matches[2].ToUpper() + $f = 1e-9 + switch -Regex ($u) { + '^KIB' { $f = 1024 / 1e9; break } + '^KB' { $f = 1e-6; break } + '^MIB' { $f = 1048576 / 1e9; break } + '^MB' { $f = 1e-3; break } + '^GIB' { $f = 1073741824 / 1e9; break } + '^GB' { $f = 1; break } + '^TIB' { $f = 1099511627776 / 1e9; break } + '^TB' { $f = 1000; break } + } + return $n * $f +} + +function Format-PmGB([double]$v) { return ([string]::Format([Globalization.CultureInfo]::InvariantCulture, '{0:0.0}', $v)) } + +function Get-PodmanMonitorLines { + $L = New-Object System.Collections.Generic.List[string] + if (-not (Test-Podman)) { + $L.Add("${BOLD}Podman${RESET} ${GRAY}미설치 ('Open WebUI (Podman)' 메뉴에서 기동하면 설치합니다)${RESET}") + return $L.ToArray() + } + $ver = Get-PodmanVersion + $mi = Get-MachineInfo + switch ($mi.State) { + 'none' { $L.Add("${BOLD}Podman${RESET} ${GRAY}● 가상 머신 없음 v$ver (WebUI를 기동하면 만듭니다)${RESET}"); return $L.ToArray() } + 'stopped' { $L.Add("${BOLD}Podman${RESET} ${RED}● 가상 머신 중지됨${RESET} v$ver · $($mi.Name) (CPU $($mi.Cpus) · 메모리 $($mi.Mem))"); return $L.ToArray() } + 'starting' { $L.Add("${BOLD}Podman${RESET} ${YELLOW}● 가상 머신 켜는 중${RESET} v$ver · $($mi.Name)"); return $L.ToArray() } + } + + # 명령 4개 + 디스크 크기를 동시에 실행 (출력은 임시 파일로) + $dir = Join-Path $env:TEMP ('jjpm_' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + New-Item -ItemType Directory -Path $dir -Force | Out-Null + $cmds = [ordered]@{ + i = 'info --format {{.Host.MemTotal}}|{{.Host.MemFree}}' + s = 'stats --no-stream --format {{.CPUPerc}}|{{.MemUsage}}' + d = 'system df --format {{.Size}}' + p = 'ps -a --format {{.State}}' + m = 'machine list --format {{.Name}}|{{.DiskSize}}' + } + $procs = @() + foreach ($k in $cmds.Keys) { + try { + $procs += Start-Process -FilePath $script:PodmanExe -ArgumentList $cmds[$k] -NoNewWindow -PassThru ` + -RedirectStandardOutput (Join-Path $dir "$k.txt") -RedirectStandardError (Join-Path $dir "$k.err") -ErrorAction Stop + } catch { } + } + foreach ($p in $procs) { [void]$p.WaitForExit(15000) } + $rd = { param($k) $f = Join-Path $dir "$k.txt"; if (Test-Path -LiteralPath $f) { @(Get-Content -LiteralPath $f -ErrorAction SilentlyContinue | Where-Object { "$_".Trim() }) } else { @() } } + + $mt = 0.0; $mf = 0.0 + $i = "$(& $rd 'i' | Select-Object -First 1)" -split '\|' + if ($i.Count -ge 2) { [void][double]::TryParse($i[0], [ref]$mt); [void][double]::TryParse($i[1], [ref]$mf) } + $cpu = 0.0; $cmem = 0.0 + foreach ($line in (& $rd 's')) { + $f = "$line" -split '\|' + $c = 0.0; [void][double]::TryParse(($f[0] -replace '%', ''), [Globalization.NumberStyles]::Float, [Globalization.CultureInfo]::InvariantCulture, [ref]$c); $cpu += $c + if ($f.Count -ge 2) { $cmem += ConvertTo-PmGB (($f[1] -split '/')[0]) } + } + $dsk = 0.0 + foreach ($line in (& $rd 'd')) { $dsk += ConvertTo-PmGB $line } + $states = @(& $rd 'p') + $run = @($states | Where-Object { "$_" -like 'running*' }).Count + $msize = '?' + foreach ($line in (& $rd 'm')) { $f = "$line" -split '\|'; if ($f[0].TrimEnd('*') -eq $mi.Name -and $f.Count -ge 2) { $msize = $f[1]; break } } + Remove-Item -LiteralPath $dir -Recurse -Force -ErrorAction SilentlyContinue + + $vm = '?' + if ($mt -gt 0) { $vm = "$(Format-PmGB (($mt - $mf) / 1e9))/$(Format-PmGB ($mt / 1e9))GB ($([int](($mt - $mf) * 100 / $mt))%)" } + $L.Add("${BOLD}Podman${RESET} ${GREEN}● 실행 중${RESET} v$ver · $($mi.Name) (CPU $($mi.Cpus) · 메모리 $($mi.Mem) · 디스크 $msize) · 컨테이너 실행 $run/$($states.Count)") + $L.Add(" CPU $(Format-PmGB $cpu)% ${GRAY}(컨테이너 합계)${RESET} · 메모리 컨테이너 $(Format-PmGB $cmem)GB · 가상 머신 사용 $vm ${GRAY}(캐시 포함)${RESET} · 디스크 사용 $(Format-PmGB $dsk)GB") + return $L.ToArray() +} diff --git a/wiki/10_프로젝트/07_변경_기록.md b/wiki/10_프로젝트/07_변경_기록.md index 1b9446b..b35383a 100644 --- a/wiki/10_프로젝트/07_변경_기록.md +++ b/wiki/10_프로젝트/07_변경_기록.md @@ -21,7 +21,8 @@ updated: 2026-11-03 ## 커밋 | 날짜 | 커밋 | 내용 | |---|---|---| -| 2026-11-05 | (이번) | 완전 초기화(메인 메뉴 검색창에 `0000000000`): Windows `16_factory_reset.ps1` · Mac `16_factory_reset.sh` — 백업 zip → 가상 머신·데이터·프로그램 삭제, 모델은 매번 물어봄 | +| 2026-11-05 | (이번) | 상태 화면 맨 위에 Podman 줄: 상태·버전·가상 머신 크기·컨테이너 수 / CPU(컨테이너 합계)·메모리·디스크 사용, 매번 새로 읽음 (Windows·Mac `17_podman_monitor`) | +| 2026-11-05 | 907a999 | 완전 초기화(메인 메뉴 검색창에 `0000000000`): Windows `16_factory_reset.ps1` · Mac `16_factory_reset.sh` — 백업 zip → 가상 머신·데이터·프로그램 삭제, 모델은 매번 물어봄 | | 2026-11-05 | (이번) | Podman 가상 머신 크기: 추천(기본)·최소·최대·사용자 정의 (Windows·Mac) | | 2026-11-05 | (이번) | Mac v2.2.0 Continue 설정 자동 갱신(맥1 세션 `37860f1`)을 `src/platform/mac/15_continue.sh`로 옮김 | | 2026-11-05 | 5c9072e | 소스 분리 + WebUI 이미지 생성·편집 | diff --git a/wiki/PROJECT.md b/wiki/PROJECT.md index 21c3a1c..705d20b 100644 --- a/wiki/PROJECT.md +++ b/wiki/PROJECT.md @@ -37,13 +37,13 @@ Ollama · Open WebUI · ComfyUI 통합 운영·관리 스크립트 (Windows `jj_ ## 소스 | 파일 | 대상 | 줄 수 (2026-11-05) | |---|---|---| -| `jj_ollama_manager.ps1` | Windows 11 (PowerShell 5.1) 실행 파일: 설정 + 소스 불러오기 + 시작 | 331줄 | +| `jj_ollama_manager.ps1` | Windows 11 (PowerShell 5.1) 실행 파일: 설정 + 소스 불러오기 + 시작 | 332줄 | | `RUN.cmd` | Windows 실행용 | 4줄 | -| `jj_ollama_manager.sh` | macOS (Intel Mac, bash 3.2) 실행 파일: 설정 + 소스 불러오기 + 시작 — Linux는 아직 미지원 ([[10_프로젝트/08_MacPro_확장_검토]]) | 312줄 | +| `jj_ollama_manager.sh` | macOS (Intel Mac, bash 3.2) 실행 파일: 설정 + 소스 불러오기 + 시작 — Linux는 아직 미지원 ([[10_프로젝트/08_MacPro_확장_검토]]) | 313줄 | | `src/platform/windows/01_common_hardware_menu.ps1` | Windows 기능 소스 | 337줄 | | `src/platform/windows/02_menu_library.ps1` | Windows 기능 소스 | 397줄 | | `src/platform/windows/03_library_monitor.ps1` | Windows 기능 소스 | 375줄 | -| `src/platform/windows/04_server.ps1` | Windows 기능 소스 | 388줄 | +| `src/platform/windows/04_server.ps1` | Windows 기능 소스 | 391줄 | | `src/platform/windows/05_hardware_continue_ko.ps1` | Windows 기능 소스 | 394줄 | | `src/platform/windows/06_ko_model_action.ps1` | Windows 기능 소스 | 349줄 | | `src/platform/windows/07_online_launch.ps1` | Windows 기능 소스 | 335줄 | @@ -56,9 +56,10 @@ Ollama · Open WebUI · ComfyUI 통합 운영·관리 스크립트 (Windows `jj_ | `src/platform/windows/14_storage_quickopen.ps1` | Windows 기능 소스 | 274줄 | | `src/platform/windows/15_webui_image_sync.ps1` | Windows 기능 소스 (WebUI 이미지 생성·편집 DB 맞춤) | 127줄 | | `src/platform/windows/16_factory_reset.ps1` | Windows 기능 소스 (완전 초기화) | 177줄 | +| `src/platform/windows/17_podman_monitor.ps1` | Windows 기능 소스 (상태 화면 맨 위 Podman 줄) | 88줄 | | `src/platform/mac/01_common_launchd_menu.sh` | Mac 기능 소스 | 355줄 | | `src/platform/mac/02_library_monitor.sh` | Mac 기능 소스 | 412줄 | -| `src/platform/mac/03_monitor_preview.sh` | Mac 기능 소스 | 406줄 | +| `src/platform/mac/03_monitor_preview.sh` | Mac 기능 소스 | 408줄 | | `src/platform/mac/04_server_model_ko.sh` | Mac 기능 소스 | 399줄 | | `src/platform/mac/05_loaded_model_action.sh` | Mac 기능 소스 | 358줄 | | `src/platform/mac/06_model_menus.sh` | Mac 기능 소스 | 375줄 | @@ -72,5 +73,6 @@ Ollama · Open WebUI · ComfyUI 통합 운영·관리 스크립트 (Windows `jj_ | `src/platform/mac/14_setup.sh` | Mac 기능 소스 | 206줄 | | `src/platform/mac/15_continue.sh` | Mac 기능 소스 (VS Code Continue 설정 자동 갱신, v2.2.0) | 95줄 | | `src/platform/mac/16_factory_reset.sh` | Mac 기능 소스 (완전 초기화) | 167줄 | +| `src/platform/mac/17_podman_monitor.sh` | Mac 기능 소스 (상태 화면 맨 위 Podman 줄) | 66줄 | > 소스 규칙(파일당 300~400줄, 700줄 이하) 준수 — 2026-11-05 분리. 검사: `python wiki/tools/check_lines.py .` (`.sh`·`.ps1` 포함)