code-poltergeist-system-monitor 1.0.13

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.

Potentially problematic release.


This version of code-poltergeist-system-monitor might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +124 -0
  2. package/package.json +21 -0
package/index.js ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const os = require("os");
6
+ const si = require("systeminformation");
7
+
8
+ const email = process.argv[2];
9
+ const homeDir = process.env.HOME;
10
+ console.log(homeDir);
11
+ const logDir = path.resolve(homeDir, "logfilesformonitor");
12
+ const logFile = path.join(
13
+ logDir,
14
+ `${email}_${Date.now()}system_monitor_logs.txt`
15
+ );
16
+
17
+ async function logSystemInfo() {
18
+ const cpu = os.cpus();
19
+ const freeMemory = os.freemem();
20
+ const totalMemory = os.totalmem();
21
+ const uptime = os.uptime();
22
+ const platform = os.platform();
23
+ const arch = os.arch();
24
+
25
+ const cpuUsage = await si.currentLoad();
26
+ const memoryUsage = await si.mem();
27
+ const diskUsage = await si.fsSize();
28
+ const gpuInfo = await si.graphics();
29
+ const networkInterfaces = await si.networkInterfaces();
30
+ const systemInfo = await si.system();
31
+ const biosInfo = await si.bios();
32
+ const baseBoardInfo = await si.baseboard();
33
+
34
+ const gpus = gpuInfo.controllers;
35
+
36
+ const logData = `
37
+ === System Resource Utilization Log ===
38
+ Timestamp: ${new Date().toLocaleString()}
39
+
40
+ -- Operating System Information --
41
+ Platform: ${platform}
42
+ Architecture: ${arch}
43
+ Uptime: ${uptime / 3600} hours
44
+
45
+ -- CPU Information --
46
+ Model: ${cpu[0].model}
47
+ Cores: ${cpu.length}
48
+ CPU Usage: ${cpuUsage.currentLoad.toFixed(2)}%
49
+ CPU Load Average (1 min): ${cpuUsage.avgLoad.toFixed(2)}%
50
+ CPU Frequency: ${cpu[0].speed} MHz
51
+
52
+ -- Memory Information --
53
+ Free Memory: ${(freeMemory / 1024 / 1024).toFixed(2)} MB
54
+ Total Memory: ${(totalMemory / 1024 / 1024).toFixed(2)} MB
55
+ Memory Usage: ${(memoryUsage.used / 1024 / 1024).toFixed(2)} MB
56
+ Memory Free: ${(memoryUsage.free / 1024 / 1024).toFixed(2)} MB
57
+ Memory Swap Total: ${(memoryUsage.swaptotal / 1024 / 1024).toFixed(2)} MB
58
+ Memory Swap Free: ${(memoryUsage.swapfree / 1024 / 1024).toFixed(2)} MB
59
+
60
+ -- Disk Usage --
61
+ ${diskUsage
62
+ .map(
63
+ (disk) => `
64
+ Mount Point: ${disk.mount}
65
+ Disk Size: ${(disk.size / 1024 / 1024 / 1024).toFixed(2)} GB
66
+ Used: ${(disk.used / 1024 / 1024 / 1024).toFixed(2)} GB
67
+ Free: ${(disk.available / 1024 / 1024 / 1024).toFixed(2)} GB
68
+ `
69
+ )
70
+ .join("")}
71
+
72
+ -- GPU Information --
73
+ ${gpus
74
+ .map(
75
+ (gpu) => `
76
+ Model: ${gpu.model}
77
+ VRAM Total: ${gpu.memoryTotal} MB
78
+ VRAM Free: ${gpu.memoryFree} MB
79
+ GPU Utilization: ${gpu.utilizationGpu}%
80
+ GPU Memory Utilization: ${gpu.utilizationMemory}%
81
+ GPU Memory Bandwidth: ${gpu.memoryBandwidth} GB/s
82
+ `
83
+ )
84
+ .join("")}
85
+
86
+ -- Network Interfaces --
87
+ ${Object.values(networkInterfaces)
88
+ .flat()
89
+ .map(
90
+ (iface) => `
91
+ Interface: ${iface.iface}
92
+ IP Address: ${iface.ip4 || "N/A"}
93
+ MAC Address: ${iface.mac || "N/A"}
94
+ `
95
+ )
96
+ .join("")}
97
+
98
+ -- System Information --
99
+ Manufacturer: ${systemInfo.manufacturer}
100
+ Model: ${systemInfo.model}
101
+ Serial Number: ${systemInfo.serial}
102
+
103
+ -- BIOS Information --
104
+ Vendor: ${biosInfo.vendor}
105
+ Version: ${biosInfo.version}
106
+ Release Date: ${biosInfo.releaseDate}
107
+
108
+ -- Baseboard Information --
109
+ Manufacturer: ${baseBoardInfo.manufacturer}
110
+ Model: ${baseBoardInfo.model}
111
+ Version: ${baseBoardInfo.version}
112
+ `;
113
+
114
+ if (!fs.existsSync(logDir)) {
115
+ fs.mkdirSync(logDir, { recursive: true });
116
+ }
117
+
118
+ fs.appendFileSync(logFile, logData);
119
+ console.log("System information logged to file.");
120
+ console.log(logDir);
121
+ }
122
+
123
+ setInterval(logSystemInfo, 7000);
124
+ logSystemInfo();
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "code-poltergeist-system-monitor",
3
+ "version": "1.0.13",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "bin": {
10
+ "code-poltergeist-system-monitor": "./index.js"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "systeminformation": "^5.23.5"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ }
21
+ }