# check_server.py
import pymysql

conn = pymysql.connect(
    host="172.16.2.100", port=9030, user="anhvh", password="v0WYGeyLRCckXotT", database="shared_source"
)

cursor = conn.cursor()

# Check max connections
cursor.execute("SHOW VARIABLES LIKE 'max_connections'")
print("Max Connections:", cursor.fetchone())

# Check current connections
cursor.execute("SHOW PROCESSLIST")
processes = cursor.fetchall()
print(f"Current Active Connections: {len(processes)}")

# Check slow queries
cursor.execute("SHOW VARIABLES LIKE 'long_query_time'")
print("Slow Query Threshold:", cursor.fetchone())

conn.close()
