Mita, named as Multi-Tangled, is a web application for monitoring runtime status and data of multiple machines (clients).
Demo: https://mita-demo.controlnet.space
The server is used to accept client post data and host the web UI.
docker run \
-d \
-p <PORT>:9000 \
-e MITA_PASSWORD=<PASSWORD> \
[-e MITA_GUEST_PASSWORD=<GUEST_PASSWORD>] \
-v <DATA_DIR>:/app/data \
--name mita \
--restart=unless-stopped \
controlnet/mita[:<VERSION>]
MITA_PASSWORD
: Password for admin accessing the api and web for read/write.MITA_GUEST_PASSWORD
: Password for guest accessing the api and web for read only.REACT_APP_PASSWORD
: Optional, set the default password for the frontend.MITA_SECRET_KEY
: Optional, Server secret key for CRSF token.MITA_TOKEN_SECRET
: Optional, Server secret key for JWT authentication token.
The client is the interface to post data to the server.
A Python client and a Rust CLI are included in this repository.
Install the client from pypi:
pip install mita_client
Use the tqdm integrated client (require tqdm
for progress bar):
from mita_client import mita_tqdm
import time
for i in mita_tqdm(range(1000), ADDRESS, PASSWORD):
time.sleep(0.1)
Use the fully client:
from mita_client.client import Mita
from mita_client.component import *
from mita_client.view import View
# initialize components
view = View("python_view")
logger = Logger("python_logger")
line_chart = LineChart("python_line_chart")
progress_bar = ProgressBar("python_progress_bar", total=100)
var = Variable("python_var", 100)
# register components to view
view.add(
var,
progress_bar,
logger,
line_chart
)
# update data in the runtime, and post to the client
with Mita(ADDRESS, PASSWORD) as client:
client.add(view)
for i in range(10):
logger.log(f"some msg {i}")
line_chart.add(1 + i, 1 + i, "pos")
line_chart.add(1 + i, 3.5 - i, "neg")
progress_bar.set(i * 8 + 1)
client.push()
Build the Rust CLI from source:
cargo install mita
Authenticate with a Mita server (falls back to MITA_ADDRESS
and MITA_PASSWORD
when flags are omitted):
mita auth --url http://your.mita.server:9000 --password <PASSWORD>
Tokens are stored in ~/.mita.json
per server URL.
Push updates (falls back to MITA_ADDRESS
and MITA_PASSWORD
when flags are omitted):
mita push [--view <VIEW_NAME>] <COMPONENT_TYPE> <COMPONENT_NAME> <COMPONENT_VALUE> [--args]
# examples
mita push progress_bar progress 20 --total 100
mita push --view my_view variable some_var "Hello World"
Add the crate to your Cargo.toml
:
# enable "progress" and "log" features if needed
mita = { version = "0.0.0", features = ["progress", "log"] } # check crates.io for the latest version
Use the library in your Rust application:
use mita::{Mita, View, Variable, ProgressBar, Logger, LineChart, Component};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut logger = Logger::new("rust_logger");
let mut line_chart = LineChart::new("rust_line_chart", "x", "y");
let mut progress_bar = ProgressBar::new("rust_progress_bar", 0.0, 100.0);
let var = Variable::new("rust_var", 100);
let mut client = Mita::init(ADDRESS, PASSWORD, false)?;
for i in 0..10 {
logger.log(format!("some msg {i}"));
line_chart.add(1.0 + i as f64, 1.0 + i as f64, "pos");
line_chart.add(1.0 + i as f64, 3.5 - i as f64, "neg");
progress_bar.set(i as f64 * 8.0 + 1.0);
let mut view = View::new(Some("rust_view"));
view.add([
Component::from(var.clone()),
Component::from(progress_bar.clone()),
Component::from(logger.clone()),
Component::from(line_chart.clone()),
]);
client.add(&view)?;
}
client.join();
Ok(())
}
#!/bin/bash
MITA_CLI="./target/release/mita" # the default cargo build directory, or anywhere you put the executable
VIEW_NAME="cli-test"
COMP_NAME="progress-loop"
TOTAL=100
URL= # your mita server address
PASSWORD= # your password
# auth on first run
$MITA_CLI auth --url $URL --password $PASSWORD
# loop
for ((i=0; i<=$TOTAL; i+=5)); do
echo "Push $i/$TOTAL"
$MITA_CLI push --view $VIEW_NAME progress_bar "$COMP_NAME" "$i" --total $TOTAL
sleep 1
done
Module | License |
---|---|
server | AGPL |
python client | MIT |
rust client | MIT |