mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-22 06:29:17 -04:00
added sqlserver monitor
This commit is contained in:
parent
332b9ab248
commit
87f933df4f
9 changed files with 1796 additions and 42 deletions
|
@ -10,6 +10,7 @@ const chardet = require("chardet");
|
|||
const mqtt = require("mqtt");
|
||||
const chroma = require("chroma-js");
|
||||
const { badgeConstants } = require("./config");
|
||||
const sql = require("mssql");
|
||||
|
||||
// From ping-lite
|
||||
exports.WIN = /^win/.test(process.platform);
|
||||
|
@ -203,6 +204,30 @@ exports.dnsResolve = function (hostname, resolverServer, rrtype) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Run a query on SQL Server
|
||||
* @param {string} connectionString The database connection string
|
||||
* @param {string} query The query to validate the database with
|
||||
* @returns {Promise<(string[]|Object[]|Object)>}
|
||||
*/
|
||||
exports.sqlserver = function (connectionString, query) {
|
||||
return new Promise((resolve, reject) => {
|
||||
sql.on("error", err => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
sql.connect(connectionString).then(pool => {
|
||||
|
||||
return pool.request()
|
||||
.query(query);
|
||||
}).then(result => {
|
||||
resolve(result);
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve value of setting based on key
|
||||
* @param {string} key Key of setting to retrieve
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue