-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into task/ignore-redis-tls
- Loading branch information
Showing
43 changed files
with
1,339 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
exports.up = function (knex) { | ||
return knex.schema | ||
.alterTable("status_page", function (table) { | ||
table.integer("auto_refresh_interval").defaultTo(300).unsigned(); | ||
}); | ||
}; | ||
|
||
exports.down = function (knex) { | ||
return knex.schema.alterTable("status_page", function (table) { | ||
table.dropColumn("auto_refresh_interval"); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
BEGIN TRANSACTION; | ||
|
||
PRAGMA writable_schema = TRUE; | ||
|
||
UPDATE | ||
SQLITE_MASTER | ||
SET | ||
sql = replace(sql, | ||
'monitor_id INTEGER NOT NULL', | ||
'monitor_id INTEGER NOT NULL REFERENCES [monitor] ([id]) ON DELETE CASCADE ON UPDATE CASCADE' | ||
) | ||
WHERE | ||
name = 'monitor_tls_info' | ||
AND type = 'table'; | ||
|
||
PRAGMA writable_schema = RESET; | ||
|
||
COMMIT; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const { MonitorType } = require("./monitor-type"); | ||
const { UP } = require("../../src/util"); | ||
const { MongoClient } = require("mongodb"); | ||
const jsonata = require("jsonata"); | ||
|
||
class MongodbMonitorType extends MonitorType { | ||
|
||
name = "mongodb"; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
async check(monitor, heartbeat, _server) { | ||
let command = { "ping": 1 }; | ||
if (monitor.databaseQuery) { | ||
command = JSON.parse(monitor.databaseQuery); | ||
} | ||
|
||
let result = await this.runMongodbCommand(monitor.databaseConnectionString, command); | ||
|
||
if (result["ok"] !== 1) { | ||
throw new Error("MongoDB command failed"); | ||
} else { | ||
heartbeat.msg = "Command executed successfully"; | ||
} | ||
|
||
if (monitor.jsonPath) { | ||
let expression = jsonata(monitor.jsonPath); | ||
result = await expression.evaluate(result); | ||
if (result) { | ||
heartbeat.msg = "Command executed successfully and the jsonata expression produces a result."; | ||
} else { | ||
throw new Error("Queried value not found."); | ||
} | ||
} | ||
|
||
if (monitor.expectedValue) { | ||
if (result.toString() === monitor.expectedValue) { | ||
heartbeat.msg = "Command executed successfully and expected value was found"; | ||
} else { | ||
throw new Error("Query executed, but value is not equal to expected value, value was: [" + JSON.stringify(result) + "]"); | ||
} | ||
} | ||
|
||
heartbeat.status = UP; | ||
} | ||
|
||
/** | ||
* Connect to and run MongoDB command on a MongoDB database | ||
* @param {string} connectionString The database connection string | ||
* @param {object} command MongoDB command to run on the database | ||
* @returns {Promise<(string[] | object[] | object)>} Response from | ||
* server | ||
*/ | ||
async runMongodbCommand(connectionString, command) { | ||
let client = await MongoClient.connect(connectionString); | ||
let result = await client.db().command(command); | ||
await client.close(); | ||
return result; | ||
} | ||
} | ||
|
||
module.exports = { | ||
MongodbMonitorType, | ||
}; |
Oops, something went wrong.