@Mattias W. @Mattias W. can you help with the Above please?
Thanks in advance
Solved! Go to Solution.
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
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")
There is now a generic way to do this:
https://community.dynatrace.com/t5/Dynatrace-tips/Custom-Database-Queries/td-p/185781