mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Added plugin support in the Port page (#8665)
* Added new plugin menu_option in the "port" page, which contain hook calling public function port_container($device, $port) in plugins * Cleaning after pre-commit error * New method in Plugins.php to allow counting all plugins implementing a specific hook. This allow conditionnal display of the plugin menu_option in the port view. * Typo after rebase * Update plugins.inc.php * Updating the documentation with device_overview_container and port_container hooks.
This commit is contained in:
committed by
Neil Lathwood
parent
f389500f65
commit
5c83d438c5
@@ -4,8 +4,9 @@ source: Extensions/Plugin-System.md
|
||||
> This will most likely be deprecated in favour of adding the possible extensions to the core code base.
|
||||
|
||||
This documentation will hopefully give you a basis for how to write a plugin for LibreNMS.
|
||||
A test plugin is included in LibreNMS distribution.
|
||||
|
||||
A test plugin is available on GitHub: https://github.com/laf/Test
|
||||
### Generic structure ###
|
||||
|
||||
Plugins need to be installed into html/plugins
|
||||
|
||||
@@ -48,17 +49,36 @@ PluginName.inc.php - This file is the main included file when browsing to the pl
|
||||
|
||||
### System Hooks ###
|
||||
|
||||
System hooks are called as functions within your plugin class, so for example to create a menu entry within the Plugin dropdown you would do:
|
||||
|
||||
```
|
||||
public function menu() {
|
||||
echo('<li><a href="plugin/p='.get_class().'">'.get_class().'</a></li>');
|
||||
}
|
||||
```
|
||||
|
||||
This would then add the name and a link to your plugin.
|
||||
|
||||
System hooks are called as functions within your plugin class.
|
||||
The following system hooks are currently available:
|
||||
|
||||
menu()
|
||||
* This is called to build the plugin menu system and you can use this to link to your plugin (you don't have to).
|
||||
* menu()
|
||||
* This is called to build the plugin menu system and you can use this to link to your plugin (you don't have to).
|
||||
```
|
||||
public static function menu() {
|
||||
echo('<li><a href="plugin/p='.get_class().'">'.get_class().'</a></li>');
|
||||
}
|
||||
```
|
||||
|
||||
* device_overview_container($device)
|
||||
* This is called in the Device Overview page. You receive the $device as a parameter, can do your work here and display your results in a frame.
|
||||
|
||||
```
|
||||
public function device_overview_container($device) {
|
||||
echo('<div class="container-fluid"><div class="row"> <div class="col-md-12"> <div class="panel panel-default panel-condensed"> <div class="panel-heading"><strong>'.get_class().' Plugin </strong> </div>');
|
||||
echo(' Example plugin in "Device - Overview" tab <br>');
|
||||
echo('</div></div></div></div>');
|
||||
}
|
||||
```
|
||||
|
||||
* port_container($device, $port)
|
||||
* This is called in the Port page, in the "Plugins" menu_option that will appear when your plugin gets enabled. In this function, you can do your work and display your results in a frame.
|
||||
|
||||
```
|
||||
public function port_container($device, $port) {
|
||||
echo('<div class="container-fluid"><div class="row"> <div class="col-md-12"> <div class="panel panel-default panel-condensed"> <div class="panel-heading"><strong>'.get_class().' plugin in "Port" tab</strong> </div>');
|
||||
echo ('Example display in Port tab</br>');
|
||||
echo('</div></div></div></div>');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user