mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-14 20:11:52 +00:00
Add windows linux mac uptime (#5583)
* add linux uptime * add mac uptime --------- Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
5581f3ace8
commit
7e1657d632
3 changed files with 76 additions and 1 deletions
|
@ -1884,6 +1884,29 @@ function getSystemInformation(func) {
|
||||||
}
|
}
|
||||||
} catch (ex) { }
|
} catch (ex) { }
|
||||||
}
|
}
|
||||||
|
if(!results.hardware.linux.LastBootUpTime) {
|
||||||
|
try {
|
||||||
|
var child = require('child_process').execFile('/usr/bin/uptime', ['', '-s']); // must include blank value at begining for some reason?
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stderr.on('data', function () { });
|
||||||
|
child.waitExit();
|
||||||
|
results.hardware.linux.LastBootUpTime = child.stdout.str.trim();
|
||||||
|
} catch (ex) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(process.platform=='darwin'){
|
||||||
|
try {
|
||||||
|
var child = require('child_process').execFile('/usr/sbin/sysctl', ['', 'kern.boottime']); // must include blank value at begining for some reason?
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stderr.on('data', function () { });
|
||||||
|
child.waitExit();
|
||||||
|
const timestampMatch = /\{ sec = (\d+), usec = \d+ \}/.exec(child.stdout.str.trim());
|
||||||
|
if(!results.hardware.darwin){
|
||||||
|
results.hardware.darwin = { LastBootUpTime: parseInt(timestampMatch[1]) };
|
||||||
|
}else{
|
||||||
|
results.hardware.darwin.LastBootUpTime = parseInt(timestampMatch[1]);
|
||||||
|
}
|
||||||
|
} catch (ex) { }
|
||||||
}
|
}
|
||||||
results.hardware.agentvers = process.versions;
|
results.hardware.agentvers = process.versions;
|
||||||
replaceSpacesWithUnderscoresRec(results);
|
replaceSpacesWithUnderscoresRec(results);
|
||||||
|
|
|
@ -5858,6 +5858,32 @@
|
||||||
x += addDetailItem("Last Boot Up Time", date);
|
x += addDetailItem("Last Boot Up Time", date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(hardware.linux && hardware.linux.LastBootUpTime){
|
||||||
|
var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
|
||||||
|
var thedate = {
|
||||||
|
year: lastBootUpTime.getFullYear(),
|
||||||
|
month: lastBootUpTime.getMonth(),
|
||||||
|
day: lastBootUpTime.getDate(),
|
||||||
|
hours: lastBootUpTime.getHours(),
|
||||||
|
minutes: lastBootUpTime.getMinutes(),
|
||||||
|
seconds: lastBootUpTime.getSeconds()
|
||||||
|
};
|
||||||
|
const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
|
||||||
|
x += addDetailItem("Last Boot Up Time", date);
|
||||||
|
}
|
||||||
|
if(hardware.darwin && hardware.darwin.LastBootUpTime){
|
||||||
|
var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct?
|
||||||
|
var thedate = {
|
||||||
|
year: lastBootUpTime.getFullYear(),
|
||||||
|
month: lastBootUpTime.getMonth(),
|
||||||
|
day: lastBootUpTime.getDate(),
|
||||||
|
hours: lastBootUpTime.getHours(),
|
||||||
|
minutes: lastBootUpTime.getMinutes(),
|
||||||
|
seconds: lastBootUpTime.getSeconds()
|
||||||
|
};
|
||||||
|
const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
|
||||||
|
x += addDetailItem("Last Boot Up Time", date);
|
||||||
|
}
|
||||||
|
|
||||||
// Windows Security Central
|
// Windows Security Central
|
||||||
if (node.wsc) {
|
if (node.wsc) {
|
||||||
|
|
|
@ -11663,6 +11663,32 @@
|
||||||
x += addDetailItem("Last Boot Up Time", date);
|
x += addDetailItem("Last Boot Up Time", date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(hardware.linux && hardware.linux.LastBootUpTime){
|
||||||
|
var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
|
||||||
|
var thedate = {
|
||||||
|
year: lastBootUpTime.getFullYear(),
|
||||||
|
month: lastBootUpTime.getMonth(),
|
||||||
|
day: lastBootUpTime.getDate(),
|
||||||
|
hours: lastBootUpTime.getHours(),
|
||||||
|
minutes: lastBootUpTime.getMinutes(),
|
||||||
|
seconds: lastBootUpTime.getSeconds()
|
||||||
|
};
|
||||||
|
const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
|
||||||
|
x += addDetailItem("Last Boot Up Time", date);
|
||||||
|
}
|
||||||
|
if(hardware.darwin && hardware.darwin.LastBootUpTime){
|
||||||
|
var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct?
|
||||||
|
var thedate = {
|
||||||
|
year: lastBootUpTime.getFullYear(),
|
||||||
|
month: lastBootUpTime.getMonth(),
|
||||||
|
day: lastBootUpTime.getDate(),
|
||||||
|
hours: lastBootUpTime.getHours(),
|
||||||
|
minutes: lastBootUpTime.getMinutes(),
|
||||||
|
seconds: lastBootUpTime.getSeconds()
|
||||||
|
};
|
||||||
|
const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
|
||||||
|
x += addDetailItem("Last Boot Up Time", date);
|
||||||
|
}
|
||||||
if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software64.png'}); }
|
if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software64.png'}); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue