1
- const os = require ( 'os' ) ;
2
1
const net = require ( 'net' ) ;
3
- const packageFile = require ( '../package.json' ) ;
4
2
5
3
const checkConnection = ( host , port , timeout = 5000 ) =>
6
4
new Promise ( ( resolve , reject ) => {
@@ -24,50 +22,7 @@ const checkConnection = (host, port, timeout = 5000) =>
24
22
resolve ( ) ;
25
23
} ) ;
26
24
27
- const getPluginVersion = ( ) => packageFile . version ;
28
-
29
- const getSystemInfo = appVersion => {
30
- return (
31
- '' +
32
- `Date: ${ new Date ( ) } ` +
33
- '\n' +
34
- `Application version: ${ appVersion } ` +
35
- '\n' +
36
- `Plugin version: ${ getPluginVersion ( ) } ` +
37
- '\n\n' +
38
- `System information:` +
39
- '\n' +
40
- ` Hostname: ${ os . hostname ( ) } ` +
41
- '\n' +
42
- ` Platform: ${ os . platform ( ) } ${ os . arch ( ) } ` +
43
- '\n' +
44
- ` Release: ${ os . release ( ) } ` +
45
- '\n' +
46
- ` Uptime: ${ toTime ( os . uptime ( ) ) } ` +
47
- '\n' +
48
- ` Total RAM: ${ ( os . totalmem ( ) / 1073741824 ) . toFixed ( 2 ) } GB` +
49
- '\n' +
50
- ` CPU Model: ${ os . cpus ( ) [ 0 ] . model } ` +
51
- '\n' +
52
- ` CPU Clock: ${ maxClock ( os . cpus ( ) ) } MHZ` +
53
- '\n' +
54
- ` CPU Cores: ${ os . cpus ( ) . length } cores` +
55
- '\n\n'
56
- ) ;
57
- } ;
58
-
59
- const maxClock = cpus => {
60
- return cpus . reduce ( ( highestClock , cpu ) => Math . max ( highestClock , cpu . speed ) , 0 ) ;
61
- } ;
62
-
63
- const prefixZero = number => ( number < 10 ? '0' + number : number ) ;
64
-
65
- const toTime = number => {
66
- return Math . floor ( number / 3600 ) + ':' + prefixZero ( parseInt ( ( number / 3600 - Math . floor ( number / 3600 ) ) * 60 ) ) ;
67
- } ;
68
-
69
25
const logHelper = {
70
- getSystemInfo,
71
26
checkConnection,
72
27
} ;
73
28
0 commit comments