expanded readme
added docker compose added example .env looped the authentication
This commit is contained in:
parent
62631bcae4
commit
5358430916
5
.env.example
Normal file
5
.env.example
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
LISTEN_ADDRES=0.0.0.0
|
||||||
|
PORT=5733
|
||||||
|
|
||||||
|
ROUTER_URL=https://127.0.0.1:7650
|
||||||
|
ROUTER_PASSWORD=itoopie
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
result*
|
result*
|
||||||
|
.env
|
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
exporter:
|
||||||
|
build:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
context: .
|
||||||
|
container_name: i2pd-exporter
|
||||||
|
environment:
|
||||||
|
- IP=${LISTEN_ADDRESS}
|
||||||
|
- PORT=${PORT}
|
||||||
|
- ROUTER=${ROUTER_URL}
|
||||||
|
- PASSWORD=${ROUTER_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "${PORT}:${PORT}"
|
106
readme.md
106
readme.md
|
@ -1,3 +1,109 @@
|
||||||
# I2PD exporter
|
# I2PD exporter
|
||||||
|
|
||||||
A basic prometheus exporter that exports miscellaneous data using the i2pcontrol protocol such as peers, data sent & received and so on...
|
A basic prometheus exporter that exports miscellaneous data using the i2pcontrol protocol such as peers, data sent & received and so on...
|
||||||
|
Right now there are some problems with using exporter as the options for i2pd in nixpkgs are wrong... Therefore upon starting the program will error out with `InvalidPassword`. But it works alright on other systems
|
||||||
|
|
||||||
|
## How to use (Nix)
|
||||||
|
|
||||||
|
1. Import to your flake
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
description = "A simple NixOS flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||||
|
i2pd-exporter = {
|
||||||
|
url = "path:/home/grape/code/i2pdexporter";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ self
|
||||||
|
, nixpkgs
|
||||||
|
, i2pd-exporter
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
nixosConfigurations.server = nixpkgs.lib.nixosSystem
|
||||||
|
{
|
||||||
|
inherit system;
|
||||||
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
|
||||||
|
i2pd-exporter.nixosModules.default
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Enable I2PControl for I2PD
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{pkgs, ...}:{
|
||||||
|
|
||||||
|
services.i2pd = {
|
||||||
|
enable = true;
|
||||||
|
proto.i2pControl = {
|
||||||
|
enable = true;
|
||||||
|
port = 7659;
|
||||||
|
name = "i2pcontrol";
|
||||||
|
address = "127.0.0.1";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Enable the exporter
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{pkgs, ...}:{
|
||||||
|
services.prometheus.exporters.i2pd = {
|
||||||
|
enable = true;
|
||||||
|
port = 3321;
|
||||||
|
openFirewall = true;
|
||||||
|
routerAddress = "https://127.0.0.1:7650";
|
||||||
|
routerPassword = "itoopie";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Scrape via prometheus
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, config, ... }: {
|
||||||
|
|
||||||
|
services.prometheus = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "i2p";
|
||||||
|
scrape_interval = "5s";
|
||||||
|
static_configs = [
|
||||||
|
{
|
||||||
|
targets = [ "localhost:${toString config.services.prometheus.exporters.i2pd.port}" ];
|
||||||
|
labels = { alias = "i2pd.server.local"; };
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Import the grafana dashboard
|
||||||
|
**todo**
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
|
@ -40,12 +40,17 @@ async fn main() {
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
||||||
|
loop {
|
||||||
|
|
||||||
match client.auth().await {
|
match client.auth().await {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
println!("Failed to authenticate: {:?}", error)
|
println!("Failed to authenticate: {:?}", error)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Bulding metrics
|
// Bulding metrics
|
||||||
let builder = PrometheusBuilder::new();
|
let builder = PrometheusBuilder::new();
|
||||||
builder
|
builder
|
||||||
|
|
Loading…
Reference in a new issue