PHP 7.4.33
Preview: template.py Size: 3.28 KB
//lib/fm-agent/plugins/template.py

"""
FortiMonitor Agent Plugin Template
Copyright 2023 Fortinet, Inc. All Rights Reserved.
[email protected]

The agent comes with pre-written plugins for checking common software (MySQL, Apache, etc) and
OS checks. If you want to track behavior of some software that's not included or custom written,
you can write your own custom plugin that can be tracked by the agent.

Place your plugin file in /usr/share/panopta-agent, so the agent will be able to find it when
rebuilding metric metadata.
"""

import agent_util


class AgentTemplate(agent_util.Plugin):
    """
    The plugin name MUST end in 'Plugin' and be a subclass of the agent_util.Plugin class
    Normally the plugin name should match the plugin textkey without special characters
    """

    # This textkey should be unique and be a short identifier for your custom plugin
    # NOTE: textkey can -not- include spaces, the only special characters allowed are
    #       underscore and periods.  We recommend using a reverse domain name prefix
    #       to generate a unique textkey, for example com.yourdomain.yourtemplate
    textkey = "TEMPLATE_PLUGIN"

    # Human readable label for your plugin that shows in the FortiMonitor controlpanel
    label = "PLUGIN TEMPLATE"

    @classmethod
    def get_metadata(self, config):
        """
        The get_metadata method specifies what data can be collected.  You can also
        use this to check if the server has the proper dependencies and config
        entries to run this plugin.

        Each entry in the dictionary that is returned is another  metric type that can be
        reported on by this plugin.
        """

        # When the agent is able to successfully collect data, return agent_util.SUPPORTED
        # Other statuses include agent_util.UNSUPPORTED and agent_util.MISCONFIGURED
        status = agent_util.SUPPORTED

        # If the plugin cannot be run for any reason, include a helpful message for the user
        msg = None

        data = {
            # 'basic_check' is the metric textkey, these must be unique within the plugin
            "basic_check": {
                # Human readable metric name shown in the controlpanel
                "label": "Checks some value",
                # Any options (such as disk names, interface name, etc) to be passed into the check
                "options": None,
                # Status as mentioned above, normally this is used for the entire plugin
                # but if some metrics need additional dependencies that aren't met, the ability
                # to set a status only on one metric is available
                "status": status,
                # Any custom error message as mentioned above
                "error_message": msg,
                # Unit in which this metric returns data (ms, requests/sec, KB/MB/GB, etc)
                "unit": "Your unit",
            },
        }

        return data

    def check(self, textkey, data, config):
        """
        The check method actually collects the metric values. The complexity of the logic
        here depends entirely on what data you need to collect, how to do so is up to the developer.

        NOTE: ALL values must be returned as a float, or None if you're unable to collect
              a value for the metric.

        """
        value = 0.0
        return your_value

Directory Contents

Dirs: 1 × Files: 55

Name Size Perms Modified Actions
- drwxr-xr-x 2025-06-19 05:08:01
Edit Download
20.07 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
13.66 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
6.34 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
22.59 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
9.46 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.89 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
9.56 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
32.09 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
7.33 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
16.80 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
38.95 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.90 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
930 B lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.00 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
5.07 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
4.68 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
13.46 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
13.21 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
13.58 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
8.39 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
3.34 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.54 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.64 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
6.04 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
26.56 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
16.61 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
20.40 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
5.58 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
12.33 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
6.44 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.98 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.30 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
15.51 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
8.88 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
5.61 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.60 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.99 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
21.37 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
17.23 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
19.85 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
11.31 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.42 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.42 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
6.59 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
3.28 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
7.09 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
19.11 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
4.62 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
3.61 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.09 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
4.73 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
4.91 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
13.84 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
19.20 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
0 B lrw-r--r-- 2025-06-18 20:44:50
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).