systeminformation 5.16.3 → 5.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/processes.js +17 -3
- package/package.json +1 -1
package/lib/processes.js
CHANGED
|
@@ -655,7 +655,7 @@ function processes(callback) {
|
|
|
655
655
|
function formatDateTime(time) {
|
|
656
656
|
const month = ('0' + (time.getMonth() + 1).toString()).substr(-2);
|
|
657
657
|
const year = time.getFullYear().toString();
|
|
658
|
-
const day = ('0' + time.
|
|
658
|
+
const day = ('0' + time.getDate().toString()).substr(-2);
|
|
659
659
|
const hours = time.getHours().toString();
|
|
660
660
|
const mins = time.getMinutes().toString();
|
|
661
661
|
const secs = ('0' + time.getSeconds().toString()).substr(-2);
|
|
@@ -663,6 +663,21 @@ function processes(callback) {
|
|
|
663
663
|
return (year + '-' + month + '-' + day + ' ' + hours + ':' + mins + ':' + secs);
|
|
664
664
|
}
|
|
665
665
|
|
|
666
|
+
function parseElapsed(etime) {
|
|
667
|
+
let started = '';
|
|
668
|
+
if (etime.indexOf('d') >= 0) {
|
|
669
|
+
const elapsed_parts = etime.split('d');
|
|
670
|
+
started = formatDateTime(new Date(Date.now() - (elapsed_parts[0] * 24 + elapsed_parts[1] * 1) * 60 * 60 * 1000));
|
|
671
|
+
} else if (etime.indexOf('h') >= 0) {
|
|
672
|
+
const elapsed_parts = etime.split('h');
|
|
673
|
+
started = formatDateTime(new Date(Date.now() - (elapsed_parts[0] * 60 + elapsed_parts[1] * 1) * 60 * 1000));
|
|
674
|
+
} else if (etime.indexOf(':') >= 0) {
|
|
675
|
+
const elapsed_parts = etime.split(':');
|
|
676
|
+
started = formatDateTime(new Date(Date.now() - (elapsed_parts.length > 1 ? (elapsed_parts[0] * 60 + elapsed_parts[1]) * 1000 : elapsed_parts[0] * 1000)));
|
|
677
|
+
}
|
|
678
|
+
return started;
|
|
679
|
+
}
|
|
680
|
+
|
|
666
681
|
let result = [];
|
|
667
682
|
lines.forEach(function (line) {
|
|
668
683
|
if (line.trim() !== '') {
|
|
@@ -670,8 +685,7 @@ function processes(callback) {
|
|
|
670
685
|
const parts = line.split(' ');
|
|
671
686
|
const command = parts.slice(9).join(' ');
|
|
672
687
|
const pmem = parseFloat((1.0 * parseInt(parts[3]) * 1024 / os.totalmem()).toFixed(1));
|
|
673
|
-
const
|
|
674
|
-
const started = formatDateTime(new Date(Date.now() - (elapsed_parts.length > 1 ? (elapsed_parts[0] * 60 + elapsed_parts[1]) * 1000 : elapsed_parts[0] * 1000)));
|
|
688
|
+
const started = parseElapsed(parts[5]);
|
|
675
689
|
|
|
676
690
|
result.push({
|
|
677
691
|
pid: parseInt(parts[0]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.16.
|
|
3
|
+
"version": "5.16.4",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|