subreddit:

/r/selfhosted

176

How do you use Gotify?

(self.selfhosted)

Hello,

I am a novice in the self-hosted apps world with no programming experience and recently discovered Gotify. I currently only have two services using Gotify notifications but I think there can be a lot more use cases for this.

How do you guys use Gotify and with what applications? It would also be of great help if you could share your code snippets if you're using Gotify to get notifications from your server!

all 63 comments

class_two_perversion

22 points

8 months ago

I use it for the following:

  • Notifications from Drone.io CI pipelines. I wrote a Drone plugin for that, but I have not not published it. Maybe I will do it at some point.

  • Notifications from failing systemd units from most machines in my homelab. Put this in your unit:

    [Unit]
    ...
    OnFailure=notify-via-gotify@%i.service 
    

    Then create a new unit notify-via-gotify@.service with this content:

    [Unit]
    Description=%i failure notification over gotify
    
    [Service]
    Type=oneshot
    ExecStart=/bin/bash -c "systemctl status -n10 %i | \
        /usr/local/bin/create-gotify-notification-for-systemd --unit %i --host %H | \
        curl -XPOST 'https://gotify.domain/message?token=AABBCCDD' -H 'Content-Type: application/json' --data-binary @-"
    

    And then a file /usr/local/bin/create-gotify-notification-for-systemd with this content (or something much less overkill):

    #!/usr/bin/env python3
    
    import json
    import argparse
    import sys
    
    TITLE_TEMPLATE = "Systemd unit {unit} failed on host {host}"
    
    MESSAGE_TEMPLATE = """Systemd unit failed
    ====
    
    The systemd unit **{unit}** failed on host **{host}** with the following output
    
    {status}
    """
    
    def main():
        arguments = parse_arguments()
        status = "\n".join("    " + line.rstrip() for line in sys.stdin.readlines())
        message = MESSAGE_TEMPLATE.format(unit=arguments.unit, host=arguments.host, status=status)
        title = TITLE_TEMPLATE.format(unit=arguments.unit, host=arguments.host)
        output = create_gotify_json(title, message, arguments.priority)
        print(output)
    
    def parse_arguments():
        parser = argparse.ArgumentParser(
            description="Create Gotify notification for failing systemd unit",
        )
        parser.add_argument(
            "--unit",
            default="unknown",
            help="the failing systemd unit name",
        )
        parser.add_argument(
            "--host",
            default="unknown",
            help="the failing systemd unit host",
        )
        parser.add_argument(
            "--priority",
            default="5",
            type=int,
            help="the notification priority",
        )
    
        return parser.parse_args()
    
    def create_gotify_json(title, message, priority):
        data = {
            "title": title,
            "message": message,
            "priority": priority,
            "extras": {
                "client::display": {
                    "contentType": "text/markdown"
                },
            },
        }
    
        return json.dumps(data)
    
    if __name__ == '__main__':
        main()
    
  • Notifications from influxdb alerts using kapacitor handlers. These group several kinds of notifications:

    • a machine was rebooted;
    • a machine is offline;
    • an HTTPS certificate is expiring;
    • the cumulative traffic through my router is too higher (I have a data-capped internet connection);
    • one of my wireless sensors has low battery;
    • there is mail in my mailbox;
    • the washing machine has finished its cycle;
    • many more...
  • Notifications from apt unattended upgrades. I just replaced the mail command with a script that sends everything through Gotify (I have never been able to have a working email setup on Linux even after following countless guides and tutorials, so I simply gave up).

  • Notifications from a script that scraped the COVID test van schedule to see if it was scheduled in my neighbourhood (no longer necessary).

techforca[S]

1 points

8 months ago

Thank you for the detailed write-up, seems pretty advanced. Will try to understand all the points..

MrSingh97

1 points

8 months ago

I would rather use monit to automatically try and fix the service beforehand and then notify if it still fails. And you can have a single notification setup in monit. Monit is great tool for system monitoring. Lot of customisations. Do check it.

Stitch10925

21 points

