Giter Site home page Giter Site logo

mi-flower-exporter's Introduction

Mi Flower Exporter

How to use

Config file

Flower Exporter work with config file whose contain flower information (Name and Mac address).

You can find an example of a config file in: templates/config.yml.

Options

See options of Flower Exporter:

  • -c|--config: Config file
  • -p|--port (Optional): Port for the webserver scraped by Prometheus [Default: 9250]
  • -d|--debug (Optional): Debug Mode [Default: False]
  • --logs (Optional): Enable writing logs to a file [Default: False]
  • --log-path <path> (Optional): Log path [Default: /var/log/mi-flower-exporter]
  • --refresh-interval <seconds> (Optional): Refresh interval in seconds for data collect [Default: 1800]
  • --dump-path <path> (Optional): Path for the dumps [Default: /tmp/mi_flower_exporter.cache]

Run with systemctl

Ensure bluetooth service is running on your host:

systemctl status bluetooth

Customize (If needed) and copy service template to systemd services path.

sudo cp templates/mi-flower-exporter.service /lib/systemd/system/

Create config and log path:

sudo mkdir /{etc,var/log}/mi-flower-exporter

Customize and copy config file in config path:

sudo cp templates/config.yml /etc/mi-flower-exporter/

Reload, enable and start service:

sudo systemctl daemon-reload
sudo systemctl enable mi-flower-exporter
sudo systemctl start mi-flower-exporter

Check service status:

sudo systemctl status mi-flower-exporter

Once service is running, you can check data with following command:

curl 127.0.0.1:9250

Run with Docker

Ensure bluetooth service is stop on your host:

systemctl status bluetooth
systemctl disable bluetooth
systemctl stop bluetooth

Run container with privileged right, host's network and a config file with your flower info:

docker run --net=host --privileged -v $(pwd)/config.yml:/exporter/config.yml --name mi_flower_exporter -ti mi-flower-exporter

Once container is running, you can check data with the following command:

curl 127.0.0.1:9250

You can check exporter status with docker logs command.

Example:

$ docker logs mi_flower_exporter -f
Starting system message bus: dbus.
Starting bluetooth: bluetoothd.
2020/05/21 14:34:19  INFO    - Mi-Flower Exporter Start (PID:20) ..
2020/05/21 14:34:19  INFO    - Prometheus web server started: my_host:9250
2020/05/21 14:34:19  INFO    - Getting data from Flower_ext_1 [C4:00:00:00:00:01]
2020/05/21 14:34:19  INFO    - Getting data from Flower_ext_2 [C4:00:00:00:00:02]
2020/05/21 14:34:21  INFO    - Exporting Completed
2020/05/21 14:36:09  INFO    - Done getting data for Flower_ext_1
2020/05/21 14:36:13  INFO    - Done getting data for Flower_ext_2

Metrics

See a table with all available metrics:

Name Description Labels
mi_flower_collect Collect status mac, name
mi_flower_poll_time Poll time in seconds mac, name
mi_flower_battery Battery level mac, name
mi_flower_conductivity Conductivity level mac, name
mi_flower_light Light level in lux mac, name
mi_flower_moisture Moisture level mac, name
mi_flower_temperature Temperature in celsius mac, name

Output example:

mi_flower_collect{mac="C4:6C:9E:12:11:1F",name="my-flower"} 1.0
mi_flower_poll_time{mac="C4:6C:9E:12:11:1F",name="my-flower"} 2.24057789556204
mi_flower_battery{mac="C4:6C:9E:12:11:1F",name="my-flower"} 99.0
mi_flower_conductivity{mac="C4:6C:9E:12:11:1F",name="my-flower"} 102.0
mi_flower_light{mac="C4:6C:9E:12:11:1F",name="my-flower"} 8956.0
mi_flower_moisture{mac="C4:6C:9E:12:11:1F",name="my-flower"} 28.0
mi_flower_temperature{mac="C4:6C:9E:12:11:1F",name="my-flower"} 19.2

mi-flower-exporter's People

Watchers

Laurent-Alou Koné avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.