Add windows linux mac uptime (#5583)
* add linux uptime * add mac uptime --------- Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Nov 26, 2023 at 18:15 UTC
7e1657d632f230a0fe94284451435520ba67ec9f
3 files changed
+76
-1
agents/meshcore.js
+23
@@ -1884,6 +1884,29 @@ function getSystemInformation(func) {
1884
}
1885
} catch (ex) { }
1886
}
1887
+ if(!results.hardware.linux.LastBootUpTime) {
1888
+ try {
1889
+ var child = require('child_process').execFile('/usr/bin/uptime', ['', '-s']); // must include blank value at begining for some reason?
1890
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
1891
+ child.stderr.on('data', function () { });
1892
+ child.waitExit();
1893
+ results.hardware.linux.LastBootUpTime = child.stdout.str.trim();
1894
+ } catch (ex) { }
1895
+ }
1896
+ }
1897
+ if(process.platform=='darwin'){
1898
+ try {
1899
+ var child = require('child_process').execFile('/usr/sbin/sysctl', ['', 'kern.boottime']); // must include blank value at begining for some reason?
1900
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
1901
+ child.stderr.on('data', function () { });
1902
+ child.waitExit();
1903
+ const timestampMatch = /\{ sec = (\d+), usec = \d+ \}/.exec(child.stdout.str.trim());
1904
+ if(!results.hardware.darwin){
1905
+ results.hardware.darwin = { LastBootUpTime: parseInt(timestampMatch[1]) };
1906
+ }else{
1907
+ results.hardware.darwin.LastBootUpTime = parseInt(timestampMatch[1]);
1908
+ }
1909
+ } catch (ex) { }
1910
}
1911
results.hardware.agentvers = process.versions;
1912
replaceSpacesWithUnderscoresRec(results);
views/default-mobile.handlebars
+27
-1
@@ -5858,7 +5858,33 @@
5858
x += addDetailItem("Last Boot Up Time", date);
5859
}
5860
}
5861
-
5861
+ if(hardware.linux && hardware.linux.LastBootUpTime){
5862
+ var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
5863
+ var thedate = {
5864
+ year: lastBootUpTime.getFullYear(),
5865
+ month: lastBootUpTime.getMonth(),
5866
+ day: lastBootUpTime.getDate(),
5867
+ hours: lastBootUpTime.getHours(),
5868
+ minutes: lastBootUpTime.getMinutes(),
5869
+ seconds: lastBootUpTime.getSeconds()
5870
+ };
5871
+ const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
5872
+ x += addDetailItem("Last Boot Up Time", date);
5873
+ }
5874
+ if(hardware.darwin && hardware.darwin.LastBootUpTime){
5875
+ var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct?
5876
+ var thedate = {
5877
+ year: lastBootUpTime.getFullYear(),
5878
+ month: lastBootUpTime.getMonth(),
5879
+ day: lastBootUpTime.getDate(),
5880
+ hours: lastBootUpTime.getHours(),
5881
+ minutes: lastBootUpTime.getMinutes(),
5882
+ seconds: lastBootUpTime.getSeconds()
5883
+ };
5884
+ const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
5885
+ x += addDetailItem("Last Boot Up Time", date);
5886
+ }
5887
+
5888
// Windows Security Central
5889
if (node.wsc) {
5890
var y = [];
views/default.handlebars
+26
@@ -11663,6 +11663,32 @@
11663
x += addDetailItem("Last Boot Up Time", date);
11664
}
11665
}
11666
+ if(hardware.linux && hardware.linux.LastBootUpTime){
11667
+ var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
11668
+ var thedate = {
11669
+ year: lastBootUpTime.getFullYear(),
11670
+ month: lastBootUpTime.getMonth(),
11671
+ day: lastBootUpTime.getDate(),
11672
+ hours: lastBootUpTime.getHours(),
11673
+ minutes: lastBootUpTime.getMinutes(),
11674
+ seconds: lastBootUpTime.getSeconds()
11675
+ };
11676
+ const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
11677
+ x += addDetailItem("Last Boot Up Time", date);
11678
+ }
11679
+ if(hardware.darwin && hardware.darwin.LastBootUpTime){
11680
+ var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct?
11681
+ var thedate = {
11682
+ year: lastBootUpTime.getFullYear(),
11683
+ month: lastBootUpTime.getMonth(),
11684
+ day: lastBootUpTime.getDate(),
11685
+ hours: lastBootUpTime.getHours(),
11686
+ minutes: lastBootUpTime.getMinutes(),
11687
+ seconds: lastBootUpTime.getSeconds()
11688
+ };
11689
+ const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
11690
+ x += addDetailItem("Last Boot Up Time", date);
11691
+ }
11692
if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software64.png'}); }
11693
}
11694