DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926` After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert. This patch allows you to avoid manually adding a transport to the list of available transports. In addition, in custom installations, where their own transports were added, the need to manually update the file "html/includes/modal/edit_alert_transport.inc.php" broke the automatic update (git detected a conflict and required manual solution). With this patch, you can avoid this, add local transports that remain outside the git repository and there is no need to create and maintain your fork in order to add your transports or add them to the upstream (they may have no value outside the local installation).
1.5 KiB
source: Alerting/Creating-Transport.md path: blob/master/doc/
Creating a new Transport.
File location
All transports are located in LibreNMS\Alert\Transport
and the files are named after the Transport name. I.e
Discord.php
for Discord.
Transport structure.
The following functions are required for a new transport to pass the unit tests:
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.
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.
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
The following function is not required for new Transports and is for legacy reasons only. deliverAlertOld()
.
Documentation
Please don't forget to update the Transport 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:
**Example:**
Config | Example
------ | -------
Discord URL | https://discordapp.com/api/webhooks/4515489001665127664/82-sf4385ysuhfn34u2fhfsdePGLrg8K7cP9wl553Fg6OlZuuxJGaa1d54fe
Options | username=myname