question

Larry R. avatar image
Larry R. asked ·

Problems with self.find_single_process_group in custom OneAgent plugin - Thoughts?

Good morning all!

I am teaching myself to build a custom plugin and so far so good. It's been fun and frustrating all at the same time :-) I am determined however I am currently stuck and hoping another developer out there can give me some insight to figure out what I am doing wrong.

This is a OneAgent plugin in Python on a Linux host to be clear. I am trying to get my plugin to look for a process to #1 ensure it's running before attempting to grab metrics and #2 to obtain the path of where that process is running from. Looking at TONS of other plugins out there which are helping me to learn allot, it appeared that the following should do it:

try:
pgi = self.find_single_process_group(pgi_name('tibemsd64'))

Yet this does not seem to be the case or at least I think. When I look at the OneAgent plugin log "pluginDevLoggerPluginEngineDefault.log" I can see it's trying, but always comes back with:


File "/opt/dynatrace/oneagent/agent/plugin/engine/ruxit/api/ base_plugin.py", line 112, in find_single_process_group
raise ConfigException("Expected exactly 1 pgi to match predicate found: %s" % len(ret))
ruxit.api.exceptions.ConfigException: Expected exactly 1 pgi to match predicate found: 0

Which if I am reading that correctly, means it is not finding that process. Yet if I do a grep for that process on the host, it is in fact clearly there.


ps -ef | grep tibemsd64
xxxxxx 1663 1 8 Oct08 ? 02:08:33 /lcl/sit/apps/tibco/ems/8.4/bin/tibemsd64

I have been trying to figure out how to get the plugin to provide more details on exactly what it is getting back from the OS doing the following:

try:
pgi = self.find_single_process_group(pgi_name('tibemsd64'))
except ConfigException as e:
raise ConfigException('Can not find the path to tibemsd64: {pgi} {e}')

This however did not work either.

I would really appreciate some pointers on what I might be doing wrong and what I can do to maybe get more information on what is going on behind the scene.

Thank you

oneagentextensionsscripting
5 comments
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Just a quick check, is the process group instance in Dynatrace also called tibemsd64? pgi is not the process name on the server, but the name used within the Dynatrace UI.

1 Like 1 · ·

AH! I was thinking it was the process name on the host. That explains allot!

Thank you SO MUCH! I have been trying for 2 days to figure this out with no luck at all.

0 Likes 0 · ·

Let me know if it worked :)

0 Likes 0 · ·

Well I changed the tibemsd64 to the process group name as detected in Dynatrace which is "Tibco EMS"...


class TibcoEMSPlugin(BasePlugin):
    def query(self, **kwargs):
        config  =  kwargs['config']
        
        url = config['url']
        user = config['user']
        password = config['password']
        pgi = None
        
        try:
            pgi = self.find_single_process_group(pgi_name('Tibco EMS'))
        except ConfigException:
            raise ConfigException('Error 1')


The pluginDevLoggerPluginEngineDefault.log shows...

  File "/opt/dynatrace/oneagent/agent/plugin/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/tibemsadmin': '/tibemsadmin'


Really lost on why it says "No such file or directory: '/tibemsadmin'. It's as if it is not picking up the path. The tibemsadmin is clearly there and in the same directory as the Process Group.


Any ideas? Thank you for the help.

0 Likes 0 · ·
progressgroup.png (30.3 KiB)
directory.png (65.0 KiB)

I'll reach out over email so you can send the log files, then we can update this case once it is resolved.

1 Like 1 · ·
Michael L. avatar image
Michael L. answered ·

The problem was resolved by using the Dynatrace processgroup instance name instead of the OS process name.

The subsequent unrelated problems were solved as well, but that's not related to the issue.

Mike

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Larry R. avatar image
Larry R. answered ·

Yes, Thank you @Michael L. - You were a HUGE help. Very much appreciated!

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Leon Z. avatar image
Leon Z. answered ·

Hey @Larry R., What metric group did you use in your plugin.json?

"metricGroup"

I can see the metric group I created under metrics for my custom chart but there is never any data, even though when I run the plugin simulator it returns a queue with at least 500 messages on it...

I also do not see anything in the logs ... /opt/dynatrace/oneagent/log/plugin/pluginDevLoggerOsAgentDefault.log

The logfile you mentioned in your initial post doesn't exist in my directory. Im using the latest version of the oneagent version 1.177.216


6 comments Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Good morning! I used...

"metricGroup": "TibcoEMS"

The log path would be (Linux)...

/opt/dynatrace/oneagent/log/plugin

Within that path you should see a new log file which gets created called ruxitagent_pluginagent_<DIFFERENT NUMBERS>.log

Each time you create a new build, the OneAgent will start a new log. I would recommend just looking at the path and then as you are testing, examine the timestamps for the logs so you know which ones to look at specifically. At least, this is how I did it anyway :-)


0 Likes 0 · ·

Thanks, tailing the logs , I cant see the plugin fireing just the docker and python heartbeat plugins. My metric group was TibcoEMS anyway.. it's odd

This is not my first plugin I've deployed .... I think I'll wait for you to share your code...:-)

0 Likes 0 · ·
1571924134658.png (28.6 KiB)
1571924203570.png (79.1 KiB)
1571924831701.png (47.0 KiB)

@Larry R. May I also ask what entries you have under :

"processTypeNames" in your plugin.json ?

0 Likes 0 · ·

@Larry R., Hi, I managed to figure it out... I was using the command line with a custom deployment directory -d argument when building the plugin, somehow dynatrace doesn't register the plugin correctly when doing this or I did not copy all the files into the plugin_deployment directory (I use custom directories, for CI pipelines with Jenkins builds for plugins) I used the defaults and my plugin now fires and works as expected. We can compare notes when you share your plugin. :-)

1 Like 1 · ·

Good deal. Glad you got it working!

0 Likes 0 · ·

Thanks Larry, keep up the good work..!!

0 Likes 0 · ·