01 Oct 2021 04:47 PM - last edited on 18 May 2023 01:00 PM by Michal_Gebacki
Could anyone help me with this error?
import mysql.connector
from mysql.connector import Error
import requests
from ruxit.api.base_plugin import RemoteBasePlugin
import logging
class PluginDBQuerySQL(RemoteBasePlugin):
def initialize(self, **kwargs):
logger.info("Config: %s", self.config)
self.url = self.config["url"]
try:
con = mysql.connector.connect(host='localhost', database='database', user='biaggio', password='')
consulta_sql = "select * from database.tb_activegate"
cursor = con.cursor()
cursor.execute(consulta_sql)
linhas = cursor.fetchall()
totalLinhas = cursor.rowcount
def query(self, **kwargs😞
#Create topology
url = self.url + "/topology"
topology = requests.get(url).json()
for group_t in topology:
group_name = group_t['name']
group = self.topology_builder.create_group(group_name, group_name)
for device_t in group_t['devices']:
device_name = device_t['name']
device = group.create_device(device_name, device_name)
logger.info("Topology: group name=%s, device name=%s", group.name, device.name)
#Collect stats
stats = device_t['stats']
device.absolute(key='totalLinhas', value=stats['counter'])
except Error as e:
print("Erro ao acessar tabela", e)
finally:
if (con.is_connected()):
con.close()
cursor.close()
print("Conexao fechada")
Solved! Go to Solution.
01 Oct 2021 04:55 PM
How does the install_requires look like in the plugin.json and are you building the extension with oneagent_build_plugin?
Mike
01 Oct 2021 06:14 PM
Hi @Mike_L
I put the:
"install_requires": [
"mysql-connector"
]
Now it's OK for mysql, but now it returns the message to the logger module.
I'm making the plugin with the activegate SDK
04 Oct 2021 12:02 PM
You never initiated a variable that you're using in your script. Did you mean to add
logger = logging.getLogger(__name__)
maybe?
17 Sep 2024 12:59 PM
In simple steps:
17 Sep 2024 01:00 PM
Refer to Dynatrace URL: activegate Purposes
17 Sep 2024 01:06 PM - edited 17 Sep 2024 01:08 PM
Hello @RodrigoBiaggio