cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Plugin Development for OneAgent: Sample py script does not work?

jan_palic
Guide

Hi there.

I try to understand and learn the plugin development of OneAgent plugins. I follow the documentation

* https://help.dynatrace.com/monitoring-plugins/cust... and
* https://dynatrace.github.io/plugin-sdk/readme.html

but I see after

* installing a proper python on my debian workstation

* installing the OneAgent and installing the whl file with pip3

nothing working and I wonder why.

First, the second documentation says that I will find a python script or module called

* oneagent_sdk.demo_app

but I do not see anything in the SDK (downloaded from the Dynatrace Server) or in the OneAgent installation directory (/opt/dynatrace).
Second, I find in the SDK directory (unzipped from the SDK archive I downloaded) the demo_plugin.py, which does nothing calling by python3.5.

I am confused and got stuck, so my question is, what I miss to do here? May anyone help me to get my next step, running the demo plugin?

Thanks in advance.
Jan

14 REPLIES 14

Julius_Loman
DynaMight Legend
DynaMight Legend

I was playing with the Oneagent SDK a while ago also on Debian. It was quite a pain since Debian is still using Python 2.7 by default and some python 3 dependencies were missing.

As far as I remember plugins are not intended to be executed directly as python files, but using oneagent_simulate_plugin command that gets installed with the SDK itself. Go to the demo_plugin directory of the SDK and run the simulate plugin command oneagent_simulate_plugin .

Then running the python -m oneagent_sdk.demo_app from the documentation, I believe the python command resolves to Python 2.7 (debian default) and that is probably your cause.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

jan_palic
Guide

Hi Julius,

thank you for your answer and the hint.

I was looking for a file oneagent_sdk.demo_app and did not found it (what is clear, now!).
My python is already set to 3.5 with update alternatives, so this was done before.

Anyway, long story short, it works... thank you.

.-)

Jan

TorstenHellwig
Organizer


Interesting - I can't get the simulator to work on Windows. Even with the supplied sample plugins I get an error:



2017-09-06 13:25:37,314 [ERROR] - 3048(MainThread) - [_main] Plugin simulator was stopped with enexpected exception
Traceback (most recent call last):
File "c:\users\torsten hellwig\appdata\local\programs\python\python35-32\lib\site-packages\oneagent_sdk\plugin_simulator.py", line 217, in _main
external_api=external_api
TypeError: main() got an unexpected keyword argument 'external_api'



Plugin simulator summary:





Python Version is 3.5.3, 32bit.



Any idea?



cheers,



Torsten

Dynatrace Master, Appmon Master

I'm currently encountering the same bug on Linux. Which version of oneagent-sdk do you have? I have plugin-sdk-1.125.174.20170821-131816

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

It must be definitely a bug in the simulator in recent versions. I've tried also the 123 version and 113 (I'v found the archive on my laptop). In 113 the oneagent_simulator seems to be working and it's not failing at the external_api error.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

TorstenHellwig
Organizer

Yes, I got the same answer in the meantime from @Michael L.

Seems to be a known bug with my 123.229 version. Good to know that 113 works.

torsten

Dynatrace Master, Appmon Master

chuan_sern_wong
Advisor

,

Hi Guys,

Just begin my baby step to the plugin exploration and encountered the same issue on my vagrant - CentOS Linux release 7.3.1611 (Core). Do anyone know where to download the previous version that works ?

[vagrant@localhost demo_plugin_multi]$ oneagent_sim
2017-09-07 07:03:23,633 [ERROR] - 140201704101696(MainThread) - [_main] Plugin simulator was stopped with enexpected exception
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/oneagent_sdk/plugin_simulator.py", line 217, in _main
external_api=external_api
TypeError: main() got an unexpected keyword argument 'external_api'

Historical versions are not available to download from the UI.
However I'm uploading here the old version (113) that was laying around on my HDD from the time I made first steps with the SDK.

Let's hope it won't violate some policy for uploading that here. 🙂

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

No, it won't 🙂

Actually, it's one of the best "self-service" threads I've read in the Dynatrace forums 🙂

Best regards,

Karolina

Keep calm and build Community!

TorstenHellwig
Organizer

Perfect! Works...

Dynatrace Master, Appmon Master

Jakub_Mierzewsk
Inactive

This bug is fixed in agent 127. @Julius L. thx for workaround

Julius_Loman
DynaMight Legend
DynaMight Legend

FYI - It seems the problem is resolved in latest SDK - version 127. At least it works for me now.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

thobishim
Frequent Guest

Hi

I am also trying to test out the SDK but I am getting the following error whenever I try to test the simulator:

