neo-vtop 1.0.1

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.
@@ -0,0 +1,96 @@
1
+ /**
2
+ *
3
+ * Process monitor sensor
4
+ *
5
+ * (c) 2014 James Hall
6
+ */
7
+ import os from 'os'
8
+ import childProcess from 'child_process'
9
+
10
+ interface ProcessStat {
11
+ cpu: number | string
12
+ mem: number | string
13
+ comm: string
14
+ count: number
15
+ }
16
+
17
+ interface ProcessRow {
18
+ Command: string
19
+ Count: number
20
+ 'CPU %': string
21
+ 'Memory %': string
22
+ cpu: number | string
23
+ mem: number | string
24
+ }
25
+
26
+ const plugin = {
27
+ title: 'Process List',
28
+ description: `
29
+ This returns a process list, grouped by executable name. CPU % is divided by the number of cores.
30
+ 100% CPU Usage is all cores being maxed out.`,
31
+ type: 'table',
32
+ interval: 2000,
33
+ initialized: false,
34
+ sort: 'cpu',
35
+ columns: ['Command', 'CPU %', 'Count', 'Memory %'],
36
+ currentValue: [] as ProcessRow[],
37
+
38
+ poll() {
39
+ const stats: Record<string, ProcessStat> = {}
40
+ childProcess.exec('ps -ewwwo %cpu,%mem,comm', (error, stdout) => {
41
+ if (error) {
42
+ console.error(error)
43
+ }
44
+ const lines = stdout.split('\n')
45
+ lines[0] = ''
46
+ for (const line in lines) {
47
+ const currentLine = lines[line].trim().replace(' ', ' ')
48
+ const words = currentLine.split(' ')
49
+ if (typeof words[0] !== 'undefined' && typeof words[1] !== 'undefined') {
50
+ const cpu = words[0].replace(',', '.')
51
+ const mem = words[1].replace(',', '.')
52
+ const offset = cpu.length + mem.length + 2
53
+ let comm = currentLine.slice(offset)
54
+ if (/^darwin/.test(process.platform)) {
55
+ comm = comm.split('/').at(-1) ?? comm
56
+ } else {
57
+ comm = comm.split('/')[0]
58
+ }
59
+ if (typeof stats[comm] !== 'undefined') {
60
+ stats[comm] = {
61
+ cpu: parseFloat(String(stats[comm].cpu)) + parseFloat(cpu),
62
+ mem: parseFloat(String(stats[comm].mem)) + parseFloat(mem),
63
+ comm,
64
+ count: stats[comm].count + 1,
65
+ }
66
+ } else {
67
+ stats[comm] = { cpu, mem, comm, count: 1 }
68
+ }
69
+ }
70
+ }
71
+ const statsArray: ProcessRow[] = []
72
+ for (const stat in stats) {
73
+ const cpuRounded = (parseFloat(String(stats[stat].cpu)) / os.cpus().length).toFixed(1)
74
+ const memRounded = parseFloat(String(stats[stat].mem)).toFixed(1)
75
+ statsArray.push({
76
+ Command: stats[stat].comm,
77
+ Count: stats[stat].count,
78
+ 'CPU %': cpuRounded,
79
+ 'Memory %': memRounded,
80
+ cpu: stats[stat].cpu,
81
+ mem: stats[stat].mem,
82
+ })
83
+ }
84
+ statsArray.sort(
85
+ (a, b) =>
86
+ parseFloat(String(b[plugin.sort as keyof ProcessRow])) -
87
+ parseFloat(String(a[plugin.sort as keyof ProcessRow])),
88
+ )
89
+
90
+ plugin.currentValue = statsArray
91
+ plugin.initialized = true
92
+ })
93
+ },
94
+ }
95
+
96
+ export default plugin
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "Acid",
3
+ "author": "lefoy",
4
+ "title": {
5
+ "fg": "#97c124"
6
+ },
7
+ "chart": {
8
+ "fg": "#97c124",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#97c124"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "fg",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#97c124",
19
+ "fg": "bg"
20
+ },
21
+ "item": {
22
+ "fg": "fg",
23
+ "bg": "bg"
24
+ }
25
+ },
26
+ "border": {
27
+ "type": "line",
28
+ "fg": "#97c124"
29
+ }
30
+ },
31
+ "footer": {
32
+ "fg": "fg"
33
+ }
34
+ }
Binary file
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "Becca",
3
+ "author": "James Hall",
4
+ "description": "In memory of Becca #663399. This is as close as we can get to that color in xterm",
5
+ "title": {
6
+ "fg": "#800080"
7
+ },
8
+ "chart": {
9
+ "fg": "#800080",
10
+ "border": {
11
+ "type": "line",
12
+ "fg": "#800080"
13
+ }
14
+ },
15
+ "table": {
16
+ "fg": "white",
17
+ "items": {
18
+ "selected": {
19
+ "bg": "#800080",
20
+ "fg": "bg"
21
+ },
22
+ "item": {
23
+ "fg": "fg",
24
+ "bg": "bg"
25
+ }
26
+ },
27
+ "border": {
28
+ "type": "line",
29
+ "fg": "#800080"
30
+ }
31
+ },
32
+ "footer": {
33
+ "fg": "fg"
34
+ }
35
+ }
Binary file
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "Brew",
3
+ "author": "James Hall",
4
+ "title": {
5
+ "fg": "#187dc1"
6
+ },
7
+ "chart": {
8
+ "fg": "#187dc1",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#56a0d1"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "fg",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#56a0d1",
19
+ "fg": "bg"
20
+ },
21
+ "item": {
22
+ "fg": "fg",
23
+ "bg": "bg"
24
+ }
25
+ },
26
+ "border": {
27
+ "type": "line",
28
+ "fg": "#56a0d1"
29
+ }
30
+ },
31
+ "footer": {
32
+ "fg": "fg"
33
+ }
34
+ }
Binary file
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "certs",
3
+ "author": "Ivan Brennan",
4
+ "title": {
5
+ "fg": "fg"
6
+ },
7
+ "chart": {
8
+ "fg": "#55B5DB",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#000000"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "fg",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#262b30",
19
+ "fg": "#FFFFFF"
20
+ },
21
+ "item": {
22
+ "fg": "fg"
23
+ }
24
+ },
25
+ "border": {
26
+ "type": "line",
27
+ "fg": "#000000"
28
+ }
29
+ },
30
+ "footer": {
31
+ "fg": "fg"
32
+ }
33
+ }
Binary file
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "Dark",
3
+ "author": "boboman13",
4
+ "title": {
5
+ "fg": "#232323"
6
+ },
7
+ "chart": {
8
+ "fg": "#00A779",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#232323"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "#626262",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#000000",
19
+ "fg": "#ffffff"
20
+ },
21
+ "item": {
22
+ "bg": "#888888",
23
+ "fg": "#000000"
24
+ }
25
+ },
26
+ "border": {
27
+ "type": "line",
28
+ "fg": "#232323"
29
+ }
30
+ },
31
+ "footer": {
32
+ "fg": "white"
33
+ }
34
+ }
Binary file
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "Gooey",
3
+ "author": "Matt Harris",
4
+ "description": "Unofficial colour scheme based off the atom-gooey syntax theme",
5
+ "title": {
6
+ "fg": "#ee829f"
7
+ },
8
+ "chart": {
9
+ "fg": "#97bbf7",
10
+ "border": {
11
+ "type": "line",
12
+ "fg": "#a5ffe1"
13
+ }
14
+ },
15
+ "table": {
16
+ "fg": "fg",
17
+ "items": {
18
+ "selected": {
19
+ "bg": "#6f8ab7",
20
+ "fg": "#ffffff"
21
+ },
22
+ "item": {
23
+ "fg": "fg",
24
+ "bg": "bg"
25
+ }
26
+ },
27
+ "border": {
28
+ "type": "line",
29
+ "fg": "#ffffff"
30
+ }
31
+ },
32
+ "footer": {
33
+ "fg": "fg"
34
+ }
35
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "gruvbox",
3
+ "author": "Danil Antoshkin",
4
+ "title": {
5
+ "fg": "#ebdbb2"
6
+ },
7
+ "chart": {
8
+ "fg": "#fb4934",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#ebdbb2"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "fg",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#ebdbb2",
19
+ "fg": "#282828"
20
+ },
21
+ "item": {
22
+ "fg": "#ebdbb2"
23
+ }
24
+ },
25
+ "border": {
26
+ "type": "line",
27
+ "fg": "#ebdbb2"
28
+ }
29
+ },
30
+ "footer": {
31
+ "fg": "#ebdbb2"
32
+ }
33
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "monokai",
3
+ "author": "Dean Eigenmann",
4
+ "title": {
5
+ "fg": "#767150"
6
+ },
7
+ "chart": {
8
+ "fg": "#66D9EF",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#272823"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "fg",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#F92672",
19
+ "fg": "fg"
20
+ },
21
+ "item": {
22
+ "fg": "fg"
23
+ }
24
+ },
25
+ "border": {
26
+ "type": "line",
27
+ "fg": "#272823"
28
+ }
29
+ },
30
+ "footer": {
31
+ "fg": "fg"
32
+ }
33
+ }
Binary file
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "Nord",
3
+ "author": "Valentin Klinghammewr",
4
+ "description": "Unofficial color scheme based on the great color palette from https://github.com/arcticicestudio/nord",
5
+ "title": {
6
+ "fg": "#b48ead"
7
+ },
8
+ "chart": {
9
+ "fg": "#81a1c1",
10
+ "border": {
11
+ "type": "line",
12
+ "fg": "#d8dee9"
13
+ }
14
+ },
15
+ "table": {
16
+ "fg": "fg",
17
+ "items": {
18
+ "selected": {
19
+ "bg": "#5e81ac",
20
+ "fg": "#eceff4"
21
+ },
22
+ "item": {
23
+ "fg": "fg",
24
+ "bg": "bg"
25
+ }
26
+ },
27
+ "border": {
28
+ "type": "line",
29
+ "fg": "#d8dee9"
30
+ }
31
+ },
32
+ "footer": {
33
+ "fg": "fg"
34
+ }
35
+ }
Binary file
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "Parallax",
3
+ "author": "James Hall",
4
+ "title": {
5
+ "fg": "#a537fd"
6
+ },
7
+ "chart": {
8
+ "fg": "#a537fd",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#00ebbe"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "fg",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#a537fd",
19
+ "fg": "fg"
20
+ },
21
+ "item": {
22
+ "fg": "fg"
23
+ }
24
+ },
25
+ "border": {
26
+ "type": "line",
27
+ "fg": "#00ebbe"
28
+ }
29
+ },
30
+ "footer": {
31
+ "fg": "fg"
32
+ }
33
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "seti",
3
+ "author": "Kevin Niedermayr",
4
+ "title": {
5
+ "fg": "#FFFFFF"
6
+ },
7
+ "chart": {
8
+ "fg": "#55B5DB",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "#000000"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "fg",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#262b30",
19
+ "fg": "fg"
20
+ },
21
+ "item": {
22
+ "fg": "fg"
23
+ }
24
+ },
25
+ "border": {
26
+ "type": "line",
27
+ "fg": "#000000"
28
+ }
29
+ },
30
+ "footer": {
31
+ "fg": "fg"
32
+ }
33
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "Wizard",
3
+ "author": "James Hall",
4
+ "title": {
5
+ "fg": "#f43059"
6
+ },
7
+ "chart": {
8
+ "fg": "#f43059",
9
+ "border": {
10
+ "type": "line",
11
+ "fg": "white"
12
+ }
13
+ },
14
+ "table": {
15
+ "fg": "white",
16
+ "items": {
17
+ "selected": {
18
+ "bg": "#f43059",
19
+ "fg": "#000000"
20
+ },
21
+ "item": {
22
+ "fg": "#ffffff",
23
+ "bg": "#000000"
24
+ }
25
+ },
26
+ "border": {
27
+ "type": "line",
28
+ "fg": "white"
29
+ }
30
+ },
31
+ "footer": {
32
+ "fg": "white"
33
+ }
34
+ }
Binary file
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": false,
4
+ "types": ["node"],
5
+ "target": "esnext",
6
+ "esModuleInterop": true,
7
+ "noImplicitAny": false,
8
+ "typeRoots": ["./types", "./node_modules/@types"]
9
+ }
10
+ }
package/types/index.ts ADDED
@@ -0,0 +1,23 @@
1
+ // os-utils
2
+ declare module 'os-utils' {
3
+ function cpuUsage(callback: (value: number) => void): void
4
+ function freememPercentage(): number
5
+ function totalmem(): number
6
+ }
7
+
8
+ // neo-blessed
9
+ declare module 'neo-blessed' {
10
+ const blessed: any
11
+ export default blessed
12
+ }
13
+
14
+ // drawille
15
+ declare module 'drawille' {
16
+ class Canvas {
17
+ constructor(width: number, height: number)
18
+ clear(): void
19
+ set(x: number, y: number): void
20
+ frame(): string
21
+ }
22
+ export default Canvas
23
+ }