Skip to content

Additional processing of data in Plugins

Brett Demetris edited this page Jun 20, 2018 · 4 revisions

In addition to running plugin scripts on the client, you can perform additional processing on the server.

To do so, you should implement the checkin_processor method of your plugin's class. You will need to handle the writing of the data back to the database yourself.

For example, in your plugin.py:

# ...Other imports here

import sal.plugin
from server.models import *

class MyPlugin(sal.plugin.Widget):

    # ...

def checkin_processor(self, machine, report_data):
    # ...Do something with the report_data
    item_we_want = report_data['Facter']['somefact']

    # Some munging could happen here - maybe sending it to another service
    plugin_name = 'WhizzyPlugin'
    plugin_script = PluginScriptSubmission(machine=machine, plugin=plugin_name, historical=False)
    plugin_script.save()
    data = plugin.get('data')
    plugin_row = PluginScriptRow(submission=plugin_script, pluginscript_name='WhizzyData', pluginscript_data=item_we_want, submission_and_script_name=(plugin_name + ': ' + 'WhizzyData'))

    plugin_row.save()

For what it's worth, none of the builtin plugins need to use this mechanism.

Processor Reference

See plugin.py for all current methods

name args description
checkin_processor machine (string), report_data (dict) handles data passed through the /checkin route
profiles_processor machine (string), profiles_list (dict) handles data passed through the /profiles route
Clone this wiki locally