@daemonitor/plugins 1.0.3 → 1.1.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.
- package/dist/index.js +9 -6
- package/dist/lib/BasePlugin.js +26 -16
- package/dist/lib/MonitoringPlugin.js +38 -22
- package/dist/lib/PluginConfigProvider.js +14 -7
- package/dist/lib/PluginLoader.js +26 -11
- package/dist/lib/PluginManager.js +78 -44
- package/dist/lib/processes.js +36 -0
- package/dist/plugins/index.js +31 -10
- package/dist/plugins/monitoring/DockerPlugin.js +170 -0
- package/dist/plugins/monitoring/LogWatchPlugin.js +212 -0
- package/dist/plugins/monitoring/LxcPlugin.js +126 -0
- package/dist/plugins/monitoring/NetScanPlugin.js +77 -0
- package/dist/plugins/monitoring/OSPlugin.js +184 -25
- package/dist/plugins/monitoring/PM2Plugin.js +71 -43
- package/dist/plugins/monitoring/WebsitePlugin.js +205 -42
- package/dist/plugins/monitoring/WordpressPlugin.js +248 -0
- package/index.ts +11 -0
- package/package.json +32 -11
- package/dist/plugins/monitoring/EwelinkPlugin.js +0 -63
- package/dist/plugins/monitoring/MongoDBPlugin.js +0 -30
package/package.json
CHANGED
|
@@ -1,36 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daemonitor/plugins",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "daemonitor plugins",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"build": "tsc",
|
|
9
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"prepublishOnly": "npm run build"
|
|
10
12
|
},
|
|
11
13
|
"files": [
|
|
12
14
|
"dist",
|
|
13
15
|
"types"
|
|
14
16
|
],
|
|
15
|
-
"
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./index.ts",
|
|
19
|
+
"./lib/*": "./lib/*.ts",
|
|
20
|
+
"./plugins/*": "./plugins/*.ts"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"main": "dist/index.js",
|
|
25
|
+
"types": "types/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./types/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./lib/*": "./dist/lib/*.js",
|
|
32
|
+
"./plugins/*": "./dist/plugins/*.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
16
35
|
"author": "",
|
|
17
36
|
"license": "ISC",
|
|
18
37
|
"packageManager": "pnpm@8.2.0",
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^26.1.1",
|
|
40
|
+
"nuxt": "^3.15.4",
|
|
41
|
+
"typescript": "^5.8.3",
|
|
42
|
+
"vue": "^3.5.13",
|
|
43
|
+
"vue-router": "^4.5.0"
|
|
44
|
+
},
|
|
19
45
|
"dependencies": {
|
|
46
|
+
"@daemonitor/common": "^1.0.0",
|
|
20
47
|
"dotenv": "^16.0.3",
|
|
21
48
|
"ewelink-api": "^3.1.1",
|
|
22
49
|
"node-machine-id": "^1.1.12",
|
|
23
50
|
"ohmyfetch": "^0.4.21",
|
|
24
|
-
"pm2": "^
|
|
51
|
+
"pm2": "^6.0.5",
|
|
25
52
|
"string-to-color": "^2.2.2",
|
|
26
53
|
"ts-node": "^10.9.1",
|
|
27
|
-
"@daemonitor/common": "^1.0.0",
|
|
28
54
|
"tsconfig-paths": "^4.2.0"
|
|
29
55
|
},
|
|
30
|
-
"exports": {
|
|
31
|
-
".": "./dist/index.js",
|
|
32
|
-
"./types": "./dist/types/index.js"
|
|
33
|
-
},
|
|
34
56
|
"repository": {
|
|
35
57
|
"type": "git",
|
|
36
58
|
"url": "git+https://github.com/daemonitor/plugins.git"
|
|
@@ -38,6 +60,5 @@
|
|
|
38
60
|
"bugs": {
|
|
39
61
|
"url": "https://github.com/daemonitor/plugins/issues"
|
|
40
62
|
},
|
|
41
|
-
|
|
42
63
|
"homepage": "https://github.com/daemonitor/plugins#readme"
|
|
43
64
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import ewelink from "ewelink-api";
|
|
2
|
-
import * as dotenv from "dotenv";
|
|
3
|
-
import { MonitoringPlugin } from "../../lib/MonitoringPlugin.js";
|
|
4
|
-
dotenv.config();
|
|
5
|
-
export class EwelinkPlugin extends MonitoringPlugin {
|
|
6
|
-
connection;
|
|
7
|
-
devices;
|
|
8
|
-
constructor() {
|
|
9
|
-
super("ewelink", "Ewelink", "Ewelink Addon");
|
|
10
|
-
this.name = "Ewelink";
|
|
11
|
-
this.description = "Ewelink Addon";
|
|
12
|
-
}
|
|
13
|
-
async setup() {
|
|
14
|
-
if (!process.env.EWELINK_EMAIL || !process.env.EWELINK_PASSWORD) {
|
|
15
|
-
console.error("EWELINK_EMAIL and EWELINK_PASSWORD environment variables must be set");
|
|
16
|
-
return Promise.reject();
|
|
17
|
-
}
|
|
18
|
-
this.connection = new ewelink({
|
|
19
|
-
email: process.env.EWELINK_EMAIL,
|
|
20
|
-
password: process.env.EWELINK_PASSWORD
|
|
21
|
-
});
|
|
22
|
-
this.refresh().then(() => {
|
|
23
|
-
});
|
|
24
|
-
return Promise.resolve();
|
|
25
|
-
}
|
|
26
|
-
async get(key) {
|
|
27
|
-
let [deviceName, propertiesString] = key.split(":");
|
|
28
|
-
deviceName = deviceName.toLowerCase();
|
|
29
|
-
const properties = propertiesString.split(",");
|
|
30
|
-
const device = this.devices?.find((d) => d.name.toLowerCase() === deviceName);
|
|
31
|
-
if (!device) {
|
|
32
|
-
return Promise.reject();
|
|
33
|
-
}
|
|
34
|
-
const values = {};
|
|
35
|
-
for (const property of properties) {
|
|
36
|
-
values[property] = device?.params[property];
|
|
37
|
-
}
|
|
38
|
-
return Promise.resolve(values);
|
|
39
|
-
}
|
|
40
|
-
async refresh() {
|
|
41
|
-
/* get all devices */
|
|
42
|
-
return this.connection.getDevices().then((devices) => {
|
|
43
|
-
if (Array.isArray(devices) && (Symbol.iterator in Object(devices))) {
|
|
44
|
-
this.devices = devices;
|
|
45
|
-
for (const device of this.devices) {
|
|
46
|
-
this.send(device, device.deviceid);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
console.error("EwelinkPlugin: Invalid response from getDevices()", devices);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async monitor() {
|
|
55
|
-
this.refreshTimer = setInterval(this.refresh.bind(this), this.config.refreshInterval || 30000);
|
|
56
|
-
}
|
|
57
|
-
async teardown() {
|
|
58
|
-
clearInterval(this.refreshTimer);
|
|
59
|
-
}
|
|
60
|
-
async render() {
|
|
61
|
-
return this.devices;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { MonitoringPlugin } from "../../lib/MonitoringPlugin.js";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
export class MongoDBPlugin extends MonitoringPlugin {
|
|
4
|
-
childProcess;
|
|
5
|
-
constructor() {
|
|
6
|
-
super("mongodb", "mongodb", "MongoDB Monitoring Plugin");
|
|
7
|
-
}
|
|
8
|
-
async setup() {
|
|
9
|
-
// no setup required
|
|
10
|
-
return Promise.resolve();
|
|
11
|
-
}
|
|
12
|
-
async refresh() {
|
|
13
|
-
// get mongodb db.serverStatus
|
|
14
|
-
}
|
|
15
|
-
async monitor() {
|
|
16
|
-
// this.refreshTimer = setInterval(this.refresh.bind(this), this.config.refreshInterval || 5000)
|
|
17
|
-
this.childProcess = spawn("mongostat", ["--json", "mongodb://localhost:27017", "10"]);
|
|
18
|
-
this.childProcess.stdout.on("data", (input) => {
|
|
19
|
-
const jsonObject = JSON.parse(input.toString());
|
|
20
|
-
if (!jsonObject["localhost:27017"]) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const data = jsonObject["localhost:27017"];
|
|
24
|
-
this.send(data, "mongodb-localhost:27017");
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
async teardown() {
|
|
28
|
-
this.childProcess.kill();
|
|
29
|
-
}
|
|
30
|
-
}
|