Support for Gotify

Thx for the information / workaround but I really would prefer a combobox (Email, Gotify) on the UI with the option to set the Gotify token.

This would allow not so tech-savvy people to be able to use it as well.
 
Why gotify though? And why doesn't it has a mail -> gotify bridge itself, would seem to have more use than every project using mail notifications adding support for a not widely spread or standard project?
 
Currently it can be integrated very easily in any project which supports `curl`.

We use it for important notifications (backup failure, updates) and emails can remain unnoticed very easily.

I'm ok to use the workaround, did it similar for several projects.

How would you make this work on a proxmox host using `/root/.forward`, especially, how to get the `SUBJECT` and `MESSAGE` from proxmox (from the email content?) and having emails still work ;)

```sh
#!/bin/bash

SUBJECT=$1
MESSAGE=$2

curl -X POST "https://gotify.myserver.com/message?token=A92DJAD83DA0" -F "title=$SUBJECT" -F "message=$MESSAGE" -F "priority=5" > /dev/null 2>&1
```
 
Last edited:
@t.lamprecht I added the script to `/usr/bin/gotify.sh` (chown 0:33, chmod 755)

```sh
#!/bin/bash

ALERTSENDTO="A92DJAD83DA0"
ALERTSUBJECT="Proxmox"
ALERTMESSAGE=$1

curl -X POST "https://gotify.myserver.com/message?token=$ALERTSENDTO" -F "title=$ALERTSUBJECT" -F "message=$ALERTMESSAGE" -F "priority=5" > /dev/null 2>&1
```

This works when executing `sh /usr/bin/gotify.sh "Test"`.

Then I added `|/usr/bin/gotify.sh` to `/root/.forward`.

But when starting a manual backup and set an email address, it won't work (email works). May be you got an idea what is missing?
 
Last edited:
What about support for markdown formatting on the forum? ^^

What about good old BB codes ;) use [code=bash][/code] tags :)

Currently it can be integrated very easily in any project which supports `curl`.

That it can be integrated is out of question, everything can in someway, it's just bits after all.
The question is, why that one, and why it has no mail bridge, that would help much more projects and be less work for all.

Look, I do not want to plainly reject this, but feature creep is a real thing and if we integrate something like that I want some good reasons about why this one and what the alternatives are.

How would you make this work on a proxmox host using `/root/.forward`, especially, how to get the `SUBJECT` and `MESSAGE` from proxmox (from the email content?) and having emails still work

I mean, you proposed a selector for either email or gotify, so I did not expect that you would want to keep mail working, albeit with .forward that can be also done just fine.

Currently the .forward file looks like:
Bash:
|/usr/bin/pvemailforward
That is the one reading the user config, getting the configured mail from root@pam and forwarding it to there.

just add a line starting with the pipe symbol (to note you want to pipe the mail through a external program) and put down the full path of your executable bash script, or whatever. For example:

Bash:
|/usr/bin/pvemailforward
|/usr/local/bin/forward-to-gotify

You get the mail in mail form over STDIN, so there's that.. Mail parsing isn't straight forward but just getting the subject can even be done with a shell script easily (but still heuristically)

Bash:
#!/bin/bash

subject="$(grep -P '^SUBJECT:' - | cut -d' ' -f2-)"

echo "$subject" # do whatever with the subject

Else using python, perl, ... with a existing mail module would work for more elaborate tasks.

A simple test would be:
echo 'SUBJECT: foo bar' | /usr/sbin/sendmail -bm -N never -f root root@localhost
 
  • Like
Reactions: Stoiko Ivanov
But when starting a manual backup and set an email address, it won't work. May be you got an idea what is missing?

this is only used for root@localhost as it's an user forward, but PVE will send things like mails about package updates, HA events, .. to that address, as our mailforwarder then gets the current admin (root@pam) mail address from the config and relays to that one.
 
Isn;t it maybe easier to send to Slack or Mattermost team?

We didn't want another chat application. Gotify is simple and very good for notifications only.

We have the option to push messages to a prosody / XMPP server as well but decided to go with Gotify for it's simplicity.
 
I'd also be interested in a Mattermost implementation. Could you please share your gotify stuff? Mattermost has also a curl-based interface, so this should be interchangeable.

Yes, I think this should work similar.

Sorry it's markdown formatted ;)

--

# Gotify notifications

Proxmox can be setup to send notifications to a gotify server.

Copy the following script `gotify.sh` to `/usr/bin/gotify.sh`.

```sh
#!/bin/bash

ALERTSENDTO="A92DJAD83DA0"
ALERTSUBJECT="Proxmox"
ALERTMESSAGE="$(grep -P '^SUBJECT:' - | cut -d' ' -f2-)"

curl -X POST "https://gotify.myserver.com/message?token=$ALERTSENDTO" -F "title=$ALERTSUBJECT" -F "message=$ALERTMESSAGE" -F "priority=5" > /dev/null 2>&1
```

Set same owner and permissions as `/usr/bin/pvemailforward`.

```sh
chown 0:33 /usr/bin/gotify.sh
chmod 755 /usr/bin/gotify.sh
```

Add `|/usr/bin/gotify.sh` to `/root/.forward`.

It can be tested using the following command.

```sh
echo 'SUBJECT: foo bar' | /usr/sbin/sendmail -bm -N never -f root root@localhost
```

--

For now we will test it extracting the subject only, it may be sufficent for our use case.
 
Last edited:
  • Like
Reactions: antektek and uiffiu
Yes, I think this should work similar.

Sorry it's markdown formatted ;)

--

# Gotify notifications

Proxmox can be setup to send notifications to a gotify server.

Copy the following script `gotify.sh` to `/usr/bin/gotify.sh`.

```sh
#!/bin/bash

ALERTSENDTO="A92DJAD83DA0"
ALERTSUBJECT="Proxmox"
ALERTMESSAGE="$(grep -P '^SUBJECT:' - | cut -d' ' -f2-)"

curl -X POST "https://gotify.myserver.com/message?token=$ALERTSENDTO" -F "title=$ALERTSUBJECT" -F "message=$ALERTMESSAGE" -F "priority=5" > /dev/null 2>&1
```

Set same owner and permissions as `/usr/bin/pvemailforward`.

```sh
chown 0:33 /usr/bin/gotify.sh
chmod 755 /usr/bin/gotify.sh
```

Add `|/usr/bin/gotify.sh` to `/root/.forward`.

It can be tested using the following command.

```sh
echo 'SUBJECT: foo bar' | /usr/sbin/sendmail -bm -N never -f root root@localhost
```

--

For now we will test it extracting the subject only, it may be sufficent for our use case.

Sorry for the thread dig, but anyone have an idea on how to make this work with PBS? PBS is missing the file/root/.forward
 
Last edited:
  • Like
Reactions: uiffiu

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!