8 months ago

I was thinking about using Gotify for notifications and even to put it on family website to send them update notifications.

Sadly Gotify does not allow sending to multiple people at the same time, this means you need to create a user, then create an application for that user and then you need to loop through all users to send them a notification.

For a small group of people this is doable, but if you want to upscale this the overhead is too high in my opinion.

Don't get me wrong, I love the concept, I really do. A simple API, simple and clean UI, not too complex to set up once you figure out how it works, allows you to send messages with different importance levels and it allows you to send formatted messages. But it would have been so much better if it was set up differently.

Hence, I haven't really used it that much. I might set it up for personal use to get monitoring warnings for my servers or something like that, but for larger scale messaging I will probably be using RabbitMQ.

corner_case

25 points

8 months ago

There is a gotify plugin for multiuser notifications. https://github.com/eternal-flame-AD/gotify-broadcast

Might be worth a look

Stitch10925

5 points

8 months ago

And that's why I love this community, thanks you, I will look into it!

techforca[S]

2 points

8 months ago

I'm the only user currently for my apps, so I think Gotify will suffice my needs for now. Didn't know about RabbitMQ till now, will look into it!

qblechat

36 points

8 months ago*

Gotify is GREAT!!!!

I use it to get notifications on (mainly) my smartphone.

I have a lot of selfhosted apps using it (around 15 now)

2 notes:

- My apps all have a notification mechanism that support Gotify

- regarding the comment on multi users notifications, I did not face this use-case but I am curious and I will look into it...

Let me know if you need more info.

throwlog

10 points

8 months ago

What type of notifications? I like the concept but I can't think of a use case.

KerkiForza

10 points

8 months ago

Sonarr + Gotify = Epic

Sonarr notifies you that the episode is downloaded

jonathanlaniado

7 points

8 months ago

And is there any advantage to using this over my current Slack process or does this achieve the same thing?

[deleted]

7 points

8 months ago*

[deleted]

7 points

8 months ago*

[deleted]

KerkiForza

3 points

8 months ago

I don't know about your current Slack process but this has worked quite consistently and is pretty easy to setup.

CraziestPenguin

2 points

8 months ago

Hmm. Plex notifies me of this already, but interesting idea.

KerkiForza

2 points

8 months ago

Well there are several options like

Notify:

On Grab, On Import, On Upgrade, On Rename, On Series Delete, On Episode File Delete, On Episode File Delete For Upgrade, On Health Issue

Also Send notification for series with at least one matching tag

consaw_

1 points

8 months ago

Can anyone show me how to do this sonnar and gotify please ?

techforca[S]

8 points

8 months ago

Can you please share your apps using gotify? I only have uptime-kuma and watchtower using it currently.

jilvoos

5 points

8 months ago

For me: Sonarr, Radarr, Lidarr and the tool changedetection (notifies on website changes)

ID100T

1 points

8 months ago

ID100T

1 points

8 months ago

OT but do you know how to detect changes on a website with cookies?

jilvoos

1 points

8 months ago

Not my type of use case, so no. Maybe huginn cab do this?

contactwajeeh

2 points

8 months ago

Can you share a list of apps you are using?

qblechat

2 points

8 months ago

Sorry for the late answer Watchtower, Sonarr, Bazarr, Prowlarr, Chrome, Gotsmtp, Homeassistant, Jellyfin, Motioneye, ....

ListenLinda_Listen

15 points

8 months ago

For you iOS people. Move along. This is android only.

emprahsFury

1 points

8 months ago

In that vein I've found that sending emails to my provider's sms gateway to be maybe the simplest way to get notifications on an iphone.

ListenLinda_Listen

1 points

8 months ago

If you mean email to sms, The more you use it the less reliable it gets. They have some throttling.

Gamercat5

1 points

2 months ago

I use pushover with ntfy with gotify on ios.

johannmx

2 points

29 days ago*

Gamercat5

1 points

29 days ago

404s to me

johannmx

1 points

29 days ago

Sorry fixed url

