13 Mar 2020 12:22 PM
@Mattias W. @Mattias W. can you help with the Above please?
Thanks in advance
Solved! Go to Solution.
13 Mar 2020 12:28 PM
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
13 Mar 2020 12:39 PM
Thank @Michael L. i will review and revert
13 Mar 2020 01:00 PM
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")
01 May 2022 04:43 PM
There is now a generic way to do this:
https://community.dynatrace.com/t5/Dynatrace-tips/Custom-Database-Queries/td-p/185781