checkdk-cli 0.2.7__tar.gz → 0.2.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/PKG-INFO +45 -22
  2. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/README.md +44 -20
  3. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdk_cli.egg-info/PKG-INFO +45 -22
  4. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdk_cli.egg-info/requires.txt +0 -1
  5. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/__init__.py +1 -1
  6. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/init.py +2 -10
  7. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/monitor.py +92 -81
  8. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/pyproject.toml +1 -2
  9. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdk_cli.egg-info/SOURCES.txt +0 -0
  10. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdk_cli.egg-info/dependency_links.txt +0 -0
  11. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdk_cli.egg-info/entry_points.txt +0 -0
  12. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdk_cli.egg-info/top_level.txt +0 -0
  13. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/client.py +0 -0
  14. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/__init__.py +0 -0
  15. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/auth.py +0 -0
  16. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/chaos.py +0 -0
  17. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/docker.py +0 -0
  18. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/kubectl.py +0 -0
  19. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/playground.py +0 -0
  20. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/commands/predict.py +0 -0
  21. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/display.py +0 -0
  22. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/checkdkcli/main.py +0 -0
  23. {checkdk_cli-0.2.7 → checkdk_cli-0.2.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkdk-cli
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: checkDK CLI – AI-powered Docker/Kubernetes issue detector and pod failure predictor
5
5
  Author-email: checkDK Team <team@checkdk.app>
6
6
  License: MIT
@@ -30,7 +30,6 @@ Requires-Dist: rich>=13.0.0
30
30
  Requires-Dist: requests>=2.31.0
31
31
  Requires-Dist: pyyaml>=6.0
32
32
  Requires-Dist: python-dotenv>=1.0.0
33
- Requires-Dist: websocket-client>=1.6.0
34
33
  Provides-Extra: dev
35
34
  Requires-Dist: pytest>=7.4.0; extra == "dev"
36
35
  Requires-Dist: black>=23.0.0; extra == "dev"
@@ -50,6 +49,29 @@ dependencies — it is a thin HTTP/WebSocket client with a rich terminal UI.
50
49
 
51
50
  ## Install
52
51
 
52
+ ### npm (no Python required)
53
+
54
+ The easiest way to install for JavaScript / Node.js users.
55
+ Pre-compiled standalone binaries are distributed per-platform — nothing else needs to be installed.
56
+
57
+ ```bash
58
+ npm install -g @checkdk/cli
59
+ ```
60
+
61
+ Supported platforms:
62
+
63
+ | Platform | Package |
64
+ | --------------------------- | --------------------------- |
65
+ | Linux x64 | `@checkdk/cli-linux-x64` |
66
+ | Linux arm64 | `@checkdk/cli-linux-arm64` |
67
+ | macOS x64 (Intel) | `@checkdk/cli-darwin-x64` |
68
+ | macOS arm64 (Apple Silicon) | `@checkdk/cli-darwin-arm64` |
69
+ | Windows x64 | `@checkdk/cli-win32-x64` |
70
+
71
+ After install, `checkdk` is available on your PATH immediately.
72
+
73
+ ### pip / pipx (Python required)
74
+
53
75
  ```bash
54
76
  # Recommended — isolated install, checkdk on PATH globally
55
77
  pipx install checkdk-cli
@@ -58,6 +80,8 @@ pipx install checkdk-cli
58
80
  pip install checkdk-cli
59
81
  ```
60
82
 
83
+ Requires Python 3.10 or later.
84
+
61
85
  The `checkdk` command is available immediately after install.
62
86
  No configuration required — the CLI talks to `https://checkdk.app/api` by default.
63
87
 
@@ -107,21 +131,21 @@ checkdk predict --cpu 93 --memory 91 --restarts 3 \
107
131
  checkdk predict --cpu 85 --memory 70 --json # CI/scripting output
108
132
  ```
109
133
 
110
- | Option | Default | Description |
111
- |---|---|---|
112
- | `--cpu` | required | CPU usage % |
113
- | `--memory` | required | Memory usage % |
114
- | `--disk` | 50 | Disk usage % |
115
- | `--latency` | 10 | Network latency ms |
116
- | `--restarts` | 0 | Container restart count |
117
- | `--probe-failures` | 0 | Liveness/readiness probe failures |
118
- | `--cpu-pressure` | 0 | Node CPU pressure (0 or 1) |
119
- | `--mem-pressure` | 0 | Node memory pressure (0 or 1) |
120
- | `--age` | 60 | Pod age in minutes |
121
- | `--service` | — | Service/pod name (label only) |
122
- | `--platform` | docker | `docker` or `kubernetes` |
123
- | `--no-ai` | — | Skip LLM, return ML result only |
124
- | `--json` | — | Raw JSON output for scripting |
134
+ | Option | Default | Description |
135
+ | ------------------ | -------- | --------------------------------- |
136
+ | `--cpu` | required | CPU usage % |
137
+ | `--memory` | required | Memory usage % |
138
+ | `--disk` | 50 | Disk usage % |
139
+ | `--latency` | 10 | Network latency ms |
140
+ | `--restarts` | 0 | Container restart count |
141
+ | `--probe-failures` | 0 | Liveness/readiness probe failures |
142
+ | `--cpu-pressure` | 0 | Node CPU pressure (0 or 1) |
143
+ | `--mem-pressure` | 0 | Node memory pressure (0 or 1) |
144
+ | `--age` | 60 | Pod age in minutes |
145
+ | `--service` | — | Service/pod name (label only) |
146
+ | `--platform` | docker | `docker` or `kubernetes` |
147
+ | `--no-ai` | — | Skip LLM, return ML result only |
148
+ | `--json` | — | Raw JSON output for scripting |
125
149
 
126
150
  ### Monitor (real-time)
127
151
 
@@ -152,10 +176,10 @@ Experiments: `cpu`, `memory`, `disk`, `network`, `pod-kill` (k8s only).
152
176
 
153
177
  ## Environment variables
154
178
 
155
- | Variable | Default | Description |
156
- |---|---|---|
157
- | `CHECKDK_API_URL` | `https://checkdk.app/api` | Backend API base URL |
158
- | `CHECKDK_TOKEN` | — | JWT auth token (set by `checkdk auth login`) |
179
+ | Variable | Default | Description |
180
+ | ----------------- | ------------------------- | -------------------------------------------- |
181
+ | `CHECKDK_API_URL` | `https://checkdk.app/api` | Backend API base URL |
182
+ | `CHECKDK_TOKEN` | — | JWT auth token (set by `checkdk auth login`) |
159
183
 
160
184
  The CLI auto-loads `~/.checkdk/.env` and `./.env` on startup.
161
185
 
@@ -183,4 +207,3 @@ pytest
183
207
  # Lint
184
208
  ruff check .
185
209
  ```
186
-
@@ -12,6 +12,29 @@ dependencies — it is a thin HTTP/WebSocket client with a rich terminal UI.
12
12
 
13
13
  ## Install
14
14
 
15
+ ### npm (no Python required)
16
+
17
+ The easiest way to install for JavaScript / Node.js users.
18
+ Pre-compiled standalone binaries are distributed per-platform — nothing else needs to be installed.
19
+
20
+ ```bash
21
+ npm install -g @checkdk/cli
22
+ ```
23
+
24
+ Supported platforms:
25
+
26
+ | Platform | Package |
27
+ | --------------------------- | --------------------------- |
28
+ | Linux x64 | `@checkdk/cli-linux-x64` |
29
+ | Linux arm64 | `@checkdk/cli-linux-arm64` |
30
+ | macOS x64 (Intel) | `@checkdk/cli-darwin-x64` |
31
+ | macOS arm64 (Apple Silicon) | `@checkdk/cli-darwin-arm64` |
32
+ | Windows x64 | `@checkdk/cli-win32-x64` |
33
+
34
+ After install, `checkdk` is available on your PATH immediately.
35
+
36
+ ### pip / pipx (Python required)
37
+
15
38
  ```bash
16
39
  # Recommended — isolated install, checkdk on PATH globally
17
40
  pipx install checkdk-cli
@@ -20,6 +43,8 @@ pipx install checkdk-cli
20
43
  pip install checkdk-cli
21
44
  ```
22
45
 
46
+ Requires Python 3.10 or later.
47
+
23
48
  The `checkdk` command is available immediately after install.
24
49
  No configuration required — the CLI talks to `https://checkdk.app/api` by default.
25
50
 
@@ -69,21 +94,21 @@ checkdk predict --cpu 93 --memory 91 --restarts 3 \
69
94
  checkdk predict --cpu 85 --memory 70 --json # CI/scripting output
70
95
  ```
71
96
 
72
- | Option | Default | Description |
73
- |---|---|---|
74
- | `--cpu` | required | CPU usage % |
75
- | `--memory` | required | Memory usage % |
76
- | `--disk` | 50 | Disk usage % |
77
- | `--latency` | 10 | Network latency ms |
78
- | `--restarts` | 0 | Container restart count |
79
- | `--probe-failures` | 0 | Liveness/readiness probe failures |
80
- | `--cpu-pressure` | 0 | Node CPU pressure (0 or 1) |
81
- | `--mem-pressure` | 0 | Node memory pressure (0 or 1) |
82
- | `--age` | 60 | Pod age in minutes |
83
- | `--service` | — | Service/pod name (label only) |
84
- | `--platform` | docker | `docker` or `kubernetes` |
85
- | `--no-ai` | — | Skip LLM, return ML result only |
86
- | `--json` | — | Raw JSON output for scripting |
97
+ | Option | Default | Description |
98
+ | ------------------ | -------- | --------------------------------- |
99
+ | `--cpu` | required | CPU usage % |
100
+ | `--memory` | required | Memory usage % |
101
+ | `--disk` | 50 | Disk usage % |
102
+ | `--latency` | 10 | Network latency ms |
103
+ | `--restarts` | 0 | Container restart count |
104
+ | `--probe-failures` | 0 | Liveness/readiness probe failures |
105
+ | `--cpu-pressure` | 0 | Node CPU pressure (0 or 1) |
106
+ | `--mem-pressure` | 0 | Node memory pressure (0 or 1) |
107
+ | `--age` | 60 | Pod age in minutes |
108
+ | `--service` | — | Service/pod name (label only) |
109
+ | `--platform` | docker | `docker` or `kubernetes` |
110
+ | `--no-ai` | — | Skip LLM, return ML result only |
111
+ | `--json` | — | Raw JSON output for scripting |
87
112
 
88
113
  ### Monitor (real-time)
89
114
 
@@ -114,10 +139,10 @@ Experiments: `cpu`, `memory`, `disk`, `network`, `pod-kill` (k8s only).
114
139
 
115
140
  ## Environment variables
116
141
 
117
- | Variable | Default | Description |
118
- |---|---|---|
119
- | `CHECKDK_API_URL` | `https://checkdk.app/api` | Backend API base URL |
120
- | `CHECKDK_TOKEN` | — | JWT auth token (set by `checkdk auth login`) |
142
+ | Variable | Default | Description |
143
+ | ----------------- | ------------------------- | -------------------------------------------- |
144
+ | `CHECKDK_API_URL` | `https://checkdk.app/api` | Backend API base URL |
145
+ | `CHECKDK_TOKEN` | — | JWT auth token (set by `checkdk auth login`) |
121
146
 
122
147
  The CLI auto-loads `~/.checkdk/.env` and `./.env` on startup.
123
148
 
@@ -145,4 +170,3 @@ pytest
145
170
  # Lint
146
171
  ruff check .
147
172
  ```
148
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkdk-cli
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: checkDK CLI – AI-powered Docker/Kubernetes issue detector and pod failure predictor
5
5
  Author-email: checkDK Team <team@checkdk.app>
6
6
  License: MIT
@@ -30,7 +30,6 @@ Requires-Dist: rich>=13.0.0
30
30
  Requires-Dist: requests>=2.31.0
31
31
  Requires-Dist: pyyaml>=6.0
32
32
  Requires-Dist: python-dotenv>=1.0.0
33
- Requires-Dist: websocket-client>=1.6.0
34
33
  Provides-Extra: dev
35
34
  Requires-Dist: pytest>=7.4.0; extra == "dev"
36
35
  Requires-Dist: black>=23.0.0; extra == "dev"
@@ -50,6 +49,29 @@ dependencies — it is a thin HTTP/WebSocket client with a rich terminal UI.
50
49
 
51
50
  ## Install
52
51
 
52
+ ### npm (no Python required)
53
+
54
+ The easiest way to install for JavaScript / Node.js users.
55
+ Pre-compiled standalone binaries are distributed per-platform — nothing else needs to be installed.
56
+
57
+ ```bash
58
+ npm install -g @checkdk/cli
59
+ ```
60
+
61
+ Supported platforms:
62
+
63
+ | Platform | Package |
64
+ | --------------------------- | --------------------------- |
65
+ | Linux x64 | `@checkdk/cli-linux-x64` |
66
+ | Linux arm64 | `@checkdk/cli-linux-arm64` |
67
+ | macOS x64 (Intel) | `@checkdk/cli-darwin-x64` |
68
+ | macOS arm64 (Apple Silicon) | `@checkdk/cli-darwin-arm64` |
69
+ | Windows x64 | `@checkdk/cli-win32-x64` |
70
+
71
+ After install, `checkdk` is available on your PATH immediately.
72
+
73
+ ### pip / pipx (Python required)
74
+
53
75
  ```bash
54
76
  # Recommended — isolated install, checkdk on PATH globally
55
77
  pipx install checkdk-cli
@@ -58,6 +80,8 @@ pipx install checkdk-cli
58
80
  pip install checkdk-cli
59
81
  ```
60
82
 
83
+ Requires Python 3.10 or later.
84
+
61
85
  The `checkdk` command is available immediately after install.
62
86
  No configuration required — the CLI talks to `https://checkdk.app/api` by default.
63
87
 
@@ -107,21 +131,21 @@ checkdk predict --cpu 93 --memory 91 --restarts 3 \
107
131
  checkdk predict --cpu 85 --memory 70 --json # CI/scripting output
108
132
  ```
109
133
 
110
- | Option | Default | Description |
111
- |---|---|---|
112
- | `--cpu` | required | CPU usage % |
113
- | `--memory` | required | Memory usage % |
114
- | `--disk` | 50 | Disk usage % |
115
- | `--latency` | 10 | Network latency ms |
116
- | `--restarts` | 0 | Container restart count |
117
- | `--probe-failures` | 0 | Liveness/readiness probe failures |
118
- | `--cpu-pressure` | 0 | Node CPU pressure (0 or 1) |
119
- | `--mem-pressure` | 0 | Node memory pressure (0 or 1) |
120
- | `--age` | 60 | Pod age in minutes |
121
- | `--service` | — | Service/pod name (label only) |
122
- | `--platform` | docker | `docker` or `kubernetes` |
123
- | `--no-ai` | — | Skip LLM, return ML result only |
124
- | `--json` | — | Raw JSON output for scripting |
134
+ | Option | Default | Description |
135
+ | ------------------ | -------- | --------------------------------- |
136
+ | `--cpu` | required | CPU usage % |
137
+ | `--memory` | required | Memory usage % |
138
+ | `--disk` | 50 | Disk usage % |
139
+ | `--latency` | 10 | Network latency ms |
140
+ | `--restarts` | 0 | Container restart count |
141
+ | `--probe-failures` | 0 | Liveness/readiness probe failures |
142
+ | `--cpu-pressure` | 0 | Node CPU pressure (0 or 1) |
143
+ | `--mem-pressure` | 0 | Node memory pressure (0 or 1) |
144
+ | `--age` | 60 | Pod age in minutes |
145
+ | `--service` | — | Service/pod name (label only) |
146
+ | `--platform` | docker | `docker` or `kubernetes` |
147
+ | `--no-ai` | — | Skip LLM, return ML result only |
148
+ | `--json` | — | Raw JSON output for scripting |
125
149
 
126
150
  ### Monitor (real-time)
127
151
 
@@ -152,10 +176,10 @@ Experiments: `cpu`, `memory`, `disk`, `network`, `pod-kill` (k8s only).
152
176
 
153
177
  ## Environment variables
154
178
 
155
- | Variable | Default | Description |
156
- |---|---|---|
157
- | `CHECKDK_API_URL` | `https://checkdk.app/api` | Backend API base URL |
158
- | `CHECKDK_TOKEN` | — | JWT auth token (set by `checkdk auth login`) |
179
+ | Variable | Default | Description |
180
+ | ----------------- | ------------------------- | -------------------------------------------- |
181
+ | `CHECKDK_API_URL` | `https://checkdk.app/api` | Backend API base URL |
182
+ | `CHECKDK_TOKEN` | — | JWT auth token (set by `checkdk auth login`) |
159
183
 
160
184
  The CLI auto-loads `~/.checkdk/.env` and `./.env` on startup.
161
185
 
@@ -183,4 +207,3 @@ pytest
183
207
  # Lint
184
208
  ruff check .
185
209
  ```
186
-
@@ -3,7 +3,6 @@ rich>=13.0.0
3
3
  requests>=2.31.0
4
4
  pyyaml>=6.0
5
5
  python-dotenv>=1.0.0
6
- websocket-client>=1.6.0
7
6
 
8
7
  [dev]
9
8
  pytest>=7.4.0
@@ -1,3 +1,3 @@
1
1
  """checkDK CLI package."""
2
2
 
3
- __version__ = "0.2.7"
3
+ __version__ = "0.2.9"
@@ -34,18 +34,10 @@ def init_cmd() -> None:
34
34
 
35
35
  existing.append(f"CHECKDK_API_URL={api_url}")
36
36
 
37
- default_ws = os.getenv("CHECKDK_WS_URL", "wss://m7fijvmhiq.us-east-1.awsapprunner.com")
38
- ws_url = console.input(
39
- f" WebSocket URL (for monitor) [[dim]{default_ws}[/]]: "
40
- ).strip() or default_ws
41
- existing = [l for l in existing if not l.startswith("CHECKDK_WS_URL=")]
42
- existing.append(f"CHECKDK_WS_URL={ws_url}")
43
-
44
37
  env_path.write_text("\n".join(existing) + "\n")
45
38
 
46
39
  console.print(
47
40
  f"\n[bold green]✓ Saved to:[/] {env_path}\n"
48
- f" [dim]CHECKDK_API_URL={api_url}[/]\n"
49
- f" [dim]CHECKDK_WS_URL={ws_url}[/]\n\n"
50
- "Tip: You can also set these as shell environment variables."
41
+ f" [dim]CHECKDK_API_URL={api_url}[/]\n\n"
42
+ "Tip: You can also set this as a shell environment variable."
51
43
  )
@@ -1,20 +1,24 @@
1
- """checkdk monitor - real-time container/pod health monitoring over WebSocket."""
1
+ """checkdk monitor - real-time container/pod health monitoring via REST polling.
2
+
3
+ Polls the /predict endpoint on each interval instead of using a WebSocket
4
+ connection, which is blocked by the App Runner infrastructure layer.
5
+ """
2
6
 
3
7
  from __future__ import annotations
4
8
 
5
- import json
6
9
  import subprocess
7
10
  import sys
8
11
  import time
9
12
  from typing import Optional
10
13
 
11
14
  import click
15
+ import requests
12
16
  from rich.console import Console
13
17
  from rich.live import Live
14
18
  from rich.table import Table
15
19
  from rich.text import Text
16
20
 
17
- from ..client import get_ws_url
21
+ from ..client import get_api_url
18
22
 
19
23
  _console = Console()
20
24
 
@@ -25,6 +29,12 @@ def _risk_color(label: str) -> str:
25
29
  )
26
30
 
27
31
 
32
+ def _level_color(level: str) -> str:
33
+ return {"low": "green", "medium": "yellow", "high": "red", "critical": "bold red"}.get(
34
+ level.lower(), "white"
35
+ )
36
+
37
+
28
38
  def _docker_stats(container: str) -> Optional[dict]:
29
39
  """Return one snapshot from docker stats --no-stream."""
30
40
  try:
@@ -63,23 +73,66 @@ def _k8s_stats(pod: str, namespace: str) -> Optional[dict]:
63
73
  return {"cpu": _pct(parts[1]), "memory": _pct(parts[2])}
64
74
 
65
75
 
76
+ def _predict(api_url: str, stats: dict, platform: str, service: str, no_ai: bool) -> Optional[dict]:
77
+ """POST to /predict and return the prediction dict, or None on error."""
78
+ # docker stats CPUPerc can exceed 100% on multi-core machines (e.g. 200% = 2 cores at max).
79
+ # The /predict endpoint validates cpu/memory in [0, 100], so clamp before sending.
80
+ cpu = min(stats["cpu"], 100.0)
81
+ memory = min(stats["memory"], 100.0)
82
+ try:
83
+ resp = requests.post(
84
+ f"{api_url}/predict",
85
+ json={
86
+ "cpu": cpu,
87
+ "memory": memory,
88
+ "disk": 50.0,
89
+ "latency": 10.0,
90
+ "restarts": 0,
91
+ "probe_failures": 0,
92
+ "cpu_pressure": 0,
93
+ "mem_pressure": 0,
94
+ "age": 60,
95
+ "service": service,
96
+ "platform": platform,
97
+ "no_ai": no_ai,
98
+ },
99
+ timeout=15,
100
+ )
101
+ resp.raise_for_status()
102
+ data = resp.json()
103
+ pred = data.get("prediction", {})
104
+ return {
105
+ "label": pred.get("label", "unknown"),
106
+ "confidence": pred.get("confidence", 0.0),
107
+ "risk_level": pred.get("risk_level", "unknown"),
108
+ }
109
+ except requests.HTTPError as exc:
110
+ _console.log(f"[dim red]Predict HTTP {exc.response.status_code}: {exc.response.text[:200]}[/]")
111
+ return None
112
+ except Exception as exc:
113
+ _console.log(f"[dim red]Predict error: {exc}[/]")
114
+ return None
115
+
116
+
66
117
  def _build_table(history: list[dict]) -> Table:
67
118
  t = Table(title="checkDK Real-Time Monitor", expand=True)
68
119
  t.add_column("#", style="dim", width=4)
69
120
  t.add_column("CPU %", style="cyan", width=8)
70
121
  t.add_column("MEM %", style="cyan", width=8)
71
122
  t.add_column("Risk Label", width=12)
123
+ t.add_column("Risk Level", width=12)
72
124
  t.add_column("Confidence", width=12)
73
125
  t.add_column("Time", style="dim")
74
126
  for i, row in enumerate(history[-20:], 1):
75
127
  label = row.get("label", "unknown")
128
+ level = row.get("risk_level", "unknown")
76
129
  conf = row.get("confidence", 0.0)
77
- col = _risk_color(label)
78
130
  t.add_row(
79
131
  str(i),
80
132
  f"{row.get('cpu', 0):.1f}",
81
133
  f"{row.get('mem', 0):.1f}",
82
- Text(label, style=f"bold {col}"),
134
+ Text(label, style=f"bold {_risk_color(label)}"),
135
+ Text(level, style=_level_color(level)),
83
136
  f"{conf:.2f}",
84
137
  row.get("ts", ""),
85
138
  )
@@ -97,37 +150,24 @@ def monitor_cmd() -> None:
97
150
  help="Stop after N seconds (0 = run until Ctrl-C)")
98
151
  @click.option("--interval", default=5, show_default=True, type=int,
99
152
  help="Polling interval in seconds")
100
- def monitor_docker(container: str, duration: int, interval: int) -> None:
153
+ @click.option("--no-ai", is_flag=True, default=False,
154
+ help="Skip LLM analysis (faster, ML prediction only)")
155
+ def monitor_docker(container: str, duration: int, interval: int, no_ai: bool) -> None:
101
156
  """Stream live Docker container metrics and predict failure risk.
102
157
 
103
158
  \b
104
159
  Example:
105
160
  checkdk monitor docker my-container
106
161
  checkdk monitor docker api --duration 120 --interval 3
162
+ checkdk monitor docker api --no-ai
107
163
  """
108
- try:
109
- import websocket # noqa: F401
110
- except ImportError:
111
- _console.print("[bold red]Missing dependency:[/] install websocket-client")
112
- _console.print(" pip install websocket-client")
113
- sys.exit(1)
114
-
115
- import websocket as ws_lib
116
-
117
- ws_url = get_ws_url() + "/ws/monitor"
164
+ api_url = get_api_url()
118
165
  history: list[dict] = []
119
166
  start = time.time()
120
167
 
121
- _console.print(f"[bold]Monitoring container:[/] [cyan]{container}[/] [dim]{ws_url}[/]")
168
+ _console.print(f"[bold]Monitoring container:[/] [cyan]{container}[/] [dim]{api_url}/predict[/]")
122
169
  _console.print("[dim]Press Ctrl-C to stop.[/]\n")
123
170
 
124
- try:
125
- sock = ws_lib.create_connection(ws_url, timeout=10)
126
- except Exception as exc:
127
- _console.print(f"[bold red]Cannot connect to WebSocket:[/] {exc}")
128
- _console.print("[yellow]Is the backend running with WebSocket support?[/]")
129
- sys.exit(1)
130
-
131
171
  try:
132
172
  with Live(_build_table(history), refresh_per_second=1) as live:
133
173
  while True:
@@ -137,29 +177,20 @@ def monitor_docker(container: str, duration: int, interval: int) -> None:
137
177
  if stats is None:
138
178
  time.sleep(interval)
139
179
  continue
140
- payload = {
141
- "cpu_usage": stats["cpu"], "memory_usage": stats["memory"],
142
- "disk_usage": 50.0, "network_latency": 0.0,
143
- "restart_count": 0, "probe_failures": 0,
144
- "cpu_pressure": 0, "memory_pressure": 0,
145
- "pod_age_minutes": 60,
146
- }
147
- sock.send(json.dumps(payload))
148
- raw = sock.recv()
149
- resp = json.loads(raw)
150
- history.append({
151
- "cpu": stats["cpu"], "mem": stats["memory"],
152
- "label": resp.get("label", "?"),
153
- "confidence": resp.get("confidence", 0.0),
154
- "ts": time.strftime("%H:%M:%S"),
155
- })
156
- live.update(_build_table(history))
180
+ pred = _predict(api_url, stats, platform="docker", service=container, no_ai=no_ai)
181
+ if pred:
182
+ history.append({
183
+ "cpu": stats["cpu"],
184
+ "mem": stats["memory"],
185
+ "label": pred["label"],
186
+ "risk_level": pred["risk_level"],
187
+ "confidence": pred["confidence"],
188
+ "ts": time.strftime("%H:%M:%S"),
189
+ })
190
+ live.update(_build_table(history))
157
191
  time.sleep(interval)
158
192
  except KeyboardInterrupt:
159
193
  pass
160
- finally:
161
- try: sock.close()
162
- except: pass
163
194
  _console.print("\n[bold green]Monitor stopped.[/]")
164
195
 
165
196
 
@@ -168,35 +199,24 @@ def monitor_docker(container: str, duration: int, interval: int) -> None:
168
199
  @click.option("--namespace", "-n", default="default", show_default=True)
169
200
  @click.option("--duration", default=0, type=int, help="Stop after N seconds (0 = Ctrl-C)")
170
201
  @click.option("--interval", default=5, show_default=True, type=int)
171
- def monitor_k8s(pod: str, namespace: str, duration: int, interval: int) -> None:
202
+ @click.option("--no-ai", is_flag=True, default=False,
203
+ help="Skip LLM analysis (faster, ML prediction only)")
204
+ def monitor_k8s(pod: str, namespace: str, duration: int, interval: int, no_ai: bool) -> None:
172
205
  """Stream live Kubernetes pod metrics and predict failure risk.
173
206
 
174
207
  \b
175
208
  Example:
176
209
  checkdk monitor k8s my-pod -n production
177
210
  checkdk monitor k8s api-pod --duration 120
211
+ checkdk monitor k8s api-pod --no-ai
178
212
  """
179
- try:
180
- import websocket # noqa: F401
181
- except ImportError:
182
- _console.print("[bold red]Missing dependency:[/] install websocket-client")
183
- sys.exit(1)
184
-
185
- import websocket as ws_lib
186
-
187
- ws_url = get_ws_url() + "/ws/monitor"
213
+ api_url = get_api_url()
188
214
  history: list[dict] = []
189
215
  start = time.time()
190
216
 
191
- _console.print(f"[bold]Monitoring pod:[/] [cyan]{pod}[/] (ns: {namespace}) [dim]{ws_url}[/]")
217
+ _console.print(f"[bold]Monitoring pod:[/] [cyan]{pod}[/] (ns: {namespace}) [dim]{api_url}/predict[/]")
192
218
  _console.print("[dim]Press Ctrl-C to stop.[/]\n")
193
219
 
194
- try:
195
- sock = ws_lib.create_connection(ws_url, timeout=10)
196
- except Exception as exc:
197
- _console.print(f"[bold red]Cannot connect to WebSocket:[/] {exc}")
198
- sys.exit(1)
199
-
200
220
  try:
201
221
  with Live(_build_table(history), refresh_per_second=1) as live:
202
222
  while True:
@@ -206,27 +226,18 @@ def monitor_k8s(pod: str, namespace: str, duration: int, interval: int) -> None:
206
226
  if stats is None:
207
227
  time.sleep(interval)
208
228
  continue
209
- payload = {
210
- "cpu_usage": stats["cpu"], "memory_usage": stats["memory"],
211
- "disk_usage": 50.0, "network_latency": 0.0,
212
- "restart_count": 0, "probe_failures": 0,
213
- "cpu_pressure": 0, "memory_pressure": 0,
214
- "pod_age_minutes": 60,
215
- }
216
- sock.send(json.dumps(payload))
217
- raw = sock.recv()
218
- resp = json.loads(raw)
219
- history.append({
220
- "cpu": stats["cpu"], "mem": stats["memory"],
221
- "label": resp.get("label", "?"),
222
- "confidence": resp.get("confidence", 0.0),
223
- "ts": time.strftime("%H:%M:%S"),
224
- })
225
- live.update(_build_table(history))
229
+ pred = _predict(api_url, stats, platform="kubernetes", service=pod, no_ai=no_ai)
230
+ if pred:
231
+ history.append({
232
+ "cpu": stats["cpu"],
233
+ "mem": stats["memory"],
234
+ "label": pred["label"],
235
+ "risk_level": pred["risk_level"],
236
+ "confidence": pred["confidence"],
237
+ "ts": time.strftime("%H:%M:%S"),
238
+ })
239
+ live.update(_build_table(history))
226
240
  time.sleep(interval)
227
241
  except KeyboardInterrupt:
228
242
  pass
229
- finally:
230
- try: sock.close()
231
- except: pass
232
243
  _console.print("\n[bold green]Monitor stopped.[/]")
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "checkdk-cli"
7
- version = "0.2.7"
7
+ version = "0.2.9"
8
8
  description = "checkDK CLI – AI-powered Docker/Kubernetes issue detector and pod failure predictor"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -34,7 +34,6 @@ dependencies = [
34
34
  "requests>=2.31.0",
35
35
  "pyyaml>=6.0",
36
36
  "python-dotenv>=1.0.0",
37
- "websocket-client>=1.6.0",
38
37
  ]
39
38
 
40
39
  [project.urls]
File without changes