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

can any one help with custom plugin that fetches database statistics using a SQL-query?

cochagwu
Newcomer

@Mattias W. @Mattias W. can you help with the Above please?

Thanks in advance

4 REPLIES 4

Mike_L
Dynatrace Guru
Dynatrace Guru

Hi,

If you have a OneAgent installed on the box I recommend you to follow these instructions to create a OneAgent plugin:

https://dynatrace.github.io/plugin-sdk/readme.html

For ActiveGate plugins we have a help page, but it is quite similar to the OneAgent plugin, except for where it is executed from:

https://www.dynatrace.com/support/help/extend-dynatrace/plugins/activegate-plugins/

If you do not have the time to dive into the above material to create it yourself, you can also reach out to your delivery or account manager and they can reach out to our services team for helping out.

Mike

Mike

Thank @Michael L. i will review and revert

Radoslaw_Szulgo
Inactive

Take a look at my example:


def collectStatsFromDB(self, device):
        try:
            connection = mysql.connector.connect(host=self.databaseUrl,
                                                database=self.dbName,
                                                user=self.dbUsername,
                                                password=self.dbPasswd)
            sql_select_Query = """
                select metric from my_table
"""
            cursor = connection.cursor()
            cursor.execute(sql_select_Query)
            record = cursor.fetchone()
            
            if cursor.rowcount > 0:
                result = [record[0]]
            else:
                result = [0] 
            
            # report stat counter
            device.stat_counter(key='count', value=StatCounterDataPoint(
                result[0], result[0], result[0], 1)
            )
        except Error as e:
            logger.exception(e)
        finally:
            if (connection.is_connected()):
                connection.close()
                cursor.close()
                print("MySQL connection is closed")
Senior Product Manager,
Dynatrace Managed expert

AntonioSousa
DynaMight Guru
DynaMight Guru

Featured Posts