Skip to main content

mqttwarn - subscribe to MQTT topics and notify pluggable services

Project description

https://github.com/jpmens/mqttwarn/workflows/Tests/badge.svg https://codecov.io/gh/jpmens/mqttwarn/branch/main/graph/badge.svg https://img.shields.io/pypi/pyversions/mqttwarn.svg https://img.shields.io/pypi/v/mqttwarn.svg https://img.shields.io/pypi/l/mqttwarn.svg https://img.shields.io/pypi/status/mqttwarn.svg https://pepy.tech/badge/mqttwarn/month https://cloud.githubusercontent.com/assets/2345521/6320105/4dd7a826-bade-11e4-9a61-72aa163a40a9.png

mqttwarn

To warn, alert, or notify.

https://raw.githubusercontent.com/jpmens/mqttwarn/main/assets/google-definition.jpg

About

mqttwarn - subscribe to MQTT topics and notify pluggable services.

Description

mqttwarn subscribes to any number of MQTT topics and publishes received payloads to one or more notification services after optionally applying sophisticated transformations.

A picture says a thousand words.

https://raw.githubusercontent.com/jpmens/mqttwarn/main/assets/mqttwarn.png

Notification service coverage

mqttwarn comes with over 70 notification handler plugins for a wide range of notification services and is very open to further contributions. You can enjoy the alphabetical list of plugins on the mqttwarn notifier catalog page.

On top of that, it integrates with the excellent Apprise notification library. Apprise notification services has a complete list of the 80+ notification services supported by Apprise.

Documentation

The mqttwarn documentation is the right place to read all about mqttwarn’s features and integrations, and how you can leverage all its framework components for building custom applications. Its service plugins can be inspected on the mqttwarn notifier catalog page.

Installation

Using pip

Synopsis:

pip install --upgrade mqttwarn

You can also add support for a specific service plugin:

pip install --upgrade 'mqttwarn[xmpp]'

You can also add support for multiple services, all at once:

pip install --upgrade 'mqttwarn[apprise,asterisk,nsca,desktopnotify,tootpaste,xmpp]'

See also: Installing mqttwarn with pip.

OCI container image

For running mqttwarn on a container infrastructure like Docker or Kubernetes, corresponding images are automatically published to the GitHub Container Registry (GHCR).

  • ghcr.io/jpmens/mqttwarn-standard:latest

  • ghcr.io/jpmens/mqttwarn-full:latest

To learn more about this topic, please follow up reading the Using the OCI image with Docker or Podman documentation section.

Configuration

In order to learn how to configure mqttwarn, please head over to the documentation section about the mqttwarn configuration.

Usage

Running interactively

Just launch mqttwarn:

# Run mqttwarn
mqttwarn

To supply a different configuration file or log file, optionally use:

# Define configuration file
export MQTTWARNINI=/etc/mqttwarn/acme.ini

# Define log file
export MQTTWARNLOG=/var/log/mqttwarn.log

# Run mqttwarn
mqttwarn

Running notification plugins

For debugging, or other purposes, you might want to directly run an individual notification plugin without the dispatching and transformation machinery of mqttwarn.

We have you covered. To launch a plugin standalone, those commands will give you an idea how to pass relevant information on the command line using JSON:

# Launch "log" service plugin
mqttwarn --plugin=log --options='{"message": "Hello world", "addrs": ["crit"]}'

# Launch "file" service plugin
mqttwarn --plugin=file --options='{"message": "Hello world\n", "addrs": ["/tmp/mqttwarn.err"]}'

# Launch "pushover" service plugin
mqttwarn --plugin=pushover --options='{"title": "About", "message": "Hello world", "addrs": ["userkey", "token"], "priority": 6}'

# Launch "ntfy" service plugin
mqttwarn --plugin=ntfy --options='{"addrs": {"url": "http://localhost:5555/testdrive"}, "title": "Example notification", "message": "Hello world"}' --data='{"tags": "foo,bar,äöü", "priority": "high"}'

# Launch "ntfy" service plugin, and add remote attachment
mqttwarn --plugin=ntfy --options='{"addrs": {"url": "http://localhost:5555/testdrive"}, "title": "Example notification", "message": "Hello world"}' --data='{"attach": "https://unsplash.com/photos/spdQ1dVuIHw/download?w=320", "filename": "goat.jpg"}'

# Launch "ntfy" service plugin, and add attachment from local filesystem
mqttwarn --plugin=ntfy --options='{"addrs": {"url": "http://localhost:5555/testdrive", "file": "goat.jpg"}, "title": "Example notification", "message": "Hello world"}'

# Launch "ssh" service plugin
mqttwarn --plugin=ssh --config='{"host": "ssh.example.org", "port": 22, "user": "foo", "password": "bar"}' --options='{"addrs": ["command with substitution %s"], "payload": "{\"args\": \"192.168.0.1\"}"}'

# Launch "cloudflare_zone" service plugin from "mqttwarn-contrib"
pip install mqttwarn-contrib
mqttwarn --plugin=mqttwarn_contrib.services.cloudflare_zone --config='{"auth-email": "foo", "auth-key": "bar"}' --options='{"addrs": ["0815", "www.example.org", ""], "message": "192.168.0.1"}'

Also, the --config-file parameter can be used to optionally specify the path to a configuration file.

Running as system daemon

There are different ways to run mqttwarn as a system daemon. There are examples for systemd, traditional init, OpenRC, and Supervisor in the etc directory of this repository, for example supervisor.ini (Supervisor) and mqttwarn.service (systemd).

Running in a development sandbox

For hacking on mqttwarn, please install it in development mode, using a mqttwarn development sandbox installation.

Project information

About

These links will guide you to the source code of mqttwarn and its documentation.

Requirements

You will need at least the following components:

  • Python 3.x or PyPy 3.x.

  • An MQTT broker. We recommend Mosquitto.

  • For invoking specific service plugins, additional Python modules may be required. See setup.py file.

Contributing

We are always happy to receive code contributions, ideas, suggestions and problem reports from the community.

So, if you would like to contribute, you are most welcome. Spend some time taking a look around, locate a bug, design issue or spelling mistake, and then send us a pull request or create an issue.

Thank you in advance for your efforts, we really appreciate any help or feedback.

License

mqttwarn is copyright © 2014-2023 Jan-Piet Mens and contributors. All rights reserved.

It is and will always be free and open source software.

Use of the source code included here is governed by the Eclipse Public License 2.0, see LICENSE file for details. Please also recognize the licenses of third-party components.

Troubleshooting

If you encounter any problems during setup or operations or if you have further suggestions, please let us know by opening an issue on GitHub. Thank you already.

Attributions

Acknowledgements

Thanks to all the contributors of mqttwarn who helped to conceive it in one way or another. You know who you are.

Download files

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

Source Distribution

mqttwarn-0.34.0.tar.gz (86.7 kB view hashes)

Uploaded Source

Built Distribution

mqttwarn-0.34.0-py3-none-any.whl (119.1 kB view hashes)

Uploaded Python 3

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