mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* fix a few bare URLs * make mdl happy * make Weathermap.md as mdl happy as possible * make Varnish.md as mdl happy as possible * make Two-Factor-Auth.md mdl happy * touch one header for Syslog.md, but little can be done about the rest * make Sub-Directory.md as mdl happy as possible * make SNMP-Trap-Handler.md lint happy * make SNMP-Proxy.md mdl happy * make Smokeping.md as mdl happy as possible * make Services.md mdl happy * make RRDTune.md mdl happy * cleanup RRDCached.md as much as possible * make RRDCached-Security.md mdl happy * make Rancid.md as mdl happy as possible * make Proxmox.md mdl happy * make Plugin-System.md as mdl happy as possible * make PeeringDB.md mdl happy * make Oxidized.md more lint happy * make Network-Map.md mdl happy * make MIB-based-polling.md as mdl happy as possible * make Metric-Storage.md mdl happy * make IRC-Bot.md as mdl happy as possible * make IRC-Bot-Extensions.md as mdl happy as possible * make * make Graylog.md mdl happy * make Gateone.md mdl happy * make Fast-Ping-Check.md mdl happy * make Distributed-Poller.md as mdl happy as possible * make Dispatcher-Service.md as mdl happy as possible * make Device-Groups.md mdl happy * make Dell-OpenManage.md mdl happy * make Dashboard.md mdl happy * make Customizing-the-Web-UI.md as mdl happy as possible * make Component.md mdl happy * make Billing-Module.md mdl happy * make Auto-Discovery.md mostly mdl happy * make Authentication.md as mdl happy as possible * tidy up a few lines in Applications.md * make Agent-Setup.md as mdl happy as possible * make metrics/OpenTSDB.md mdl happy * spelling fix
97 lines
3.0 KiB
Markdown
97 lines
3.0 KiB
Markdown
source: Extensions/Plugin-System.md
|
|
path: blob/master/doc/
|
|
|
|
# Developing for the Plugin System
|
|
|
|
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.
|
|
|
|
# Generic structure
|
|
|
|
Plugins need to be installed into html/plugins
|
|
|
|
The structure of a plugin is follows:
|
|
|
|
```
|
|
html/plugins
|
|
/PluginName
|
|
/PluginName.php
|
|
/PluginName.inc.php
|
|
```
|
|
|
|
The above structure is checked before a plugin can be installed.
|
|
|
|
All files / folder names are case sensitive and must match.
|
|
|
|
PluginName - This is a directory and needs to be named as per the
|
|
plugin you are creating.
|
|
|
|
- PluginName.php :: This file is used to process calls into the plugin
|
|
from the main LibreNMS install. Here only functions within the class
|
|
for your plugin that LibreNMS calls will be executed. For a list of
|
|
currently enabled system hooks, please see further down. The minimum
|
|
code required in this file is (replace Test with the name of your
|
|
plugin):
|
|
|
|
```
|
|
<?php
|
|
|
|
class Test {
|
|
}
|
|
|
|
?>
|
|
```
|
|
|
|
- PluginName.inc.php :: This file is the main included file when
|
|
browsing to the plugin itself. You can use this
|
|
to display / edit / remove whatever you like. The
|
|
minimum code required in this file is:
|
|
|
|
```
|
|
<?php
|
|
|
|
?>
|
|
```
|
|
|
|
# System Hooks
|
|
|
|
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).
|
|
|
|
```
|
|
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>');
|
|
}
|
|
```
|