mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-10 02:14:50 +08:00
Add support for MySQL/MariaDB databases #1817
This commit adds support for monitoring MySQL and MariaDB database servers. The mysql2 package was choosen over mysql as it provides a promise wrapper and is reportedly faster than the original mysql package whilst still maintaining the same API. Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
@@ -13,6 +13,7 @@ const { badgeConstants } = require("./config");
|
||||
const mssql = require("mssql");
|
||||
const { Client } = require("pg");
|
||||
const postgresConParse = require("pg-connection-string").parse;
|
||||
const mysql = require("mysql2/promise");
|
||||
const { NtlmClient } = require("axios-ntlm");
|
||||
const { Settings } = require("./settings");
|
||||
const radiusClient = require("node-radius-client");
|
||||
@@ -291,6 +292,28 @@ exports.postgresQuery = function (connectionString, query) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Run a query on MySQL/MariaDB
|
||||
* @param {string} connectionString The database connection string
|
||||
* @param {string} query The query to validate the database with
|
||||
* @returns {Promise<(string[]|Object[]|Object)>}
|
||||
*/
|
||||
exports.mysqlQuery = function (connectionString, query) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return mysql.createConnection(connectionString)
|
||||
.then(connection => {
|
||||
connection.connect();
|
||||
return connection.query(query);
|
||||
})
|
||||
.then(res => {
|
||||
resolve(res);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.radius = function (
|
||||
hostname,
|
||||
username,
|
||||
|
Reference in New Issue
Block a user