Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Plug-Ins

    Plug-ins can be used to extend the set of metrics monitored and analyzed by AppFormix. Plug-ins are executed by an AppFormix Agent. The metrics produced by the plug-in are associated with the host on which the Agent executed.

    AppFormix Ansible playbooks install a plug-in executable file on a host(s) and configure the plug-in in the AppFormix Platform.

    Add a User-Defined Plug-In

    To create a user-defined plug-in, provide an executable command that produces output in a valid format for plug-ins. For this example, the check_nginx.py script is used, which produces the following output:

    $ python ./check_nginx.py
    OK - nginx.host: 4connections active_connections

    The contents of check_nginx.py can be:

    def get_plugin_name():
        return 'nginx.host'
    
    def get_metric():
        return 4
    
    def get_metric_units():
        return 'connections'
    
    def get_metric_name():
        return 'active_connections'
    
    print "OK - {0}: {1}{2} {3}".format(get_plugin_name(),
                                        get_metric(),
                                        get_metric_units(),
                                        get_metric_name())

    To add this plug-in, define a JSON configuration file in the user_defined_plugins directory of the AppFormix software distribution. The JSON configuration file specifies how to execute the plug-in and the metrics that are produced by the plug-in. In this example, create the nginx.json file with the plug-in configuration for the check_nginx.py plug-in referenced above.

    $ cat > appformix-2.15.2/user_defined_plugins/nginx.json <<EOF
    {
        "AggregateId": "web",
        "Collection": "host_pythonchecknginxpy_collection",
        "Config": {
            "CommandLine": "python check_nginx.py"
        },
        "MetricMap": [
            {
                "Name": "active_connections",
                "Units": "connections"
            }
        ],
        "PluginId": "pythonchecknginxpy",
        "PluginName": "nginx.host",
        "PluginType": "command",
        "Scope": "host",
        "State": "enabled",
    }
    EOF

    Table Table 1 describes the fields in the sample configuration.

    Table 1: Explanation of Fields in the Plug-In Configuration JSON File

    Field

    Description

    AggregateId

    Specifies a host aggregate. Plug-in is installed and configured to run on hosts in this aggregate. If AggregateId is not specified, then plug-in is configured to run on all hosts on which AppFormix Agent is installed.

    Collection

    A label applied to data produced by this plug-in.

    Config.CommandLine

    The command to execute.

    MetricMap

    A list of metrics produced by the plug-in and the units of each metric (for display in the Dashboard).

    PluginId

    Plug-in identifier in AppFormix. This must be unique among all configured plug-ins.

    PluginName

    Name of the plug-in. Name is used as a prefix for the name of all metrics produced by the plug-in.

    PluginType

    Type of the plug-in. Valid options: command.

    Scope

    Scope of this plug-in. Valid options: host.

    State

    Specifies if plug-in is active. Valid options: enabled, disabled.

    A list of user-defined plug-ins can be specified in Ansible group_vars in a variable appformix_user_defined_plugins. The variable specifies a list in which each element of the list is a dictionary. Each dictionary has a plugin_info field to specify the JSON configuration file and plugin_file to specify a file to be copied to the host on which the plug-in will be executed by the AppFormix Agent.

    appformix_user_defined_plugins:
      - { plugin_info: 'user_defined_plugins/nginx.json',
          plugin_file: 'user_defined_plugins/check_nginx.py'}
    

    Configure a Supported Plug-In

    AppFormix includes a set of supported plug-ins in the certified_plugins directory of the release bundle. You can configure a supported plug-in to be installed by setting the appformix_plugins variable in Ansible and running the installation playbook. For example:

    appformix_plugins:
            - { plugin_info: 'certified_plugins/contrail_vrouter.json' }
            - { plugin_info: 'certified_plugins/cassandra_node_usage.json' }
            - { plugin_info: 'certified_plugins/zookeeper_usage.json' }

    Modified: 2018-05-23