Plugin simulator

To facilitate plugin development, Plugin SDK comes with a tool that can execute your plugin without the need for you to run ActiveGate or connect to Dynatrace Server. This plugin simulator is a purely Python solution that's designed to mimic ActiveGate, with a few limitations:

  • Plugin configuration (if any) needs to be provided manually in form of a JSON file.
  • No data is sent to or received from Dynatrace Server.
  • The Python environment contains the libraries required by the plugin.

The format used for plugin configuration is JSON. Following is an example properties.json that must be saved in the directory that contains the developed plugin:

{
  "url": "http://localhost:8769",
  "user": "ruxit",
  "password": "ruxit"
}

The configuration corresponds to the properties section in plugin.json - see ActiveGate plugins reference.

To start the simulator, use the following command:

oneagent_simulate_plugin

Or shorter:

oneagent_sim

No additional arguments are needed if the command is executed from the directory that contains the plugin. For other options, please refer to the command help message.

The simulator runs until it is stopped manually (usually by pressing Ctrl-C), output is written to the terminal and log file, and a short summary of operations is provided upon completion, which should look similar to:

INFO:plugin_development.global:{('custom.remote.python.demo', '123'): (PluginState(pluginName='custom.remote.python.demo', pluginVersion='1.0', state='OK', description='', monitoredEntityId='123', stacktrace=''), 242022.234)}
WARNING:plugin_sdk.plugin_simulator:Plugin simulator was stopped with a Keyboard interrupt                                                                                                                                        
Plugin simulator summary:                                                                                                                                                                                                         
At 10:03:30 reported measurements:                                                                                                                                                                                                
[WrappedPluginMeasurement(monitoredEntityId=8410346495561112286, tsIdentifier='custom.remote.python.demo:countercd', dimensions=[], value=2.0, aggregation=1, isV3=False, isStatetimeseries=False, isStatCounter=False),          
 WrappedPluginMeasurement(monitoredEntityId=837416055638757496, tsIdentifier='custom.remote.python.demo:countercd', dimensions=[], value=2.0, aggregation=1, isV3=False, isStatetimeseries=False, isStatCounter=False)]           
At 10:03:30 reported status: OK                                                                                                                                              

If an error occurs, the summary may offer a hint as to why:

Plugin simulator summary:
At 10:05:17 reported status: UNINITIALIZED
At 10:05:17 reported status: ERROR_UNKNOWN
Status details:
HTTPConnectionPool(host='localhost', port=8769): Max retries exceeded with url: /topology (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000275168A3E48>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

In this example, the error was caused by not having a running oneagent_sdk.demo_app process. So the plugin was unable to gather data.

The report at the end of the simulator run is not the only source of information. You can also analyze log messages that are sent out while the simulator runs.