# Plugin Development ## Overview Cacti plugins extend the web interface and the polling process. The plugin architecture grew out of Jimmy Conner's work on the SquirrelMail project. - [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. 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 need changes to run on Cacti 1.x. Cacti 1.x uses the Plugin Architecture (PIA) 2.x installation and setup conventions. ## Plugin Migration 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 ### Required Steps - 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 - 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. ### INFO File Structure The `INFO` file uses INI syntax. Put the following keys in its `[info]` section. - `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 Monitor 3.0 declares Thold as a dependency. Cacti checks the installed version of Thold before it installs Monitor. ```ini [info] name = monitor version = 3.0 longname = Device Monitoring author = The Cacti Group email = homepage = http://www.cacti.net 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 ``` 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 = 5.0 longname = Syslog Monitoring author = The Cacti Group email = homepage = http://www.cacti.net compat = 1.2.23 nosync = config.php capabilities = online_view:1, online_mgmt:1, offline_view:1, offline_mgmt:1, remote_collect:0, remote_poller:1 ``` 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+ 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. [development-guide]: ## Charting Functionality 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 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