systeminformation 4.34.5 → 4.34.9
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/CHANGELOG.md +4 -0
- package/lib/graphics.js +10 -6
- package/lib/network.js +181 -176
- package/lib/processes.js +34 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -30,6 +30,10 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
|
|
30
30
|
|
|
31
31
|
| Version | Date | Comment |
|
|
32
32
|
| -------------- | -------------- | -------- |
|
|
33
|
+
| 4.34.9 | 2020-01-25 | `graphics()` virtual controller vram value fix (win) |
|
|
34
|
+
| 4.34.8 | 2020-01-25 | `graphics()` controller subDeviceId fix (win) |
|
|
35
|
+
| 4.34.7 | 2020-01-13 | `services()` improved service discovery (linux) |
|
|
36
|
+
| 4.34.6 | 2020-01-12 | `networkInterfaces()` catch errors |
|
|
33
37
|
| 4.34.5 | 2020-01-07 | `networkInterfaceDefault()` fixed CMD popup (windows) |
|
|
34
38
|
| 4.34.4 | 2020-01-06 | `system()` fixed vitrual catch error |
|
|
35
39
|
| 4.34.3 | 2020-01-06 | `graphics()` fixed non nvidia-smi controllers (win) |
|
package/lib/graphics.js
CHANGED
|
@@ -720,8 +720,8 @@ function graphics(callback) {
|
|
|
720
720
|
result.controllers = parseLinesLinuxControllers(lines);
|
|
721
721
|
const nvidiaData = nvidiaDevices();
|
|
722
722
|
// needs to be rewritten ... using no spread operators
|
|
723
|
-
result.controllers = result.controllers.map((
|
|
724
|
-
return mergeControllerNvidia(controller, nvidiaData.find(({ pciBus }) => pciBus.endsWith(controller.busAddress)) || {}
|
|
723
|
+
result.controllers = result.controllers.map((controller) => { // match by busAddress
|
|
724
|
+
return mergeControllerNvidia(controller, nvidiaData.find(({ pciBus }) => pciBus.endsWith(controller.busAddress)) || {});
|
|
725
725
|
})
|
|
726
726
|
}
|
|
727
727
|
let cmd = "clinfo --raw";
|
|
@@ -887,15 +887,19 @@ function graphics(callback) {
|
|
|
887
887
|
if (sections[i].trim() !== '') {
|
|
888
888
|
|
|
889
889
|
let lines = sections[i].trim().split('\r\n');
|
|
890
|
-
let
|
|
891
|
-
|
|
892
|
-
|
|
890
|
+
let pnpDeviceId = util.getValue(lines, 'PNPDeviceID', '=').match(/SUBSYS_[a-fA-F\d]{8}/);
|
|
891
|
+
let subDeviceId = null;
|
|
892
|
+
if (pnpDeviceId) {
|
|
893
|
+
subDeviceId = pnpDeviceId[0];
|
|
894
|
+
if (subDeviceId) {
|
|
895
|
+
subDeviceId = subDeviceId.split('_')[1];
|
|
896
|
+
}
|
|
893
897
|
}
|
|
894
898
|
controllers.push({
|
|
895
899
|
vendor: util.getValue(lines, 'AdapterCompatibility', '='),
|
|
896
900
|
model: util.getValue(lines, 'name', '='),
|
|
897
901
|
bus: util.getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : '',
|
|
898
|
-
vram:
|
|
902
|
+
vram: util.toInt(util.getValue(lines, 'AdapterRAM', '=')) / 1024 / 1024,
|
|
899
903
|
vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2'),
|
|
900
904
|
subDeviceId
|
|
901
905
|
});
|
package/lib/network.js
CHANGED
|
@@ -685,132 +685,133 @@ function networkInterfaces(callback, rescan = true) {
|
|
|
685
685
|
}
|
|
686
686
|
return new Promise((resolve) => {
|
|
687
687
|
process.nextTick(() => {
|
|
688
|
-
let ifaces = os.networkInterfaces();
|
|
689
|
-
|
|
690
688
|
let result = [];
|
|
691
689
|
let nics = [];
|
|
692
690
|
let dnsSuffixes = [];
|
|
693
691
|
let nics8021xInfo = [];
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
nics = getDarwinNics();
|
|
692
|
+
try {
|
|
693
|
+
let ifaces = os.networkInterfaces();
|
|
697
694
|
|
|
695
|
+
// seperate handling in OSX
|
|
696
|
+
if (_darwin || _freebsd || _openbsd || _netbsd) {
|
|
697
|
+
nics = getDarwinNics();
|
|
698
698
|
|
|
699
|
-
nics.forEach(nic => {
|
|
700
699
|
|
|
701
|
-
|
|
702
|
-
ifaces[nic.iface].forEach(function (details) {
|
|
703
|
-
if (details.family === 'IPv4') {
|
|
704
|
-
nic.ip4subnet = details.netmask;
|
|
705
|
-
}
|
|
706
|
-
if (details.family === 'IPv6') {
|
|
707
|
-
nic.ip6subnet = details.netmask;
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
}
|
|
700
|
+
nics.forEach(nic => {
|
|
711
701
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
operstate: nic.operstate,
|
|
723
|
-
type: nic.type,
|
|
724
|
-
duplex: nic.duplex,
|
|
725
|
-
mtu: nic.mtu,
|
|
726
|
-
speed: nic.speed,
|
|
727
|
-
dhcp: getDarwinIfaceDHCPstatus(nic.iface),
|
|
728
|
-
dnsSuffix: '',
|
|
729
|
-
ieee8021xAuth: '',
|
|
730
|
-
ieee8021xState: '',
|
|
731
|
-
carrierChanges: 0
|
|
732
|
-
});
|
|
733
|
-
});
|
|
734
|
-
_networkInterfaces = result;
|
|
735
|
-
if (callback) { callback(result); }
|
|
736
|
-
resolve(result);
|
|
737
|
-
} else {
|
|
738
|
-
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
|
739
|
-
// no changes - just return object
|
|
740
|
-
result = _networkInterfaces;
|
|
702
|
+
if ({}.hasOwnProperty.call(ifaces, nic.iface)) {
|
|
703
|
+
ifaces[nic.iface].forEach(function (details) {
|
|
704
|
+
if (details.family === 'IPv4') {
|
|
705
|
+
nic.ip4subnet = details.netmask;
|
|
706
|
+
}
|
|
707
|
+
if (details.family === 'IPv6') {
|
|
708
|
+
nic.ip6subnet = details.netmask;
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
}
|
|
741
712
|
|
|
713
|
+
result.push({
|
|
714
|
+
iface: nic.iface,
|
|
715
|
+
ifaceName: nic.iface,
|
|
716
|
+
ip4: nic.ip4,
|
|
717
|
+
ip4subnet: nic.ip4subnet || '',
|
|
718
|
+
ip6: nic.ip6,
|
|
719
|
+
ip6subnet: nic.ip6subnet || '',
|
|
720
|
+
mac: nic.mac,
|
|
721
|
+
internal: nic.internal,
|
|
722
|
+
virtual: nic.internal ? false : testVirtualNic(nic.iface, nic.iface, nic.mac),
|
|
723
|
+
operstate: nic.operstate,
|
|
724
|
+
type: nic.type,
|
|
725
|
+
duplex: nic.duplex,
|
|
726
|
+
mtu: nic.mtu,
|
|
727
|
+
speed: nic.speed,
|
|
728
|
+
dhcp: getDarwinIfaceDHCPstatus(nic.iface),
|
|
729
|
+
dnsSuffix: '',
|
|
730
|
+
ieee8021xAuth: '',
|
|
731
|
+
ieee8021xState: '',
|
|
732
|
+
carrierChanges: 0
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
_networkInterfaces = result;
|
|
742
736
|
if (callback) { callback(result); }
|
|
743
737
|
resolve(result);
|
|
744
738
|
} else {
|
|
745
|
-
|
|
739
|
+
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
|
740
|
+
// no changes - just return object
|
|
741
|
+
result = _networkInterfaces;
|
|
742
|
+
|
|
743
|
+
if (callback) { callback(result); }
|
|
744
|
+
resolve(result);
|
|
745
|
+
} else {
|
|
746
|
+
_ifaces = Object.assign({}, ifaces);
|
|
747
|
+
|
|
748
|
+
if (_windows) {
|
|
749
|
+
nics = getWindowsNics();
|
|
750
|
+
nics.forEach(nic => {
|
|
751
|
+
let found = false;
|
|
752
|
+
Object.keys(ifaces).forEach(key => {
|
|
753
|
+
if (!found) {
|
|
754
|
+
ifaces[key].forEach(value => {
|
|
755
|
+
if (Object.keys(value).indexOf('mac') >= 0) {
|
|
756
|
+
found = value['mac'] === nic.mac;
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
});
|
|
746
761
|
|
|
747
|
-
if (_windows) {
|
|
748
|
-
nics = getWindowsNics();
|
|
749
|
-
nics.forEach(nic => {
|
|
750
|
-
let found = false;
|
|
751
|
-
Object.keys(ifaces).forEach(key => {
|
|
752
762
|
if (!found) {
|
|
753
|
-
ifaces[
|
|
754
|
-
if (Object.keys(value).indexOf('mac') >= 0) {
|
|
755
|
-
found = value['mac'] === nic.mac;
|
|
756
|
-
}
|
|
757
|
-
});
|
|
763
|
+
ifaces[nic.name] = [{ mac: nic.mac }];
|
|
758
764
|
}
|
|
759
765
|
});
|
|
760
766
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
let ifaceName = dev;
|
|
791
|
-
ifaces[dev].forEach(function (details) {
|
|
792
|
-
if (details.family === 'IPv4') {
|
|
793
|
-
ip4 = details.address;
|
|
794
|
-
ip4subnet = details.netmask;
|
|
795
|
-
}
|
|
796
|
-
if (details.family === 'IPv6') {
|
|
797
|
-
if (!ip6 || ip6.match(/^fe80::/i)) {
|
|
798
|
-
ip6 = details.address;
|
|
799
|
-
ip6subnet = details.netmask;
|
|
767
|
+
nics8021xInfo = getWindowsWiredProfilesInformation();
|
|
768
|
+
dnsSuffixes = getWindowsDNSsuffixes();
|
|
769
|
+
}
|
|
770
|
+
if (_linux) {
|
|
771
|
+
_dhcpNics = getLinuxDHCPNics();
|
|
772
|
+
}
|
|
773
|
+
for (let dev in ifaces) {
|
|
774
|
+
let ip4 = '';
|
|
775
|
+
let ip4subnet = '';
|
|
776
|
+
let ip6 = '';
|
|
777
|
+
let ip6subnet = '';
|
|
778
|
+
let mac = '';
|
|
779
|
+
let duplex = '';
|
|
780
|
+
let mtu = '';
|
|
781
|
+
let speed = -1;
|
|
782
|
+
let carrierChanges = 0;
|
|
783
|
+
let operstate = 'down';
|
|
784
|
+
let dhcp = false;
|
|
785
|
+
let dnsSuffix = '';
|
|
786
|
+
let ieee8021xAuth = '';
|
|
787
|
+
let ieee8021xState = '';
|
|
788
|
+
let type = '';
|
|
789
|
+
|
|
790
|
+
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
|
791
|
+
let ifaceName = dev;
|
|
792
|
+
ifaces[dev].forEach(function (details) {
|
|
793
|
+
if (details.family === 'IPv4') {
|
|
794
|
+
ip4 = details.address;
|
|
795
|
+
ip4subnet = details.netmask;
|
|
800
796
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
_mac = getMacAddresses();
|
|
797
|
+
if (details.family === 'IPv6') {
|
|
798
|
+
if (!ip6 || ip6.match(/^fe80::/i)) {
|
|
799
|
+
ip6 = details.address;
|
|
800
|
+
ip6subnet = details.netmask;
|
|
801
|
+
}
|
|
807
802
|
}
|
|
808
|
-
mac =
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
803
|
+
mac = details.mac;
|
|
804
|
+
// fallback due to https://github.com/nodejs/node/issues/13581 (node 8.1 - node 8.2)
|
|
805
|
+
if (mac.indexOf('00:00:0') > -1 && (_linux || _darwin) && parseInt(process.versions.node.split('.'), 10) === 8) {
|
|
806
|
+
if (Object.keys(_mac).length === 0) {
|
|
807
|
+
_mac = getMacAddresses();
|
|
808
|
+
}
|
|
809
|
+
mac = _mac[dev] || '';
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
if (_linux) {
|
|
813
|
+
let iface = dev.split(':')[0].trim().toLowerCase();
|
|
814
|
+
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${iface}/addr_assign_type 2>/dev/null; echo;
|
|
814
815
|
echo -n "address: "; cat /sys/class/net/${iface}/address 2>/dev/null; echo;
|
|
815
816
|
echo -n "addr_len: "; cat /sys/class/net/${iface}/addr_len 2>/dev/null; echo;
|
|
816
817
|
echo -n "broadcast: "; cat /sys/class/net/${iface}/broadcast 2>/dev/null; echo;
|
|
@@ -836,86 +837,90 @@ function networkInterfaces(callback, rescan = true) {
|
|
|
836
837
|
echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null \| grep ${iface}; echo;
|
|
837
838
|
echo -n "wirelessspeed: "; iw dev ${iface} link 2>&1 \| grep bitrate; echo;`;
|
|
838
839
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
speed = isNaN(myspeed) ? -1 : myspeed;
|
|
855
|
-
let wirelessspeed = util.getValue(lines, 'wirelessspeed').split('tx bitrate: ');
|
|
856
|
-
if (speed === -1 && wirelessspeed.length === 2) {
|
|
857
|
-
myspeed = parseFloat(wirelessspeed[1]);
|
|
840
|
+
let lines = [];
|
|
841
|
+
try {
|
|
842
|
+
lines = execSync(cmd).toString().split('\n');
|
|
843
|
+
const connectionName = getLinuxIfaceConnectionName(iface);
|
|
844
|
+
dhcp = getLinuxIfaceDHCPstatus(iface, connectionName, _dhcpNics);
|
|
845
|
+
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
|
|
846
|
+
ieee8021xAuth = getLinuxIfaceIEEE8021xAuth(connectionName);
|
|
847
|
+
ieee8021xState = getLinuxIfaceIEEE8021xState(ieee8021xAuth);
|
|
848
|
+
} catch (e) {
|
|
849
|
+
util.noop();
|
|
850
|
+
}
|
|
851
|
+
duplex = util.getValue(lines, 'duplex');
|
|
852
|
+
duplex = duplex.startsWith('cat') ? '' : duplex;
|
|
853
|
+
mtu = parseInt(util.getValue(lines, 'mtu'), 10);
|
|
854
|
+
let myspeed = parseInt(util.getValue(lines, 'speed'), 10);
|
|
858
855
|
speed = isNaN(myspeed) ? -1 : myspeed;
|
|
856
|
+
let wirelessspeed = util.getValue(lines, 'wirelessspeed').split('tx bitrate: ');
|
|
857
|
+
if (speed === -1 && wirelessspeed.length === 2) {
|
|
858
|
+
myspeed = parseFloat(wirelessspeed[1]);
|
|
859
|
+
speed = isNaN(myspeed) ? -1 : myspeed;
|
|
860
|
+
}
|
|
861
|
+
carrierChanges = parseInt(util.getValue(lines, 'carrier_changes'), 10);
|
|
862
|
+
operstate = util.getValue(lines, 'operstate');
|
|
863
|
+
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
|
864
|
+
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
|
859
865
|
}
|
|
860
|
-
|
|
861
|
-
operstate = util.getValue(lines, 'operstate');
|
|
862
|
-
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
|
863
|
-
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
|
864
|
-
}
|
|
865
|
-
if (_windows) {
|
|
866
|
+
if (_windows) {
|
|
866
867
|
|
|
867
868
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
869
|
+
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
|
870
|
+
nics.forEach(detail => {
|
|
871
|
+
if (detail.mac === mac) {
|
|
872
|
+
ifaceName = detail.name;
|
|
873
|
+
dhcp = detail.dhcp;
|
|
874
|
+
operstate = detail.operstate;
|
|
875
|
+
speed = detail.speed;
|
|
876
|
+
type = detail.type;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('802.11n') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) {
|
|
881
|
+
type = 'wireless';
|
|
876
882
|
}
|
|
877
|
-
});
|
|
878
883
|
|
|
879
|
-
|
|
880
|
-
|
|
884
|
+
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
|
|
885
|
+
ieee8021xAuth = IEEE8021x.protocol;
|
|
886
|
+
ieee8021xState = IEEE8021x.state;
|
|
881
887
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
888
|
+
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
|
889
|
+
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
|
890
|
+
internal = true;
|
|
891
|
+
}
|
|
892
|
+
const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
|
|
893
|
+
result.push({
|
|
894
|
+
iface: dev,
|
|
895
|
+
ifaceName,
|
|
896
|
+
ip4,
|
|
897
|
+
ip4subnet,
|
|
898
|
+
ip6,
|
|
899
|
+
ip6subnet,
|
|
900
|
+
mac,
|
|
901
|
+
internal,
|
|
902
|
+
virtual,
|
|
903
|
+
operstate,
|
|
904
|
+
type,
|
|
905
|
+
duplex,
|
|
906
|
+
mtu,
|
|
907
|
+
speed,
|
|
908
|
+
dhcp,
|
|
909
|
+
dnsSuffix,
|
|
910
|
+
ieee8021xAuth,
|
|
911
|
+
ieee8021xState,
|
|
912
|
+
carrierChanges,
|
|
913
|
+
});
|
|
890
914
|
}
|
|
891
|
-
const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
|
|
892
|
-
result.push({
|
|
893
|
-
iface: dev,
|
|
894
|
-
ifaceName,
|
|
895
|
-
ip4,
|
|
896
|
-
ip4subnet,
|
|
897
|
-
ip6,
|
|
898
|
-
ip6subnet,
|
|
899
|
-
mac,
|
|
900
|
-
internal,
|
|
901
|
-
virtual,
|
|
902
|
-
operstate,
|
|
903
|
-
type,
|
|
904
|
-
duplex,
|
|
905
|
-
mtu,
|
|
906
|
-
speed,
|
|
907
|
-
dhcp,
|
|
908
|
-
dnsSuffix,
|
|
909
|
-
ieee8021xAuth,
|
|
910
|
-
ieee8021xState,
|
|
911
|
-
carrierChanges,
|
|
912
|
-
});
|
|
913
915
|
}
|
|
916
|
+
_networkInterfaces = result;
|
|
917
|
+
if (callback) { callback(result); }
|
|
918
|
+
resolve(result);
|
|
914
919
|
}
|
|
915
|
-
_networkInterfaces = result;
|
|
916
|
-
if (callback) { callback(result); }
|
|
917
|
-
resolve(result);
|
|
918
920
|
}
|
|
921
|
+
} catch (e) {
|
|
922
|
+
if (callback) { callback(result); }
|
|
923
|
+
resolve(result);
|
|
919
924
|
}
|
|
920
925
|
});
|
|
921
926
|
});
|
package/lib/processes.js
CHANGED
|
@@ -120,20 +120,42 @@ function services(srv, callback) {
|
|
|
120
120
|
let srvs = srvString.split('|');
|
|
121
121
|
let result = [];
|
|
122
122
|
let dataSrv = [];
|
|
123
|
-
let allSrv = [];
|
|
123
|
+
// let allSrv = [];
|
|
124
124
|
|
|
125
125
|
if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
|
|
126
126
|
if ((_linux || _freebsd || _openbsd || _netbsd) && srvString === '*') {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
try {
|
|
128
|
+
srvString = '';
|
|
129
|
+
const tmpsrv = execSync('service --status-all 2> /dev/null').toString().split('\n');
|
|
130
|
+
for (const s of tmpsrv) {
|
|
131
|
+
const parts = s.split(']');
|
|
132
|
+
if (parts.length === 2) {
|
|
133
|
+
srvString += (srvString !== '' ? '|' : '') + parts[1].trim();
|
|
134
|
+
// allSrv.push({ name: parts[1].trim(), running: parts[0].indexOf('+') > 0 });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
srvs = srvString.split('|');
|
|
138
|
+
} catch (e) {
|
|
139
|
+
try {
|
|
140
|
+
const srvStr = execSync('ls /etc/init.d/ -m 2> /dev/null').toString().split('\n').join('');
|
|
141
|
+
srvString = '';
|
|
142
|
+
if (srvStr) {
|
|
143
|
+
const tmpsrv = srvStr.split(',');
|
|
144
|
+
for (const s of tmpsrv) {
|
|
145
|
+
const name = s.trim();
|
|
146
|
+
if (name) {
|
|
147
|
+
srvString += (srvString !== '' ? '|' : '') + name;
|
|
148
|
+
// allSrv.push({ name: name, running: null });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
srvs = srvString.split('|');
|
|
152
|
+
}
|
|
153
|
+
} catch (f) {
|
|
154
|
+
// allSrv = [];
|
|
155
|
+
srvString = '';
|
|
156
|
+
srvs = [];
|
|
134
157
|
}
|
|
135
158
|
}
|
|
136
|
-
srvs = srvString.split('|');
|
|
137
159
|
}
|
|
138
160
|
let comm = (_darwin) ? 'ps -caxo pcpu,pmem,pid,command' : 'ps -axo pcpu,pmem,pid,command';
|
|
139
161
|
if (srvString !== '' && srvs.length > 0) {
|
|
@@ -152,7 +174,7 @@ function services(srv, callback) {
|
|
|
152
174
|
return (e.toLowerCase().indexOf(' ' + srv + ':') !== -1) || (e.toLowerCase().indexOf('/' + srv) !== -1);
|
|
153
175
|
});
|
|
154
176
|
}
|
|
155
|
-
let singleSrv = allSrv.filter(item => { return item.name === srv; });
|
|
177
|
+
// let singleSrv = allSrv.filter(item => { return item.name === srv; });
|
|
156
178
|
const pids = [];
|
|
157
179
|
for (const p of ps) {
|
|
158
180
|
const pid = p.trim().split(' ')[2];
|
|
@@ -162,7 +184,8 @@ function services(srv, callback) {
|
|
|
162
184
|
}
|
|
163
185
|
result.push({
|
|
164
186
|
name: srv,
|
|
165
|
-
running: (allSrv.length && singleSrv.length ? singleSrv[0].running : ps.length > 0),
|
|
187
|
+
// running: (allSrv.length && singleSrv.length && singleSrv[0].running !== null ? singleSrv[0].running : ps.length > 0),
|
|
188
|
+
running: ps.length > 0,
|
|
166
189
|
startmode: '',
|
|
167
190
|
pids: pids,
|
|
168
191
|
pcpu: parseFloat((ps.reduce(function (pv, cv) {
|
package/package.json
CHANGED