glancewatch 1.0.0__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.
- glancewatch-1.0.0/LICENSE +21 -0
- glancewatch-1.0.0/MANIFEST.in +10 -0
- glancewatch-1.0.0/PKG-INFO +542 -0
- glancewatch-1.0.0/QUICKSTART-UBUNTU.md +335 -0
- glancewatch-1.0.0/QUICKSTART.md +160 -0
- glancewatch-1.0.0/README.md +499 -0
- glancewatch-1.0.0/app/__init__.py +3 -0
- glancewatch-1.0.0/app/api/__init__.py +1 -0
- glancewatch-1.0.0/app/api/health.py +51 -0
- glancewatch-1.0.0/app/config.py +190 -0
- glancewatch-1.0.0/app/main.py +333 -0
- glancewatch-1.0.0/app/models.py +67 -0
- glancewatch-1.0.0/app/monitor.py +233 -0
- glancewatch-1.0.0/glancewatch.egg-info/PKG-INFO +542 -0
- glancewatch-1.0.0/glancewatch.egg-info/SOURCES.txt +26 -0
- glancewatch-1.0.0/glancewatch.egg-info/dependency_links.txt +1 -0
- glancewatch-1.0.0/glancewatch.egg-info/entry_points.txt +2 -0
- glancewatch-1.0.0/glancewatch.egg-info/requires.txt +15 -0
- glancewatch-1.0.0/glancewatch.egg-info/top_level.txt +1 -0
- glancewatch-1.0.0/pyproject.toml +178 -0
- glancewatch-1.0.0/requirements-dev.txt +15 -0
- glancewatch-1.0.0/requirements.txt +6 -0
- glancewatch-1.0.0/setup.cfg +4 -0
- glancewatch-1.0.0/tests/test_api.py +192 -0
- glancewatch-1.0.0/tests/test_monitor.py +239 -0
- glancewatch-1.0.0/ui/dist/index.html +14 -0
- glancewatch-1.0.0/ui/index-simple.html +534 -0
- glancewatch-1.0.0/ui/index.html +544 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GlanceWatch Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include requirements.txt
|
|
4
|
+
include requirements-dev.txt
|
|
5
|
+
include QUICKSTART.md
|
|
6
|
+
include QUICKSTART-UBUNTU.md
|
|
7
|
+
recursive-include ui *.html
|
|
8
|
+
recursive-include app *.py
|
|
9
|
+
global-exclude __pycache__
|
|
10
|
+
global-exclude *.py[co]
|
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: glancewatch
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Lightweight monitoring adapter bridging Glances metrics with Uptime Kuma
|
|
5
|
+
Author-email: Collins Kramp <collynes@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/collinskramp/glancewatch
|
|
8
|
+
Project-URL: Documentation, https://github.com/collinskramp/glancewatch#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/collinskramp/glancewatch
|
|
10
|
+
Project-URL: Issues, https://github.com/collinskramp/glancewatch/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/collinskramp/glancewatch/releases
|
|
12
|
+
Keywords: monitoring,glances,uptime-kuma,metrics,system-monitoring,server-monitoring
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: System :: Monitoring
|
|
23
|
+
Classifier: Topic :: System :: Systems Administration
|
|
24
|
+
Classifier: Framework :: FastAPI
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: fastapi>=0.109.0
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.27.0
|
|
30
|
+
Requires-Dist: httpx>=0.26.0
|
|
31
|
+
Requires-Dist: pydantic>=2.5.0
|
|
32
|
+
Requires-Dist: pydantic-settings>=2.1.0
|
|
33
|
+
Requires-Dist: PyYAML>=6.0.1
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=24.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
41
|
+
Requires-Dist: ipython>=8.18.0; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# GlanceWatch ๐ฏ
|
|
45
|
+
|
|
46
|
+
[](https://www.python.org/downloads/)
|
|
47
|
+
[](https://fastapi.tiangolo.com/)
|
|
48
|
+
[](https://opensource.org/licenses/MIT)
|
|
49
|
+
|
|
50
|
+
**GlanceWatch** is a lightweight monitoring adapter that bridges [Glances](https://nicolargo.github.io/glances/) system metrics with [Uptime Kuma](https://github.com/louislam/uptime-kuma) and other monitoring tools. It exposes simple HTTP endpoints with configurable thresholds that answer: *"Is my system healthy?"*
|
|
51
|
+
|
|
52
|
+
## โจ Features
|
|
53
|
+
|
|
54
|
+
- ๐ฏ **Simple HTTP Endpoints**: Returns HTTP 200 (OK) or 503 (unhealthy) based on thresholds
|
|
55
|
+
- ๐จ **Web UI**: Modern dashboard with sliders to configure thresholds in real-time
|
|
56
|
+
- โ๏ธ **Configurable Thresholds**: Set custom limits for RAM, CPU, and disk usage
|
|
57
|
+
- ๐พ **Persistent Configuration**: Changes saved to config.yaml automatically
|
|
58
|
+
- ๏ฟฝ **Easy Installation**: Just `pip install glancewatch` - everything included!
|
|
59
|
+
- ๐ **Multiple Disk Monitoring**: Monitor all or specific mount points
|
|
60
|
+
- ๐ฅ **Health Checks**: Built-in health endpoint for service monitoring
|
|
61
|
+
- ๐ **OpenAPI Docs**: Auto-generated API documentation at `/docs`
|
|
62
|
+
- ๐ **Real-Time Metrics**: Auto-refreshing dashboard shows live system status
|
|
63
|
+
|
|
64
|
+
## ๐ Quick Start
|
|
65
|
+
|
|
66
|
+
**Prerequisites: Glances must be installed and running**
|
|
67
|
+
|
|
68
|
+
### One-Line Install (Ubuntu/Debian)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
curl -sSL https://raw.githubusercontent.com/collinskramp/glancewatch/main/install-pip.sh | bash
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This installs Glances, GlanceWatch, and sets up systemd services automatically!
|
|
75
|
+
|
|
76
|
+
### Manual Installation
|
|
77
|
+
|
|
78
|
+
#### 1. Install and Start Glances
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Ubuntu/Debian
|
|
82
|
+
sudo apt install -y glances
|
|
83
|
+
glances -w
|
|
84
|
+
|
|
85
|
+
# macOS
|
|
86
|
+
brew install glances
|
|
87
|
+
glances -w
|
|
88
|
+
|
|
89
|
+
# Or via pip
|
|
90
|
+
pip install glances
|
|
91
|
+
glances -w
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### 2. Install GlanceWatch
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Install from PyPI
|
|
98
|
+
pip install glancewatch
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### 3. Run GlanceWatch
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
glancewatch
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
That's it! ๐
|
|
108
|
+
|
|
109
|
+
**Access the dashboard:**
|
|
110
|
+
- **Web UI**: http://localhost:8000/configure/
|
|
111
|
+
- **API Docs**: http://localhost:8000/docs
|
|
112
|
+
- **Status Endpoint**: http://localhost:8000/status
|
|
113
|
+
|
|
114
|
+
**See [INSTALL.md](INSTALL.md) for detailed instructions, systemd setup, and troubleshooting.**
|
|
115
|
+
|
|
116
|
+
## ๐ก API Endpoints
|
|
117
|
+
|
|
118
|
+
### Core Monitoring Endpoints
|
|
119
|
+
|
|
120
|
+
#### `GET /status`
|
|
121
|
+
Overall system status combining all metrics.
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"ok": true,
|
|
126
|
+
"ram": {
|
|
127
|
+
"ok": true,
|
|
128
|
+
"value": 45.2,
|
|
129
|
+
"threshold": 80.0,
|
|
130
|
+
"unit": "%"
|
|
131
|
+
},
|
|
132
|
+
"cpu": {
|
|
133
|
+
"ok": true,
|
|
134
|
+
"value": 32.5,
|
|
135
|
+
"threshold": 80.0,
|
|
136
|
+
"unit": "%"
|
|
137
|
+
},
|
|
138
|
+
"disk": {
|
|
139
|
+
"ok": true,
|
|
140
|
+
"disks": [
|
|
141
|
+
{
|
|
142
|
+
"mount_point": "/",
|
|
143
|
+
"percent_used": 62.3,
|
|
144
|
+
"size_gb": 500.0,
|
|
145
|
+
"ok": true
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"threshold": 85.0
|
|
149
|
+
},
|
|
150
|
+
"last_check": "2025-11-11T10:30:00"
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### `GET /ram`
|
|
155
|
+
RAM usage check.
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"ok": true,
|
|
160
|
+
"value": 45.2,
|
|
161
|
+
"threshold": 80.0,
|
|
162
|
+
"unit": "%",
|
|
163
|
+
"last_check": "2025-11-11T10:30:00"
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### `GET /cpu`
|
|
168
|
+
CPU usage check (average across all cores).
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"ok": true,
|
|
173
|
+
"value": 32.5,
|
|
174
|
+
"threshold": 80.0,
|
|
175
|
+
"unit": "%",
|
|
176
|
+
"last_check": "2025-11-11T10:30:00"
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### `GET /disk`
|
|
181
|
+
Disk usage check for monitored mount points.
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"ok": true,
|
|
186
|
+
"disks": [
|
|
187
|
+
{
|
|
188
|
+
"mount_point": "/",
|
|
189
|
+
"fs_type": "ext4",
|
|
190
|
+
"percent_used": 62.3,
|
|
191
|
+
"size_gb": 500.0,
|
|
192
|
+
"used_gb": 311.5,
|
|
193
|
+
"free_gb": 188.5,
|
|
194
|
+
"ok": true
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"threshold": 85.0,
|
|
198
|
+
"last_check": "2025-11-11T10:30:00"
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Utility Endpoints
|
|
203
|
+
|
|
204
|
+
#### `GET /health`
|
|
205
|
+
Service health check.
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"status": "healthy",
|
|
210
|
+
"version": "1.0.0",
|
|
211
|
+
"glances_connected": true,
|
|
212
|
+
"glances_url": "http://localhost:61208",
|
|
213
|
+
"uptime_seconds": 3600.5,
|
|
214
|
+
"timestamp": "2025-11-11T10:30:00"
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### `GET /config`
|
|
219
|
+
View current configuration.
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"glances_base_url": "http://localhost:61208",
|
|
224
|
+
"thresholds": {
|
|
225
|
+
"ram_percent": 80.0,
|
|
226
|
+
"cpu_percent": 80.0,
|
|
227
|
+
"disk_percent": 85.0
|
|
228
|
+
},
|
|
229
|
+
"disk_mounts": ["/"],
|
|
230
|
+
"timestamp": "2025-11-11T10:30:00"
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### `PUT /config`
|
|
235
|
+
Update monitoring thresholds (also available via Web UI).
|
|
236
|
+
|
|
237
|
+
**Request:**
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"thresholds": {
|
|
241
|
+
"ram_percent": 75.0,
|
|
242
|
+
"cpu_percent": 85.0,
|
|
243
|
+
"disk_percent": 90.0
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Response:**
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"ok": true,
|
|
252
|
+
"message": "Configuration updated successfully",
|
|
253
|
+
"thresholds": {
|
|
254
|
+
"ram_percent": 75.0,
|
|
255
|
+
"cpu_percent": 85.0,
|
|
256
|
+
"disk_percent": 90.0
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Changes are persisted to `/var/lib/glancewatch/config.yaml` and take effect immediately.
|
|
262
|
+
|
|
263
|
+
### Web UI
|
|
264
|
+
|
|
265
|
+
Access the configuration interface at `http://localhost:8100/ui`
|
|
266
|
+
|
|
267
|
+
- **Dashboard**: Real-time metrics with visual indicators
|
|
268
|
+
- **Sliders**: Adjust RAM, CPU, and Disk thresholds (10-100%)
|
|
269
|
+
- **Persistence**: Changes saved automatically to config.yaml
|
|
270
|
+
- **Auto-refresh**: Dashboard updates every 5 seconds
|
|
271
|
+
- **Status Colors**:
|
|
272
|
+
- ๐ข Green: < 75% of threshold
|
|
273
|
+
- ๐ก Yellow: 75-90% of threshold
|
|
274
|
+
- ๐ด Red: > 90% of threshold
|
|
275
|
+
|
|
276
|
+
## โ๏ธ Configuration
|
|
277
|
+
|
|
278
|
+
### Environment Variables
|
|
279
|
+
|
|
280
|
+
Create a `.env` file or set environment variables:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# Glances Connection
|
|
284
|
+
GLANCES_BASE_URL=http://localhost:61208
|
|
285
|
+
GLANCES_TIMEOUT=5
|
|
286
|
+
|
|
287
|
+
# Server Settings
|
|
288
|
+
HOST=0.0.0.0
|
|
289
|
+
PORT=8000
|
|
290
|
+
|
|
291
|
+
# Thresholds (0-100)
|
|
292
|
+
RAM_THRESHOLD=80.0
|
|
293
|
+
CPU_THRESHOLD=80.0
|
|
294
|
+
DISK_THRESHOLD=85.0
|
|
295
|
+
|
|
296
|
+
# Disk Monitoring
|
|
297
|
+
DISK_MOUNTS=/ # Single mount
|
|
298
|
+
# DISK_MOUNTS=/,/home,/data # Multiple mounts
|
|
299
|
+
# DISK_MOUNTS=all # All mounts
|
|
300
|
+
DISK_EXCLUDE_TYPES=tmpfs,devtmpfs,overlay,squashfs
|
|
301
|
+
|
|
302
|
+
# Error Handling
|
|
303
|
+
RETURN_HTTP_ON_FAILURE= # 200 with ok=false (default)
|
|
304
|
+
# RETURN_HTTP_ON_FAILURE=503 # Return 503 on failure
|
|
305
|
+
|
|
306
|
+
# Logging
|
|
307
|
+
LOG_LEVEL=INFO
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### YAML Configuration
|
|
311
|
+
|
|
312
|
+
Create `~/.config/glancewatch/config.yaml` (or `/var/lib/glancewatch/config.yaml` in Docker):
|
|
313
|
+
|
|
314
|
+
```yaml
|
|
315
|
+
glances_base_url: http://localhost:61208
|
|
316
|
+
glances_timeout: 5
|
|
317
|
+
|
|
318
|
+
host: 0.0.0.0
|
|
319
|
+
port: 8000
|
|
320
|
+
|
|
321
|
+
thresholds:
|
|
322
|
+
ram_percent: 80.0
|
|
323
|
+
cpu_percent: 80.0
|
|
324
|
+
disk_percent: 85.0
|
|
325
|
+
|
|
326
|
+
disk:
|
|
327
|
+
mounts:
|
|
328
|
+
- /
|
|
329
|
+
- /home
|
|
330
|
+
exclude_types:
|
|
331
|
+
- tmpfs
|
|
332
|
+
- devtmpfs
|
|
333
|
+
|
|
334
|
+
log_level: INFO
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Note**: Environment variables override YAML settings.
|
|
338
|
+
|
|
339
|
+
## ๐ Uptime Kuma Integration
|
|
340
|
+
|
|
341
|
+
Add GlanceWatch to Uptime Kuma for automatic alerting:
|
|
342
|
+
|
|
343
|
+
1. **Add New Monitor** in Uptime Kuma
|
|
344
|
+
2. **Monitor Type**: HTTP(s)
|
|
345
|
+
3. **URL**: `http://your-server:8000/status`
|
|
346
|
+
4. **Heartbeat Interval**: 20 seconds (or your preference)
|
|
347
|
+
5. **Expected Status Code**: 2xx (for success)
|
|
348
|
+
6. **Save**
|
|
349
|
+
|
|
350
|
+
**How it works:**
|
|
351
|
+
- โ
**HTTP 200**: All thresholds OK (Uptime Kuma shows GREEN/UP)
|
|
352
|
+
- โ ๏ธ **HTTP 503**: One or more thresholds exceeded (Uptime Kuma shows RED/DOWN and alerts)
|
|
353
|
+
|
|
354
|
+
Configure your thresholds via the Web UI at http://your-server:8000/configure/
|
|
355
|
+
|
|
356
|
+
**See [INSTALL.md](INSTALL.md) for detailed setup instructions.**
|
|
357
|
+
|
|
358
|
+
## ๐ณ Docker Deployment (Optional)
|
|
359
|
+
|
|
360
|
+
If you prefer Docker, a `docker-compose.yml` is included that runs both Glances and GlanceWatch:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
git clone https://github.com/collinskramp/glancewatch.git
|
|
364
|
+
cd glancewatch/docker
|
|
365
|
+
docker-compose up -d
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Access:
|
|
369
|
+
- GlanceWatch: http://localhost:8000
|
|
370
|
+
- Glances Web UI: http://localhost:61208
|
|
371
|
+
|
|
372
|
+
**See [INSTALL.md](INSTALL.md) for more deployment options.**
|
|
373
|
+
|
|
374
|
+
## โ๏ธ Configuration
|
|
375
|
+
|
|
376
|
+
Configure via **Web UI** (easiest) or edit config file.
|
|
377
|
+
|
|
378
|
+
### Web UI (Recommended)
|
|
379
|
+
|
|
380
|
+
Visit http://localhost:8000/configure/ and use the sliders to adjust thresholds.
|
|
381
|
+
|
|
382
|
+
### Config File
|
|
383
|
+
|
|
384
|
+
Config is stored at `~/.config/glancewatch/config.yaml`:
|
|
385
|
+
|
|
386
|
+
```yaml
|
|
387
|
+
thresholds:
|
|
388
|
+
ram_percent: 80.0
|
|
389
|
+
cpu_percent: 80.0
|
|
390
|
+
disk_percent: 85.0
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Environment Variables
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
export GLANCEWATCH_GLANCES_URL=http://localhost:61208
|
|
397
|
+
export GLANCEWATCH_RAM_THRESHOLD=80.0
|
|
398
|
+
export GLANCEWATCH_CPU_THRESHOLD=80.0
|
|
399
|
+
export GLANCEWATCH_DISK_THRESHOLD=85.0
|
|
400
|
+
glancewatch
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**See [INSTALL.md](INSTALL.md) for complete configuration options.**
|
|
404
|
+
|
|
405
|
+
## ๐งช Testing
|
|
406
|
+
|
|
407
|
+
Run the test suite:
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
# Install dev dependencies
|
|
411
|
+
pip install -r requirements-dev.txt
|
|
412
|
+
|
|
413
|
+
# Run tests
|
|
414
|
+
pytest tests/ -v
|
|
415
|
+
|
|
416
|
+
# With coverage
|
|
417
|
+
pytest tests/ --cov=app --cov-report=html
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## ๐ Example Use Cases
|
|
421
|
+
|
|
422
|
+
### 1. Alert When RAM Exceeds 80%
|
|
423
|
+
```bash
|
|
424
|
+
# Set threshold
|
|
425
|
+
export RAM_THRESHOLD=80
|
|
426
|
+
|
|
427
|
+
# Monitor endpoint
|
|
428
|
+
curl http://localhost:8000/ram
|
|
429
|
+
# Returns: {"ok": false, "value": 85.2, ...} when exceeded
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### 2. Monitor Multiple Disks
|
|
433
|
+
```bash
|
|
434
|
+
# Monitor root and data partitions
|
|
435
|
+
export DISK_MOUNTS=/,/data
|
|
436
|
+
|
|
437
|
+
curl http://localhost:8000/disk
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### 3. Integration with Scripts
|
|
441
|
+
```bash
|
|
442
|
+
#!/bin/bash
|
|
443
|
+
RESPONSE=$(curl -s http://localhost:8000/status)
|
|
444
|
+
OK=$(echo $RESPONSE | jq -r '.ok')
|
|
445
|
+
|
|
446
|
+
if [ "$OK" != "true" ]; then
|
|
447
|
+
echo "System unhealthy!"
|
|
448
|
+
# Send notification, trigger action, etc.
|
|
449
|
+
fi
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## ๐ ๏ธ Development
|
|
453
|
+
|
|
454
|
+
### Code Quality
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
# Format code
|
|
458
|
+
black app/ tests/
|
|
459
|
+
|
|
460
|
+
# Lint
|
|
461
|
+
ruff check app/ tests/
|
|
462
|
+
|
|
463
|
+
# Type checking
|
|
464
|
+
mypy app/
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Project Structure
|
|
468
|
+
|
|
469
|
+
```
|
|
470
|
+
glancewatch/
|
|
471
|
+
โโโ app/
|
|
472
|
+
โ โโโ __init__.py # Package initialization
|
|
473
|
+
โ โโโ main.py # FastAPI application
|
|
474
|
+
โ โโโ monitor.py # Core monitoring logic
|
|
475
|
+
โ โโโ config.py # Configuration management
|
|
476
|
+
โ โโโ models.py # Pydantic data models
|
|
477
|
+
โ โโโ api/
|
|
478
|
+
โ โโโ __init__.py
|
|
479
|
+
โ โโโ health.py # Health check endpoint
|
|
480
|
+
โโโ tests/
|
|
481
|
+
โ โโโ test_monitor.py # Monitor tests
|
|
482
|
+
โ โโโ test_api.py # API endpoint tests
|
|
483
|
+
โโโ docker/
|
|
484
|
+
โ โโโ Dockerfile # Container image
|
|
485
|
+
โ โโโ docker-compose.yml # Development stack
|
|
486
|
+
โโโ requirements.txt # Production dependencies
|
|
487
|
+
โโโ requirements-dev.txt # Development dependencies
|
|
488
|
+
โโโ README.md # This file
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
## ๐ง Troubleshooting
|
|
492
|
+
|
|
493
|
+
### Glances Connection Failed
|
|
494
|
+
|
|
495
|
+
**Problem**: `"error": "Failed to fetch RAM data"`
|
|
496
|
+
|
|
497
|
+
**Solutions**:
|
|
498
|
+
1. Check Glances is running: `ps aux | grep glances`
|
|
499
|
+
2. Verify Glances API: `curl http://localhost:61208/api/3/mem`
|
|
500
|
+
3. Check `GLANCES_BASE_URL` configuration
|
|
501
|
+
4. Ensure Glances web server is enabled: `glances -w`
|
|
502
|
+
|
|
503
|
+
### High False Positive Rate
|
|
504
|
+
|
|
505
|
+
**Problem**: Alerts trigger too frequently
|
|
506
|
+
|
|
507
|
+
**Solutions**:
|
|
508
|
+
1. Increase thresholds: `RAM_THRESHOLD=90`
|
|
509
|
+
2. Adjust check interval in monitoring tool
|
|
510
|
+
3. Use `/status` for combined health (all metrics must fail)
|
|
511
|
+
|
|
512
|
+
### Docker Container Unhealthy
|
|
513
|
+
|
|
514
|
+
**Problem**: Health checks failing
|
|
515
|
+
|
|
516
|
+
**Solutions**:
|
|
517
|
+
1. Check logs: `docker logs glancewatch`
|
|
518
|
+
2. Verify Glances connectivity from container
|
|
519
|
+
3. Increase health check timeout in compose file
|
|
520
|
+
|
|
521
|
+
## ๐ License
|
|
522
|
+
|
|
523
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
524
|
+
|
|
525
|
+
## ๐ Support & Contributing
|
|
526
|
+
|
|
527
|
+
- ๐ **Bug Reports**: [GitHub Issues](https://github.com/collinskramp/glancewatch/issues)
|
|
528
|
+
- ๐ก **Feature Requests**: [GitHub Discussions](https://github.com/collinskramp/glancewatch/discussions)
|
|
529
|
+
- ๐ **Documentation**:
|
|
530
|
+
- [Installation Guide](INSTALL.md)
|
|
531
|
+
- [API Documentation](http://localhost:8000/docs) (when running)
|
|
532
|
+
- [Ubuntu Quickstart](QUICKSTART-UBUNTU.md)
|
|
533
|
+
|
|
534
|
+
## ๐ Acknowledgments
|
|
535
|
+
|
|
536
|
+
- [Glances](https://nicolargo.github.io/glances/) - Excellent cross-platform monitoring tool
|
|
537
|
+
- [Uptime Kuma](https://github.com/louislam/uptime-kuma) - Self-hosted monitoring solution
|
|
538
|
+
- [FastAPI](https://fastapi.tiangolo.com/) - Modern Python web framework
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
**Made with โค๏ธ for the self-hosted community**
|