Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
235491b
draft impl
radulucut Oct 6, 2025
8edd260
Merge branch 'master' into feature/add-globalping-support
radulucut Oct 6, 2025
2eabb3b
finalize ping
radulucut Oct 7, 2025
f97d2fd
Merge branch 'master' into feature/add-globalping-support
CommanderStorm Oct 7, 2025
eb68637
add subtype and http support
radulucut Oct 9, 2025
88c595a
merge
radulucut Oct 9, 2025
082235f
add dns support
radulucut Oct 10, 2025
64628d5
update Details, ignore globalpingDNSResolveTypeOptions
radulucut Oct 10, 2025
7e75ad8
add keyword and json query to http
radulucut Oct 11, 2025
d59422f
Merge branch 'master' into feature/add-globalping-support
radulucut Oct 11, 2025
361ba48
revert rename
radulucut Oct 11, 2025
d4efaa3
handle TLS info
radulucut Oct 13, 2025
79989dc
update response text, add retries & reorder inputs
radulucut Oct 14, 2025
a5c5449
update text & fix issue when ping is 0
radulucut Oct 14, 2025
cf916a6
update DNS message
radulucut Oct 14, 2025
db4d9d8
fix DNS message, add location default
radulucut Oct 14, 2025
d956708
Merge remote-tracking branch 'upstream' into feature/add-globalping-s…
radulucut Oct 16, 2025
c7ba733
Merge branch 'master' into feature/add-globalping-support
radulucut Oct 20, 2025
afc3d59
review updates
radulucut Oct 20, 2025
f9f54bb
remove dns subtype
radulucut Oct 22, 2025
9650498
Merge branch 'master' into feature/add-globalping-support
radulucut Oct 27, 2025
a377cb6
implement copilot suggestions
radulucut Oct 27, 2025
4a5fe2a
Merge branch 'master' into feature/add-globalping-support
CommanderStorm Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions db/knex_migrations/2025-10-06-0000-add-globalping-monitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exports.up = function (knex) {
// Add new columns
return knex.schema.alterTable("monitor", function (table) {
table.string("subtype", 255).nullable();
table.string("location", 255).nullable();
table.string("protocol", 255).nullable();
});
};

exports.down = function (knex) {
// Drop columns
return knex.schema.alterTable("monitor", function (table) {
table.dropColumn("subtype");
table.dropColumn("location");
table.dropColumn("protocol");
});
};
21 changes: 21 additions & 0 deletions package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be resync with master

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"globalping" npm has deprecated @hey-api dependencies package

