mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-20 12:34:39 -04:00
added MongoDB ping monitor
This commit is contained in:
parent
cb4e512dc6
commit
b059a36e66
5 changed files with 2227 additions and 1 deletions
|
@ -13,6 +13,7 @@ const { badgeConstants } = require("./config");
|
|||
const mssql = require("mssql");
|
||||
const { Client } = require("pg");
|
||||
const postgresConParse = require("pg-connection-string").parse;
|
||||
const { MongoClient } = require("mongodb");
|
||||
const { NtlmClient } = require("axios-ntlm");
|
||||
const { Settings } = require("./settings");
|
||||
const grpc = require("@grpc/grpc-js");
|
||||
|
@ -294,6 +295,27 @@ exports.postgresQuery = function (connectionString, query) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Connect to and Ping a MongoDB database
|
||||
* @param {string} connectionString The database connection string
|
||||
* @returns {Promise<(string[]|Object[]|Object)>}
|
||||
*/
|
||||
exports.mongodbPing = async function (connectionString) {
|
||||
let client, db;
|
||||
try {
|
||||
client = await MongoClient.connect(connectionString, {useNewUrlParser: true})
|
||||
db = client.db();
|
||||
dbping = await db.command({ ping: 1 });
|
||||
if (dbping["ok"] === 1) {
|
||||
return 'UP'
|
||||
}
|
||||
throw Error("failed");
|
||||
}
|
||||
catch(err){ console.error(err); }
|
||||
finally{ client.close(); }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query radius server
|
||||
* @param {string} hostname Hostname of radius server
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue