Messages with webhooks or api call instead of emails

23 views
Skip to first unread message

Giacomo Gorgellino

unread,
Jun 5, 2020, 9:28:34 AM6/5/20
to bareos...@googlegroups.com

Hi,

it would be highly appreciated if bareos could send notifications via webhooks or web API. AFAIK "Messages" directive only supports email.
Can "Mail Command" be customized to use eg cURL?

Let say.. something similar to:

Messages {
  Name = webhook_ERM
  Mail Command = "curl -vs -H \"Content-Type: application/json\" -X POST -d '{\"JobName\": \"%n\", \"JobId\": \"%i\", \"ExitStatus\": \"%e\", \"Message\": \"Job %n - id %i is ended with Exit code %e\"}' \"http://mywebhookserver/invoke?token=supertokenhere\""

  mail on error = bac...@risorsa.com = all, !skipped, !audit
  console = all, !skipped, !saved, !audit
  append = "/var/log/bareos/bareos.log" = all, !skipped, !saved, !audit
  catalog = all, !skipped, !saved, !audit

}

Can it work?

Jörg Steffens

unread,
Jun 8, 2020, 12:47:28 PM6/8/20
to bareos...@googlegroups.com
On 05.06.20 at 15:28 wrote Giacomo Gorgellino:
> Hi,
>
> it would be highly appreciated if bareos could send notifications via
> webhooks or web API. AFAIK "Messages" directive only supports email.
> Can "Mail Command" be customized to use eg cURL?

Yes, this can work. Alternatively you can use after job RunScripts. If
more advanced features are required, plugins can be used/created. There
are already similar plugins, like
https://github.com/bareos/bareos-contrib/tree/master/dir-plugins/nagios_icinga
(sending a notification to Icinga after the job), ...

>
> Let say.. something similar to:
>
> Messages {
>   Name = webhook_ERM
>   Mail Command = "curl -vs -H \"Content-Type: application/json\" -X POST
> -d '{\"JobName\": \"%n\", \"JobId\": \"%i\", \"ExitStatus\": \"%e\",
> \"Message\": \"Job %n - id %i is ended with Exit code %e\"}'
> \"http://mywebhookserver/invoke?token=supertokenhere\""
>
>   mail on error = bac...@risorsa.com = all, !skipped, !audit
>   console = all, !skipped, !saved, !audit
>   append = "/var/log/bareos/bareos.log" = all, !skipped, !saved, !audit
>   catalog = all, !skipped, !saved, !audit
>
> }
>
> Can it work?
>
> --
> You received this message because you are subscribed to the Google
> Groups "bareos-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bareos-users...@googlegroups.com
> <mailto:bareos-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bareos-users/916b2acb-c0b6-f0a3-2d00-65b0582641f6%40risorsa.com
> <https://groups.google.com/d/msgid/bareos-users/916b2acb-c0b6-f0a3-2d00-65b0582641f6%40risorsa.com?utm_medium=email&utm_source=footer>.


--
Jörg Steffens joerg.s...@bareos.com
Bareos GmbH & Co. KG Phone: +49 221 630693-91
http://www.bareos.com Fax: +49 221 630693-10

Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRA 29646
Komplementär: Bareos Verwaltungs-GmbH
Geschäftsführer:
S. Dühr, M. Außendorf, Jörg Steffens, P. Storz

Reply all
Reply to author
Forward
0 new messages