Gotify - an open source project for delivering notifications and sending messages to the server



    For those who administer servers and / or web projects, there is an acute question of awareness about what is happening with their “wards”. There are a lot of decisions on the market about alerts about failures, connection status and other parameters, including via SMS. We are talking about MRTG, Twilio, F-Droid, Google services and many, many others. The only problem is that most of these solutions are very narrowly specialized, and it is not possible to influence their functions. MRTG will give information about traffic and connection, Google will send SMS. Twilio gives some freedom in terms of writing JavaScript scripts to fit your needs, but I'm sorry, this is a commercial project. That is, "come on, pay the loot or go away."

    So, in this family of tools, we have open source replenishment: Gotify is a simple client-server project for receiving and sending push notifications and commands, including through an Android application. And it’s definitely worth telling a little more about it, I think it will come in handy for those who were looking for something similar and at the same time free, but eventually started their own pet-project. It is possible this publication will save you a couple of hundred hours of your time.

    What Gotify Offers


    The project has been existing and developing peacefully on GitHub for several years, and during this time it acquired a server, a web client, an Android application, an API, and, of course, documentation. I decided to talk about Gotrify for two reasons: it is open source and works not only on “reception”, but also on “return”, all sorts are on GitHub, plus it is configured using bash scripts. And of course, it's free.

    Most existing solutions are aimed exclusively at receiving notifications from the target server / device, but not at full interaction between the client and server. That is, you may receive a notification that your server has crashed or the Internet has disappeared. It’s not always convenient to ask yourself what is happening on the “other side” and can be done in the same application / window. Most often, to obtain this kind of information, you have to cut off a VPN or (God forbid) some TeamViever and watch it “with your hands”. I mentioned above that Twilio gives some scope through self-written JS scripts, but it’s paid, so by.

    In fact, the entire Gotify project is divided into three parts: server, client, and application. The server works understandably how - to send and receive messages, the client - only to receive, and the application - only to send.



    In addition, the project has an API client (and documentation), an API template, a plugin template, its own website, Go configuration library that supports JSON, YAML, TOML and environment variables, as well as a server build, client and, in fact , Android application. The only thing that may bother is the Android app. There is nothing more helpless, irresponsible and immoral in the world than monitoring infrastructure through a mobile phone. But technology is advancing and we know that sooner or later we will move on to this rubbish. Not that it was the minimum necessary set to communicate remotely with the server, but when the open source community begins to cut its own tools, it is difficult for it to stop.

    Separately, it is worth mentioning that to communicate with the server you need only authentication and the application token, which is returned by the server through a REST request. In the future, using this token, you can receive messages through any http client, for example, through curl or HTTPie :

    $ curl -X POST "https://push.example.de/message?token=" -F "title=my title" -F "message=my message" -F "priority=5"
    $ http -f POST "https://push.example.de/message?token=" title="my title" message="my message" priority="5"

    According to the manual on the project’s official website, push to the server with different priorities can be sent to both Golang and Python:

    Golang

    package main
    import (
            "net/http"
            "net/url"
    )
    func main() {
        http.PostForm("http://localhost:8008/message?",
            url.Values{"message": {"My Message"}, "title": {"My Title"}})
    }

    Python

    import requests #pip install requests
    resp = requests.post('http://localhost:8008/message?token=', json={
        "message": "Well hello there.",
        "priority": 2,
        "title": "This is my title"
    })

    Also for Linux and Mac, writing your own plugins is also possible. Here are their available features, which are listed on the project website:

    • individual plugins for each user;
    • registration of custom http handlers;
    • sending messages as an application;
    • YAML-based configuration system in WebUI;
    • persistent storage for each user plugin;
    • Display dynamically generated instructions for users.

    The Gotify plugin system is based on the standard Go plugin system, which is described here . Why can they be used in Gotify? developers cite the example of receiving webhooks from GitHub, Travis CI and others, polling feeds via RSS, Atom sources and expanding the standard functionality of WebUI, and of course delivery of alert alerts about crashes. On this page you can find a template for the plugin and explanation of the code. For plug-ins to work correctly, developers recommend using Docker, but without it, it is quite possible to configure Gotify to work, although the correct sending and receiving of messages in this case is not guaranteed.

    I did not give here the full text of the basic documentation for the project - you can read everything yourself. Judging by the reviews, the project turned out to be quite thoughtful, at least on the other hand, that SMS notification is not used (which is inconvenient if you are abroad or in the basement), actively trying to ignore the power-safe mode that was brought in Android 6-7 . Gotify is curious even if it is open source, that is, free and nothing prevents to fork, pick up a file and bring this tool to a state suitable for the needs of certain people / teams.



    References


    1. GitHub repository.
    2. The official site of the project.
    3. API documentation.

    Also popular now: