peach-workspace/peach-jsonrpc-server
glyph c6f8591600 replace miniserde_support with serde_support 2022-01-12 12:21:12 +02:00
..
src replace miniserde_support with serde_support 2022-01-12 12:21:12 +02:00
Cargo.toml replace miniserde_support with serde_support 2022-01-12 12:21:12 +02:00
README.md jsonrpc server with peach-stats methods 2021-12-10 11:01:51 +02:00

README.md

peach-jsonrpc-server

A JSON-RPC server for the PeachCloud system which exposes an API over HTTP.

Currently includes peach-stats capability (system statistics).

JSON-RPC API

Method Description Returns
cpu_stats CPU statistics user, system, nice, idle
cpu_stats_percent CPU statistics as percentages user, system, nice, idle
disk_usage Disk usage statistics (array of disks) filesystem, one_k_blocks, one_k_blocks_used, one_k_blocks_free, used_percentage, mountpoint
load_average Load average statistics one, five, fifteen
mem_stats Memory statistics total, free, used
ping Microservice status success if running
uptime System uptime secs

Environment

The JSON-RPC HTTP server is currently hardcoded to run on "127.0.0.1:5110". Address and port configuration settings will later be exposed via CLI arguments and possibly an environment variable.

Logging is made available with env_logger:

export RUST_LOG=info

Other logging levels include debug, warn and error.

Setup

Clone the peach-workspace repo:

git clone https://git.coopcloud.tech/PeachCloud/peach-workspace

Move into the repo peaach-jsonrpc-server directory and compile a release build:

cd peach-jsonrpc-server
cargo build --release

Run the binary:

./peach-workspace/target/release/peach-jsonrpc-server

Debian Packaging

TODO.

Example Usage

Get CPU Statistics

With microservice running, open a second terminal window and use curl to call server methods:

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "cpu_stats", "id":1 }' 127.0.0.1:5110

Server responds with:

{"jsonrpc":"2.0","result":"{\"user\":4661083,\"system\":1240371,\"idle\":326838290,\"nice\":0}","id":1}

Get System Uptime

With microservice running, open a second terminal window and use curl to call server methods:

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "uptime", "id":1 }' 127.0.0.1:5110

Server responds with:

{"jsonrpc":"2.0","result":"{\"secs\":840968}","id":1}

Licensing

AGPL-3.0