always show operating system section and LastBootUpTime fix

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458 2024-09-15 23:02:23 +01:00
parent 8bc760855e
commit 7172d1f701
3 changed files with 118 additions and 111 deletions

View File

@ -364,7 +364,18 @@ function linux_identifiers()
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.on('data', function () { });
child.waitExit();
values.linux.LastBootUpTime = child.stdout.str.trim();
var regex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
if (regex.test(child.stdout.str.trim())) {
values.linux.LastBootUpTime = child.stdout.str.trim();
} else {
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('date -d "@$(( $(date +%s) - $(awk \'{print int($1)}\' /proc/uptime) ))" "+%Y-%m-%d %H:%M:%S"\nexit\n');
child.waitExit();
if (regex.test(child.stdout.str.trim())) {
values.linux.LastBootUpTime = child.stdout.str.trim();
}
}
child = null;
} catch (ex) { }

View File

@ -6152,91 +6152,89 @@
var sections = [], s = {};
// Operating System
if ((hardware.windows && hardware.windows.osinfo) || node.osdesc) {
var x = '';
if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); }
if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); }
if (hardware.windows && hardware.windows.osinfo) {
var m = hardware.windows.osinfo;
if (m.OSArchitecture) {
if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); }
else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); }
else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); }
}
if(m.LastBootUpTime){
var thedate = {
year: parseInt(m.LastBootUpTime.substring(0, 4)),
month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December)
day: parseInt(m.LastBootUpTime.substring(6, 8)),
hours: parseInt(m.LastBootUpTime.substring(8, 10)),
minutes: parseInt(m.LastBootUpTime.substring(10, 12)),
seconds: parseInt(m.LastBootUpTime.substring(12, 14)),
};
const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
x += addDetailItem("Last Boot Up Time", date);
}
var x = '';
if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); }
if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); }
if (hardware.windows && hardware.windows.osinfo) {
var m = hardware.windows.osinfo;
if (m.OSArchitecture) {
if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); }
else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); }
else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); }
}
if(hardware.linux && hardware.linux.LastBootUpTime){
var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
if(m.LastBootUpTime){
var thedate = {
year: lastBootUpTime.getFullYear(),
month: lastBootUpTime.getMonth(),
day: lastBootUpTime.getDate(),
hours: lastBootUpTime.getHours(),
minutes: lastBootUpTime.getMinutes(),
seconds: lastBootUpTime.getSeconds()
year: parseInt(m.LastBootUpTime.substring(0, 4)),
month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December)
day: parseInt(m.LastBootUpTime.substring(6, 8)),
hours: parseInt(m.LastBootUpTime.substring(8, 10)),
minutes: parseInt(m.LastBootUpTime.substring(10, 12)),
seconds: parseInt(m.LastBootUpTime.substring(12, 14)),
};
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
if (node.wsc) {
var y = [];
if (node.wsc.antiVirus != null) { if (node.wsc.antiVirus == 'OK') { y.push("AV" + ' - <span style=color:green>' + "OK" + '</span>'); } else { y.push("AV" + ' - <span style=color:red>' + "BAD" + '</span>'); } }
if (node.wsc.autoUpdate != null) { if (node.wsc.autoUpdate == 'OK') { y.push("Update" + ' - <span style=color:green>' + "OK" + '</span>'); } else { y.push("Update" + ' - <span style=color:red>' + "BAD" + '</span>'); } }
if (node.wsc.firewall != null) { if (node.wsc.firewall == 'OK') { y.push("Firewall" + ' - <span style=color:green>' + "OK" + '</span>'); } else { y.push("Firewall" + ' - <span style=color:red>' + "BAD" + '</span>'); } }
x += addDetailItem("Windows Security", y.join(', '));
}
// Defender for Windows Server
if(node.defender && !node.wsc) {
var y = [];
if (node.defender.RealTimeProtection != null) { if (node.defender.RealTimeProtection == true) { y.push("RealTimeProtection" + ' - <span style=color:green>' + "On" + '</span>'); } else { y.push("RealTimeProtection" + ' - <span style=color:red>' + "Off" + '</span>'); } }
if (node.defender.TamperProtected != null) { if (node.defender.TamperProtected == true) { y.push("TamperProtection" + ' - <span style=color:green>' + "On" + '</span>'); } else { y.push("TamperProtection" + ' - <span style=color:red>' + "Off" + '</span>'); } }
x += addDetailItem("Windows Defender", y.join(', '));
}
// Antivirus
if (node.av && node.av.length > 0) {
var y = [];
for (var i in node.av) {
if (node.av[i].product) {
var avx = EscapeHtml(node.av[i].product);
if (node.av[i].enabled !== true) { avx += ' - <span style=color:red>' + "Disabled" + '</span>'; }
if (node.av[i].updated !== true) { avx += ' - <span style=color:red>' + "Out of date" + '</span>'; }
if ((node.av[i].enabled == true) && (node.av[i].updated == true)) { avx += ' - <span style=color:green>' + "OK" + '</span>'; }
y.push(avx);
}
}
x += addDetailItem("Antivirus", y.join('<br />'));
}
if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software' }); }
}
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
if (node.wsc) {
var y = [];
if (node.wsc.antiVirus != null) { if (node.wsc.antiVirus == 'OK') { y.push("AV" + ' - <span style=color:green>' + "OK" + '</span>'); } else { y.push("AV" + ' - <span style=color:red>' + "BAD" + '</span>'); } }
if (node.wsc.autoUpdate != null) { if (node.wsc.autoUpdate == 'OK') { y.push("Update" + ' - <span style=color:green>' + "OK" + '</span>'); } else { y.push("Update" + ' - <span style=color:red>' + "BAD" + '</span>'); } }
if (node.wsc.firewall != null) { if (node.wsc.firewall == 'OK') { y.push("Firewall" + ' - <span style=color:green>' + "OK" + '</span>'); } else { y.push("Firewall" + ' - <span style=color:red>' + "BAD" + '</span>'); } }
x += addDetailItem("Windows Security", y.join(', '));
}
// Defender for Windows Server
if(node.defender && !node.wsc) {
var y = [];
if (node.defender.RealTimeProtection != null) { if (node.defender.RealTimeProtection == true) { y.push("RealTimeProtection" + ' - <span style=color:green>' + "On" + '</span>'); } else { y.push("RealTimeProtection" + ' - <span style=color:red>' + "Off" + '</span>'); } }
if (node.defender.TamperProtected != null) { if (node.defender.TamperProtected == true) { y.push("TamperProtection" + ' - <span style=color:green>' + "On" + '</span>'); } else { y.push("TamperProtection" + ' - <span style=color:red>' + "Off" + '</span>'); } }
x += addDetailItem("Windows Defender", y.join(', '));
}
// Antivirus
if (node.av && node.av.length > 0) {
var y = [];
for (var i in node.av) {
if (node.av[i].product) {
var avx = EscapeHtml(node.av[i].product);
if (node.av[i].enabled !== true) { avx += ' - <span style=color:red>' + "Disabled" + '</span>'; }
if (node.av[i].updated !== true) { avx += ' - <span style=color:red>' + "Out of date" + '</span>'; }
if ((node.av[i].enabled == true) && (node.av[i].updated == true)) { avx += ' - <span style=color:green>' + "OK" + '</span>'; }
y.push(avx);
}
}
x += addDetailItem("Antivirus", y.join('<br />'));
}
if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software' }); }
// MeshAgent
if (node.agent) {

View File

@ -12018,42 +12018,40 @@
var sections = [], s = {};
// Operating System
if ((hardware.windows && hardware.windows.osinfo) || node.osdesc) {
var x = '';
if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); }
if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); }
if (hardware.windows && hardware.windows.osinfo) {
var m = hardware.windows.osinfo;
if (m.OSArchitecture) {
if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); }
else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); }
else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); }
}
if(m.LastBootUpTime){
var thedate = {
year: parseInt(m.LastBootUpTime.substring(0, 4)),
month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December)
day: parseInt(m.LastBootUpTime.substring(6, 8)),
hours: parseInt(m.LastBootUpTime.substring(8, 10)),
minutes: parseInt(m.LastBootUpTime.substring(10, 12)),
seconds: parseInt(m.LastBootUpTime.substring(12, 14)),
};
const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
x += addDetailItem("Last Boot Up Time", date);
}
var x = '';
if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); }
if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); }
if (hardware.windows && hardware.windows.osinfo) {
var m = hardware.windows.osinfo;
if (m.OSArchitecture) {
if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); }
else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); }
else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); }
}
if(hardware.linux && hardware.linux.LastBootUpTime){
var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
const date = printDateTime(lastBootUpTime);
if(m.LastBootUpTime){
var thedate = {
year: parseInt(m.LastBootUpTime.substring(0, 4)),
month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December)
day: parseInt(m.LastBootUpTime.substring(6, 8)),
hours: parseInt(m.LastBootUpTime.substring(8, 10)),
minutes: parseInt(m.LastBootUpTime.substring(10, 12)),
seconds: parseInt(m.LastBootUpTime.substring(12, 14)),
};
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?
const date = printDateTime(lastBootUpTime);
x += addDetailItem("Last Boot Up Time", date);
}
if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software64.png'}); }
}
if(hardware.linux && hardware.linux.LastBootUpTime){
var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
const date = printDateTime(lastBootUpTime);
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?
const date = printDateTime(lastBootUpTime);
x += addDetailItem("Last Boot Up Time", date);
}
if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software64.png'}); }
// MeshAgent
if (node.agent) {