code-poltergeist-system-monitor 1.0.11

Sign up to get free protection for your applications and to get access to all the features.

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 +85 -0
  2. package/package.json +21 -0
package/index.js ADDED
@@ -0,0 +1,85 @@
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
+
30
+ const logData = `
31
+ === System Resource Utilization Log ===
32
+ Timestamp: ${new Date().toLocaleString()}
33
+
34
+ -- Operating System Information --
35
+ Platform: ${platform}
36
+ Architecture: ${arch}
37
+ Uptime: ${uptime / 3600} hours
38
+
39
+ -- CPU Information --
40
+ Model: ${cpu[0].model}
41
+ Cores: ${cpu.length}
42
+ CPU Usage: ${cpuUsage.currentLoad.toFixed(2)}%
43
+
44
+ -- Memory Information --
45
+ Free Memory: ${(freeMemory / 1024 / 1024).toFixed(2)} MB
46
+ Total Memory: ${(totalMemory / 1024 / 1024).toFixed(2)} MB
47
+ Memory Usage: ${(memoryUsage.used / 1024 / 1024).toFixed(2)} MB
48
+ Memory Free: ${(memoryUsage.free / 1024 / 1024).toFixed(2)} MB
49
+
50
+ -- Disk Usage --
51
+ ${diskUsage
52
+ .map(
53
+ (disk) => `
54
+ Mount Point: ${disk.mount}
55
+ Disk Size: ${(disk.size / 1024 / 1024 / 1024).toFixed(2)} GB
56
+ Used: ${(disk.used / 1024 / 1024 / 1024).toFixed(2)} GB
57
+ Free: ${(disk.available / 1024 / 1024 / 1024).toFixed(2)} GB
58
+ `
59
+ )
60
+ .join("")}
61
+
62
+ -- GPU Information --
63
+ ${gpuInfo.controllers
64
+ .map(
65
+ (gpu) => `
66
+ Model: ${gpu.model}
67
+ Memory: ${gpu.memoryTotal} MB
68
+ GPU Utilization: ${gpu.utilizationGpu}%
69
+ `
70
+ )
71
+ .join("")}
72
+ `;
73
+
74
+ // Ensure the directory exists
75
+ if (!fs.existsSync(logDir)) {
76
+ fs.mkdirSync(logDir, { recursive: true });
77
+ }
78
+
79
+ fs.appendFileSync(logFile, logData);
80
+ console.log("System information logged to file.");
81
+ console.log(logDir);
82
+ }
83
+
84
+ setInterval(logSystemInfo, 7000);
85
+ logSystemInfo();
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "code-poltergeist-system-monitor",
3
+ "version": "1.0.11",
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
+ }