Skip to main content

A proxy to forward messages received via HTTP to MESHTASTIC

Project description

Alertmanager webhook for meshtastic

linux/amd64 dockerhub github pypi

This little Adapter receives alertmanager webhooks and sends the notifications via a over serial attached Meshtastic device to the specified nodeID.

Warning Caution: The Tests that are provided for the code in this repository are not currently updated! Also this is a quickly hacked together peace of software, that has not built any security in it at the moment. Also the way that the ack is checked is not optimal, so messages tend to take longer to get to the device, but are delivered for sure(maybe multiple times). If you have the skill and the time to contribute in any way, take a look at the Contribution section

Credits

This is based on the work of https://github.com/homeworkprod/weitersager Thanks to GUVWAF for the support and thanks to the whole meshtastic team for this awsome software!

Alertmanager configuration example

	receivers:
	- name: 'meshtastic-webhook'
	  webhook_configs:
	  - url: http://alertmanager-meshtastic:9119/alert
	    send_resolved: true

config.toml example

This is an example config, that shows all of the config options.

log_level = "debug"

[http]
host = "0.0.0.0"
port = 9119

[meshtastic.connection]
tty = "/tmp/vcom0"
nodeid = 631724152
maxsendingattempts = 30
timeout = 60

docker compose service example - Hardware Serial (default)

To integrate this bridge into your composed prometheus/alertmanager cluster, this is a good startingpoint.

    alertmanagermeshtastic:
      image: apfelwurm/alertmanagermeshtastic
      ports:
        - 9119:9119
      devices:
        -/dev/ttyACM0
      volumes:
        - ./alertmanager-meshtastic/config.toml:/app/config.toml
      restart: always

docker compose service example - Virtual Serial

To integrate this bridge into your composed prometheus/alertmanager cluster, this is a good startingpoint. If you plan to use a virtual serial port that is provided with socat you have to use the socat connector in this container or run your alertmanagermeshtastic instance on the terminating linux machine, because the reconnecting is not working if you either mount it as volume or as a device.

    alertmanagermeshtastic:
      image: apfelwurm/alertmanagermeshtastic
      ports:
        - 9119:9119
      environment:
        - SOCAT_ENABLE=TRUE
        - SOCAT_CONNECTION=tcp:192.168.178.46:5000
      volumes:
        - ./alertmanager-meshtastic/config.toml:/app/config.toml
      restart: always

Note: If you set SOCAT_ENABLE to TRUE, the tty option from [meshtastic.connection] in config.toml will be overwritten with /tmp/vcom0 as thats the virtual serial port.

Running on docker example - Hardware Serial (default)

    docker run -d --name alertmanagermeshtastic \
		--device=/dev/ttyACM0 \
		-v ./alertmanager-meshtastic/config.toml:/app/config.toml \
    -p 9119:9119 apfelwurm/alertmanagermeshtastic:latest

Running on docker example - Virtual Serial

If you plan to use a virtual serial port that is provided with socat you have to use the socat connector in this container or run your alertmanagermeshtastic instance on the terminating linux machine, because the reconnecting is not working if you either mount it as volume or as a device.

    docker run -d --name alertmanagermeshtastic \
		--env SOCAT_ENABLE=TRUE --env SOCAT_CONNECTION=tcp:192.168.178.46:5000 \
		-v ./alertmanager-meshtastic/config.toml:/app/config.toml \
    -p 9119:9119 apfelwurm/alertmanagermeshtastic:latest

Note: If you set SOCAT_ENABLE to TRUE, the tty option from [meshtastic.connection] in config.toml will be overwritten with /tmp/vcom0 as thats the virtual serial port.

Contribution

This is currently a minimal implementation that supports only a single node as a receiver. If you need additional features, you are welcome to open an issue, or even better, submit a pull request. You can also take a look on the opened Issues, where i have opened some for planned features and work on them if you want. I would appreciate any help.

Example to test

You can use the test.sh or the test single.sh or the following curl command to test alertmanager-meshtastic

	curl -XPOST --data '{"status":"resolved","groupLabels":{"alertname":"instance_down"},"commonAnnotations":{"description":"i-0d7188fkl90bac100 of job ec2-sp-node_exporter has been down for more than 2 minutes.","summary":"Instance i-0d7188fkl90bac100 down"},"alerts":[{"status":"resolved","labels":{"name":"olokinho01-prod","instance":"i-0d7188fkl90bac100","job":"ec2-sp-node_exporter","alertname":"instance_down","os":"linux","severity":"page"},"endsAt":"2019-07-01T16:16:19.376244942-03:00","generatorURL":"http://pmts.io:9090","startsAt":"2019-07-01T16:02:19.376245319-03:00","annotations":{"description":"i-0d7188fkl90bac100 of job ec2-sp-node_exporter has been down for more than 2 minutes.","summary":"Instance i-0d7188fkl90bac100 down"}}],"version":"4","receiver":"infra-alert","externalURL":"http://alm.io:9093","commonLabels":{"name":"olokinho01-prod","instance":"i-0d7188fkl90bac100","job":"ec2-sp-node_exporter","alertname":"instance_down","os":"linux","severity":"page"}}' http://alertmanager-meshtastic:9119/alert

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alertmanagermeshtastic-2023.8.2.9.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file alertmanagermeshtastic-2023.8.2.9.tar.gz.

File metadata

File hashes

Hashes for alertmanagermeshtastic-2023.8.2.9.tar.gz
Algorithm Hash digest
SHA256 c390ab513f820f05f8713e51345ac0ecb6d89c9896df273682bbdafbe26ca79a
MD5 99eb661e0157c24bc3880ea91ec0d3ac
BLAKE2b-256 05839a0286d184f37996693f3aeab38d975569c56ae700bed647108c08457646

See more details on using hashes here.

File details

Details for the file alertmanagermeshtastic-2023.8.2.9-py3-none-any.whl.

File metadata

File hashes

Hashes for alertmanagermeshtastic-2023.8.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 24d8fdce2fb4b55c840c52c8d9d191137c4fe68774f3ec672f841df900cf8c56
MD5 b4122d89c8156d71278e960b5112ce54
BLAKE2b-256 5c2c07f412c32a51bfb0b7d9c0fb13ec2adce2e1e558d1145c836a5c1c4496dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page