diff --git a/Development-and-Testing.md b/Development-and-Testing.md new file mode 100644 index 0000000..338a558 --- /dev/null +++ b/Development-and-Testing.md @@ -0,0 +1,49 @@ +# Development and Testing + +## Choose the Source and Version + +Use the branch you intend to change in the application, plugin, and manual +repositories. This chapter describes Cacti's 1.2.x branch. +Read its [Composer requirements][composer] before setting up PHP. For a +plugin, check the supported Cacti versions and dependencies in its `INFO`. + +## Theme and Plugin Checks + +The **Cacti 1.2 theme style regressions** workflow uses PHP 8.2, Node 22, +and Chromium. From a checkout of the Cacti `1.2.x` branch, run: + +```console +cd tests/e2e +npm ci --ignore-scripts +node node_modules/@playwright/test/cli.js install chromium +node node_modules/@playwright/test/cli.js test --config=playwright.config.js \ + theme-style-regressions.spec.js theme-css.spec.js --workers=1 +``` + +These tests check theme styles in a browser. For changes to plugin behavior, +also install the plugin on a disposable 1.2.x system, enable it, visit its +pages with the relevant user permissions, and exercise the affected action. + +## Read Actions Results + +Open **Actions > Cacti 1.2 theme style regressions** and select **Theme CSS +browser contracts**. The workflow runs on relevant changes to `1.2.x` and +supports a manual run. Inspect the failing test and browser assertion to +identify the theme, selector, and expected value. + +The [workflow definition][workflow] lists its triggers, dependencies, and +exact commands. + +## Documentation Checks + +Run the spelling, Markdown, and navigation checks from the documentation +checkout. Render the manual before submitting changes to examples, links, or +screenshots. See [Documentation Standards](Standards-Documentation.md). + +[composer]: https://github.com/Cacti/cacti/blob/1.2.x/composer.json +[workflow]: + + +--- + +Copyright (c) 2004-2026 The Cacti Group diff --git a/Plugin-Creating-Plugins.md b/Plugin-Creating-Plugins.md index fa26949..6f20c96 100644 --- a/Plugin-Creating-Plugins.md +++ b/Plugin-Creating-Plugins.md @@ -1,210 +1,109 @@ # Creating a plugin -Your plugin will require a few things to be properly detected by Cacti. +Build and test your plugin in a disposable Cacti installation. The +[reference plugin](Plugin-Reference.md) shows the smallest installable +example. The [downloadable example](Plugin-Guidelines.md#plugin-namespaces) +also registers a tab, a page, and a permission realm. ## Directory Structure -Your plugin will reside in its own directory in Cacti's plugin directory. You -will need to create a new directory, with a unique name. It is recommended that -you use all lowercase alpha letters, and try to keep it short (you will be -typing it a lot). All plugin names must contain only upper or lowercase letters -a-z and digits 0-9. - -So to begin, create your directory in the plugins directory like this. - -```console -/plugins/PLUGINNAME/ -``` +Choose a short lowercase directory name, such as `example`. Place the +directory directly under Cacti's `plugins/` directory. The result should +contain `plugins/example/setup.php` and `plugins/example/INFO`. Use the same +name for the `INFO` entry and the prefix of the setup functions. ## Setup File -Cacti detects plugins by looking for a 'setup.php' file located inside your -plugin's directory. It must be all lowercase. Inside this file should only be -functions, no code that runs automatically. +Define the plugin's lifecycle functions in `setup.php`. Cacti loads this file +when it discovers or manages the plugin. Keep page output and database changes +inside the callbacks that need them. ## INFO File -Every Cacti plugin must have an INFO file. Any legacy plugins that do not have -an INFO file will not work with Cacti 1.x. This was done intentionally so that -plugin users could know ahead of time that their plugin was not designed for -Cacti 1.x. The info file includes several lines, including: - -setting | description -:--- | :--- -*name* | The short name for the plugin. Must be alpha with no spaces and match the directory name. -*version* | The version of the plugin. Use two to three decimal places. -*longname* | A user readable short description for the plugin. -*author* | The author of the plugin. -*email* | The author's email address for obtaining support. -*homepage* | If the author maintains a homepage, the address for that page. -*compat* | The minimum version of Cacti that is required to use this plugin. -*requires* | A space delimited list of plugins:version that are required to use this plugin. -*capabilities* | A comma delimited list of capabilities to define what capabilities the plugin has primarily remotely. -*nosync* | A comma delimited list of relative paths that should not be synchronized with the remote data collectors, for example transient folders that may contain quite a bit of data that changes often. +Put the plugin metadata under `[info]`. Supply the directory name, display +name, version, author, homepage, and Cacti compatibility. Add `requires` for +plugin dependencies, `capabilities` for remote collector behavior, and +`nosync` for synchronization exclusions when applicable. See the field +definitions and examples in [Plugin Development](Plugin-Development.md). ## Mandatory functions -Inside the setup file, there are several functions that are mandatory in order -for your plugin to properly be detected, and to properly function. - -### plugin_PLUGINNAME_install - -This first function is the installation function that is run when a request is -received to install your plugin. There are no arguments passed to this -function. - -You will need to replace PLUGINNAME with the exact folder name (including case -sensitivity). Below is an example of this function. We will discuss the -register_hook function later in this document. - -```php -function plugin_PLUGINNAME_install () { - api_plugin_register_hook('PLUGINNAME', 'top_graph_header_tabs', 'PLUGINNAME_show_tab', 'setup.php'); -} -``` - -### plugin_PLUGINNAME_uninstall - -The next function is the uninstall function. This is a function that is called -when someone requests to uninstall your plugin. You can use this to clean up -any extra data that is left by your plugin. If you used the API function to -install any tables, they will be cleaned up automatically. Cacti only calls -this function if the plugin defines it. +Cacti calls the version and installation functions by name. Replace +`PLUGINNAME` in the headings below with the plugin's directory name. ### plugin_PLUGINNAME_version -The next function is used for checking the version of your plugin, plus -providing a little bit more information. - -Below is an example of this function. The few extra things to return are the -longname (aka Pretty Name that will be displayed), the author, website, etc. -The `url` is a special URL used to check for updates of your plugin to be -compatible with the 'update' plugin. +Return the metadata array from the `[info]` section. The installer reads +`longname`, `author`, and `version` from this array. ```php -function plugin_PLUGINNAME_version () { - global $config; - $info = parse_ini_file($config['base_path'] . '/plugins/PLUGINNAME/INFO', true); +function plugin_example_version() { + $info = parse_ini_file(__DIR__ . '/INFO', true, INI_SCANNER_RAW); - return $info['info']; + return $info['info']; } ``` +### plugin_PLUGINNAME_install + +Register hooks and realms here. If the plugin needs database tables, create +them with Cacti's plugin database helpers. Make installation safe to retry. +A successful install callback can return without a value. On the current +branch, returning `false` or throwing an exception signals installation +failure. + +```php +function plugin_example_install() { + api_plugin_register_hook('example', 'top_graph_header_tabs', 'example_show_tab', 'setup.php'); + api_plugin_register_realm('example', 'example.php', 'View Example', true); +} +``` + +The downloadable example supplies `example_show_tab()` and the authenticated +page `example.php`. Install and enable the plugin to make its tab available to +users with the **View Example** realm. + +On Cacti 1.2.x, the enabled plugin shows **Active**. + +![Enabled example](images/plugin-example-management.png) + +## Optional functions + ### plugin_PLUGINNAME_check_config -The last mandatory function is used for determining whether your plugin is -ready to be enabled after being installed. +Define this callback if the plugin needs settings before it can run. Return +`true` when it is ready and `false` when an administrator still needs to +configure it. Cacti treats an absent callback as ready. An empty callback +returns `null` and prevents the plugin from passing the check. -When a plugin is installed, it starts in a disabled state. Only a few of the -necessary hooks for the plugin are enabled. These are the config_settings, -config_arrays and config_form hooks. Anything that uses those hooks will still -be available while the plugin is disabled. This allows a user to modify any -necessary settings for the plugin before the plugin is actually enabled and goes -live. You can then use this check_config function to determine whether -everything is correctly set up, before you allow the plugin to be enabled. From -this function, you will simply need to return TRUE if everything checks out, or -return FALSE if something else needs to be set up. If the plugin does not -define this function, Cacti treats the plugin as ready to be enabled. +### plugin_PLUGINNAME_uninstall -```php -function plugin_PLUGINNAME_check_config () { - if (read_config_option('PLUGINNAME_SETTING') != '') { - return true; - } +Use this callback for plugin-specific cleanup. Cacti also processes the schema +changes it recorded through its plugin database API. Tell administrators which +data uninstalling will remove and how to back it up. - return false; -} -``` +### Registering Hooks -## Optional functions -Some plugins delete all your data and settings when you uninstall them. -However, some plugins preserve the data and can be used again in the future. -The following 2 functions allow you to delete all data and settings without -uninstalling the plugin or manually deleting them. -If the plugin does not contain the function, the delete icon will not appear -in the settings (console -> configuration -> plugins). -These functions are used in version 1.3 and higher. +The arguments to `api_plugin_register_hook()` identify the plugin, hook, +callback, and callback file relative to the plugin directory. Cacti loads +that file when it invokes the callback. Use the hook name and argument list +from the [Hook API Reference](Plugin-Hook-API-Ref.md) and its core call site. -```php -function plugin_PLUGINNAME_has_data() { - return true; -} +Cacti registers `config_arrays`, `config_form`, and `config_settings` as +enabled by default so administrators can configure a newly installed plugin. +An optional fifth argument enables a hook at registration. -function plugin_PLUGINNAME_remove_data() { - return false; -} -``` +### Registering Realms -#### Registering Hooks +Pass the plugin name, page filename, and permission label to +`api_plugin_register_realm()`. A comma-separated filename list can share one +realm. The fourth argument controls whether the administrator receives the +realm at registration. Grant access to other users or groups explicitly. -The way that your plugin is able to interact within Cacti is via the many hooks -that are placed into the interface. As Cacti processes the various visual -pages and backend functions, it will call specific hook functions which pass -control over to any plugins that might want to interact with that aspect of -Cacti. In order to utilize these hooks, your plugin must register for each -hook that you require inside our installation function. This is done via a -simple API function. - -```php -api_plugin_register_hook('PLUGINNAME', 'HOOKNAME', 'CALLBACKFUNCTION', 'FILENAME'); -``` - -Name | Description ---- | --- -PLUGINNAME | The name of your plugin -HOOKNAME | The name of the hook you want to register -CALLBACKFUNCTION | The name of your function to call when the hook is triggered. -FILENAME | The name of the file which contains the above function (path relative to your plugin directory) - -Taking our above example, if you wanted to display a new tab at the top of -Cacti's Console, your setup.php file may look like this. - -```php -function plugin_PLUGINNAME_install () { - api_plugin_register_hook('PLUGINNAME', 'top_graph_header_tabs', 'PLUGINNAME_show_tab', 'setup.php'); -} - -function PLUGINNAME_show_tab () { - global $config; - print ''; -} -``` - -Here you can find a full listing of the available hooks - -[Hook Api Reference](Plugin-Hook-API-Ref.md) - -#### Registering Realms - -Cacti allows you to restrict access to various portions of Cacti by utilizing -Realm Permissions. Creating a new realm will add a checkbox to the User -Permissions form for the page you desire to restrict access to. You can create -1 realm that permits access to multiple pages, or use multiple realms for -different functional duties (ex: separating out the viewing and the -configuration sections of your plugin). - -We need to call this hook in the same function as we registered for hooks. -Either of the api calls can come first (there is no order necessary). - -```php -api_plugin_register_realm('PLUGINNAME', 'FILENAMETORESTRICT', 'DISPLAYTEXT', 1); -``` - -Name | Description ---- | --- -PLUGINNAME | Your plugin's name -FILENAMETORESTRICT | the filename (relative to your plugin directory) to restrict access to, you can separate multiple with a comma -DISPLAYTEXT | This is the text that will display on the User Permissions form for this Realm -1 or 0 (true or false) | This tells it whether to automatically grant permission to the 'admin' user account (true) - -So to follow our example, your install function would look like this - -```php -function plugin_PLUGINNAME_install () { - api_plugin_register_hook('PLUGINNAME', 'top_graph_header_tabs', 'PLUGINNAME_show_tab', 'setup.php'); - api_plugin_register_realm('PLUGINNAME', 'PLUGINNAME.php,', 'View PLUGINNAME', 1); -} -``` +Load Cacti's authentication bootstrap on the plugin page. When drawing its +tab, check `api_plugin_user_realm_auth('example.php')`. Test the page with +an account that has the realm and one that lacks it. --- + Copyright (c) 2004-2026 The Cacti Group diff --git a/Plugin-Development.md b/Plugin-Development.md index 97fded7..4bdefd7 100644 --- a/Plugin-Development.md +++ b/Plugin-Development.md @@ -2,154 +2,119 @@ ## Overview -Cacti Plugins allow users of Cacti to extend its functionality into areas -that the core Cacti developers have not. They were written based off of -the work of Jimmy Conner from the Squirrel Mail project years ago. They -allow developers to augment the Cacti Website, and its polling processes -to extend Cacti's reach. +Cacti plugins extend the web interface and the polling process. The plugin +architecture grew out of Jimmy Conner's work on the SquirrelMail project. -There are a number of popular plugins including: +- [Thold](Plugin-Thold.md) checks data source values against thresholds. +- [Syslog](Plugin-Syslog.md) collects log messages and matches them against + rules that can trigger alerts. +- [Monitor](Plugin-Monitor.md) shows device status on a dashboard. +- [Intropage](Plugin-Intropage.md) displays Cacti metrics on a single page. +- [Weathermap](Plugin-Weathermap.md) displays live data on network diagrams. -- **Thold** - A graph based service checking framework that leverages the - data on Cacti graphs for performing service checks -- **Syslog** - A plugin that allows you to view log data from hundreds or - thousands of hosts and generate faults based upon pattern matching of - that log data. -- **Monitor** - A plugin that provides a Device Dashboard highlighting - Cacti Devices that are experiencing faults. -- **Intropage** - A plugin that provides a replacement to the Cacti console - showing key performance metrics across all of Cacti from a single page. -- **Weathermap** - A plugin that allows you to create architectural - diagrams of your network and to animate them with status data. - -In theory, these plugins can be integrated into Cacti very simply, and removed -without breaking Cacti. However, it must be noted to always review the -plugin's documentation before you start to use it. +Read the plugin's installation and removal instructions before enabling it. +To start a new plugin, see [Creating Plugins](Plugin-Creating-Plugins.md). ## Legacy Plugins Notice -Plugins written for Cacti 0.8.x require modifications in order to be compatible -with Cacti 1.x. There are several changes that all plugin developers need to -be aware of. Any of the Cacti Group maintained plugins can be -used as reference plugins for driving your plugin migration to the 1.x -framework and are available on [GitHub](https://github.com/Cacti/). +Plugins written for Cacti 0.8.x need changes to run on Cacti 1.x. Cacti 1.x +uses the Plugin Architecture (PIA) 2.x installation and setup conventions. ## Plugin Migration -In order to migrate your legacy Cacti plugins, there are several steps that -need to be taken. This guide will provide a brief synopsis of changes that are -required to make your plugins compatible with Cacti 1.0. +For an example of how a maintained plugin registers its hooks, see +[Graph Export](https://github.com/Cacti/plugin_gexport). For a core page with +list filters, pagination, and bulk actions, see +[vdef.php](https://github.com/Cacti/cacti/blob/1.2.x/vdef.php) on the +1.2.x branch. ## Migration Steps -Each of the following steps should be followed to migrate your plugins. Some -of these changes are optional, and some are mandatory. We will start with the -list of steps that are required. Then, in future sections, we will provide -details on performing each step. - ### Required Steps -- Creation of Information (INFO) file (mandatory) - -- Applying correct classes to Anchor tags to trigger callbacks (mandatory) - -- Remove instances of including top_header.php, top_graph_header.php, - top_general_header.php and replacing with function calls top_header(), - bottom_footer(), top_graph_header(), and general_header(). (mandatory) - -- Adding '&header=false' to most header() function calls to drive Ajax - rendering. (mandatory) - -- Movement of form elements to be W3C compliant as HTML5 requires it (mandatory) - -- Moving the $nav variable within the page to ensure tables are formatted - correctly. This includes the $nav before the table and the $nav afterwards. - (mandatory) - -- Remove all instances of $_GET, $_REQUEST, and $_POST and replacing the - wrappers get_request_var(), get_filter_request_var(), set_request_var(), - isset_request_var(), isempty_request_var() (mandatory) - -- Utilize the 'validate_store_request_vars()' function to greatly simplify - request validation on your pages. (mandatory) - -- Migration of the Plugin to the PIA 2.x+ install and setup process. Cacti PIA - 1.x plugins are not supported in Cacti 1.0 and beyond. (mandatory) - -- Removal of hooks that inject jQuery, jQueryUI into Cacti's header (mandatory) +- Create an `INFO` file in the plugin directory and update the installation and + setup functions in `setup.php`. See + [Creating Plugins](Plugin-Creating-Plugins.md). +- Replace direct header includes with the function for the page. Use + `top_header()` for a console page, `top_graph_header()` for a graph page, + or `general_header()` for the general header. End the page with + `bottom_footer()`. +- Use the link classes from the corresponding core page so Cacti can attach + its navigation callbacks. When an AJAX request needs only the page content, + include `header=false` in the destination URL. +- Keep form controls inside their form and use valid HTML table markup. For + paginated tables, render the navigation bar above and below the table. +- Validate named request fields with `get_filter_request_var()`. Its default + filter checks integers. Choose a filter appropriate to the field. After + validation, use `get_request_var()` to read the value. Use + `isset_request_var()` and `isempty_request_var()` to check presence or + emptiness, and `set_request_var()` to set a request value. +- For bulk actions with dynamically named checkboxes, inspect the submitted + field names. For example, `vdef.php` matches `chk_` followed by digits and + validates the extracted ID. Check the user's permission for each selected + object before applying the action. +- Remove hooks that load jQuery or jQuery UI into the page header. Cacti + already supplies both libraries. ### Optional Steps -- Remove inline styles, and use Cacti's classes instead (highly recommended) +- Use Cacti's CSS classes for colors and alternating table rows. Remove + inline styles and references to the legacy `$colors` array. +- Use AJAX callbacks to refresh filtered results. For list pages that keep + filters between requests, `validate_store_request_vars()` validates the + fields and stores their values in the session when given a session prefix. +- Use the table helpers for sortable headings, checkbox columns, tooltips, + and alignment. Use `html_nav_bar()` to generate pagination links. -- Migration of filters to Ajax callbacks (highly recommended) +### INFO File Structure -- Removing references to the $colors array (optional) +The `INFO` file uses INI syntax. Put the following keys in its `[info]` +section. -- Using new functions for alternate colored rows, sorted, checkbox and other - headers (optional) - -- Using new options for headers to support tool tips, alignment etc (optional) - -- Migration to new pagination functions, which simplify page navigation - -### INFO File structure - -The INFO file follows the INI file specification. An example INFO file -includes the following sections: - -- **name** - The name of the plugin directory - -- **version** - The version number of the plugin - -- **longname** - A description for the plugin - -- **author** - The plugin's author - -- **email** - An email contact in order to reach the author - -- **homepage** - A link to the plugin author's homepage - -- **compat** - Prior to Cacti 1.3, the minimum version of Cacti to support the - plugin. After Cacti 1.3, it will represent the range of Cacti versions - supported. - -- **requires** - The list of plugins and versions that the current plugin needs - in order to operate. This is a space delimited list of Plugins with version - attributes similar to the **compat** section. - -- **capabilities** - a comma delimited string of capabilities defining how the - plugin works with remote data collectors - -- **nosync** - a comma delimited string of directories or file extensions to - skip during the remote data collector synchronization. File extensions must be - formatted as `*.extension` and only are relevant in the base directory of the - plugin. The following extensions are automatically excluded regardless of - directory: 'tar', 'gz', 'zip', 'tgz', 'ttf', 'z', 'exe', 'pack', 'swp', 'swo'. +- `name` is the plugin's directory name. +- `version` is the plugin's version number. +- `longname` is the plugin's display name. +- `author`, `email`, and `homepage` identify the maintainer and provide contact + information. +- `compat` specifies the Cacti versions the plugin supports. A bare version + sets the minimum. Use this form for plugins that support Cacti 1.2.x. +- `requires` lists plugin dependencies. Separate entries with a single space. + Each entry gives the directory name and can include a colon followed by a + minimum version. For example, `thold:1.2.1 monitor:2.0` requires Thold 1.2.1 + or later and Monitor 2.0 or later. +- `capabilities` is a comma-separated list of flags that describe which + operations the plugin supports on a remote data collector. +- `nosync` is a comma-separated list of files or directories to skip at the + top level of the plugin directory. An entry such as `*.csv` skips files with + that extension at the top level. Throughout the directory tree, Cacti skips + files ending in `tar`, `gz`, `zip`, `tgz`, `ttf`, `z`, `exe`, `pack`, + `swp`, and `swo`. ### Example INFO Files -From the Monitor plugin, we can see the following format: +Monitor 3.0 declares Thold as a dependency. Cacti checks the installed +version of Thold before it installs Monitor. -``` +```ini [info] name = monitor -version = 2.8 +version = 3.0 longname = Device Monitoring author = The Cacti Group email = homepage = http://www.cacti.net -compat = 1.2.15 +compat = 1.2.29 requires = thold:1.2.1 capabilities = online_view:1, online_mgmt:1, offline_view:0, offline_mgmt:0, remote_collect:0 ``` -From the Syslog plugin, we can see a slightly different format. +Syslog 5.0 excludes its local configuration file from synchronization and +declares which hooks it uses on a remote collector. -``` +```ini [info] name = syslog -version = 4.2 +version = 5.0 longname = Syslog Monitoring author = The Cacti Group email = @@ -159,48 +124,38 @@ nosync = config.php capabilities = online_view:1, online_mgmt:1, offline_view:1, offline_mgmt:1, remote_collect:0, remote_poller:1 ``` -Here we can see that the config.php file in the plugin directory will not be copied over to remote -pollers, and we can see that Syslog allows for remote data collection using the -**remote_poller:1** capabilities attribute. +With `nosync = config.php`, each collector can keep its own Syslog +configuration. The `remote_poller:1` flag allows Cacti to run the plugin's +registered `poller_bottom` hook on a remote collector. Collection hooks such +as `poller_top` and `poller_output` use `remote_collect`, which Syslog sets +to `0`. See the [plugin hook reference](Plugin-Hook-API-Ref.md) for hook +descriptions. ### Changes in Cacti 1.3+ -Starting with Cacti 1.3 and beyond, the **compat** and **requires** lines can -include ranges of support. For example, the following will be supported: +On 1.2.x, write a single minimum Cacti version in `compat`, such as +`compat = 1.2.32`. For plugin dependencies, use space-separated entries such +as `requires = thold:1.2.1 monitor:2.0`. Consult the +[development manual][development-guide] when porting a plugin to 1.3. -``` -compat = >=1.2.15 <1.3.0 -requires = thold:>1.2.1 <=2.0, monitor:>2.0 -``` - -Before Cacti 1.3, the **compat** and **requires** attributes assumed always >=, -and there were never provisions for < or <= for any plugin. Due to changes in the -Plugin Architecture, this will change starting with Cacti 1.3. - -As mentioned, there are some very good examples of how to create or migrate -plugins in the various Cacti plugins included on The Cacti Group's GitHub site. -Also, for a very simple Cacti page, you can look at vdef.php as an example. -You can use this as a template to manage a table using the Cacti framework. -For a simple plugin example, please review the gexport plugin. +[development-guide]: + ## Charting Functionality -Several JavaScript based HTML5 Charting packages have been included in Cacti in -an effort to assist plugin developers who wish to use graphing APIs in their -plugins other than RRDtool. - -- [Billboard.js](https://naver.github.io/billboard.js/) -- [D3](https://d3js.org/) -- [Chart.js](http://www.chartjs.org/) -- [DyGraphs](http://dygraphs.com/) -- [jQuery Sparklines](http://omnipotent.net/jquery.sparkline/) +For browser charts, Cacti includes +[billboard.js](https://naver.github.io/billboard.js/), +[D3](https://d3js.org/), and [Chart.js](https://www.chartjs.org/). +This branch also ships dygraphs and jQuery Sparklines. Check the JavaScript +files on each branch your plugin supports before choosing a library. ## Logging -For developers using the Cacti framework, it is important to note that -additional controls on logging have been added. Debug logging can now be -controlled at not only a global level, but now per plugin, per device and even -per file. +In the console, open **Configuration > Settings**. On the **General** tab, +select the plugin under **Selective Plugin Debug**. +Use **Selective File Debug** for individual files or **Selective Device Debug** +to trace polling for specific device IDs. +See [Log Settings](Settings-General.md#log-settings). --- Copyright (c) 2004-2026 The Cacti Group diff --git a/Plugin-Guidelines.md b/Plugin-Guidelines.md index 1a21847..e205a79 100644 --- a/Plugin-Guidelines.md +++ b/Plugin-Guidelines.md @@ -2,25 +2,40 @@ ## Overview -This section will help the Cacti plugin developer structure their plugins. -However, the best way to create a plugin is to borrow someone else's. There -are Cacti plugin examples on [Cacti's GitHub page](https://github.com/Cacti) and -you can find them all over GitHub just by searching. +Build against the Cacti branch you support. Use its core pages for request +handling, navigation, and forms. Compare a maintained plugin that uses the +same hooks, such as [Monitor](https://github.com/Cacti/plugin_monitor). ## Plugin Creation -Use the following guidelines for creating your first plugin. +Start with the [minimal reference plugin](Plugin-Reference.md). To try a +plugin with a visible page, download the example below and extract its +`example/` directory under `plugins/` in a disposable installation. Open +**Console > Configuration > Plugins**, install **Example Plugin**, and enable +it. A user with the **View Example** realm can open the **Example** tab. + +![Example tab and page](images/plugin-example-page.png) + +The page displays **The example page is enabled.** If the tab is missing, +check the plugin's status, hook registration, and the user's realm. See +[Creating a plugin](Plugin-Creating-Plugins.md#registering-realms). ## Plugin Namespaces -All plugins must use namespace isolation either through Classes or using -the plugin name in their functions. This prevents name space collisions. +Prefix global functions, settings, and plugin-owned tables with the directory +name. Use a plugin-specific namespace for classes. Keep the lifecycle function +names Cacti looks up, such as `plugin_example_version()`, in the global +namespace. -An example plugin is provided here [Example Plugin](resources/example.tgz). +[Download the example plugin](resources/example.tgz). ## Publishing Your Plugin -GitHub is the best place to publish your plugins. Learn to use it. +Publish an archive that unpacks to the expected directory. Document the tested +Cacti and PHP versions, dependencies, permissions, data collection behavior, +and what happens to stored data during upgrade or removal. Test the archive +itself on a fresh installation and test upgrading from the previous release. --- + Copyright (c) 2004-2026 The Cacti Group diff --git a/Plugin-Hook-API-Ref.md b/Plugin-Hook-API-Ref.md index 94a247e..e7c1e78 100644 --- a/Plugin-Hook-API-Ref.md +++ b/Plugin-Hook-API-Ref.md @@ -1,65 +1,81 @@ # Plugin Hook API Reference -The following table shows all known Cacti plugin hooks and a brief description -of their function. +Find the hook for the event you need, then inspect the linked core call site +on this branch for the arguments and how Cacti uses the result. Some hooks +are dispatched through a helper that constructs the hook name at runtime. -| hook | hook | hook | -| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| [add_graph_template_to_host](Plugin-Hook-API-Ref.md#add_graph_template_to_host) | [admin_alert](Plugin-Hook-API-Ref.md#admin_alert) | [api_device_new](Plugin-Hook-API-Ref.md#api_device_new) | -| [api_device_save](Plugin-Hook-API-Ref.md#api_device_save) | [auth_alternate_realms](Plugin-Hook-API-Ref.md#auth_alternate_realms) | [auth_profile_reset](Plugin-Hook-API-Ref.md#auth_profile_reset) | -| [auth_profile_reset_value](Plugin-Hook-API-Ref.md#auth_profile_reset_value) | [auth_profile_run_action](Plugin-Hook-API-Ref.md#auth_profile_run_action) | [auth_profile_save](Plugin-Hook-API-Ref.md#auth_profile_save) | -| [auth_profile_tabs](Plugin-Hook-API-Ref.md#auth_profile_tabs) | [auth_profile_update_data](Plugin-Hook-API-Ref.md#auth_profile_update_data) | [boost_poller_bottom](Plugin-Hook-API-Ref.md#boost_poller_bottom) | -| [bottom_footer](Plugin-Hook-API-Ref.md#bottom_footer) | [cacti_stats_update](Plugin-Hook-API-Ref.md#cacti_stats_update) | [change_password_title](Plugin-Hook-API-Ref.md#change_password_title) | -| [clog_regex_array](Plugin-Hook-API-Ref.md#clog_regex_array) | [config_arrays](Plugin-Hook-API-Ref.md#config_arrays) | [config_form](Plugin-Hook-API-Ref.md#config_form) | -| [config_insert](Plugin-Hook-API-Ref.md#config_insert) | [config_settings](Plugin-Hook-API-Ref.md#config_settings) | [console_after](Plugin-Hook-API-Ref.md#console_after) | -| [console_before](Plugin-Hook-API-Ref.md#console_before) | [copy_user](Plugin-Hook-API-Ref.md#copy_user) | [create_complete_graph_from_template](Plugin-Hook-API-Ref.md#create_complete_graph_from_template) | -| [custom_denied](Plugin-Hook-API-Ref.md#custom_denied) | [custom_login](Plugin-Hook-API-Ref.md#custom_login) | [custom_logout_message](Plugin-Hook-API-Ref.md#custom_logout_message) | -| [custom_password](Plugin-Hook-API-Ref.md#custom_password) | [custom_version_info](Plugin-Hook-API-Ref.md#custom_version_info) | [customize_graph](Plugin-Hook-API-Ref.md#customize_graph) | -| [customize_template_details](Plugin-Hook-API-Ref.md#customize_template_details) | [data_input_sql_where](Plugin-Hook-API-Ref.md#data_input_sql_where) | [data_source_action_array](Plugin-Hook-API-Ref.md#data_source_action_array) | -| [data_source_action_bottom](Plugin-Hook-API-Ref.md#data_source_action_bottom) | [data_source_action_execute](Plugin-Hook-API-Ref.md#data_source_action_execute) | [data_source_action_prepare](Plugin-Hook-API-Ref.md#data_source_action_prepare) | -| [data_source_edit_bottom](Plugin-Hook-API-Ref.md#data_source_edit_bottom) | [data_source_edit_top](Plugin-Hook-API-Ref.md#data_source_edit_top) | [data_source_remove](Plugin-Hook-API-Ref.md#data_source_remove) | -| [data_source_to_poller_items](Plugin-Hook-API-Ref.md#data_source_to_poller_items) | [data_sources_table](Plugin-Hook-API-Ref.md#data_sources_table) | [device_action_array](Plugin-Hook-API-Ref.md#device_action_array) | -| [device_action_bottom](Plugin-Hook-API-Ref.md#device_action_bottom) | [device_action_execute](Plugin-Hook-API-Ref.md#device_action_execute) | [device_action_prepare](Plugin-Hook-API-Ref.md#device_action_prepare) | -| [device_change_javascript](Plugin-Hook-API-Ref.md#device_change_javascript) | [device_display_text](Plugin-Hook-API-Ref.md#device_display_text) | [device_edit_pre_bottom](Plugin-Hook-API-Ref.md#device_edit_pre_bottom) | -| [device_edit_top_links](Plugin-Hook-API-Ref.md#device_edit_top_links) | [device_filter_end](Plugin-Hook-API-Ref.md#device_filter_end) | [device_filter_start](Plugin-Hook-API-Ref.md#device_filter_start) | -| [device_filters](Plugin-Hook-API-Ref.md#device_filters) | [device_remove](Plugin-Hook-API-Ref.md#device_remove) | [device_sql_where](Plugin-Hook-API-Ref.md#device_sql_where) | -| [device_table_bottom](Plugin-Hook-API-Ref.md#device_table_bottom) | [device_table_replace](Plugin-Hook-API-Ref.md#device_table_replace) | [device_template_change](Plugin-Hook-API-Ref.md#device_template_change) | -| [device_template_edit](Plugin-Hook-API-Ref.md#device_template_edit) | [device_template_top](Plugin-Hook-API-Ref.md#device_template_top) | [device_top](Plugin-Hook-API-Ref.md#device_top) | -| [draw_navigation_text](Plugin-Hook-API-Ref.md#draw_navigation_text) | [expand_title](Plugin-Hook-API-Ref.md#expand_title) | [export_action](Plugin-Hook-API-Ref.md#export_action) | -| [fgc_contextoption](Plugin-Hook-API-Ref.md#fgc_contextoption) | [get_friendly_name](Plugin-Hook-API-Ref.md#get_friendly_name) | [get_template_account](Plugin-Hook-API-Ref.md#get_template_account) | -| [global_settings_update](Plugin-Hook-API-Ref.md#global_settings_update) | [graph](Plugin-Hook-API-Ref.md#graph) | [graph_buttons](Plugin-Hook-API-Ref.md#graph_buttons) | -| [graph_buttons_thumbnails](Plugin-Hook-API-Ref.md#graph_buttons_thumbnails) | [graph_edit_after](Plugin-Hook-API-Ref.md#graph_edit_after) | [graph_image](Plugin-Hook-API-Ref.md#graph_image) | -| [graph_items_remove](Plugin-Hook-API-Ref.md#graph_items_remove) | [graph_tree_page_buttons](Plugin-Hook-API-Ref.md#graph_tree_page_buttons) | [graphs_action_array](Plugin-Hook-API-Ref.md#graphs_action_array) | -| [graphs_action_bottom](Plugin-Hook-API-Ref.md#graphs_action_bottom) | [graphs_action_execute](Plugin-Hook-API-Ref.md#graphs_action_execute) | [graphs_action_prepare](Plugin-Hook-API-Ref.md#graphs_action_prepare) | -| [graphs_item_array](Plugin-Hook-API-Ref.md#graphs_item_array) | [graphs_new_top_links](Plugin-Hook-API-Ref.md#graphs_new_top_links) | [graphs_remove](Plugin-Hook-API-Ref.md#graphs_remove) | -| [graphs_sql_where](Plugin-Hook-API-Ref.md#graphs_sql_where) | [help_page](Plugin-Hook-API-Ref.md#help_page) | [hmib_get_cpu](Plugin-Hook-API-Ref.md#hmib_get_cpu) | -| [hmib_get_cpu_indexes](Plugin-Hook-API-Ref.md#hmib_get_cpu_indexes) | [hmib_get_disk](Plugin-Hook-API-Ref.md#hmib_get_disk) | [host_edit_bottom](Plugin-Hook-API-Ref.md#host_edit_bottom) | -| [host_edit_top](Plugin-Hook-API-Ref.md#host_edit_top) | [host_save](Plugin-Hook-API-Ref.md#host_save) | [import_action](Plugin-Hook-API-Ref.md#import_action) | -| [is_console_page](Plugin-Hook-API-Ref.md#is_console_page) | [login_after](Plugin-Hook-API-Ref.md#login_after) | [login_before](Plugin-Hook-API-Ref.md#login_before) | -| [login_options_navigate](Plugin-Hook-API-Ref.md#login_options_navigate) | [login_process](Plugin-Hook-API-Ref.md#login_process) | [login_realms](Plugin-Hook-API-Ref.md#login_realms) | -| [login_title](Plugin-Hook-API-Ref.md#login_title) | [logout_post_session_destroy](Plugin-Hook-API-Ref.md#logout_post_session_destroy) | [logout_pre_session_destroy](Plugin-Hook-API-Ref.md#logout_pre_session_destroy) | -| [nav_login_after](Plugin-Hook-API-Ref.md#nav_login_after) | [nav_login_before](Plugin-Hook-API-Ref.md#nav_login_before) | [page_bottom](Plugin-Hook-API-Ref.md#page_bottom) | -| [page_buttons](Plugin-Hook-API-Ref.md#page_buttons) | [page_head](Plugin-Hook-API-Ref.md#page_head) | [page_title](Plugin-Hook-API-Ref.md#page_title) | -| [poller_bottom](Plugin-Hook-API-Ref.md#poller_bottom) | [poller_command_args](Plugin-Hook-API-Ref.md#poller_command_args) | [poller_exiting](Plugin-Hook-API-Ref.md#poller_exiting) | -| [poller_finishing](Plugin-Hook-API-Ref.md#poller_finishing) | [poller_output](Plugin-Hook-API-Ref.md#poller_output) | [poller_remote_maint](Plugin-Hook-API-Ref.md#poller_remote_maint) | -| [poller_top](Plugin-Hook-API-Ref.md#poller_top) | [remote_agent](Plugin-Hook-API-Ref.md#remote_agent) | [replicate_in](Plugin-Hook-API-Ref.md#replicate_in) | -| [replicate_out](Plugin-Hook-API-Ref.md#replicate_out) | [resolve_dependencies](Plugin-Hook-API-Ref.md#resolve_dependencies) | [rrd_graph_graph_options](Plugin-Hook-API-Ref.md#rrd_graph_graph_options) | -| [run_data_query](Plugin-Hook-API-Ref.md#run_data_query) | [settings_bottom](Plugin-Hook-API-Ref.md#settings_bottom) | [snmpagent_cache_install](Plugin-Hook-API-Ref.md#snmpagent_cache_install) | -| [substitute_host_data](Plugin-Hook-API-Ref.md#substitute_host_data) | [top_graph_header](Plugin-Hook-API-Ref.md#top_graph_header) | [top_graph_header_tabs](Plugin-Hook-API-Ref.md#top_graph_header_tabs) | -| [top_graph_jquery_function](Plugin-Hook-API-Ref.md#top_graph_jquery_function) | [top_graph_refresh](Plugin-Hook-API-Ref.md#top_graph_refresh) | [top_header](Plugin-Hook-API-Ref.md#top_header) | -| [tree_after](Plugin-Hook-API-Ref.md#tree_after) | [tree_view_page_end](Plugin-Hook-API-Ref.md#tree_view_page_end) | [ugroup_tabs](Plugin-Hook-API-Ref.md#ugroup_tabs) | -| [update_data_source_title_cache](Plugin-Hook-API-Ref.md#update_data_source_title_cache) | [user_admin_action](Plugin-Hook-API-Ref.md#user_admin_action) | [user_admin_edit](Plugin-Hook-API-Ref.md#user_admin_edit) | -| [user_admin_run_action](Plugin-Hook-API-Ref.md#user_admin_run_action) | [user_admin_setup_sql_save](Plugin-Hook-API-Ref.md#user_admin_setup_sql_save) | [user_admin_tab](Plugin-Hook-API-Ref.md#user_admin_tab) | -| [user_admin_user_save](Plugin-Hook-API-Ref.md#user_admin_user_save) | [user_group_admin_action](Plugin-Hook-API-Ref.md#user_group_admin_action) | [user_group_admin_edit](Plugin-Hook-API-Ref.md#user_group_admin_edit) | -| [user_group_admin_run_action](Plugin-Hook-API-Ref.md#user_group_admin_run_action) | [user_group_admin_save](Plugin-Hook-API-Ref.md#user_group_admin_save) | [user_group_admin_setup_sql_save](Plugin-Hook-API-Ref.md#user_group_admin_setup_sql_save) | -| [user_group_admin_tab](Plugin-Hook-API-Ref.md#user_group_admin_tab) | [user_group_remove](Plugin-Hook-API-Ref.md#user_group_remove) | [user_remove](Plugin-Hook-API-Ref.md#user_remove) | -| [utilities_action](Plugin-Hook-API-Ref.md#utilities_action) | [utilities_array](Plugin-Hook-API-Ref.md#utilities_array) | [utilities_list](Plugin-Hook-API-Ref.md#utilities_list) | -| [utilities_tab](Plugin-Hook-API-Ref.md#utilities_tab) | [valid_host_fields](Plugin-Hook-API-Ref.md#valid_host_fields) | | +Register callbacks during plugin installation. For a value passed through +`api_plugin_hook_function()`, return the value that subsequent callbacks +should receive. A caller that renders output can instead consume what the +callback prints. With `api_plugin_hook()`, check the arguments supplied by +the dispatcher. See [Creating a plugin](Plugin-Creating-Plugins.md). + +The tables retain historical file and release information. A **Current +source** link identifies an active call site in this branch. + +| Hook | Hook | Hook | +| --- | --- | --- | +| [add_graph_template_to_host](#add_graph_template_to_host) | [admin_alert](#admin_alert) | [api_device_new](#api_device_new) | +| [api_device_save](#api_device_save) | [auth_alternate_realms](#auth_alternate_realms) | [auth_profile_reset](#auth_profile_reset) | +| [auth_profile_reset_value](#auth_profile_reset_value) | [auth_profile_run_action](#auth_profile_run_action) | [auth_profile_save](#auth_profile_save) | +| [auth_profile_tabs](#auth_profile_tabs) | [auth_profile_update_data](#auth_profile_update_data) | [boost_poller_bottom](#boost_poller_bottom) | +| [bottom_footer](#bottom_footer) | [cacti_stats_update](#cacti_stats_update) | [change_password_title](#change_password_title) | +| [clog_regex_array](#clog_regex_array) | [config_arrays](#config_arrays) | [config_form](#config_form) | +| [config_insert](#config_insert) | [config_settings](#config_settings) | [console_after](#console_after) | +| [console_before](#console_before) | [copy_user](#copy_user) | [create_complete_graph_from_template](#create_complete_graph_from_template) | +| [custom_denied](#custom_denied) | [custom_login](#custom_login) | [custom_logout_message](#custom_logout_message) | +| [custom_password](#custom_password) | [custom_version_info](#custom_version_info) | [customize_graph](#customize_graph) | +| [customize_template_details](#customize_template_details) | [data_input_sql_where](#data_input_sql_where) | [data_source_action_array](#data_source_action_array) | +| [data_source_action_bottom](#data_source_action_bottom) | [data_source_action_execute](#data_source_action_execute) | [data_source_action_prepare](#data_source_action_prepare) | +| [data_source_edit_bottom](#data_source_edit_bottom) | [data_source_edit_top](#data_source_edit_top) | [data_source_remove](#data_source_remove) | +| [data_source_to_poller_items](#data_source_to_poller_items) | [data_sources_table](#data_sources_table) | [device_action_array](#device_action_array) | +| [device_action_bottom](#device_action_bottom) | [device_action_execute](#device_action_execute) | [device_action_prepare](#device_action_prepare) | +| [device_change_javascript](#device_change_javascript) | [device_display_text](#device_display_text) | [device_edit_pre_bottom](#device_edit_pre_bottom) | +| [device_edit_top_links](#device_edit_top_links) | [device_filter_end](#device_filter_end) | [device_filter_start](#device_filter_start) | +| [device_filters](#device_filters) | [device_remove](#device_remove) | [device_sql_where](#device_sql_where) | +| [device_table_bottom](#device_table_bottom) | [device_table_replace](#device_table_replace) | [device_template_change](#device_template_change) | +| [device_template_edit](#device_template_edit) | [device_template_top](#device_template_top) | [device_top](#device_top) | +| [draw_navigation_text](#draw_navigation_text) | [expand_title](#expand_title) | [export_action](#export_action) | +| [fgc_contextoption](#fgc_contextoption) | [get_friendly_name](#get_friendly_name) | [get_template_account](#get_template_account) | +| [global_settings_update](#global_settings_update) | [graph](#graph) | [graph_buttons](#graph_buttons) | +| [graph_buttons_thumbnails](#graph_buttons_thumbnails) | [graph_edit_after](#graph_edit_after) | [graph_image](#graph_image) | +| [graph_items_remove](#graph_items_remove) | [graph_tree_page_buttons](#graph_tree_page_buttons) | [graphs_action_array](#graphs_action_array) | +| [graphs_action_bottom](#graphs_action_bottom) | [graphs_action_execute](#graphs_action_execute) | [graphs_action_prepare](#graphs_action_prepare) | +| [graphs_item_array](#graphs_item_array) | [graphs_new_top_links](#graphs_new_top_links) | [graphs_remove](#graphs_remove) | +| [graphs_sql_where](#graphs_sql_where) | [help_page](#help_page) | [hmib_get_cpu](#hmib_get_cpu) | +| [hmib_get_cpu_indexes](#hmib_get_cpu_indexes) | [hmib_get_disk](#hmib_get_disk) | [host_edit_bottom](#host_edit_bottom) | +| [host_edit_top](#host_edit_top) | [host_save](#host_save) | [import_action](#import_action) | +| [is_console_page](#is_console_page) | [login_after](#login_after) | [login_before](#login_before) | +| [login_options_navigate](#login_options_navigate) | [login_process](#login_process) | [login_realms](#login_realms) | +| [login_title](#login_title) | [logout_post_session_destroy](#logout_post_session_destroy) | [logout_pre_session_destroy](#logout_pre_session_destroy) | +| [nav_login_after](#nav_login_after) | [nav_login_before](#nav_login_before) | [page_bottom](#page_bottom) | +| [page_buttons](#page_buttons) | [page_head](#page_head) | [page_title](#page_title) | +| [poller_bottom](#poller_bottom) | [poller_command_args](#poller_command_args) | [poller_exiting](#poller_exiting) | +| [poller_finishing](#poller_finishing) | [poller_output](#poller_output) | [poller_remote_maint](#poller_remote_maint) | +| [poller_top](#poller_top) | [remote_agent](#remote_agent) | [replicate_in](#replicate_in) | +| [replicate_out](#replicate_out) | [resolve_dependencies](#resolve_dependencies) | [rrd_graph_graph_options](#rrd_graph_graph_options) | +| [run_data_query](#run_data_query) | [settings_bottom](#settings_bottom) | [snmpagent_cache_install](#snmpagent_cache_install) | +| [substitute_host_data](#substitute_host_data) | [top_graph_header](#top_graph_header) | [top_graph_header_tabs](#top_graph_header_tabs) | +| [top_graph_jquery_function](#top_graph_jquery_function) | [top_graph_refresh](#top_graph_refresh) | [top_header](#top_header) | +| [tree_after](#tree_after) | [tree_view_page_end](#tree_view_page_end) | [ugroup_tabs](#ugroup_tabs) | +| [update_data_source_title_cache](#update_data_source_title_cache) | [user_admin_action](#user_admin_action) | [user_admin_edit](#user_admin_edit) | +| [user_admin_run_action](#user_admin_run_action) | [user_admin_setup_sql_save](#user_admin_setup_sql_save) | [user_admin_tab](#user_admin_tab) | +| [user_admin_user_save](#user_admin_user_save) | [user_group_admin_action](#user_group_admin_action) | [user_group_admin_edit](#user_group_admin_edit) | +| [user_group_admin_run_action](#user_group_admin_run_action) | [user_group_admin_save](#user_group_admin_save) | [user_group_admin_setup_sql_save](#user_group_admin_setup_sql_save) | +| [user_group_admin_tab](#user_group_admin_tab) | [user_group_remove](#user_group_remove) | [user_remove](#user_remove) | +| [utilities_action](#utilities_action) | [utilities_array](#utilities_array) | [utilities_list](#utilities_list) | +| [utilities_tab](#utilities_tab) | [valid_host_fields](#valid_host_fields) | | ## add_graph_template_to_host -Allows you to perform additional operations when adding a graph template to a -host. The parameters passed are `host_id` and `graph_template_id`. +Runs when Cacti adds a graph template to a device. The callback receives the +device ID in `host_id` and the template ID in `graph_template_id`. + +**Current source** +[host.php][add_graph_template_to_host-source]. + +[add_graph_template_to_host-source]: + | file | introduced | retired | | ---------------------------- | :--------- | :------ | @@ -72,10 +88,16 @@ host. The parameters passed are `host_id` and `graph_template_id`. Allows a plugin to deliver an administrator alert instead of the email that `admin_email()` would send. The hook receives an array with `contract_version`, -`status` (`unhandled`), `event_id`, `occurred_at`, `collector_id`, `subject` and -`message`. A plugin that handles the alert returns the array with `status` set -to `accepted` or `already_accepted`. Any other result, a missing handler or an -exception falls back to email. +`status` (`unhandled`), `event_id`, `occurred_at`, `collector_id`, `subject` +and `message`. A plugin that handles the alert returns the array with `status` +set to `accepted` or `already_accepted`. Any other result, a missing handler or +an exception falls back to email. + +**Current source** +[lib/functions.php][admin_alert-source]. + +[admin_alert-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -83,9 +105,14 @@ exception falls back to email. ## api_device_new -This hook allows you to perform additional operations at the end of -api_device_save function. Unlike the api_device_save hook, the device ID is -already defined here. +Runs after Cacti saves a newly created device and assigns its ID. The callback +receives the saved device fields. + +**Current source** +[lib/api_device.php][api_device_new-source]. + +[api_device_new-source]: + | file | introduced | retired | | ------------------ | :--------- | :------ | @@ -93,13 +120,15 @@ already defined here. ## api_device_save -This hook allows you to perform additional operations at the end of -api_device_save function. Unlike the api_device_new hook, the device ID might -not be defined here. +Receives device fields immediately before Cacti writes the host record. Return +the fields to save. A new device does not yet have an assigned ID at this +point. -This hook allows you to alter the contents of the device table with custom -fields. When used properly, it allows you to extend the host table with your -plugin's custom fields. +**Current source** +[lib/api_device.php][api_device_save-source]. + +[api_device_save-source]: + | file | introduced | retired | | ------------------ | :--------- | :------ | @@ -107,16 +136,29 @@ plugin's custom fields. ## auth_alternate_realms -This hook allows you to handle user login checks for alternate plugin defined +Runs during the authentication bootstrap so plugins can handle their own authentication realms. +**Current source** +[include/auth.php][auth_alternate_realms-source]. + +[auth_alternate_realms-source]: + + | file | introduced | retired | | ---------------- | :--------- | :------ | | include/auth.php | 1.0.0 | ## auth_profile_reset -Allows you to reset plugin's all user settings +Runs when the user resets profile settings. Reset the plugin’s saved user +settings here. + +**Current source** +[auth_profile.php][auth_profile_reset-source]. + +[auth_profile_reset-source]: + | file | introduced | retired | | ---------------- | :---------- | :------ | @@ -124,7 +166,13 @@ Allows you to reset plugin's all user settings ## auth_profile_reset_value -Allows you to reset plugin's single user settings +Receives the name of one profile setting to reset. + +**Current source** +[auth_profile.php][auth_profile_reset_value-source]. + +[auth_profile_reset_value-source]: + | file | introduced | retired | | ---------------- | :---------- | :------ | @@ -132,7 +180,13 @@ Allows you to reset plugin's single user settings ## auth_profile_run_action -Allows you to draw plugin's user settings form +Receives the selected tab when Cacti processes an action on the profile page. + +**Current source** +[auth_profile.php][auth_profile_run_action-source]. + +[auth_profile_run_action-source]: + | file | introduced | retired | | ---------------- | :---------- | :------ | @@ -140,7 +194,13 @@ Allows you to draw plugin's user settings form ## auth_profile_save -Allows you to save plugin's all user settings +Runs when Cacti saves the user profile. Save the plugin’s user settings here. + +**Current source** +[auth_profile.php][auth_profile_save-source]. + +[auth_profile_save-source]: + | file | introduced | retired | | ---------------- | :---------- | :------ | @@ -148,7 +208,14 @@ Allows you to save plugin's all user settings ## auth_profile_tabs -Allows you to draw plugin's user setting tabs +Receives the profile tab definitions. Return the definitions with the plugin’s +tab included. + +**Current source** +[auth_profile.php][auth_profile_tabs-source]. + +[auth_profile_tabs-source]: + | file | introduced | retired | | ---------------- | :---------- | :------ | @@ -156,7 +223,13 @@ Allows you to draw plugin's user setting tabs ## auth_profile_update_data -Allows you to update plugin's single user setting +Receives the current tab when Cacti updates user profile data. + +**Current source** +[auth_profile.php][auth_profile_update_data-source]. + +[auth_profile_update_data-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -164,13 +237,23 @@ Allows you to update plugin's single user setting ## boost_poller_bottom +Runs at the end of the Boost poller’s processing cycle. Register here for +post-processing specific to Boost. + +**Current source** +[poller_boost.php][boost_poller_bottom-source]. + +[boost_poller_bottom-source]: + + | file | introduced | retired | | ---------------- | :--------- | :------ | | poller_boost.php | 1.0.0 | ## bottom_footer -Allows you to override the rendering of the bottom_footer html snippet. +Historical hook for customizing the page footer. See the file and version +history below. | file | introduced | retired | | ------------------------- | :--------- | :------ | @@ -178,19 +261,43 @@ Allows you to override the rendering of the bottom_footer html snippet. ## cacti_stats_update +Receives the poller performance data when Cacti records its polling statistics. + +**Current source** +[poller.php][cacti_stats_update-source]. + +[cacti_stats_update-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | poller.php | 1.0.0 | ## change_password_title +Receives the browser title for the password change page. Return the title to +display. + +**Current source** +[auth_changepassword.php][change_password_title-source]. + +[change_password_title-source]: + + | file | introduced | retired | | ----------------------- | :---------- | :------ | | auth_changepassword.php | 1.2.0-beta1 | ## clog_regex_array -Allows you to enhance the Logs display with additional information or links. +Receives the expressions used to recognize references in log messages. Return +the array with any additional patterns. + +**Current source** +[lib/clog_webapi.php][clog_regex_array-source]. + +[clog_regex_array-source]: + | file | introduced | retired | | ------------------- | :--------- | :------ | @@ -198,8 +305,14 @@ Allows you to enhance the Logs display with additional information or links. ## config_arrays -Allows your plug-in to define custom array elements to be used throughout Cacti. -Things like dropdown arrays and the like. +Define shared arrays, such as menu entries, that the plugin uses across Cacti +pages. + +**Current source** +[include/global_arrays.php][config_arrays-source]. + +[config_arrays-source]: + | file | introduced | retired | | ------------------------- | :--------- | :------ | @@ -207,11 +320,13 @@ Things like dropdown arrays and the like. ## config_form -Allows you to define a form object to represent data to be stored in your tables. -In the case of MacTrack, there is a table called `mac_track_sites` and in order -to drive the UI and allow for the user to provide input and save a site, you -must provide the Cacti form engine a form array to allow for the form to be -presented and contents to be saved. +Define form field arrays for use with Cacti’s form helpers. + +**Current source** +[include/global_form.php][config_form-source]. + +[config_form-source]: + | file | introduced | retired | | ----------------------- | :--------- | :------ | @@ -219,8 +334,14 @@ presented and contents to be saved. ## config_insert -This is a general purpose hook used for connecting to other databases, or -sourcing common includes that would otherwise not be sourced. +Runs during Cacti initialization so a plugin can load shared definitions or +initialize a connection. + +**Current source** +[include/global.php][config_insert-source]. + +[config_insert-source]: + | file | introduced | retired | | ------------------ | :--------- | :------ | @@ -228,8 +349,13 @@ sourcing common includes that would otherwise not be sourced. ## config_settings -Allows you to extend the Cacti settings page to allow for custom tabs and global -settings within them. +Register plugin settings and the tabs on which administrators can edit them. + +**Current source** +[include/global_settings.php][config_settings-source]. + +[config_settings-source]: + | file | introduced | retired | | --------------------------- | :--------- | :------ | @@ -237,7 +363,13 @@ settings within them. ## console_after -Allows you to add text after the default message on the console page +Adds content after the default console message. + +**Current source** +[index.php][console_after-source]. + +[console_after-source]: + | file | introduced | retired | | --------- | :--------- | :------ | @@ -245,9 +377,13 @@ Allows you to add text after the default message on the console page ## console_before -Allows you to add text before the default message on the console page. For -instance, the Update plug-in will display a message here if there are new -versions of plugins. +Adds content before the default console message. + +**Current source** +[index.php][console_before-source]. + +[console_before-source]: + | file | introduced | retired | | --------- | :--------- | :------ | @@ -255,8 +391,14 @@ versions of plugins. ## copy_user -Allows a plugin to take part in the Copy User actions. This is important if a -plugin maintains user settings. +Receives the source account ID in `template_id` and the destination account ID +in `new_id`. Use them to copy plugin-owned profile settings. + +**Current source** +[lib/auth.php][copy_user-source]. + +[copy_user-source]: + | file | introduced | retired | | ------------ | :--------- | :------ | @@ -264,8 +406,13 @@ plugin maintains user settings. ## create_complete_graph_from_template -Allows you to perform additional operations when adding a new graph to a device from -a graph template. +Runs when Cacti creates a device graph from a graph template. + +**Current source** +[lib/template.php][create_complete_graph_from_template-source]. + +[create_complete_graph_from_template-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -275,6 +422,12 @@ a graph template. Allows you to override the rendering of the permission denied interface. +**Current source** +[permission_denied.php][custom_denied-source]. + +[custom_denied-source]: + + | file | introduced | retired | | --------------------- | :--------- | :------ | | permission_denied.php | 1.2.2 | @@ -284,6 +437,12 @@ Allows you to override the rendering of the permission denied interface. Allows you to override the rendering of the auth_login.php page. +**Current source** +[auth_login.php][custom_login-source]. + +[custom_login-source]: + + | file | introduced | retired | | -------------- | :--------- | :------ | | auth_login.php | 1.0.0 | @@ -292,6 +451,12 @@ Allows you to override the rendering of the auth_login.php page. Allows you to override the rendering of the logout.php page. +**Current source** +[logout.php][custom_logout_message-source]. + +[custom_logout_message-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | logout.php | 1.0.0 | @@ -300,6 +465,12 @@ Allows you to override the rendering of the logout.php page. Allows you to override the rendering of the auth_changepassword.php page. +**Current source** +[auth_changepassword.php][custom_password-source]. + +[custom_password-source]: + + | file | introduced | retired | | ----------------------- | :--------- | :------ | | auth_changepassword.php | 1.0.0 | @@ -309,14 +480,26 @@ Allows you to override the rendering of the auth_changepassword.php page. Allows your plugin to display additional information on the Cacti tech support page. +**Current source** +[utilities.php][custom_version_info-source]. + +[custom_version_info-source]: + + | file | introduced | retired | | ------------- | :--------- | :------ | | utilities.php | 1.0.0 | ## customize_graph -Allows you to change the graph record of a graph that is not created from a -template (`graph_source` is `0`) before it is listed. +Receives the graph record when the graph list displays a graph without a +template. Return the record to use. + +**Current source** +[graph_view.php][customize_graph-source]. + +[customize_graph-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -325,8 +508,14 @@ template (`graph_source` is `0`) before it is listed. ## customize_template_details -Allows you to change the template details of a graph that is not created from -a template (`graph_source` is `0`) before it is listed. +Receives template details for an untemplated graph in the graph list. Return +the details to display. + +**Current source** +[graph_view.php][customize_template_details-source]. + +[customize_template_details-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -335,13 +524,29 @@ a template (`graph_source` is `0`) before it is listed. ## data_input_sql_where +Receives the filter used to list data input methods. Return the filter to apply +to the count and list queries. + +**Current source** +[data_input.php][data_input_sql_where-source]. + +[data_input_sql_where-source]: + + | file | introduced | retired | | -------------- | :--------- | :------ | | data_input.php | 1.0.0 | ## data_source_action_array -Allows you to define custom dropdown actions from within the data sources page. +Receives the available bulk data source actions. Return the list with any +additional actions. + +**Current source** +[data_sources.php][data_source_action_array-source]. + +[data_source_action_array-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -349,13 +554,29 @@ Allows you to define custom dropdown actions from within the data sources page. ## data_source_action_bottom +Receives the action and the selected items when Cacti builds the bulk data +source action form. + +**Current source** +[data_sources.php][data_source_action_bottom-source]. + +[data_source_action_bottom-source]: + + | file | introduced | retired | | ---------------- | :--------- | :------ | | data_sources.php | 1.0.0 | ## data_source_action_execute -Allows you to define custom actions to be taken upon your dropdown selection. +Receives the selected action when Cacti executes a custom bulk data source +operation. + +**Current source** +[data_sources.php][data_source_action_execute-source]. + +[data_source_action_execute-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -363,10 +584,16 @@ Allows you to define custom actions to be taken upon your dropdown selection. ## data_source_action_prepare -This is the final component to creating a custom action within the data sources. -In Cacti's form engine, you must provide the dropdown action and then two -follow-up actions to complete the cycle. This is where you actually save the -data. +This is the final component to creating a custom action within the data +sources. In Cacti's form engine, you must provide the drop-down action and then +two follow-up actions to complete the cycle. This is where you actually save +the data. + +**Current source** +[data_sources.php][data_source_action_prepare-source]. + +[data_source_action_prepare-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -374,8 +601,13 @@ data. ## data_source_edit_bottom -Allows you to make minor changes to the Data Sources page, like add a tabbed -interface. +Adds content near the bottom of the data source editor. + +**Current source** +[data_sources.php][data_source_edit_bottom-source]. + +[data_source_edit_bottom-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -383,8 +615,13 @@ interface. ## data_source_edit_top -Allows you to make minor changes to the Data Sources page, like add a tabbed -interface. +Adds content near the top of the data source editor. + +**Current source** +[data_sources.php][data_source_edit_top-source]. + +[data_source_edit_top-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -392,8 +629,13 @@ interface. ## data_source_remove -This hook is called when the data sources used by a graph are removed. The -parameters are the graph's data sources. +Receives an array of local data source IDs when Cacti removes data sources. + +**Current source** +[lib/api_data_source.php][data_source_remove-source]. + +[data_source_remove-source]: + | file | introduced | retired | | ----------------------- | :---------- | :------ | @@ -404,14 +646,29 @@ parameters are the graph's data sources. ## data_source_to_poller_items +Receives the data source, data input definition, and poller items. Return the +array with any additional entries in `poller_items`. + +**Current source** +[lib/utility.php][data_source_to_poller_items-source]. + +[data_source_to_poller_items-source]: + + | file | introduced | retired | | --------------- | :--------- | :------ | | lib/utility.php | 1.0.0 | ## data_sources_table -Allows you to change the data displayed on the Data Sources table. THold uses -this to create a link to that data source's threshold. +Receives the data source being rendered in the list. A plugin can add +information or a link for that data source. + +**Current source** +[data_sources.php][data_sources_table-source]. + +[data_sources_table-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -419,7 +676,14 @@ this to create a link to that data source's threshold. ## device_action_array -Allows you to define custom dropdown actions from within the device/host page. +Receives the available bulk device actions. Return the list with any additional +actions. + +**Current source** +[host.php][device_action_array-source]. + +[device_action_array-source]: + | file | introduced | retired | | -------- | :--------- | :------ | @@ -427,13 +691,28 @@ Allows you to define custom dropdown actions from within the device/host page. ## device_action_bottom +Receives the action and the selected items when Cacti builds the bulk device +action form. + +**Current source** +[host.php][device_action_bottom-source]. + +[device_action_bottom-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | ## device_action_execute -Allows you to define custom actions to be taken upon your dropdown selection. +Receives the action selected for a custom bulk device operation. + +**Current source** +[host.php][device_action_execute-source]. + +[device_action_execute-source]: + | file | introduced | retired | | -------- | :--------- | :------ | @@ -442,8 +721,15 @@ Allows you to define custom actions to be taken upon your dropdown selection. ## device_action_prepare This is the final component to creating a custom action within the devices. In -Cacti's form engine, you must provide the dropdown action and then two follow-up -actions to complete the cycle. This is where you actually save the data. +Cacti's form engine, you must provide the drop-down action and then two +follow-up actions to complete the cycle. This is where you actually save the +data. + +**Current source** +[host.php][device_action_prepare-source]. + +[device_action_prepare-source]: + | file | introduced | retired | | -------- | :--------- | :------ | @@ -451,8 +737,13 @@ actions to complete the cycle. This is where you actually save the data. ## device_change_javascript -Allows you to add JavaScript to the device edit page, after the script that -shows and hides the device fields. +Adds JavaScript to the device settings page. + +**Current source** +[host.php][device_change_javascript-source]. + +[device_change_javascript-source]: + | file | introduced | retired | | -------- | :--------- | :------ | @@ -460,7 +751,14 @@ shows and hides the device fields. ## device_display_text -This hook allows you to add custom column headers to the host list page +Receives the column definitions for the device list. Return the definitions to +display. + +**Current source** +[host.php][device_display_text-source]. + +[device_display_text-source]: + | file | introduced | retired | | -------- | :---------- | :------ | @@ -468,6 +766,15 @@ This hook allows you to add custom column headers to the host list page ## device_edit_pre_bottom +Runs near the bottom of the device edit form. Use it to render additional form +content. + +**Current source** +[host.php][device_edit_pre_bottom-source]. + +[device_edit_pre_bottom-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | @@ -477,14 +784,26 @@ This hook allows you to add custom column headers to the host list page This hook allows you to add custom actions to the host edit page, below the "Create graphs for this Host". +**Current source** +[host.php][device_edit_top_links-source]. + +[device_edit_top_links-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | ## device_filter_end -This hook allows you to add custom filter fields before Cacti's built-in filter to -the host list page +This hook allows you to add custom filter fields before Cacti's built-in filter +to the host list page. + +**Current source** +[host.php][device_filter_end-source]. + +[device_filter_end-source]: + | file | introduced | retired | | -------- | :---------- | :------ | @@ -492,8 +811,14 @@ the host list page ## device_filter_start -This hook allows you to add custom filter fields after Cacti's built-in filter to -the host list page +This hook allows you to add custom filter fields after Cacti's built-in filter +to the host list page. + +**Current source** +[host.php][device_filter_start-source]. + +[device_filter_start-source]: + | file | introduced | retired | | -------- | :---------- | :------ | @@ -501,15 +826,28 @@ the host list page ## device_filters +Receives the list of device filter definitions. Return the definitions to use +for the Devices page. + +**Current source** +[host.php][device_filters-source]. + +[device_filters-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | ## device_remove -This hook allows you to perform additional actions on devices that have been -selected for deletion. The parameter is an array of deleted device IDs. Note -that at this point, the devices are already deleted from the host table. +Receives an array of device IDs after Cacti deletes their host records. + +**Current source** +[lib/api_device.php][device_remove-source]. + +[device_remove-source]: + | file | introduced | retired | | ------------------ | :---------- | :------ | @@ -518,19 +856,44 @@ that at this point, the devices are already deleted from the host table. ## device_sql_where +Receives the query filter used for the device list. Return the filter the page +should use. + +**Current source** +[host.php][device_sql_where-source]. + +[device_sql_where-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | ## device_table_bottom +Runs at the bottom of the device list. Use it to add content in that part of +the page. + +**Current source** +[host.php][device_table_bottom-source]. + +[device_table_bottom-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | ## device_table_replace -Allows you to override the rendering of the host list page +Renders device rows when a plugin changes the column count and the list +contains devices. The callback receives the host records. + +**Current source** +[host.php][device_table_replace-source]. + +[device_table_replace-source]: + | file | introduced | retired | | -------- | :---------- | :------ | @@ -538,8 +901,14 @@ Allows you to override the rendering of the host list page ## device_template_change -Allows you to add template items such as a threshold upon a -device template change +Allows you to add template items such as a threshold upon a device template +change. + +**Current source** +[lib/api_device.php][device_template_change-source]. + +[device_template_change-source]: + | file | introduced | retired | | ------------------ | :---------- | :------ | @@ -547,20 +916,42 @@ device template change ## device_template_edit +Runs while Cacti renders the device template editor. + +**Current source** +[host_templates.php][device_template_edit-source]. + +[device_template_edit-source]: + + | file | introduced | retired | | ------------------ | :--------- | :------ | | host_templates.php | 1.0.0 | ## device_template_top +Runs at the top of the device template page. + +**Current source** +[host_templates.php][device_template_top-source]. + +[device_template_top-source]: + + | file | introduced | retired | | ------------------ | :--------- | :------ | | host_templates.php | 1.0.0 | ## device_top -Called near the top of host.php, after the device actions are defined and -before the requested action is run. +Runs at the top of the Devices page before Cacti processes the requested +action. + +**Current source** +[host.php][device_top-source]. + +[device_top-source]: + | file | introduced | retired | | -------- | :--------- | :------ | @@ -568,9 +959,14 @@ before the requested action is run. ## draw_navigation_text -Just below the Cacti "Console" and "Graphs" tabs, Cacti provides a Navigation -bar that allows you to move backward in a selection tree. Although it is not -foolproof, this hook allows you to populate and navigate that tree. +Receives the navigation definitions. Return the array with entries for plugin +pages so Cacti can build their breadcrumb trail. + +**Current source** +[lib/functions.php][draw_navigation_text-source]. + +[draw_navigation_text-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -578,9 +974,15 @@ foolproof, this hook allows you to populate and navigate that tree. ## expand_title -Allows you to change the expanded title of a data source or graph. The parameter -is an array with `host_id`, `snmp_query_id`, `snmp_index` and `title`. The -returned `title` is used. +Allows you to change the expanded title of a data source or graph. The +parameter is an array with `host_id`, `snmp_query_id`, `snmp_index` and +`title`. The returned `title` is used. + +**Current source** +[lib/variables.php][expand_title-source]. + +[expand_title-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -588,18 +990,45 @@ returned `title` is used. ## export_action +Receives the export parameters for a plugin-defined item. Return the array with +its exported XML in `xml_text`. + +**Current source** +[lib/export.php][export_action-source]. + +[export_action-source]: + + | file | introduced | retired | | -------------- | :---------- | :------ | | lib/export.php | 1.2.0-beta1 | ## fgc_contextoption +Receives the stream context options Cacti has assembled for an HTTP request. +Return the options to use. + +**Current source** +[lib/functions.php][fgc_contextoption-source]. + +[fgc_contextoption-source]: + + | file | introduced | retired | | ----------------- | :--------- | :------ | | lib/functions.php | 1.1.28 | ## get_friendly_name +Runs when the importer requests a display name for an additional object type. +The input includes the current name prefix. + +**Current source** +[lib/import.php][get_friendly_name-source]. + +[get_friendly_name-source]: + + | file | introduced | retired | | -------------- | :---------- | :------ | | lib/import.php | 1.2.0-beta1 | @@ -610,19 +1039,40 @@ Allows a plugin to select the template account for a user. The parameter is the user name or ID. If the plugin returns the value it was given, Cacti uses the account from the `user_template` setting. +**Current source** +[lib/functions.php][get_template_account-source]. + +[get_template_account-source]: + + | file | introduced | retired | | ----------------- | :--------- | :------ | | lib/functions.php | 1.2.20 | ## global_settings_update +Runs when Cacti saves global settings. Use it to refresh plugin state derived +from those settings. + +**Current source** +[settings.php][global_settings_update-source]. + +[global_settings_update-source]: + + | file | introduced | retired | | ------------ | :--------- | :------ | | settings.php | 1.0.0 | ## graph -This hook is called at the top of graph.php page +Runs at the top of the graph page. + +**Current source** +[graph.php][graph-source]. + +[graph-source]: + | file | introduced | retired | | --------- | :--------- | :------ | @@ -630,8 +1080,14 @@ This hook is called at the top of graph.php page ## graph_buttons -You know about the zoom button right? Well this allows you to add any additional -custom button to the right of a graph. +Adds controls to a graph view. Inspect the hook arguments for the local graph +ID and view context. + +**Current source** +[graph.php][graph_buttons-source]. + +[graph_buttons-source]: + | file | introduced | retired | | ------------ | :--------- | :------ | @@ -642,9 +1098,14 @@ The hook is also fired as `graph_buttons_thumbnails`; see below. ## graph_buttons_thumbnails -Same as `graph_buttons`, but called for the drill down icons of the thumbnail -view drawn by `html_graph_thumbnail_area()`. The parameter is an array -with `hook`, `local_graph_id`, `rra`, `view_type`, `tree_id` and `branch_id`. +Adds drill-down controls to thumbnail graphs. The dispatcher supplies the graph +ID, view type, tree ID, and branch ID. + +**Current source** +[lib/html.php][graph_buttons_thumbnails-source]. + +[graph_buttons_thumbnails-source]: + | file | introduced | retired | | ------------ | :--------- | :------ | @@ -652,6 +1113,15 @@ with `hook`, `local_graph_id`, `rra`, `view_type`, `tree_id` and `branch_id`. ## graph_edit_after +Runs after the graph editor renders. The callback receives the graph ID when +the request contains one. + +**Current source** +[graphs.php][graph_edit_after-source]. + +[graph_edit_after-source]: + + | file | introduced | retired | | ---------- | :---------- | :------ | | graphs.php | 1.2.0-beta1 | @@ -659,8 +1129,14 @@ with `hook`, `local_graph_id`, `rra`, `view_type`, `tree_id` and `branch_id`. ## graph_image This hook allows displaying of alternative graphics in place of a graph image. -This hook cannot output text, only modify the image, as it is only called when a -graph is required to be outputted. +This hook cannot output text, only modify the image, as it is only called when +a graph is required to be outputted. + +**Current source** +[graph_image.php][graph_image-source]. + +[graph_image-source]: + | file | introduced | retired | | --------------- | :--------- | :------ | @@ -669,8 +1145,14 @@ graph is required to be outputted. ## graph_items_remove -This hook is called when the data source is deleted, and the option to -remove all graph items tied to the data source is selected. +This hook is called when the data source is deleted, and the option to remove +all graph items tied to the data source is selected. + +**Current source** +[data_sources.php][graph_items_remove-source]. + +[graph_items_remove-source]: + | file | introduced | retired | | ---------------- | :--------- | :------ | @@ -681,14 +1163,26 @@ remove all graph items tied to the data source is selected. Allows you to add custom HTML to the graph tree view page, under the timespan presets and the graph search box. +**Current source** +[lib/html_tree.php][graph_tree_page_buttons-source]. + +[graph_tree_page_buttons-source]: + + | file | introduced | retired | | ----------------- | :--------- | :------ | | lib/html_tree.php | 0.8.7i | ## graphs_action_array -Similar to the host actions and host, prepare and execute hooks. It allows you -to have custom dropdown actions within the graph management interface. +Receives the available bulk graph actions. Return the list with any additional +actions. + +**Current source** +[graphs.php][graphs_action_array-source]. + +[graphs_action_array-source]: + | file | introduced | retired | | ---------- | :--------- | :------ | @@ -696,24 +1190,59 @@ to have custom dropdown actions within the graph management interface. ## graphs_action_bottom +Receives the action and the selected items when Cacti builds the bulk graph +action form. + +**Current source** +[graphs.php][graphs_action_bottom-source]. + +[graphs_action_bottom-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | graphs.php | 1.0.0 | ## graphs_action_execute +Receives the selected action when Cacti dispatches a custom bulk graph action. + +**Current source** +[graphs.php][graphs_action_execute-source]. + +[graphs_action_execute-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | graphs.php | 1.0.0 | ## graphs_action_prepare +Runs while Cacti prepares the confirmation for a custom bulk graph action. The +callback receives the selected action data. + +**Current source** +[graphs.php][graphs_action_prepare-source]. + +[graphs_action_prepare-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | graphs.php | 1.0.0 | ## graphs_item_array +Receives the list of graph template items used by the editor. Return the list +to display. + +**Current source** +[graphs.php][graphs_item_array-source]. + +[graphs_item_array-source]: + + | file | introduced | retired | | ---------- | :---------- | :------ | | graphs.php | 1.2.0-beta1 | @@ -722,14 +1251,26 @@ to have custom dropdown actions within the graph management interface. Add a link at the top of the "Create New Graphs" page. +**Current source** +[graphs_new.php][graphs_new_top_links-source]. + +[graphs_new_top_links-source]: + + | file | introduced | retired | | -------------- | :--------- | :------ | | graphs_new.php | 1.0.0 | ## graphs_remove -This hook is called after one or more graphs are removed. The parameters are the -removed graph IDs. +This hook is called after one or more graphs are removed. The parameters are +the removed graph IDs. + +**Current source** +[lib/api_graph.php][graphs_remove-source]. + +[graphs_remove-source]: + | file | introduced | retired | | ----------------- | :---------- | :------ | @@ -740,8 +1281,14 @@ removed graph IDs. ## graphs_sql_where -This hook allows you to add additional where clauses to the select statement -used to display graphs on the graphs.php page. +Receives the filter used by graph management queries. Return the filter to +apply. + +**Current source** +[graphs.php][graphs_sql_where-source]. + +[graphs_sql_where-source]: + | file | introduced | retired | | ---------- | :--------- | :------ | @@ -752,24 +1299,57 @@ used to display graphs on the graphs.php page. Allows you to add or change entries in the array that maps a page to its help file. +**Current source** +[lib/html.php][help_page-source]. + +[help_page-source]: + + | file | introduced | retired | | ------------ | :--------- | :------ | | lib/html.php | 1.2.17 | ## hmib_get_cpu +Receives the device ID, requested CPU field, and index from the host CPU script +when it handles a get request. + +**Current source** +[scripts/ss_host_cpu.php][hmib_get_cpu-source]. + +[hmib_get_cpu-source]: + + | file | introduced | retired | | ----------------------- | :--------- | :------ | | scripts/ss_host_cpu.php | 1.0.0 | ## hmib_get_cpu_indexes +Receives the device ID when the host CPU script requests processor indexes, +their count, or their query values. + +**Current source** +[scripts/ss_host_cpu.php][hmib_get_cpu_indexes-source]. + +[hmib_get_cpu_indexes-source]: + + | file | introduced | retired | | ----------------------- | :--------- | :------ | | scripts/ss_host_cpu.php | 1.0.0 | ## hmib_get_disk +Receives the device ID, requested storage field, and index from the host disk +script when it handles a get request. + +**Current source** +[scripts/ss_host_disk.php][hmib_get_disk-source]. + +[hmib_get_disk-source]: + + | file | introduced | retired | | ------------------------ | :--------- | :------ | | scripts/ss_host_disk.php | 1.0.0 | @@ -779,6 +1359,12 @@ file. Allows you to make minor changes to the Devices page, like add a tabbed interface. +**Current source** +[host.php][host_edit_bottom-source]. + +[host_edit_bottom-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | @@ -788,24 +1374,57 @@ interface. Allows you to make minor changes to the Devices page, like add a tabbed interface. +**Current source** +[host.php][host_edit_top-source]. + +[host_edit_top-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | ## host_save +Runs on the device save path. The input contains the saved device ID in +`host_id`. + +**Current source** +[host.php][host_save-source]. + +[host_save-source]: + + | file | introduced | retired | | -------- | :--------- | :------ | | host.php | 1.0.0 | ## import_action +Receives the import parameters for a plugin-defined object. Return the array +with the entries for `hash_cache`. + +**Current source** +[lib/import.php][import_action-source]. + +[import_action-source]: + + | file | introduced | retired | | -------------- | :---------- | :------ | | lib/import.php | 1.2.0-beta1 | ## is_console_page +Receives a candidate page URL. The caller treats a return value that differs +from the input as a match for the console. + +**Current source** +[lib/html.php][is_console_page-source]. + +[is_console_page-source]: + + | file | introduced | retired | | ------------ | :--------- | :------ | | lib/html.php | 1.0.0 | @@ -814,15 +1433,27 @@ interface. This allows you to display text or html after the login form. +**Current source** +[auth_login.php][login_after-source]. + +[login_after-source]: + + | file | introduced | retired | | -------------- | :--------- | :------ | | auth_login.php | 1.0.0 | ## login_before -This allows you to display text or html before the login form. Combined with the -above hook, you could draw a box, etc., around the form, change its background -color, etc., to slightly customize the login page. +This allows you to display text or html before the login form. Combined with +the above hook, you could draw a box, etc., around the form, change its +background color, etc., to slightly customize the login page. + +**Current source** +[auth_login.php][login_before-source]. + +[login_before-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -832,6 +1463,12 @@ color, etc., to slightly customize the login page. Used to support alternate login realm types. +**Current source** +[lib/auth.php][login_options_navigate-source]. + +[login_options_navigate-source]: + + | file | introduced | retired | | ----------------------- | :--------- | :------ | | lib/auth.php | 1.0.0 | @@ -840,6 +1477,12 @@ Used to support alternate login realm types. Used to authenticate the user logging in to a custom plugin defined realm. +**Current source** +[lib/auth.php][login_process-source]. + +[login_process-source]: + + | file | introduced | retired | | ------------ | :--------- | :------ | | lib/auth.php | 1.0.0 | @@ -849,6 +1492,12 @@ Used to authenticate the user logging in to a custom plugin defined realm. Used to define additional custom plugin defined authentication realms. The parameter passed is an array of existing authentication realms. +**Current source** +[auth_login.php][login_realms-source]. + +[login_realms-source]: + + | file | introduced | retired | | -------------- | :--------- | :------ | | auth_login.php | 1.0.0 | @@ -857,6 +1506,12 @@ parameter passed is an array of existing authentication realms. Allows the plugin to set/modify that page title. +**Current source** +[auth_login.php][login_title-source]. + +[login_title-source]: + + | file | introduced | retired | | -------------- | :--------- | :------ | | auth_login.php | 1.0.0 | @@ -867,6 +1522,12 @@ This pair of hooks (`logout_pre_session_destroy` and `logout_post_session_destroy`) allows you to preserve some session variables that would otherwise get unset when `session_destroy()` is called. +**Current source** +[logout.php][logout_post_session_destroy-source]. + +[logout_post_session_destroy-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | logout.php | 1.0.0 | @@ -877,14 +1538,25 @@ This pair of hooks (`logout_pre_session_destroy` and `logout_post_session_destroy`) allows you to preserve some session variables that would otherwise get unset when `session_destroy()` is called. +**Current source** +[logout.php][logout_pre_session_destroy-source]. + +[logout_pre_session_destroy-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | logout.php | 1.0.0 | ## nav_login_after -This pair of hooks (`nav_login_before` and `nav_login_after`) allows you to add -custom HTML to the navigation bar, before and after the "Logged in as " text. +Adds navigation content after the signed-in user label. + +**Current source** +[lib/functions.php][nav_login_after-source]. + +[nav_login_after-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -892,8 +1564,13 @@ custom HTML to the navigation bar, before and after the "Logged in as " text. ## nav_login_before -This pair of hooks (`nav_login_before` and `nav_login_after`) allows you to add -custom HTML to the navigation bar, before and after the "Logged in as " text. +Adds navigation content before the signed-in user label. + +**Current source** +[lib/functions.php][nav_login_before-source]. + +[nav_login_before-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -904,14 +1581,26 @@ custom HTML to the navigation bar, before and after the "Logged in as " text. This hook allows you to add custom HTML to the bottom of the page, after the main layout table. +**Current source** +[include/bottom_footer.php][page_bottom-source]. + +[page_bottom-source]: + + | file | introduced | retired | | ------------------------- | :--------- | :------ | | include/bottom_footer.php | 1.0.0 | ## page_buttons -Allows you to add custom buttons and HTML to the top of the graph.php page, -above the "Viewing graph" row. +Adds controls above the graph on the graph view page. Inspect the supplied +graph ID and view context before rendering a control. + +**Current source** +[graph.php][page_buttons-source]. + +[page_buttons-source]: + | file | introduced | retired | | --------- | :--------- | :------ | @@ -919,7 +1608,13 @@ above the "Viewing graph" row. ## page_head -This hook allows you to add custom HTML tags to the page `` tag. +Adds elements to the HTML head of a Cacti page. + +**Current source** +[lib/html.php][page_head-source]. + +[page_head-source]: + | file | introduced | retired | | ------------------------------ | :--------- | :------ | @@ -931,7 +1626,13 @@ This hook allows you to add custom HTML tags to the page `` tag. ## page_title -Allows the plugin to set/modify the page title +Receives the page title. Return the title to display. + +**Current source** +[include/top_graph_header.php][page_title-source]. + +[page_title-source]: + | file | introduced | retired | | ------------------------------ | :--------- | :------ | @@ -941,9 +1642,15 @@ Allows the plugin to set/modify the page title ## poller_bottom -This hook allows you to launch other polling activities once Cacti has completed -its polling activities. Things like MacTrack, Boost, THold, and others use this -hook to launch their respective poller. +Runs near the end of the poller cycle. Plugins use it to launch their own +polling work. On remote collectors Cacti checks the `remote_poller` capability +for this hook. + +**Current source** +[poller.php][poller_bottom-source]. + +[poller_bottom-source]: + | file | introduced | retired | | ---------- | :--------- | :------ | @@ -951,8 +1658,7 @@ hook to launch their respective poller. ## poller_command_args -Using this hook, your plugin can pass additional command line arguments to the -poller. +Historical hook for adding command-line arguments to the poller. | file | introduced | retired | | ---------- | :--------- | :------ | @@ -960,25 +1666,45 @@ poller. ## poller_exiting +Runs on the timeout path when the poller exceeds its maximum runtime. Use it +for timeout handling. + +**Current source** +[poller.php][poller_exiting-source]. + +[poller_exiting-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | poller.php | 1.0.0 | ## poller_finishing +Runs once when the poller observes that all scheduled poller processes have +finished. Cacti then processes any remaining output on the main collector. + +**Current source** +[poller.php][poller_finishing-source]. + +[poller_finishing-source]: + + | file | introduced | retired | | ---------- | :--------- | :------ | | poller.php | 1.0.0 | ## poller_output -This hook was designed specifically for the boost plug-in. However, it has found -new life in many plugins making them much faster now. What this hook allows you -to do is intercept the contents of the `poller_output` table before the data is -deleted. This allows for things like threshold checking and other interesting -actions such as checking for up/down events and the like. Previously, plugins -were reliant on using things like `rrdtool fetch` to perform these actions. Now -they can leverage the poller's output directly. +Receives a batch of RRD update data during poller output processing. A plugin +can use the values for threshold checks. On a remote collector this hook uses +the `remote_collect` capability. + +**Current source** +[lib/poller.php][poller_output-source]. + +[poller_output-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -986,8 +1712,13 @@ they can leverage the poller's output directly. ## poller_remote_maint -This hook will fire for plugins that need to perform remote maintenance. It will -only fire on the Remote Data Collectors. +Runs on a remote data collector during poller maintenance. + +**Current source** +[poller_maintenance.php][poller_remote_maint-source]. + +[poller_remote_maint-source]: + | file | introduced | retired | | ---------------------- | :--------- | :------ | @@ -995,8 +1726,14 @@ only fire on the Remote Data Collectors. ## poller_top -This hook allows you to launch processes concurrently with the Cacti poller for -things like THold's fast poller for example. +Runs at the start of polling. On a remote collector Cacti checks the +`remote_collect` capability. + +**Current source** +[poller.php][poller_top-source]. + +[poller_top-source]: + | file | introduced | retired | | ---------- | :--------- | :------ | @@ -1004,18 +1741,39 @@ things like THold's fast poller for example. ## remote_agent +Receives an action the remote agent did not handle internally. Return a truthy +value when the plugin handled the request. + +**Current source** +[remote_agent.php][remote_agent-source]. + +[remote_agent-source]: + + | file | introduced | retired | | ---------------- | :--------- | :------ | | remote_agent.php | 1.0.0 | ## replicate_in +Historical hook for receiving replicated data. See the retirement version +below. + | file | introduced | retired | | -------------- | :--------- | :------ | | lib/poller.php | 1.0.0 | 1.2.20 | ## replicate_out +Receives the target collector ID, connection, and replication class when Cacti +replicates data to a remote collector. + +**Current source** +[lib/api_device.php][replicate_out-source]. + +[replicate_out-source]: + + | file | introduced | retired | | ------------------ | :--------- | :------ | | lib/api_device.php | | @@ -1023,6 +1781,15 @@ things like THold's fast poller for example. ## resolve_dependencies +Receives the export dependency parameters. Return the array with the +dependencies in `dep_array`. + +**Current source** +[lib/export.php][resolve_dependencies-source]. + +[resolve_dependencies-source]: + + | file | introduced | retired | | -------------- | :---------- | :------ | | lib/export.php | 1.2.0-beta1 | @@ -1033,14 +1800,26 @@ This hook allows you to specify additional options or change parameters regarding graph image rendering. Some of the parameters will be passed to RRDtool. +**Current source** +[lib/rrd.php][rrd_graph_graph_options-source]. + +[rrd_graph_graph_options-source]: + + | file | introduced | retired | | ----------- | :--------- | :------ | | lib/rrd.php | 1.0.0 | ## run_data_query -This hook allows your plugin to perform additional operations after a data query -update was triggered. +Runs when Cacti processes a data query. The arguments identify the device and +the data query. + +**Current source** +[lib/data_query.php][run_data_query-source]. + +[run_data_query-source]: + | file | introduced | retired | | ------------------ | :--------- | :------ | @@ -1048,7 +1827,13 @@ update was triggered. ## settings_bottom -Allows you to add output at the bottom of the Settings page. +Adds content at the bottom of the Settings page. + +**Current source** +[settings.php][settings_bottom-source]. + +[settings_bottom-source]: + | file | introduced | retired | | ------------ | :--------- | :------ | @@ -1056,6 +1841,15 @@ Allows you to add output at the bottom of the Settings page. ## snmpagent_cache_install +Runs when Cacti installs the SNMP agent cache. Plugins that expose SNMP data +can initialize their entries here. + +**Current source** +[lib/snmpagent.php][snmpagent_cache_install-source]. + +[snmpagent_cache_install-source]: + + | file | introduced | retired | | ----------------- | :--------- | :------ | | lib/snmpagent.php | 1.0.0 | @@ -1064,13 +1858,20 @@ Allows you to add output at the bottom of the Settings page. This allows you to add to the substitution variables that Cacti can parse. +**Current source** +[lib/variables.php][substitute_host_data-source]. + +[substitute_host_data-source]: + + | file | introduced | retired | | ----------------- | :--------- | :------ | | lib/variables.php | 1.0.0 | ## top_graph_header -Allows you to override the rendering of the top_graph_header.php include. +Historical hook for customizing the graph header. See the file and version +history below. | file | introduced | retired | | ---------------------------- | :--------- | :------ | @@ -1078,7 +1879,14 @@ Allows you to override the rendering of the top_graph_header.php include. ## top_graph_header_tabs -This hook is used to add tabs to Cacti's user interface. +Adds tabs to the Cacti navigation bar. Register a callback that checks the +visitor’s realm before emitting the tab link. + +**Current source** +[lib/html.php][top_graph_header_tabs-source]. + +[top_graph_header_tabs-source]: + | file | introduced | retired | | ------------ | :--------- | :------ | @@ -1086,14 +1894,29 @@ This hook is used to add tabs to Cacti's user interface. ## top_graph_jquery_function +The graph tree prints the callback result inside its JavaScript initialization +code. + +**Current source** +[lib/html_tree.php][top_graph_jquery_function-source]. + +[top_graph_jquery_function-source]: + + | file | introduced | retired | | ----------------- | :--------- | :------ | | lib/html_tree.php | 1.0.0 | ## top_graph_refresh -This allows you to change the refresh on the graph (and any plug-in page that -calls the graph header) +This allows you to change the refresh on the graph (and any plugin page that +calls the graph header). + +**Current source** +[include/global_session.php][top_graph_refresh-source]. + +[top_graph_refresh-source]: + | file | introduced | retired | | ----------------------------------------- | :--------- | :------ | @@ -1102,9 +1925,8 @@ calls the graph header) ## top_header -This hooks enables you to output custom HTML on top of the graph view page, if -navigation tabs are not rendered. Allows you to override the rendering of the -top_header.php include. +Historical hook for customizing the header. See the file and version history +below. | file | introduced | retired | | ------------------------------ | :--------- | :------ | @@ -1113,8 +1935,14 @@ top_header.php include. ## tree_after -This hook allows you to add additional HTML at the bottom of the graph tree view -page. The HTML is rendered only if a valid graph tree leaf is selected. +This hook allows you to add additional HTML at the bottom of the graph tree +view page. The HTML is rendered only if a valid graph tree leaf is selected. + +**Current source** +[lib/html_tree.php][tree_after-source]. + +[tree_after-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -1122,8 +1950,14 @@ page. The HTML is rendered only if a valid graph tree leaf is selected. ## tree_view_page_end -This hook allows you to add additional HTML at the bottom of the graph tree view -page, irrespective of the leaf selection. +Adds content at the end of the graph tree page, including when no leaf is +selected. + +**Current source** +[graph.php][tree_view_page_end-source]. + +[tree_view_page_end-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -1132,7 +1966,7 @@ page, irrespective of the leaf selection. ## ugroup_tabs -This hook was replaced by `user_group_admin_tab`. +Historical hook for adding tabs to the user group editor. | file | introduced | retired | | -------------------- | :--------- | :------ | @@ -1140,7 +1974,13 @@ This hook was replaced by `user_group_admin_tab`. ## update_data_source_title_cache -This hook is called after the data source title cache is updated. +Receives the local data source ID after Cacti refreshes the title cache. + +**Current source** +[lib/variables.php][update_data_source_title_cache-source]. + +[update_data_source_title_cache-source]: + | file | introduced | retired | | ----------------- | :--------- | :------ | @@ -1148,15 +1988,14 @@ This hook is called after the data source title cache is updated. ## user_admin_action -This hook is part of a series of hooks that allow you to add custom user -settings. Consider a plug-in called "abc". In that plug-in, you want to save -custom settings on a per user basis. Therefore, following our unpublished -table naming standards, you would create a table called "abc_settings". When you -tab over to the "abc" plug-in, you are provided an "abc settings" on the right -similar to "Graphs". The next series of hooks allow you to present those -settings to the user, enable or disable the user's access to that specific "abc -settings" tab and allow an administrator to define custom values for that -plug-in on a per user basis. +Receives the requested user administration action. Return a truthy value when +the plugin has handled it. + +**Current source** +[user_admin.php][user_admin_action-source]. + +[user_admin_action-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -1164,7 +2003,13 @@ plug-in on a per user basis. ## user_admin_edit -See the explanation on `user_admin_action` +Receives the user ID while Cacti renders the editor, or zero for a new user. + +**Current source** +[user_admin.php][user_admin_edit-source]. + +[user_admin_edit-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -1172,7 +2017,14 @@ See the explanation on `user_admin_action` ## user_admin_run_action -See the explanation on `user_admin_action` +Receives the selected user administration tab. Return a truthy value when the +plugin has rendered the tab. + +**Current source** +[user_admin.php][user_admin_run_action-source]. + +[user_admin_run_action-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -1180,7 +2032,13 @@ See the explanation on `user_admin_action` ## user_admin_setup_sql_save -See the explanation on `user_admin_action` +Receives the fields prepared for the user record. Return the fields to save. + +**Current source** +[user_admin.php][user_admin_setup_sql_save-source]. + +[user_admin_setup_sql_save-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -1188,7 +2046,13 @@ See the explanation on `user_admin_action` ## user_admin_tab -See the explanation on `user_admin_action` +Adds a tab to the user editor. + +**Current source** +[user_admin.php][user_admin_tab-source]. + +[user_admin_tab-source]: + | file | introduced | retired | | -------------- | :--------- | :---------- | @@ -1197,7 +2061,14 @@ See the explanation on `user_admin_action` ## user_admin_user_save -See the explanation on `user_admin_action` +Runs when Cacti saves a user account. Use it to save plugin-owned user +settings. + +**Current source** +[user_admin.php][user_admin_user_save-source]. + +[user_admin_user_save-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -1205,7 +2076,14 @@ See the explanation on `user_admin_action` ## user_group_admin_action -Similar to `user_admin_action` +Receives the requested group administration action. Return a truthy value when +the plugin has handled it. + +**Current source** +[user_group_admin.php][user_group_admin_action-source]. + +[user_group_admin_action-source]: + | file | introduced | retired | | -------------------- | :--------- | :------ | @@ -1213,7 +2091,13 @@ Similar to `user_admin_action` ## user_group_admin_edit -See the explanation on `user_admin_action` +Receives the group ID while Cacti renders the editor, or zero for a new group. + +**Current source** +[user_group_admin.php][user_group_admin_edit-source]. + +[user_group_admin_edit-source]: + | file | introduced | retired | | -------------------- | :--------- | :------ | @@ -1221,8 +2105,14 @@ See the explanation on `user_admin_action` ## user_group_admin_run_action -See the explanation on `user_admin_action`. The parameter is the current tab. -When the hook returns a true value, Cacti draws the realm editor for the group. +Receives the selected group administration tab. Return a truthy value when the +plugin has rendered the tab. + +**Current source** +[user_group_admin.php][user_group_admin_run_action-source]. + +[user_group_admin_run_action-source]: + | file | introduced | retired | | -------------------- | :--------- | :------ | @@ -1230,7 +2120,13 @@ When the hook returns a true value, Cacti draws the realm editor for the group. ## user_group_admin_save -See the explanation on `user_admin_action` +Runs when Cacti saves a user group. Use it to save plugin-owned group settings. + +**Current source** +[user_group_admin.php][user_group_admin_save-source]. + +[user_group_admin_save-source]: + | file | introduced | retired | | -------------------- | :--------- | :------ | @@ -1238,13 +2134,27 @@ See the explanation on `user_admin_action` ## user_group_admin_setup_sql_save +Receives the fields prepared for the group record. Return the fields to save. + +**Current source** +[user_group_admin.php][user_group_admin_setup_sql_save-source]. + +[user_group_admin_setup_sql_save-source]: + + | file | introduced | retired | | -------------------- | :--------- | :------ | | user_group_admin.php | 1.0.0 | ## user_group_admin_tab -See the explanation on `user_admin_action`. This hook replaces `ugroup_tabs`. +Adds a tab to the group editor. + +**Current source** +[user_group_admin.php][user_group_admin_tab-source]. + +[user_group_admin_tab-source]: + | file | introduced | retired | | -------------------- | :--------- | :------ | @@ -1252,9 +2162,13 @@ See the explanation on `user_admin_action`. This hook replaces `ugroup_tabs`. ## user_group_remove -Allows the plugin to take part in the user group removal process. The parameter -is the ID of the removed group. Important when the plugin maintains group -settings. +Receives the ID of the group being removed. + +**Current source** +[user_group_admin.php][user_group_remove-source]. + +[user_group_remove-source]: + | file | introduced | retired | | -------------------- | :--------- | :------ | @@ -1262,8 +2176,13 @@ settings. ## user_remove -Allows the plugin to take part in the user removal process. Important when the -plugin maintains user settings. +Receives the ID of the user being removed. + +**Current source** +[lib/auth.php][user_remove-source]. + +[user_remove-source]: + | file | introduced | retired | | -------------- | :--------- | :------ | @@ -1272,8 +2191,14 @@ plugin maintains user settings. ## utilities_action -This hook sets up the function to be executed from within Cacti's utilities -section. +Receives the requested System Utilities action. Return a truthy value if the +plugin handled it. + +**Current source** +[utilities.php][utilities_action-source]. + +[utilities_action-source]: + | file | introduced | retired | | ------------- | :--------- | :------ | @@ -1281,14 +2206,28 @@ section. ## utilities_array +Runs before System Utilities renders its list. Plugins can add entries to the +global `$utilities` array. + +**Current source** +[utilities.php][utilities_array-source]. + +[utilities_array-source]: + + | file | introduced | retired | | ------------- | :--------- | :------ | | utilities.php | 1.0.4 | ## utilities_list -This hook allows you to add a custom utilities pick under Cacti's "Utilities" -page. +Adds entries to the System Utilities page. + +**Current source** +[utilities.php][utilities_list-source]. + +[utilities_list-source]: + | file | introduced | retired | | ------------- | :--------- | :------ | @@ -1296,8 +2235,13 @@ page. ## utilities_tab -This hook allows you to add a custom utilities tab under Cacti's "Utilities" -page. +Adds a tab to System Utilities. + +**Current source** +[utilities.php][utilities_tab-source]. + +[utilities_tab-source]: + | file | introduced | retired | | ------------- | :---------- | :------ | @@ -1311,6 +2255,12 @@ substitute_host_data. Pretty sure that this hook allows you to define custom replacement values in graphs. +**Current source** +[include/global_form.php][valid_host_fields-source]. + +[valid_host_fields-source]: + + | file | introduced | retired | | ----------------------- | :--------- | :------ | | include/global_form.php | 1.0.0 | diff --git a/Plugin-Reference.md b/Plugin-Reference.md index a29be53..f48f10d 100644 --- a/Plugin-Reference.md +++ b/Plugin-Reference.md @@ -1,144 +1,68 @@ # Reference Plugins -FIXME The reference plugin is under development. Nothing to see here yet. - -The Reference Plugin(s) are generic plugins that implement key pieces of the -Plugin Architecture. - -They are broken down into several separate plugins, each covering different -portions of the [Hook API Reference](Plugin-Hook-API-Ref.md). +Use this example to check that Cacti can discover, install, and enable a +plugin before you add a page, hook, or database table. ## Standard Files -The following files should be included in every plugin - -* CHANGELOG -* INFO -* LICENSE -* index.php -* README.md -* setup.php - -In general, the index.php file example below should be included in every plugin -directory as it prevents remote file browsing of your Cacti site. - -```php - -``` +Cacti uses `INFO` for metadata and `setup.php` for lifecycle callbacks. Ship a +README with installation and upgrade instructions, a license, and a record of +release changes. Add an `index.php` in browsable directories if your web +server serves directory indexes. Protect each application page with Cacti's +authentication bootstrap. ## File Structure -All plugin files should reside under their own respective plugin directory. The -example below is for a plugin called 'myplugin'. +Create this directory in a test installation. The two files below are +sufficient for the example. -```console -myplugin/ - images/ - myimage.png - index.php - lib/ - index.php - functions.php - include/ - index.php - settings.php - CHANGELOG - INFO - LICENSE - README.md - index.php - setup.php +```text +plugins/ + myplugin/ + INFO + setup.php ``` +As the plugin grows, put shared functions in `lib/`, settings in `include/`, +and static images in `images/`. Keep the code in `setup.php` small because +Cacti loads it during plugin discovery. + ## Contents of Files -The four core sub-directories included in your plugin should be docs, images, -lib, and include. As previously mentioned, each of these directories should -include an index.php that points to its parent directory index.php. This way -we prevent people from randomly browsing the contents of our web site. +Save the following as `plugins/myplugin/INFO`. Set the compatibility floor of +your own plugin to the oldest Cacti release you support and test. -The two main files required for every plugin are the INFO and the setup.php -file. Without these two files, the plugin directory will not be recognized as a -valid plugin and will be skipped. - -The INFO file is formatted as a Microsoft standard INI file. It contains -information about the plugin including its version, author, dependencies, -functions, and minimum version of Cacti and other plugins required. Below, you -can see a reference INFO file for the myplugin plugin. - -```console +```ini [info] name = myplugin version = 1.0 longname = My First Plugin -author = Depeche Mode -email = somewhere@outthere.com -homepage = http://www.outthere.com -compat = 1.2 -requires = thold monitor -capabilities = online_view:1, online_mgmt:1, offline_view:0, offline_mgmt:0, remote_collect:0 +author = Example Maintainer +homepage = https://www.cacti.net +compat = 1.2.32 ``` -The setup file includes key plugin functions that allow the plugin to be -installed, uninstalled, upgraded, etc. Those core functions include: +Save the following as `plugins/myplugin/setup.php`. ```php +function plugin_myplugin_install() { + // This example has no hooks, realms, or tables to register. +} ``` -Without these core functions, in your setup.php, your plugin will not fully -operate. We will document those functions and what they should include as we -continue to document the plugin design principles. - -Any core plugin functions should always be placed in the lib/functions.php file, -and settings should go into the include/settings.php file. The plugin -architecture allows hooks to be defined that reach into the include/settings.php -file. Having those hooks point to the include version of the file will keep -Cacti page loads fast. Including too much in the setup.php slows Cacti and -should be avoided. +Open **Console > Configuration > Plugins**. Install **My First Plugin** and +enable it. Verify that the management page shows version **1.0** and the +enabled state. This example has no user interface. To add a page or tab, see +[Creating a plugin](Plugin-Creating-Plugins.md). --- + Copyright (c) 2004-2026 The Cacti Group diff --git a/README.md b/README.md index 153c8af..dd388b0 100644 --- a/README.md +++ b/README.md @@ -365,6 +365,8 @@ the maintained Enterprise Linux instructions. 5. [Hook API Reference](Plugin-Hook-API-Ref.md) +6. [Development and Testing](Development-and-Testing.md) + ### Plugins 1. [Supported Plugins](supported-plugins.md) diff --git a/bin/build_html_docs.sh b/bin/build_html_docs.sh index 7a61a64..53f4b11 100755 --- a/bin/build_html_docs.sh +++ b/bin/build_html_docs.sh @@ -72,6 +72,10 @@ then exit 1 fi +# Keep the downloadable plugin alongside its guide in the offline manual. +mkdir -p "${BASE_PATH}/${ODIR}/resources" || exit 1 +cp "${BASE_PATH}/resources/example.tgz" "${BASE_PATH}/${ODIR}/resources/" || exit 1 + # copy css resourse echo "Copying css..." diff --git a/images/plugin-example-management.png b/images/plugin-example-management.png new file mode 100644 index 0000000..369dd2a Binary files /dev/null and b/images/plugin-example-management.png differ diff --git a/images/plugin-example-page.png b/images/plugin-example-page.png new file mode 100644 index 0000000..b33b40a Binary files /dev/null and b/images/plugin-example-page.png differ diff --git a/resources/example.tgz b/resources/example.tgz index 0a5a70a..fbc9d40 100644 Binary files a/resources/example.tgz and b/resources/example.tgz differ