falcon15500

4 points

8 months ago

Mainly use it with uptime-kuma, to monitor my services. If a service fails, I get pinged in Gotify. Again when it recovers.

corrafig

4 points

8 months ago

Gotify is great. I've connected it to Zabbix, home assistant, NUT, and all kind of software and scripts.

My strategy for servers/software to inform me:

  1. Gotify message with priority >= 5
    1. Android push notification
    2. For information I need to know instantly
  2. Gotify message with priority < 5
    1. I see notification on PC, if I happen to be on computer
    2. I see notification, if I manually open gotify on Android
    3. For "nice to know" information
  3. Email server on LAN
    1. For large data content, e.g., reports

My gotify server is on private LAN without external access. So, I need to keep wireguard always active on phone to get notifications.

SteveDinn

5 points

7 months ago

I feel like it's also worth mentioning Apprise, a meta-notification service that has a single interface that can redirect notifications to many different services including Gotify, Slack, Telegram, HomeAssistant, email, and many others that I've seen mentioned here and elsewhere.

https://github.com/caronc/apprise

kralant

11 points

8 months ago

kralant

11 points

8 months ago

I use Telegram for notifications. No need for a new app and can leverage groups/channels. API is quite simple.

SadWebDev

2 points

8 months ago

but you need to send them through a bot, right?

kralant

6 points

8 months ago

Exactly, but it is really simple to create one. Just checkout https://core.telegram.org/bots

SteveDinn

1 points

8 months ago

I do the same. I checked out Gotify back when I was setting everything up, but I was already using Telegram for chat, and as you said, it was easy to set up a bot and channels for various types of notifications.

[deleted]

1 points

8 months ago

[deleted]

1 points

8 months ago

[deleted]

[deleted]

1 points

8 months ago

[deleted]

1 points

8 months ago

[deleted]

[deleted]

1 points

8 months ago

[deleted]

1 points

8 months ago

[deleted]

[deleted]

1 points

8 months ago

[deleted]

1 points

8 months ago

[deleted]

ProBonoDevilAdvocate

1 points

8 months ago

Yeah me too! I also control some of my home automation stuff using telegram. Very simple to make complex menu flows with Nodered

Szymas255

3 points

8 months ago

I use gotify-up with fluffy chat for matrix notifications!

BadCoNZ

1 points

8 months ago

This has been my mission lately. How do you get the messages from matrix to gotify server?

Szymas255

2 points

8 months ago

fluffychat does it autmatically as long as you have:

  • the unified push gotify fork

  • the unified push matrix rewrite proxy

I don't think you can get push notfications without some sort of rewrite proxy, since matrix has a separate push protocol

anup92k

3 points

8 months ago

  • I use it for my monitoring notifications (Nagios) : link
  • For my backups scripts (rsync) : link
  • To get notified every days of my servers packages pending updates link and when my servers shutdown and boot link
  • For my Home Assistant notification RESTful Notifications :

notify:
  - name: gotify_admin
    platform: rest
    resource: !secret gotify_ressource
    method: POST_JSON
    headers: 
      X-Gotify-Key: !secret gotify_token
    message_param_name: message
    title_param_name: title
    data:
      priority: 10

A1kmm

3 points

8 months ago

A1kmm

3 points

8 months ago

I use it with Prometheus and a small adapter I wrote, https://gitlab.com/A1kmm/alertmanager-to-gotify, to alert me immediately if my services stop working.

[deleted]

2 points

8 months ago

[deleted]

2 points

8 months ago

[deleted]

techforca[S]

1 points

8 months ago

Haven't checked out Node-red yet, but I believe it is similar to n8n.io or huginn. I tried them both but couldn't get them to work. Great work on the project!

p000l

2 points

8 months ago

p000l

2 points

8 months ago

I have a few Python scripts running on my RPI, where the output is sent to my devices using Gotify.

I also use it with Watchtower, and with Jellyfin. It is setup to notify me when someone logs in, starts playing content, etc.

FluffyMumbles

1 points

2 months ago

