Browse Source

add debian packaging and update readme

master
n0m1s 2 years ago
parent
commit
63c399c052
Signed by: nomis GPG Key ID: BC0454CAD76FE803
4 changed files with 91 additions and 5 deletions
  1. +19
    -0
      Cargo.toml
  2. +44
    -5
      README.md
  3. +20
    -0
      debian/config.toml
  4. +8
    -0
      debian/systemd/mqtt2statsd.service

+ 19
- 0
Cargo.toml View File

@ -1,6 +1,7 @@
[package] [package]
name = "mqtt2statsd" name = "mqtt2statsd"
description = "MQTT to StatsD bridge" description = "MQTT to StatsD bridge"
authors = [ "n0m1s <git@homnomnom.fr>" ]
license = "MIT" license = "MIT"
readme = "README.md" readme = "README.md"
homepage = "https://git.homnomnom.fr/nomis/mqtt2statsd" homepage = "https://git.homnomnom.fr/nomis/mqtt2statsd"
@ -8,6 +9,24 @@ repository = "https://git.homnomnom.fr/nomis/mqtt2statsd"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[package.metadata.deb]
license-file = [ "LICENSE.txt", "2" ]
depends = "$auto"
section = "utility"
revision = ""
extended-description = """\
A service that translates numeric MQTT messages into StatsD gauge metrics."""
maintainer-scripts = "debian/systemd"
systemd-units = { enable = false }
assets = [
[ "target/release/mqtt2statsd", "/usr/bin/", "755" ],
[ "README.md", "usr/share/doc/mqtt2statsd/README", "644"],
[ "debian/config.toml", "etc/mqtt2statsd/config.toml", "644"]
]
conf-files = [
"etc/mqtt2statsd/config.toml"
]
[dependencies] [dependencies]
clap = { version = "4.3", features = [ "derive", "cargo" ]} clap = { version = "4.3", features = [ "derive", "cargo" ]}
paho-mqtt = "0.12" paho-mqtt = "0.12"


+ 44
- 5
README.md View File

@ -2,10 +2,34 @@
mqtt2statsd is a service that translates numeric MQTT messages into statsd gauge metrics. mqtt2statsd is a service that translates numeric MQTT messages into statsd gauge metrics.
## Dependencies
## Installing and running
Ubuntu:
Currently, only supported on debian-based distributions.
For other distributions, see the "Building" section below.
Download the provided `.deb` file, and install it using `apt`:
```bash
$ sudo apt install ./mqtt2statsd_0.1.0_amd64.deb
``` ```
Configure the MQTT and StasD server, as well as the topics to subscribe to in the
configuration file `/etc/mqtt2statsd/config.toml`.
Once configured, enable and start the systemd service:
```bash
$ sudo systemctl enable mqtt2statsd.service
$ sudo systemctl start mqtt2statsd.service
```
## Configuration
mqtt2statsd is configured via a toml configuration file.
Check [example.toml](./example.toml) for an example configuration.
## Building
To build the package, you need the following dependencies (shown here for Ubuntu, actual package names may vary slightly)
```bash
$ sudo apt install \ $ sudo apt install \
libssl-dev \ libssl-dev \
pkg-config \ pkg-config \
@ -13,7 +37,22 @@ cmake \
gcc gcc
``` ```
## Configuration
Then, install the latest version of rust with `rustup` ([documentation here](https://rustup.rs/)).
mqtt2statsd is configured via a toml configuration file.
Check [example.toml](./example.toml) for an example configuration.
If building the debian package, install `cargo-deb` with:
```bash
$ cargo install cargo-deb
```
Clone the repository, and build the package:
```bash
$ git clone https://git.homnomnom.fr/nomis/mqtt2statsd.git
$ cd mqtt2statsd
$ cargo build --release
$ cargo deb # optional, if building deb package
```
You can now run the mqtt2statsd:
```bash
$ ./target/release/mqtt2statsd ./example.toml
```

+ 20
- 0
debian/config.toml View File

@ -0,0 +1,20 @@
# How to subscribe to the MQTT server
[mqtt]
hostname = "localhost"
#port = 1883 # optional, default: 1883
#timeout = 60 # in seconds, optional, default: 60
# Which Statsd server to send data to
[statsd]
hostname = "localhost"
#port = 8125 # optional, default: 8125
#prefix = "mqtt.stats" # optional, default: "mqtt.stats"
# List of topics to subscribe to, and corresponding stat
#[[topics]]
#mqtt = "$SYS/broker/messages/publish/sent"
#statsd = "publish_message_sent"
#
#[[topics]]
#mqtt = "$SYS/broker/clients/connected"
#statsd = "connected_clients"

+ 8
- 0
debian/systemd/mqtt2statsd.service View File

@ -0,0 +1,8 @@
[Unit]
Description=MQTT to StatsD bridge
[Service]
ExecStart=/usr/bin/mqtt2statsd /etc/mqtt2statsd/config.toml
[Install]
WantedBy=multi-user.target

Loading…
Cancel
Save