fix typescript typings, code cleanup, docs updated
This commit is contained in:
+1
-1
@@ -230,7 +230,7 @@ module.exports = function (callback) {
|
||||
workload.push(util.powerShell('(Get-WmiObject -Class BatteryFullChargedCapacity -Namespace ROOT/WMI).FullChargedCapacity'));
|
||||
util.promiseAll(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
if (data) {
|
||||
let parts = data.results[0].split(/\n\s*\n/);
|
||||
let batteries = [];
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ const si = require('./index');
|
||||
// ----------------------------------------------------------------------------------
|
||||
(function () {
|
||||
si.getStaticData().then(
|
||||
(data => {
|
||||
((data) => {
|
||||
data.time = si.time();
|
||||
console.log(JSON.stringify(data, null, 2));
|
||||
}
|
||||
|
||||
+2
-2
@@ -656,7 +656,7 @@ function getCpu() {
|
||||
result.cores = parseInt(countThreads) || util.cores();
|
||||
result.physicalCores = parseInt(countCores) || util.cores();
|
||||
}
|
||||
cpuCache().then(res => {
|
||||
cpuCache().then((res) => {
|
||||
result.cache = res;
|
||||
resolve(result);
|
||||
});
|
||||
@@ -816,7 +816,7 @@ function getCpu() {
|
||||
|
||||
Promise.all(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
let lines = data[0].split('\r\n');
|
||||
let name = util.getValue(lines, 'name', ':') || '';
|
||||
if (name.indexOf('@') >= 0) {
|
||||
|
||||
+6
-19
@@ -35,7 +35,7 @@ function dockerInfo(callback) {
|
||||
}
|
||||
const result = {};
|
||||
|
||||
_docker_socket.getInfo(data => {
|
||||
_docker_socket.getInfo((data) => {
|
||||
result.id = data.ID;
|
||||
result.containers = data.Containers;
|
||||
result.containersRunning = data.ContainersRunning;
|
||||
@@ -130,7 +130,7 @@ function dockerImages(all, callback) {
|
||||
if (workload.length) {
|
||||
Promise.all(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
});
|
||||
@@ -255,24 +255,11 @@ function dockerContainers(all, callback) {
|
||||
element.Name = element.Names[0].replace(/^\/|\/$/g, '');
|
||||
}
|
||||
workload.push(dockerContainerInspect(element.Id.trim(), element));
|
||||
// result.push({
|
||||
// id: element.Id,
|
||||
// name: element.Name,
|
||||
// image: element.Image,
|
||||
// imageID: element.ImageID,
|
||||
// command: element.Command,
|
||||
// created: element.Created,
|
||||
// state: element.State,
|
||||
// ports: element.Ports,
|
||||
// mounts: element.Mounts,
|
||||
// // hostconfig: element.HostConfig,
|
||||
// // network: element.NetworkSettings
|
||||
// });
|
||||
});
|
||||
if (workload.length) {
|
||||
Promise.all(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
});
|
||||
@@ -511,7 +498,7 @@ function dockerContainerStats(containerIDs, callback) {
|
||||
if (workload.length) {
|
||||
Promise.all(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
});
|
||||
@@ -685,7 +672,7 @@ function dockerVolumes(callback) {
|
||||
if (!_docker_socket) {
|
||||
_docker_socket = new DockerSocket();
|
||||
}
|
||||
_docker_socket.listVolumes(data => {
|
||||
_docker_socket.listVolumes((data) => {
|
||||
let dockerVolumes = {};
|
||||
try {
|
||||
dockerVolumes = data;
|
||||
@@ -726,7 +713,7 @@ function dockerAll(callback) {
|
||||
if (result && Object.prototype.toString.call(result) === '[object Array]' && result.length > 0) {
|
||||
let l = result.length;
|
||||
result.forEach(function (element) {
|
||||
dockerContainerStats(element.id).then(res => {
|
||||
dockerContainerStats(element.id).then((res) => {
|
||||
// include stats in array
|
||||
element.memUsage = res[0].memUsage;
|
||||
element.memLimit = res[0].memLimit;
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ function fsSize(callback) {
|
||||
const linuxTmpFileSystems = ['rootfs', 'unionfs', 'squashfs', 'cramfs', 'initrd', 'initramfs', 'devtmpfs', 'tmpfs', 'udev', 'devfs', 'specfs', 'type', 'appimaged'];
|
||||
let result = false;
|
||||
linuxTmpFileSystems.forEach(linuxFs => {
|
||||
if (fs.toLowerCase().indexOf(linuxFs) >= 0) result = true;
|
||||
if (fs.toLowerCase().indexOf(linuxFs) >= 0) { result = true; }
|
||||
});
|
||||
return result;
|
||||
}
|
||||
@@ -1209,7 +1209,7 @@ function diskLayout(callback) {
|
||||
}
|
||||
util.promiseAll(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
let devices = data.results[0].toString().split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
let lines = device.split('\r\n');
|
||||
|
||||
+1
-1
@@ -784,7 +784,7 @@ function graphics(callback) {
|
||||
|
||||
Promise.all(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
// controller + vram
|
||||
let csections = data[0].replace(/\r/g, '').split(/\n\s*\n/);
|
||||
let vsections = data[1].replace(/\r/g, '').split(/\n\s*\n/);
|
||||
|
||||
Vendored
+35
-32
@@ -156,16 +156,16 @@ export namespace Systeminformation {
|
||||
type: string;
|
||||
protocol: string;
|
||||
};
|
||||
model_family?: string,
|
||||
model_name?: string,
|
||||
serial_number?: string,
|
||||
firmware_version?: string,
|
||||
model_family?: string;
|
||||
model_name?: string;
|
||||
serial_number?: string;
|
||||
firmware_version?: string;
|
||||
smart_status: {
|
||||
passed: boolean;
|
||||
};
|
||||
trim?: {
|
||||
supported: boolean;
|
||||
},
|
||||
};
|
||||
ata_smart_attributes?: {
|
||||
revision: number;
|
||||
table: {
|
||||
@@ -185,7 +185,10 @@ export namespace Systeminformation {
|
||||
event_count: boolean;
|
||||
auto_keep: boolean;
|
||||
};
|
||||
raw: { value: number; string: string; };
|
||||
raw: {
|
||||
value: number;
|
||||
string: string;
|
||||
};
|
||||
}[];
|
||||
};
|
||||
ata_smart_error_log?: {
|
||||
@@ -201,12 +204,12 @@ export namespace Systeminformation {
|
||||
type: {
|
||||
value: number;
|
||||
string: string;
|
||||
},
|
||||
};
|
||||
status: {
|
||||
value: number;
|
||||
string: string;
|
||||
passed: boolean;
|
||||
},
|
||||
};
|
||||
lifetime_hours: number;
|
||||
}[];
|
||||
count: number;
|
||||
@@ -215,34 +218,34 @@ export namespace Systeminformation {
|
||||
};
|
||||
};
|
||||
nvme_pci_vendor?: {
|
||||
id: number,
|
||||
id: number;
|
||||
subsystem_id: number;
|
||||
},
|
||||
nvme_smart_health_information_log?: {
|
||||
critical_warning?: number,
|
||||
temperature?: number,
|
||||
available_spare?: number,
|
||||
available_spare_threshold?: number,
|
||||
percentage_used?: number,
|
||||
data_units_read?: number,
|
||||
data_units_written?: number,
|
||||
host_reads?: number,
|
||||
host_writes?: number,
|
||||
controller_busy_time?: number,
|
||||
power_cycles?: number,
|
||||
power_on_hours?: number,
|
||||
unsafe_shutdowns?: number,
|
||||
media_errors?: number,
|
||||
num_err_log_entries?: number,
|
||||
warning_temp_time?: number,
|
||||
critical_comp_time?: number,
|
||||
critical_warning?: number;
|
||||
temperature?: number;
|
||||
available_spare?: number;
|
||||
available_spare_threshold?: number;
|
||||
percentage_used?: number;
|
||||
data_units_read?: number;
|
||||
data_units_written?: number;
|
||||
host_reads?: number;
|
||||
host_writes?: number;
|
||||
controller_busy_time?: number;
|
||||
power_cycles?: number;
|
||||
power_on_hours?: number;
|
||||
unsafe_shutdowns?: number;
|
||||
media_errors?: number;
|
||||
num_err_log_entries?: number;
|
||||
warning_temp_time?: number;
|
||||
critical_comp_time?: number;
|
||||
temperature_sensors?: number[];
|
||||
},
|
||||
user_capacity?: {
|
||||
blocks: number,
|
||||
blocks: number;
|
||||
bytes: number;
|
||||
},
|
||||
logical_block_size?: number,
|
||||
logical_block_size?: number;
|
||||
temperature: {
|
||||
current: number;
|
||||
};
|
||||
@@ -283,7 +286,7 @@ export namespace Systeminformation {
|
||||
currentCapacity: number;
|
||||
capacityUnit: string;
|
||||
percent: number;
|
||||
timeRemaining: number,
|
||||
timeRemaining: number;
|
||||
acConnected: boolean;
|
||||
type: string;
|
||||
model: string;
|
||||
@@ -618,7 +621,7 @@ export namespace Systeminformation {
|
||||
interface ProcessesProcessData {
|
||||
pid: number;
|
||||
parentPid: number;
|
||||
name: string,
|
||||
name: string;
|
||||
cpu: number;
|
||||
cpuu: number;
|
||||
cpus: number;
|
||||
@@ -627,7 +630,7 @@ export namespace Systeminformation {
|
||||
memVsz: number;
|
||||
memRss: number;
|
||||
nice: number;
|
||||
started: string,
|
||||
started: string;
|
||||
state: string;
|
||||
tty: string;
|
||||
user: string;
|
||||
@@ -772,7 +775,7 @@ export namespace Systeminformation {
|
||||
restartCount: number;
|
||||
cpuStats: any;
|
||||
precpuStats: any;
|
||||
memoryStats: any,
|
||||
memoryStats: any;
|
||||
networks: any;
|
||||
}
|
||||
|
||||
|
||||
+20
-20
@@ -95,7 +95,7 @@ function getStaticData(callback) {
|
||||
network.networkInterfaces(),
|
||||
memory.memLayout(),
|
||||
filesystem.diskLayout()
|
||||
]).then(res => {
|
||||
]).then((res) => {
|
||||
data.system = res[0];
|
||||
data.bios = res[1];
|
||||
data.baseboard = res[2];
|
||||
@@ -181,95 +181,95 @@ function getDynamicData(srv, iface, callback) {
|
||||
data.node = process.versions.node;
|
||||
data.v8 = process.versions.v8;
|
||||
|
||||
cpu.cpuCurrentSpeed().then(res => {
|
||||
cpu.cpuCurrentSpeed().then((res) => {
|
||||
data.cpuCurrentSpeed = res;
|
||||
functionProcessed();
|
||||
});
|
||||
|
||||
users.users().then(res => {
|
||||
users.users().then((res) => {
|
||||
data.users = res;
|
||||
functionProcessed();
|
||||
});
|
||||
|
||||
processes.processes().then(res => {
|
||||
processes.processes().then((res) => {
|
||||
data.processes = res;
|
||||
functionProcessed();
|
||||
});
|
||||
|
||||
cpu.currentLoad().then(res => {
|
||||
cpu.currentLoad().then((res) => {
|
||||
data.currentLoad = res;
|
||||
functionProcessed();
|
||||
});
|
||||
|
||||
if (!_sunos) {
|
||||
cpu.cpuTemperature().then(res => {
|
||||
cpu.cpuTemperature().then((res) => {
|
||||
data.temp = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
if (!_openbsd && !_freebsd && !_netbsd && !_sunos) {
|
||||
network.networkStats(iface).then(res => {
|
||||
network.networkStats(iface).then((res) => {
|
||||
data.networkStats = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
if (!_sunos) {
|
||||
network.networkConnections().then(res => {
|
||||
network.networkConnections().then((res) => {
|
||||
data.networkConnections = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
memory.mem().then(res => {
|
||||
memory.mem().then((res) => {
|
||||
data.mem = res;
|
||||
functionProcessed();
|
||||
});
|
||||
|
||||
if (!_sunos) {
|
||||
battery().then(res => {
|
||||
battery().then((res) => {
|
||||
data.battery = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
if (!_sunos) {
|
||||
processes.services(srv).then(res => {
|
||||
processes.services(srv).then((res) => {
|
||||
data.services = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
if (!_sunos) {
|
||||
filesystem.fsSize().then(res => {
|
||||
filesystem.fsSize().then((res) => {
|
||||
data.fsSize = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
if (!_windows && !_openbsd && !_freebsd && !_netbsd && !_sunos) {
|
||||
filesystem.fsStats().then(res => {
|
||||
filesystem.fsStats().then((res) => {
|
||||
data.fsStats = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
if (!_windows && !_openbsd && !_freebsd && !_netbsd && !_sunos) {
|
||||
filesystem.disksIO().then(res => {
|
||||
filesystem.disksIO().then((res) => {
|
||||
data.disksIO = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
if (!_openbsd && !_freebsd && !_netbsd && !_sunos) {
|
||||
wifi.wifiNetworks().then(res => {
|
||||
wifi.wifiNetworks().then((res) => {
|
||||
data.wifiNetworks = res;
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
|
||||
internet.inetLatency().then(res => {
|
||||
internet.inetLatency().then((res) => {
|
||||
data.inetLatency = res;
|
||||
functionProcessed();
|
||||
});
|
||||
@@ -301,9 +301,9 @@ function getAllData(srv, iface, callback) {
|
||||
iface = '';
|
||||
}
|
||||
|
||||
getStaticData().then(res => {
|
||||
getStaticData().then((res) => {
|
||||
data = res;
|
||||
getDynamicData(srv, iface).then(res => {
|
||||
getDynamicData(srv, iface).then((res) => {
|
||||
for (let key in res) {
|
||||
if ({}.hasOwnProperty.call(res, key)) {
|
||||
data[key] = res[key];
|
||||
@@ -333,7 +333,7 @@ function get(valueObject, callback) {
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(allPromises).then(data => {
|
||||
Promise.all(allPromises).then((data) => {
|
||||
const result = {};
|
||||
let i = 0;
|
||||
for (let key in valueObject) {
|
||||
@@ -419,7 +419,7 @@ function observe(valueObject, interval, callback) {
|
||||
let _data = null;
|
||||
|
||||
const result = setInterval(() => {
|
||||
get(valueObject).then(data => {
|
||||
get(valueObject).then((data) => {
|
||||
if (JSON.stringify(_data) !== JSON.stringify(data)) {
|
||||
_data = Object.assign({}, data);
|
||||
callback(data);
|
||||
|
||||
+7
-7
@@ -250,7 +250,7 @@ function getWindowsNics() {
|
||||
let cmd = 'Get-WmiObject Win32_NetworkAdapter | fl *' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_NetworkAdapterConfiguration | fl DHCPEnabled' + '';
|
||||
try {
|
||||
util.powerShell(cmd).then(data => {
|
||||
util.powerShell(cmd).then((data) => {
|
||||
data = data.split('#-#-#-#');
|
||||
const nsections = (data[0] || '').split(/\n\s*\n/);
|
||||
const nconfigsections = (data[1] || '').split(/\n\s*\n/);
|
||||
@@ -1161,7 +1161,7 @@ function networkStats(ifaces, callback) {
|
||||
if (workload.length) {
|
||||
Promise.all(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
});
|
||||
@@ -1183,7 +1183,7 @@ function networkStatsSingle(iface) {
|
||||
if (sections[i].trim() !== '') {
|
||||
let lines = sections[i].trim().split('\r\n');
|
||||
perfData.push({
|
||||
name: util.getValue(lines, 'Name', ':').replace(/[()[\] ]+/g, '').replace(/\#|\//g, '_').toLowerCase(),
|
||||
name: util.getValue(lines, 'Name', ':').replace(/[()[\] ]+/g, '').replace(/#|\//g, '_').toLowerCase(),
|
||||
rx_bytes: parseInt(util.getValue(lines, 'BytesReceivedPersec', ':'), 10),
|
||||
rx_errors: parseInt(util.getValue(lines, 'PacketsReceivedErrors', ':'), 10),
|
||||
rx_dropped: parseInt(util.getValue(lines, 'PacketsReceivedDiscarded', ':'), 10),
|
||||
@@ -1202,7 +1202,7 @@ function networkStatsSingle(iface) {
|
||||
let ifaceSanitized = '';
|
||||
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
|
||||
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
|
||||
if (!(s[i] === undefined)) {
|
||||
if (s[i] !== undefined) {
|
||||
ifaceSanitized = ifaceSanitized + s[i];
|
||||
}
|
||||
}
|
||||
@@ -1334,8 +1334,8 @@ function networkStatsSingle(iface) {
|
||||
det.mac.toLowerCase() === ifaceSanitized.toLowerCase() ||
|
||||
det.ip4.toLowerCase() === ifaceSanitized.toLowerCase() ||
|
||||
det.ip6.toLowerCase() === ifaceSanitized.toLowerCase() ||
|
||||
det.ifaceName.replace(/[()[\] ]+/g, '').replace(/\#|\//g, '_').toLowerCase() === ifaceSanitized.replace(/[()[\] ]+/g, '').replace('#', '_').toLowerCase()) &&
|
||||
(det.ifaceName.replace(/[()[\] ]+/g, '').replace(/\#|\//g, '_').toLowerCase() === detail.name)) {
|
||||
det.ifaceName.replace(/[()[\] ]+/g, '').replace(/#|\//g, '_').toLowerCase() === ifaceSanitized.replace(/[()[\] ]+/g, '').replace('#', '_').toLowerCase()) &&
|
||||
(det.ifaceName.replace(/[()[\] ]+/g, '').replace(/#|\//g, '_').toLowerCase() === detail.name)) {
|
||||
ifaceName = det.iface;
|
||||
rx_bytes = detail.rx_bytes;
|
||||
rx_dropped = detail.rx_dropped;
|
||||
@@ -1693,7 +1693,7 @@ function networkGatewayDefault(callback) {
|
||||
});
|
||||
if (!result) {
|
||||
util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }')
|
||||
.then(data => {
|
||||
.then((data) => {
|
||||
let lines = data.toString().split('\r\n');
|
||||
if (lines.length > 1 && !result) {
|
||||
result = util.getValue(lines, 'NextHop');
|
||||
|
||||
+2
-2
@@ -250,7 +250,7 @@ function osInfo(callback) {
|
||||
result.build = (release.BUILD_ID || '').replace(/"/g, '').trim();
|
||||
isUefiLinux().then(uefi => {
|
||||
result.uefi = uefi;
|
||||
uuid().then(data => {
|
||||
uuid().then((data) => {
|
||||
result.serial = data.os;
|
||||
if (callback) {
|
||||
callback(result);
|
||||
@@ -333,7 +333,7 @@ function osInfo(callback) {
|
||||
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SystemInformation]::TerminalServerSession'));
|
||||
util.promiseAll(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
|
||||
result.distro = util.getValue(lines, 'Caption', ':').trim();
|
||||
result.serial = util.getValue(lines, 'SerialNumber', ':').trim();
|
||||
|
||||
+3
-3
@@ -571,7 +571,7 @@ function baseboard(callback) {
|
||||
workload.push(execPromise('export LC_ALL=C; dmidecode -t memory 2>/dev/null'));
|
||||
util.promiseAll(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
let lines = data.results[0] ? data.results[0].toString().split('\n') : [''];
|
||||
result.manufacturer = util.getValue(lines, 'Manufacturer');
|
||||
result.model = util.getValue(lines, 'Product Name');
|
||||
@@ -630,7 +630,7 @@ function baseboard(callback) {
|
||||
workload.push(execPromise('system_profiler SPMemoryDataType'));
|
||||
util.promiseAll(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
let lines = data.results[0] ? data.results[0].toString().replace(/[<>"]/g, '').split('\n') : [''];
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
||||
result.model = util.getValue(lines, 'model', '=', true);
|
||||
@@ -668,7 +668,7 @@ function baseboard(callback) {
|
||||
workload.push(util.powerShell(`Get-WmiObject Win32_physicalmemoryarray | select ${maxCapacityAttribute}, MemoryDevices | fl`));
|
||||
util.promiseAll(
|
||||
workload
|
||||
).then(data => {
|
||||
).then((data) => {
|
||||
let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
|
||||
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', ':');
|
||||
|
||||
-15
@@ -278,21 +278,6 @@ function usb(callback) {
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
|
||||
// util.powerShell("gwmi Win32_USBControllerDevice |\%{[wmi]($_.Dependent)}").then(data => {
|
||||
|
||||
// const parts = data.toString().split(/\n\s*\n/);
|
||||
// for (let i = 0; i < parts.length; i++) {
|
||||
// const usb = parseWindowsUsb(parts[i].split('\n'), i)
|
||||
// if (usb) {
|
||||
// result.push(usb)
|
||||
// }
|
||||
// }
|
||||
// if (callback) {
|
||||
// callback(result);
|
||||
// }
|
||||
// resolve(result);
|
||||
// });
|
||||
}
|
||||
if (_sunos || _freebsd || _openbsd || _netbsd) {
|
||||
resolve(null);
|
||||
|
||||
+1
-49
@@ -26,44 +26,6 @@ const _openbsd = (_platform === 'openbsd');
|
||||
const _netbsd = (_platform === 'netbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
// let _winDateFormat = {
|
||||
// dateFormat: '',
|
||||
// dateSeperator: '',
|
||||
// timeFormat: '',
|
||||
// timeSeperator: '',
|
||||
// amDesignator: '',
|
||||
// pmDesignator: ''
|
||||
// };
|
||||
|
||||
// --------------------------
|
||||
// array of users online = sessions
|
||||
|
||||
// function getWinCulture() {
|
||||
// return new Promise((resolve) => {
|
||||
// process.nextTick(() => {
|
||||
// if (!_winDateFormat.dateFormat) {
|
||||
// util.powerShell('(get-culture).DateTimeFormat')
|
||||
// .then(data => {
|
||||
// let lines = data.toString().split('\r\n');
|
||||
// _winDateFormat.dateFormat = util.getValue(lines, 'ShortDatePattern', ':');
|
||||
// _winDateFormat.dateSeperator = util.getValue(lines, 'DateSeparator', ':');
|
||||
// _winDateFormat.timeFormat = util.getValue(lines, 'ShortTimePattern', ':');
|
||||
// _winDateFormat.timeSeperator = util.getValue(lines, 'TimeSeparator', ':');
|
||||
// _winDateFormat.amDesignator = util.getValue(lines, 'AMDesignator', ':');
|
||||
// _winDateFormat.pmDesignator = util.getValue(lines, 'PMDesignator', ':');
|
||||
|
||||
// resolve(_winDateFormat);
|
||||
// })
|
||||
// .catch(() => {
|
||||
// resolve(_winDateFormat);
|
||||
// });
|
||||
// } else {
|
||||
// resolve(_winDateFormat);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
function parseUsersLinux(lines, phase) {
|
||||
let result = [];
|
||||
let result_who = [];
|
||||
@@ -245,21 +207,11 @@ function users(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
// const workload = [];
|
||||
// // workload.push(util.powerShell('Get-CimInstance -ClassName Win32_Account | fl *'));
|
||||
// workload.push(util.powerShell('Get-WmiObject Win32_LogonSession | fl *'));
|
||||
// workload.push(util.powerShell('Get-WmiObject Win32_LoggedOnUser | fl *'));
|
||||
// workload.push(util.powerShell('Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl'));
|
||||
// Promise.all(
|
||||
// workload
|
||||
// ).then(data => {
|
||||
let cmd = 'Get-WmiObject Win32_LogonSession | select LogonId,StartTime | fl' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_LoggedOnUser | select antecedent,dependent | fl ' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="sessionid";Expression={$_.SessionId}}, @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'query user';
|
||||
util.powerShell(cmd).then(data => {
|
||||
// controller + vram
|
||||
// let accounts = parseWinAccounts(data[0].split(/\n\s*\n/));
|
||||
util.powerShell(cmd).then((data) => {
|
||||
if (data) {
|
||||
data = data.split('#-#-#-#');
|
||||
let sessions = parseWinSessions((data[0] || '').split(/\n\s*\n/));
|
||||
|
||||
Reference in New Issue
Block a user