Crates.io | mackerel_plugin |
lib.rs | mackerel_plugin |
version | 0.2.6 |
source | src |
created_at | 2017-09-30 17:30:08.881513 |
updated_at | 2023-11-13 23:47:51.24246 |
description | Mackerel plugin helper library |
homepage | |
repository | https://github.com/itchyny/mackerel-plugin-rs |
max_upload_size | |
id | 34010 |
size | 35,424 |
ー Mackerel plugin helper library for Rust ー
Plugins using this library.
use mackerel_plugin::*;
use rand;
use std::collections::HashMap;
struct DicePlugin {}
impl Plugin for DicePlugin {
fn fetch_metrics(&self) -> Result<HashMap<String, f64>, String> {
Ok(HashMap::from([
("dice.d6".to_owned(), (rand::random::<u64>() % 6 + 1) as f64),
("dice.d20".to_owned(), (rand::random::<u64>() % 20 + 1) as f64),
]))
}
fn graph_definition(&self) -> Vec<Graph> {
vec![
graph! {
name: "dice",
label: "My Dice",
unit: "integer",
metrics: [
{ name: "d6", label: "Die 6" },
{ name: "d20", label: "Die 20" },
],
},
]
}
}
fn main() {
let plugin = DicePlugin {};
match plugin.run() {
Ok(_) => {},
Err(err) => {
eprintln!("mackerel-plugin-dice: {}", err);
std::process::exit(1);
}
}
}
itchyny (https://github.com/itchyny)
This software is released under the MIT License, see LICENSE.