Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/milonoir/schwer
A single binary application with built-in web front-end that can produce cpu/mem load.
https://github.com/milonoir/schwer
cpu-load cpu-monitoring memory-load memory-monitoring testing-tool
Last synced: 2 days ago
JSON representation
A single binary application with built-in web front-end that can produce cpu/mem load.
- Host: GitHub
- URL: https://github.com/milonoir/schwer
- Owner: milonoir
- License: apache-2.0
- Created: 2019-06-24T08:38:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-03T07:31:54.000Z (over 5 years ago)
- Last Synced: 2024-03-18T14:13:50.527Z (10 months ago)
- Topics: cpu-load, cpu-monitoring, memory-load, memory-monitoring, testing-tool
- Language: Go
- Homepage:
- Size: 291 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Schwer
_German_ | _adjective_ | /ʃveːɐ/ | _meaning_: heavy
A single binary application with built-in web front-end that can produce cpu/mem load.
## Installation
1. Clone this repo
2. Change working directory to your local cloned repo
3. `$ go generate . && go build .`## Usage
Once you built the application, just run it. Schwer, by default, binds to port `9999`, but you
can specify a different port (between 1024-65535) if you like by using the `-port` flag:`$ ./schwer -port 19999`
### Web
While Schwer is running, you can open the web front-end in your browser by visiting `localhost:`.
You should see something like this:
![Schwer index page](img/schwer_index.png)
The amount of CPU load percentage Schwer can produce can be specified by typing a number between
0 - 100 into the little input field and hitting enter or clicking the `[Update]` button.The size of extra memory to be allocated (on top of the memory consumption of Schwer itself) can be
set by typing a positive integer (in MB) into the little input field and hitting enter or clicking
the `[Update]` button.### API
You can also use Schwer via its HTTP API.
| Endpoint | Method | Params | Response code | Description |
| -------- | ------ | ------ | ------------- | ----------- |
| `/cpu` | `GET` | `-` | 200 OK | Returns an array of CPU utilisation levels per core (e.g. `[49, 34, 50, 32]` in case of a machine with 4 cores). |
| `/cpu` | `POST` | `pct` - load level % (0-100) | 202 Accepted
400 Bad Request | Sets the load level for Schwer to produce. |
| `/mem` | `GET` | `-` | 200 OK | Returns a JSON object of memory stats in MB (e.g. `{"total": 16384, "available": 5413, "used": 10966, "usedpct": 67}`). |
| `/mem` | `POST` | `size` - memory allocation size in MB | 202 Accepted
400 Bad Request | Schwer allocates this amount of extra memory. |## Limitations
Under the hood Schwer spins up a goroutine for each CPU core in order to make them busy. However,
due to the nature of the Go runtime and scheduler, a goroutine cannot tell which CPU core it is
running on. Hence, Schwer cannot control the load of a specific CPU core (i.e. one cannot set 70%
load for CPU core #1 and 15% load for CPU core #2, etc.). For this reason Schwer tries to load all
CPU cores equally.## TODO
- [x] CPU load monitor
- [x] Memory load monitor
- [ ] Make it work on Windows