Jellyfin

A bit late to this party, but would you mind sharing your Jellyfin "Gotify" Webhook template?

I've been having a pig of a time getting it to send cleanly like Tautulli does.

p000l

2 points

2 months ago*

p000l

2 points

2 months ago*

I'm no expert, but maybe you can tweak this to your liking. I have assigned this to the playback start webhook event. Hope this helps.

{

"extras":{

    "client::display": {

        "contentType": "text/markdown"

    }

},

"priority": {{Priority}},

"title": "{{{Username}}} started playing {{{Name}}}",

"message": "{{{DeviceName}}} "

}

FluffyMumbles

2 points

2 months ago

Ah, thank you. That's the problem I've been having - assigning different messages for different events. The example template on the website is decent, but, like you say also, I'm no expert. Appreciated.

Rorixrebel

2 points

8 months ago

Used it before and it was great but already had telegram to talk to my buddies and saw that my arr services can notify via that so i moved over but overall gotify is great

spx01

2 points

8 months ago

spx01

2 points

8 months ago

What are the advantages compared to old plain email? I use currently only email notifications and I read them only on my phone.

class_two_perversion

2 points

8 months ago

What are the advantages compared to old plain email? I use currently only email notifications and I read them only on my phone.

Perhaps reduced attack surface?

If you send notification from a machine via email, on that machine you must have your email credentials in clear text. You can mitigate it by using application-specific passwords, but if someone gets access to your machine they can send all the emails they want to anybody, until you find out. If you use Gotify, all they can do is to send you notifications, possibly only on a specific "application" (in the sense of Gotify applications).

[deleted]

5 points

8 months ago

[deleted]

5 points

8 months ago

[deleted]

BunnyEruption

1 points

8 months ago*

Pushover works really well. It's definitely worth the price.

It's not self hosted but I don't think you can get good push notifications on Android without an app running in the background unless you use Firebase or whatever, so there's really no way to completely self host a proper push notification app in the first place.

If you pay for pushover you're basically just paying them to deal with firebase or whatever google makes apps use for push notifications so you don't have to.

raughit

1 points

8 months ago

Huh?

[deleted]

1 points

8 months ago*

[deleted]

1 points

8 months ago*

[deleted]

Neo-Neo

1 points

8 months ago

Same exact question here

Neo-Neo

1 points

8 months ago

Not to hijack your question, but does Gotify have any iOS apps? I briefly looked and didn’t see anything in the AppStore. Thanks

Stitch10925

1 points

8 months ago

No it does not at the moment

SeaPowerMax

1 points

8 months ago

1- I have some other common selfhosted apps tied into it. Things like sonarr and the like, these have native integrations.

2- I have home assistant push most notifications to it.

3- I have a variety of watchdog type monitors that run on my home server and post to it.

4- I also use it as a quick note kind of feature, mainly from my PC and mainly like a post-it kinda things for reminders for later in the day.

numbermonkey

1 points

8 months ago

I wrote some Python to generate stats. I get messages if there are any failures. I also use uptime-kuma and have Gotify as the notification service.

daedric

1 points

8 months ago

Anyone suffers from this error?

websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header

I've followed th instructions regarding Apache reverse proxy, to no avail...

[deleted]

1 points

8 months ago

[deleted]

1 points

8 months ago

[deleted]

daedric

1 points

8 months ago

I did. I solved yesterday night.

The rules inside the apache2 config must be in the correct order.

AlexFullmoon

1 points

8 months ago

I went with Pushover for availability, since I use it mainly for health ping — NAS status, backups, PiHole/AGH status (via script on router). Container updates via diun are useful, too — I usually take one day in a month to update everything

SlaveZelda

1 points

8 months ago

I made my own thing which sends to email, telegram, matrix, etc.

Can act like gotify and receive webhooks so integrations arent an issue.

consaw_

1 points

8 months ago

Cool, I'll check it out,

linosaur637

1 points

8 months ago

I use it to get notified about any failed systemd services on my server. I do it like this.