https://www.npmjs.com/package/@hey-api/client-fetch

Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"feed": "^4.2.2",
"form-data": "~4.0.0",
"gamedig": "^4.2.0",
"globalping": "^0.2.0",
"html-escaper": "^3.0.3",
"http-cookie-agent": "~5.0.4",
"http-graceful-shutdown": "~3.1.7",
Expand Down
68 changes: 9 additions & 59 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const { log, UP, DOWN, PENDING, MAINTENANCE, flipStatus, MAX_INTERVAL_SECOND, MI
PING_COUNT_MIN, PING_COUNT_MAX, PING_COUNT_DEFAULT,
PING_PER_REQUEST_TIMEOUT_MIN, PING_PER_REQUEST_TIMEOUT_MAX, PING_PER_REQUEST_TIMEOUT_DEFAULT
} = require("../../src/util");
const { tcping, ping, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, setSetting, httpNtlm, radius, grpcQuery,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok old setSetting usage

redisPingAsync, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal
const { tcping, ping, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, httpNtlm, radius, grpcQuery,
redisPingAsync, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal, encodeBase64, checkCertExpiryNotifications
} = require("../util-server");
const { R } = require("redbean-node");
const { BeanModel } = require("redbean-node/dist/bean-model");
Expand Down Expand Up @@ -103,11 +103,14 @@ class Monitor extends BeanModel {
method: this.method,
hostname: this.hostname,
port: this.port,
location: this.location,
protocol: this.protocol,
maxretries: this.maxretries,
weight: this.weight,
active: preloadData.activeStatus.get(this.id),
forceInactive: preloadData.forceInactive.get(this.id),
type: this.type,
subtype: this.subtype,
timeout: this.timeout,
interval: this.interval,
retryInterval: this.retryInterval,
Expand Down Expand Up @@ -241,17 +244,6 @@ class Monitor extends BeanModel {
};
}

/**
* Encode user and password to Base64 encoding
* for HTTP "basic" auth, as per RFC-7617
* @param {string|null} user - The username (nullable if not changed by a user)
* @param {string|null} pass - The password (nullable if not changed by a user)
* @returns {string} Encoded Base64 string
*/
encodeBase64(user, pass) {
return Buffer.from(`${user || ""}:${pass || ""}`).toString("base64");
}

/**
* Is the TLS expiry notification enabled?
* @returns {boolean} Enabled?
Expand Down Expand Up @@ -349,6 +341,7 @@ class Monitor extends BeanModel {
let previousBeat = null;
let retries = 0;

this.rootCertificates = rootCertificates;
this.prometheus = new Prometheus(this);

const beat = async () => {
Expand Down Expand Up @@ -409,7 +402,7 @@ class Monitor extends BeanModel {
let basicAuthHeader = {};
if (this.auth_method === "basic") {
basicAuthHeader = {
"Authorization": "Basic " + this.encodeBase64(this.basic_auth_user, this.basic_auth_pass),
"Authorization": "Basic " + encodeBase64(this.basic_auth_user, this.basic_auth_pass),
};
}

Expand Down Expand Up @@ -861,7 +854,7 @@ class Monitor extends BeanModel {
let startTime = dayjs().valueOf();
const monitorType = UptimeKumaServer.monitorTypeList[this.type];
await monitorType.check(this, bean, UptimeKumaServer.getInstance());
if (!bean.ping) {
if (bean.ping === undefined || bean.ping === null) {
bean.ping = dayjs().valueOf() - startTime;
}

Expand Down Expand Up @@ -1371,49 +1364,6 @@ class Monitor extends BeanModel {
return notificationList;
}

/**
* checks certificate chain for expiring certificates
* @param {object} tlsInfoObject Information about certificate
* @returns {void}
*/
async checkCertExpiryNotifications(tlsInfoObject) {
if (tlsInfoObject && tlsInfoObject.certInfo && tlsInfoObject.certInfo.daysRemaining) {
const notificationList = await Monitor.getNotificationList(this);

if (! notificationList.length > 0) {
// fail fast. If no notification is set, all the following checks can be skipped.
log.debug("monitor", "No notification, no need to send cert notification");
return;
}

let notifyDays = await setting("tlsExpiryNotifyDays");
if (notifyDays == null || !Array.isArray(notifyDays)) {
// Reset Default
await setSetting("tlsExpiryNotifyDays", [ 7, 14, 21 ], "general");
notifyDays = [ 7, 14, 21 ];
}

if (Array.isArray(notifyDays)) {
for (const targetDays of notifyDays) {
let certInfo = tlsInfoObject.certInfo;
while (certInfo) {
let subjectCN = certInfo.subject["CN"];
if (rootCertificates.has(certInfo.fingerprint256)) {
log.debug("monitor", `Known root cert: ${certInfo.certType} certificate "${subjectCN}" (${certInfo.daysRemaining} days valid) on ${targetDays} deadline.`);
break;
} else if (certInfo.daysRemaining > targetDays) {
log.debug("monitor", `No need to send cert notification for ${certInfo.certType} certificate "${subjectCN}" (${certInfo.daysRemaining} days valid) on ${targetDays} deadline.`);
} else {
log.debug("monitor", `call sendCertNotificationByTargetDays for ${targetDays} deadline on certificate ${subjectCN}.`);
await this.sendCertNotificationByTargetDays(subjectCN, certInfo.certType, certInfo.daysRemaining, targetDays, notificationList);
}
certInfo = certInfo.issuerCertificate;
}
}
}
}
}

/**
* Send a certificate notification when certificate expires in less
* than target days
Expand Down Expand Up @@ -1769,7 +1719,7 @@ class Monitor extends BeanModel {

if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) {
log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`);
await this.checkCertExpiryNotifications(tlsInfo);
await checkCertExpiryNotifications(this, tlsInfo);
}
}
}
Expand Down
Loading
Loading