core: telemetry: add dbVersion

pull/421/head
undefined 2 years ago
parent b1b933f3d7
commit 01d9879ebf

@ -48,6 +48,7 @@ class DataReportHandler extends Handler {
discussionCount: payload.discussionCount,
recordCount: payload.recordCount,
sandbox: payload.sandbox,
dbVersion: payload.dbVersion,
},
}, { upsert: true });
bus.emit('center/report', this, installId, old, payload);

@ -1,6 +1,6 @@
{
"name": "@hydrooj/center",
"version": "0.1.1",
"version": "0.1.2",
"main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git",
"author": "undefined <i@undefined.moe>",

@ -31,14 +31,7 @@ export async function feedback(): Promise<[string, StatusUpdate]> {
document.coll.find({ docType: document.TYPE_DISCUSSION }).count(),
record.coll.find().count(),
]);
let sandbox = '';
try {
let host = system.get('hydrojudge.sandbox_host') || 'http://localhost:5050/';
if (!host.endsWith('/')) host += '/';
const res = await superagent.get(`${host}version`);
sandbox = res.body;
} catch (e) { }
const payload = crypt(dump({
const info: Record<string, any> = {
mid: mid.toString(),
version,
name,
@ -52,8 +45,18 @@ export async function feedback(): Promise<[string, StatusUpdate]> {
memory: inf.memory,
osinfo: inf.osinfo,
cpu: inf.cpu,
sandbox,
}, {
};
try {
let host = system.get('hydrojudge.sandbox_host') || 'http://localhost:5050/';
if (!host.endsWith('/')) host += '/';
const res = await superagent.get(`${host}version`);
info.sandbox = res.body;
} catch (e) { }
try {
const status = await db.db.admin().serverStatus();
info.dbVersion = status.version;
} catch (e) { }
const payload = crypt(dump(info, {
replacer: (key, value) => {
if (typeof value === 'function') return '';
return value;

Loading…
Cancel
Save