--------------------------------------------------------------------------------------------------------------------------------------------

C:\Users\NB204316\Documents\plugin-sdk-1.149.213.20180809-141631\examples\demo_oneagent_plugin>oneagent_simulate_plugin INFO:ruxit.plugin_loop:Installing plugins with conflict resolution INFO:ruxit.package_utils.plugin_updater:Unable to get revision from plugin_directory_path 'C:\\Users\\NB204316\\Documents\\plugin-sdk-1.149.213.20180809-141631\\examples\\demo_oneagent_plugin', assuming -1 INFO:ruxit.package_utils.plugin_updater:plugins_by_revision: defaultdict(<class 'dict'>, {'no_revision': {'custom.python.demo_plugin': PluginInfo(name='custom.python.demo_plugin', reported_name='custom.python.demo_plugin', version='1.2', directory='C:\\Users\\NB204316\\Documents\\plugin-sdk-1.149.213.20180809-141631\\examples\\demo_oneagent_plugin' package='demo_plugin')}}) INFO:ruxit.package_utils.plugin_updater:Installing plugins INFO:ruxit.package_utils.plugin_updater:Processing revision 'no_revision' INFO:ruxit.package_utils.plugin_updater:Processing candidate_entries: {'custom.python.demo_plugin': PluginInfo(name='custom.python.demo_plugin', reported_name='custom.python.demo_plugin', version='1.2', directory='C:\\Users\\NB204316\\Documents\\plugin-sdk-1.149.213.20180809-141631\\examples\\demo_oneagent_plugin' package='demo_plugin')} INFO:ruxit.package_utils.plugin_updater:Working set validated, new current_entries: OrderedDict([('custom.python.demo_plugin', PluginInfo(name='custom.python.demo_plugin', reported_name='custom.python.demo_plugin', version='1.2', directory='C:\\Users\\NB204316\\Documents\\plugin-sdk-1.149.213.20180809-141631\\examples\\demo_oneagent_plugin' package='demo_plugin'))]) INFO:ruxit.package_utils.plugin_updater:Plugin PluginInfo(name='custom.python.demo_plugin', reported_name='custom.python.demo_plugin', version='1.2', directory='C:\\Users\\NB204316\\Documents\\plugin-sdk-1.149.213.20180809-141631\\examples\\demo_oneagent_plugin' package='demo_plugin') from revision 'no_revision' compatible INFO:ruxit.package_utils.plugin_updater:Processing revision 'plugin_deployment' INFO:ruxit.package_utils.plugin_updater:Processing revision 'plugin_development' INFO:ruxit.plugin_loop:========= INCOMPATIBLE PLUGINS ========= INFO:ruxit.plugin_loop:[] INFO:ruxit.plugin_loop:======================================== INFO:ruxit.plugin_loop:**************************************** INFO:ruxit.plugin_loop:[PluginInfo(name='custom.python.demo_plugin', reported_name='custom.python.demo_plugin', version='1.2', directory='C:\\Users\\NB204316\\Documents\\plugin-sdk-1.149.213.20180809-141631\\examples\\demo_oneagent_plugin' package='demo_plugin')] INFO:ruxit.plugin_loop:**************************************** INFO:ruxit.plugin_loop:sys.path after installing plugins: ['C:\\Python35\\Scripts\\oneagent_simulate_plugin.exe', 'c:\\python35\\python35.zip', 'c:\\python35\\DLLs', 'c:\\python35\\lib', 'c:\\python35', 'c:\\python35\\lib\\site-packages', 'C:\\Users\\NB204316\\Documents\\plugin-sdk-1.149.213.20180809-141631\\examples\\demo_oneagent_plugin'] ERROR:oneagent_sdk.plugin_simulator:Plugin simulator was stopped with unexpected exception Traceback (most recent call last): File "c:\python35\lib\site-packages\oneagent_sdk\plugin_simulator.py", line 265, in _main platform_api=platform_api File "c:\python35\lib\site-packages\ruxit\plugin_loop.py", line 340, in main loop.main() File "c:\python35\lib\site-packages\ruxit\plugin_loop.py", line 91, in main next(support_alert_creator) TypeError: 'Mock' object is not an iterator

--------------------------------------------------------------------------------------------------------------------------------------------

I am running Python 3.5 and my sdk is plugin-sdk-1.149.213.20180809-141631 on Windows 10

I am trying to run "oneagent_simulate_plugin"


I'm not sure if I am missing anything, as this is a the error that has more meaning "TypeError: 'Mock' object is not an iterator"

It looks like python is having issues with the Mock object


Featured Posts