2018-07-21 13:34:59 -06:00
|
|
|
source: Alerting/Creating-Transport.md
|
2018-10-27 23:04:34 +01:00
|
|
|
path: blob/master/doc/
|
2018-07-21 13:34:59 -06:00
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
# Creating a new Transport
|
2018-07-21 13:34:59 -06:00
|
|
|
|
2019-10-21 02:47:40 +02:00
|
|
|
## File location
|
2019-06-20 13:53:45 -05:00
|
|
|
|
|
|
|
All transports are located in `LibreNMS\Alert\Transport` and the files
|
|
|
|
are named after the Transport name. I.e `Discord.php` for Discord.
|
|
|
|
|
2019-10-21 02:47:40 +02:00
|
|
|
## Transport structure
|
2019-06-20 13:53:45 -05:00
|
|
|
|
2018-07-21 13:34:59 -06:00
|
|
|
The following functions are required for a new transport to pass the unit tests:
|
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
`deliverAlert()` - This is function called within alerts to invoke the
|
|
|
|
transport. Here you should do any post processing of the transport
|
|
|
|
config to get it ready for use.
|
2018-07-21 13:34:59 -06:00
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
`contact$Transport()` - This is named after the transport so for
|
|
|
|
Discord it would be `contactDiscord()`. This is what actually
|
|
|
|
interacts with the 3rd party API, invokes the mail command or whatever
|
|
|
|
you want your alert to do.
|
2018-07-21 13:34:59 -06:00
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
`configTemplate()` - This is used to define the form that will accept
|
|
|
|
the transport config in the webui and then what data should be
|
|
|
|
validated and how. Validation is done using [Laravel validation](https://laravel.com/docs/5.7/validation)
|
|
|
|
|
|
|
|
The following function is __not__ required for new Transports and is
|
|
|
|
for legacy reasons only. `deliverAlertOld()`.
|
2018-07-21 13:34:59 -06:00
|
|
|
|
2019-10-21 02:47:40 +02:00
|
|
|
## Documentation
|
2018-07-21 13:34:59 -06:00
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
Please don't forget to update the [Transport](Transports.md) file to
|
|
|
|
include details of your new transport.
|
|
|
|
|
|
|
|
A table should be provided to indicate the form values that we ask for
|
|
|
|
and examples. I.e:
|
2018-07-21 13:34:59 -06:00
|
|
|
|
2019-10-21 02:47:40 +02:00
|
|
|
|Config | Example|
|
2018-07-21 13:34:59 -06:00
|
|
|
------ | -------
|
2019-10-21 02:47:40 +02:00
|
|
|
Discord URL | <https://discordapp.com/api/webhooks/4515489001665127664/82-sf4385ysuhfn34u2fhfsdePGLrg8K7cP9wl553Fg6OlZuuxJGaa1d54fe>|
|
|
|
|
Options | username=myname|
|
|
|
|
|