cpu-loader 0.5.7__tar.gz → 0.5.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.
- {cpu_loader-0.5.7/src/cpu_loader.egg-info → cpu_loader-0.5.9}/PKG-INFO +146 -3
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/README.md +144 -1
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/pyproject.toml +2 -2
- {cpu_loader-0.5.7 → cpu_loader-0.5.9/src/cpu_loader.egg-info}/PKG-INFO +146 -3
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader.egg-info/requires.txt +1 -1
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/LICENSE +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/MANIFEST.in +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/screenshots/01-initial-view.png +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/screenshots/02-with-load.png +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/screenshots/03-live-metrics.png +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/screenshots/04-mobile-view.png +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/setup.cfg +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/setup.py +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/__init__.py +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/__main__.py +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/cpu_loader.py +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/cpu_loader_core.c +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/example.py +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/main.py +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/mqtt_publisher.py +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/static/favicon.svg +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader/templates/index.html +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader.egg-info/SOURCES.txt +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader.egg-info/dependency_links.txt +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader.egg-info/entry_points.txt +0 -0
- {cpu_loader-0.5.7 → cpu_loader-0.5.9}/src/cpu_loader.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cpu-loader
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.9
|
|
4
4
|
Summary: A tool to generate CPU load on a system with runtime configuration through a WebUI and REST API
|
|
5
5
|
Author-email: the78mole <the78mole@users.noreply.github.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Classifier: Topic :: System :: Monitoring
|
|
|
25
25
|
Requires-Python: >=3.9
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
License-File: LICENSE
|
|
28
|
-
Requires-Dist: fastapi==0.
|
|
28
|
+
Requires-Dist: fastapi==0.124.0
|
|
29
29
|
Requires-Dist: uvicorn[standard]==0.38.0
|
|
30
30
|
Requires-Dist: pydantic==2.12.5
|
|
31
31
|
Requires-Dist: requests==2.32.5
|
|
@@ -93,7 +93,22 @@ A tool to generate CPU load on a system with runtime configuration through a Web
|
|
|
93
93
|
|
|
94
94
|
## Installation
|
|
95
95
|
|
|
96
|
-
###
|
|
96
|
+
### Using uv tool (Recommended for CLI usage)
|
|
97
|
+
|
|
98
|
+
For users who want the `cpu-loader` command available system-wide, use `uv tool install`:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
uv tool install cpu-loader
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This installs cpu-loader as a standalone tool that can be run from anywhere:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
cpu-loader --help
|
|
108
|
+
cpu-loader --host 0.0.0.0 --port 8000
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### From Pre-built Wheels
|
|
97
112
|
|
|
98
113
|
Pre-compiled wheels are available for Linux (x86_64, ARM64) and macOS (x86_64, ARM64):
|
|
99
114
|
|
|
@@ -381,6 +396,134 @@ The demo script:
|
|
|
381
396
|
- Provides performance comparisons between algorithms
|
|
382
397
|
- Shows timing accuracy for each computation method
|
|
383
398
|
|
|
399
|
+
## Running as a Systemd Service
|
|
400
|
+
|
|
401
|
+
You can run CPU Loader as a systemd service to start automatically on boot and run in the background.
|
|
402
|
+
|
|
403
|
+
### Create Systemd Service File
|
|
404
|
+
|
|
405
|
+
Create `/etc/systemd/system/cpu-loader.service`:
|
|
406
|
+
|
|
407
|
+
```ini
|
|
408
|
+
[Unit]
|
|
409
|
+
Description=CPU Loader Service
|
|
410
|
+
After=network.target
|
|
411
|
+
|
|
412
|
+
[Service]
|
|
413
|
+
Type=simple
|
|
414
|
+
User=your-username
|
|
415
|
+
WorkingDirectory=/home/your-username
|
|
416
|
+
ExecStart=/home/your-username/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
417
|
+
Restart=on-failure
|
|
418
|
+
RestartSec=5
|
|
419
|
+
|
|
420
|
+
# Optional: Set environment variables for MQTT
|
|
421
|
+
#Environment="MQTT_BROKER_HOST=mqtt.example.com"
|
|
422
|
+
#Environment="MQTT_BROKER_PORT=1883"
|
|
423
|
+
#Environment="MQTT_USERNAME=myuser"
|
|
424
|
+
#Environment="MQTT_PASSWORD=mypassword"
|
|
425
|
+
#Environment="MQTT_TOPIC_PREFIX=cpu-loader"
|
|
426
|
+
#Environment="MQTT_CLIENT_ID=cpu-loader-001"
|
|
427
|
+
|
|
428
|
+
# Optional: Disable temperature monitoring
|
|
429
|
+
#Environment="DISABLE_TEMPERATURE=1"
|
|
430
|
+
|
|
431
|
+
[Install]
|
|
432
|
+
WantedBy=multi-user.target
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Important:** Replace `your-username` with your actual username, and adjust the `ExecStart` path to point to where `cpu-loader` is installed:
|
|
436
|
+
- If installed with `uv tool install`: Usually `~/.local/bin/cpu-loader`
|
|
437
|
+
- If installed with `pip install --user`: Usually `~/.local/bin/cpu-loader`
|
|
438
|
+
- If installed system-wide: Usually `/usr/local/bin/cpu-loader`
|
|
439
|
+
|
|
440
|
+
### Enable and Start the Service
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Reload systemd to recognize the new service
|
|
444
|
+
sudo systemctl daemon-reload
|
|
445
|
+
|
|
446
|
+
# Enable the service to start on boot
|
|
447
|
+
sudo systemctl enable cpu-loader
|
|
448
|
+
|
|
449
|
+
# Start the service now
|
|
450
|
+
sudo systemctl start cpu-loader
|
|
451
|
+
|
|
452
|
+
# Check service status
|
|
453
|
+
sudo systemctl status cpu-loader
|
|
454
|
+
|
|
455
|
+
# View service logs
|
|
456
|
+
sudo journalctl -u cpu-loader -f
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Manage the Service
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
# Stop the service
|
|
463
|
+
sudo systemctl stop cpu-loader
|
|
464
|
+
|
|
465
|
+
# Restart the service
|
|
466
|
+
sudo systemctl restart cpu-loader
|
|
467
|
+
|
|
468
|
+
# Disable auto-start on boot
|
|
469
|
+
sudo systemctl disable cpu-loader
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Example Service Configurations
|
|
473
|
+
|
|
474
|
+
**Basic Service (no MQTT):**
|
|
475
|
+
```ini
|
|
476
|
+
[Unit]
|
|
477
|
+
Description=CPU Loader Service
|
|
478
|
+
After=network.target
|
|
479
|
+
|
|
480
|
+
[Service]
|
|
481
|
+
Type=simple
|
|
482
|
+
User=cpuloader
|
|
483
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
484
|
+
Restart=on-failure
|
|
485
|
+
|
|
486
|
+
[Install]
|
|
487
|
+
WantedBy=multi-user.target
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
**Service with MQTT Integration:**
|
|
491
|
+
```ini
|
|
492
|
+
[Unit]
|
|
493
|
+
Description=CPU Loader Service with MQTT
|
|
494
|
+
After=network.target
|
|
495
|
+
|
|
496
|
+
[Service]
|
|
497
|
+
Type=simple
|
|
498
|
+
User=cpuloader
|
|
499
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
500
|
+
Environment="MQTT_BROKER_HOST=192.168.1.100"
|
|
501
|
+
Environment="MQTT_BROKER_PORT=1883"
|
|
502
|
+
Environment="MQTT_USERNAME=cpuloader"
|
|
503
|
+
Environment="MQTT_PASSWORD=secretpassword"
|
|
504
|
+
Environment="MQTT_TOPIC_PREFIX=home/sensors/cpu-loader"
|
|
505
|
+
Restart=on-failure
|
|
506
|
+
|
|
507
|
+
[Install]
|
|
508
|
+
WantedBy=multi-user.target
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**Service with Custom Computation Type:**
|
|
512
|
+
```ini
|
|
513
|
+
[Unit]
|
|
514
|
+
Description=CPU Loader Service (Matrix Computation)
|
|
515
|
+
After=network.target
|
|
516
|
+
|
|
517
|
+
[Service]
|
|
518
|
+
Type=simple
|
|
519
|
+
User=cpuloader
|
|
520
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8080 --computation-type matrix
|
|
521
|
+
Restart=on-failure
|
|
522
|
+
|
|
523
|
+
[Install]
|
|
524
|
+
WantedBy=multi-user.target
|
|
525
|
+
```
|
|
526
|
+
|
|
384
527
|
## Architecture
|
|
385
528
|
|
|
386
529
|
- **src/cpu_loader_core.c**: High-performance C implementation using pthreads for CPU load generation
|
|
@@ -57,7 +57,22 @@ A tool to generate CPU load on a system with runtime configuration through a Web
|
|
|
57
57
|
|
|
58
58
|
## Installation
|
|
59
59
|
|
|
60
|
-
###
|
|
60
|
+
### Using uv tool (Recommended for CLI usage)
|
|
61
|
+
|
|
62
|
+
For users who want the `cpu-loader` command available system-wide, use `uv tool install`:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv tool install cpu-loader
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This installs cpu-loader as a standalone tool that can be run from anywhere:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cpu-loader --help
|
|
72
|
+
cpu-loader --host 0.0.0.0 --port 8000
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### From Pre-built Wheels
|
|
61
76
|
|
|
62
77
|
Pre-compiled wheels are available for Linux (x86_64, ARM64) and macOS (x86_64, ARM64):
|
|
63
78
|
|
|
@@ -345,6 +360,134 @@ The demo script:
|
|
|
345
360
|
- Provides performance comparisons between algorithms
|
|
346
361
|
- Shows timing accuracy for each computation method
|
|
347
362
|
|
|
363
|
+
## Running as a Systemd Service
|
|
364
|
+
|
|
365
|
+
You can run CPU Loader as a systemd service to start automatically on boot and run in the background.
|
|
366
|
+
|
|
367
|
+
### Create Systemd Service File
|
|
368
|
+
|
|
369
|
+
Create `/etc/systemd/system/cpu-loader.service`:
|
|
370
|
+
|
|
371
|
+
```ini
|
|
372
|
+
[Unit]
|
|
373
|
+
Description=CPU Loader Service
|
|
374
|
+
After=network.target
|
|
375
|
+
|
|
376
|
+
[Service]
|
|
377
|
+
Type=simple
|
|
378
|
+
User=your-username
|
|
379
|
+
WorkingDirectory=/home/your-username
|
|
380
|
+
ExecStart=/home/your-username/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
381
|
+
Restart=on-failure
|
|
382
|
+
RestartSec=5
|
|
383
|
+
|
|
384
|
+
# Optional: Set environment variables for MQTT
|
|
385
|
+
#Environment="MQTT_BROKER_HOST=mqtt.example.com"
|
|
386
|
+
#Environment="MQTT_BROKER_PORT=1883"
|
|
387
|
+
#Environment="MQTT_USERNAME=myuser"
|
|
388
|
+
#Environment="MQTT_PASSWORD=mypassword"
|
|
389
|
+
#Environment="MQTT_TOPIC_PREFIX=cpu-loader"
|
|
390
|
+
#Environment="MQTT_CLIENT_ID=cpu-loader-001"
|
|
391
|
+
|
|
392
|
+
# Optional: Disable temperature monitoring
|
|
393
|
+
#Environment="DISABLE_TEMPERATURE=1"
|
|
394
|
+
|
|
395
|
+
[Install]
|
|
396
|
+
WantedBy=multi-user.target
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Important:** Replace `your-username` with your actual username, and adjust the `ExecStart` path to point to where `cpu-loader` is installed:
|
|
400
|
+
- If installed with `uv tool install`: Usually `~/.local/bin/cpu-loader`
|
|
401
|
+
- If installed with `pip install --user`: Usually `~/.local/bin/cpu-loader`
|
|
402
|
+
- If installed system-wide: Usually `/usr/local/bin/cpu-loader`
|
|
403
|
+
|
|
404
|
+
### Enable and Start the Service
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# Reload systemd to recognize the new service
|
|
408
|
+
sudo systemctl daemon-reload
|
|
409
|
+
|
|
410
|
+
# Enable the service to start on boot
|
|
411
|
+
sudo systemctl enable cpu-loader
|
|
412
|
+
|
|
413
|
+
# Start the service now
|
|
414
|
+
sudo systemctl start cpu-loader
|
|
415
|
+
|
|
416
|
+
# Check service status
|
|
417
|
+
sudo systemctl status cpu-loader
|
|
418
|
+
|
|
419
|
+
# View service logs
|
|
420
|
+
sudo journalctl -u cpu-loader -f
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Manage the Service
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
# Stop the service
|
|
427
|
+
sudo systemctl stop cpu-loader
|
|
428
|
+
|
|
429
|
+
# Restart the service
|
|
430
|
+
sudo systemctl restart cpu-loader
|
|
431
|
+
|
|
432
|
+
# Disable auto-start on boot
|
|
433
|
+
sudo systemctl disable cpu-loader
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Example Service Configurations
|
|
437
|
+
|
|
438
|
+
**Basic Service (no MQTT):**
|
|
439
|
+
```ini
|
|
440
|
+
[Unit]
|
|
441
|
+
Description=CPU Loader Service
|
|
442
|
+
After=network.target
|
|
443
|
+
|
|
444
|
+
[Service]
|
|
445
|
+
Type=simple
|
|
446
|
+
User=cpuloader
|
|
447
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
448
|
+
Restart=on-failure
|
|
449
|
+
|
|
450
|
+
[Install]
|
|
451
|
+
WantedBy=multi-user.target
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Service with MQTT Integration:**
|
|
455
|
+
```ini
|
|
456
|
+
[Unit]
|
|
457
|
+
Description=CPU Loader Service with MQTT
|
|
458
|
+
After=network.target
|
|
459
|
+
|
|
460
|
+
[Service]
|
|
461
|
+
Type=simple
|
|
462
|
+
User=cpuloader
|
|
463
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
464
|
+
Environment="MQTT_BROKER_HOST=192.168.1.100"
|
|
465
|
+
Environment="MQTT_BROKER_PORT=1883"
|
|
466
|
+
Environment="MQTT_USERNAME=cpuloader"
|
|
467
|
+
Environment="MQTT_PASSWORD=secretpassword"
|
|
468
|
+
Environment="MQTT_TOPIC_PREFIX=home/sensors/cpu-loader"
|
|
469
|
+
Restart=on-failure
|
|
470
|
+
|
|
471
|
+
[Install]
|
|
472
|
+
WantedBy=multi-user.target
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
**Service with Custom Computation Type:**
|
|
476
|
+
```ini
|
|
477
|
+
[Unit]
|
|
478
|
+
Description=CPU Loader Service (Matrix Computation)
|
|
479
|
+
After=network.target
|
|
480
|
+
|
|
481
|
+
[Service]
|
|
482
|
+
Type=simple
|
|
483
|
+
User=cpuloader
|
|
484
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8080 --computation-type matrix
|
|
485
|
+
Restart=on-failure
|
|
486
|
+
|
|
487
|
+
[Install]
|
|
488
|
+
WantedBy=multi-user.target
|
|
489
|
+
```
|
|
490
|
+
|
|
348
491
|
## Architecture
|
|
349
492
|
|
|
350
493
|
- **src/cpu_loader_core.c**: High-performance C implementation using pthreads for CPU load generation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cpu-loader"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.9"
|
|
4
4
|
description = "A tool to generate CPU load on a system with runtime configuration through a WebUI and REST API"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.9"
|
|
@@ -25,7 +25,7 @@ classifiers = [
|
|
|
25
25
|
"Topic :: System :: Monitoring",
|
|
26
26
|
]
|
|
27
27
|
dependencies = [
|
|
28
|
-
"fastapi==0.
|
|
28
|
+
"fastapi==0.124.0",
|
|
29
29
|
"uvicorn[standard]==0.38.0",
|
|
30
30
|
"pydantic==2.12.5",
|
|
31
31
|
"requests==2.32.5",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cpu-loader
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.9
|
|
4
4
|
Summary: A tool to generate CPU load on a system with runtime configuration through a WebUI and REST API
|
|
5
5
|
Author-email: the78mole <the78mole@users.noreply.github.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Classifier: Topic :: System :: Monitoring
|
|
|
25
25
|
Requires-Python: >=3.9
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
License-File: LICENSE
|
|
28
|
-
Requires-Dist: fastapi==0.
|
|
28
|
+
Requires-Dist: fastapi==0.124.0
|
|
29
29
|
Requires-Dist: uvicorn[standard]==0.38.0
|
|
30
30
|
Requires-Dist: pydantic==2.12.5
|
|
31
31
|
Requires-Dist: requests==2.32.5
|
|
@@ -93,7 +93,22 @@ A tool to generate CPU load on a system with runtime configuration through a Web
|
|
|
93
93
|
|
|
94
94
|
## Installation
|
|
95
95
|
|
|
96
|
-
###
|
|
96
|
+
### Using uv tool (Recommended for CLI usage)
|
|
97
|
+
|
|
98
|
+
For users who want the `cpu-loader` command available system-wide, use `uv tool install`:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
uv tool install cpu-loader
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This installs cpu-loader as a standalone tool that can be run from anywhere:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
cpu-loader --help
|
|
108
|
+
cpu-loader --host 0.0.0.0 --port 8000
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### From Pre-built Wheels
|
|
97
112
|
|
|
98
113
|
Pre-compiled wheels are available for Linux (x86_64, ARM64) and macOS (x86_64, ARM64):
|
|
99
114
|
|
|
@@ -381,6 +396,134 @@ The demo script:
|
|
|
381
396
|
- Provides performance comparisons between algorithms
|
|
382
397
|
- Shows timing accuracy for each computation method
|
|
383
398
|
|
|
399
|
+
## Running as a Systemd Service
|
|
400
|
+
|
|
401
|
+
You can run CPU Loader as a systemd service to start automatically on boot and run in the background.
|
|
402
|
+
|
|
403
|
+
### Create Systemd Service File
|
|
404
|
+
|
|
405
|
+
Create `/etc/systemd/system/cpu-loader.service`:
|
|
406
|
+
|
|
407
|
+
```ini
|
|
408
|
+
[Unit]
|
|
409
|
+
Description=CPU Loader Service
|
|
410
|
+
After=network.target
|
|
411
|
+
|
|
412
|
+
[Service]
|
|
413
|
+
Type=simple
|
|
414
|
+
User=your-username
|
|
415
|
+
WorkingDirectory=/home/your-username
|
|
416
|
+
ExecStart=/home/your-username/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
417
|
+
Restart=on-failure
|
|
418
|
+
RestartSec=5
|
|
419
|
+
|
|
420
|
+
# Optional: Set environment variables for MQTT
|
|
421
|
+
#Environment="MQTT_BROKER_HOST=mqtt.example.com"
|
|
422
|
+
#Environment="MQTT_BROKER_PORT=1883"
|
|
423
|
+
#Environment="MQTT_USERNAME=myuser"
|
|
424
|
+
#Environment="MQTT_PASSWORD=mypassword"
|
|
425
|
+
#Environment="MQTT_TOPIC_PREFIX=cpu-loader"
|
|
426
|
+
#Environment="MQTT_CLIENT_ID=cpu-loader-001"
|
|
427
|
+
|
|
428
|
+
# Optional: Disable temperature monitoring
|
|
429
|
+
#Environment="DISABLE_TEMPERATURE=1"
|
|
430
|
+
|
|
431
|
+
[Install]
|
|
432
|
+
WantedBy=multi-user.target
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Important:** Replace `your-username` with your actual username, and adjust the `ExecStart` path to point to where `cpu-loader` is installed:
|
|
436
|
+
- If installed with `uv tool install`: Usually `~/.local/bin/cpu-loader`
|
|
437
|
+
- If installed with `pip install --user`: Usually `~/.local/bin/cpu-loader`
|
|
438
|
+
- If installed system-wide: Usually `/usr/local/bin/cpu-loader`
|
|
439
|
+
|
|
440
|
+
### Enable and Start the Service
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Reload systemd to recognize the new service
|
|
444
|
+
sudo systemctl daemon-reload
|
|
445
|
+
|
|
446
|
+
# Enable the service to start on boot
|
|
447
|
+
sudo systemctl enable cpu-loader
|
|
448
|
+
|
|
449
|
+
# Start the service now
|
|
450
|
+
sudo systemctl start cpu-loader
|
|
451
|
+
|
|
452
|
+
# Check service status
|
|
453
|
+
sudo systemctl status cpu-loader
|
|
454
|
+
|
|
455
|
+
# View service logs
|
|
456
|
+
sudo journalctl -u cpu-loader -f
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Manage the Service
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
# Stop the service
|
|
463
|
+
sudo systemctl stop cpu-loader
|
|
464
|
+
|
|
465
|
+
# Restart the service
|
|
466
|
+
sudo systemctl restart cpu-loader
|
|
467
|
+
|
|
468
|
+
# Disable auto-start on boot
|
|
469
|
+
sudo systemctl disable cpu-loader
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Example Service Configurations
|
|
473
|
+
|
|
474
|
+
**Basic Service (no MQTT):**
|
|
475
|
+
```ini
|
|
476
|
+
[Unit]
|
|
477
|
+
Description=CPU Loader Service
|
|
478
|
+
After=network.target
|
|
479
|
+
|
|
480
|
+
[Service]
|
|
481
|
+
Type=simple
|
|
482
|
+
User=cpuloader
|
|
483
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
484
|
+
Restart=on-failure
|
|
485
|
+
|
|
486
|
+
[Install]
|
|
487
|
+
WantedBy=multi-user.target
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
**Service with MQTT Integration:**
|
|
491
|
+
```ini
|
|
492
|
+
[Unit]
|
|
493
|
+
Description=CPU Loader Service with MQTT
|
|
494
|
+
After=network.target
|
|
495
|
+
|
|
496
|
+
[Service]
|
|
497
|
+
Type=simple
|
|
498
|
+
User=cpuloader
|
|
499
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8000
|
|
500
|
+
Environment="MQTT_BROKER_HOST=192.168.1.100"
|
|
501
|
+
Environment="MQTT_BROKER_PORT=1883"
|
|
502
|
+
Environment="MQTT_USERNAME=cpuloader"
|
|
503
|
+
Environment="MQTT_PASSWORD=secretpassword"
|
|
504
|
+
Environment="MQTT_TOPIC_PREFIX=home/sensors/cpu-loader"
|
|
505
|
+
Restart=on-failure
|
|
506
|
+
|
|
507
|
+
[Install]
|
|
508
|
+
WantedBy=multi-user.target
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**Service with Custom Computation Type:**
|
|
512
|
+
```ini
|
|
513
|
+
[Unit]
|
|
514
|
+
Description=CPU Loader Service (Matrix Computation)
|
|
515
|
+
After=network.target
|
|
516
|
+
|
|
517
|
+
[Service]
|
|
518
|
+
Type=simple
|
|
519
|
+
User=cpuloader
|
|
520
|
+
ExecStart=/home/cpuloader/.local/bin/cpu-loader --host 0.0.0.0 --port 8080 --computation-type matrix
|
|
521
|
+
Restart=on-failure
|
|
522
|
+
|
|
523
|
+
[Install]
|
|
524
|
+
WantedBy=multi-user.target
|
|
525
|
+
```
|
|
526
|
+
|
|
384
527
|
## Architecture
|
|
385
528
|
|
|
386
529
|
- **src/cpu_loader_core.c**: High-performance C implementation using pthreads for CPU load generation
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|