@bitcall/pm2-pulse-agent 1.0.1-beta.1 → 1.0.1-beta.3
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/README.md +60 -7
- package/agent.js +9 -3
- package/package.json +23 -1
- package/scripts/setup-agent.js +2 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ A Node.js monitoring agent that tracks server metrics (CPU, RAM, processes) and
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install
|
|
17
|
+
npm install @bitcall/pm2-pulse-agent@beta
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
### Dependencies
|
|
@@ -28,7 +28,14 @@ npm install
|
|
|
28
28
|
Run the interactive setup script to configure the agent:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
|
|
31
|
+
npx @bitcall/pm2-pulse-agent pm2-pulse-setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or if installed globally:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g @bitcall/pm2-pulse-agent@beta
|
|
38
|
+
pm2-pulse-setup
|
|
32
39
|
```
|
|
33
40
|
|
|
34
41
|
This will prompt you to configure:
|
|
@@ -36,16 +43,25 @@ This will prompt you to configure:
|
|
|
36
43
|
- **MONITOR_SERVER**: gRPC server address (default: `localhost:50051`)
|
|
37
44
|
- **VPS_ID**: Unique identifier for this server (default: `server-{hostname}`)
|
|
38
45
|
|
|
39
|
-
Settings are saved to `.env` file.
|
|
46
|
+
Settings are saved to `.env` file in your current directory.
|
|
40
47
|
|
|
41
48
|
## Usage
|
|
42
49
|
|
|
43
50
|
### Start the Agent
|
|
44
51
|
|
|
52
|
+
**Using npx (recommended):**
|
|
53
|
+
```bash
|
|
54
|
+
npx @bitcall/pm2-pulse-agent pm2-pulse-agent
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**If installed globally:**
|
|
58
|
+
```bash
|
|
59
|
+
pm2-pulse-agent
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Run with PM2 (for persistent monitoring):**
|
|
45
63
|
```bash
|
|
46
|
-
|
|
47
|
-
# or
|
|
48
|
-
npm run monitor
|
|
64
|
+
pm2 start "npx @bitcall/pm2-pulse-agent pm2-pulse-agent" --name pm2-pulse-agent
|
|
49
65
|
```
|
|
50
66
|
|
|
51
67
|
### Configuration Options
|
|
@@ -118,6 +134,43 @@ RAM Threshold: 80%
|
|
|
118
134
|
✓ Alert sent to server
|
|
119
135
|
```
|
|
120
136
|
|
|
137
|
+
## Quick Start Guide
|
|
138
|
+
|
|
139
|
+
1. **Install the package:**
|
|
140
|
+
```bash
|
|
141
|
+
npm install -g @bitcall/pm2-pulse-agent@beta
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
2. **Run setup:**
|
|
145
|
+
```bash
|
|
146
|
+
pm2-pulse-setup
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
3. **Start monitoring:**
|
|
150
|
+
```bash
|
|
151
|
+
pm2 start pm2-pulse-agent --name monitoring-agent
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
4. **Check status:**
|
|
155
|
+
```bash
|
|
156
|
+
pm2 logs monitoring-agent
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Troubleshooting
|
|
160
|
+
|
|
161
|
+
**Agent not connecting to server:**
|
|
162
|
+
- Verify `MONITOR_SERVER` address is correct in `.env`
|
|
163
|
+
- Check network connectivity: `telnet <server-host> <port>`
|
|
164
|
+
- Ensure firewall allows outbound connections
|
|
165
|
+
|
|
166
|
+
**PM2 processes not detected:**
|
|
167
|
+
- Verify PM2 is installed: `pm2 --version`
|
|
168
|
+
- Check PM2 has running processes: `pm2 list`
|
|
169
|
+
|
|
170
|
+
**Authentication errors:**
|
|
171
|
+
- Verify `AUTH_TOKEN` in `.env` matches server configuration
|
|
172
|
+
- Check token hasn't expired
|
|
173
|
+
|
|
121
174
|
## License
|
|
122
175
|
|
|
123
|
-
MIT
|
|
176
|
+
MIT
|
package/agent.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
const os = require('os')
|
|
4
|
+
const path = require('path')
|
|
2
5
|
const { exec } = require('child_process')
|
|
3
6
|
const grpc = require('@grpc/grpc-js')
|
|
4
7
|
const protoLoader = require('@grpc/proto-loader')
|
|
@@ -12,6 +15,9 @@ const DEFAULT_CPU_THRESHOLD = 70
|
|
|
12
15
|
const DEFAULT_RAM_THRESHOLD = 80
|
|
13
16
|
const DEFAULT_AUTH_TOKEN = process.env.AUTH_TOKEN || ''
|
|
14
17
|
|
|
18
|
+
// Load proto from package directory
|
|
19
|
+
const PROTO_PATH = path.join(__dirname, 'monitoring.proto')
|
|
20
|
+
|
|
15
21
|
class MonitoringAgent {
|
|
16
22
|
static instance = null
|
|
17
23
|
|
|
@@ -161,9 +167,9 @@ class MonitoringAgent {
|
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
|
|
164
|
-
// Load proto
|
|
170
|
+
// Load proto with correct path
|
|
165
171
|
const proto = grpc.loadPackageDefinition(
|
|
166
|
-
protoLoader.loadSync(
|
|
172
|
+
protoLoader.loadSync(PROTO_PATH, {
|
|
167
173
|
keepCase: true,
|
|
168
174
|
longs: String,
|
|
169
175
|
enums: String,
|
|
@@ -176,4 +182,4 @@ module.exports = MonitoringAgent
|
|
|
176
182
|
|
|
177
183
|
if (require.main === module) {
|
|
178
184
|
MonitoringAgent.getInstance().start()
|
|
179
|
-
}
|
|
185
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitcall/pm2-pulse-agent",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.3",
|
|
4
|
+
"description": "PM2 monitoring agent that tracks server metrics and sends alerts via gRPC",
|
|
5
|
+
"main": "agent.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pm2-pulse-setup": "./scripts/setup-agent.js",
|
|
8
|
+
"pm2-pulse-agent": "./agent.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"agent.js",
|
|
12
|
+
"monitoring.proto",
|
|
13
|
+
"scripts/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
4
16
|
"scripts": {
|
|
5
17
|
"agent": "node agent.js",
|
|
6
18
|
"monitor": "node agent.js",
|
|
7
19
|
"setup-agent": "node scripts/setup-agent.js"
|
|
8
20
|
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"pm2",
|
|
23
|
+
"monitoring",
|
|
24
|
+
"metrics",
|
|
25
|
+
"grpc",
|
|
26
|
+
"server-monitoring",
|
|
27
|
+
"alerts"
|
|
28
|
+
],
|
|
29
|
+
"author": "bitcaller",
|
|
30
|
+
"license": "MIT",
|
|
9
31
|
"dependencies": {
|
|
10
32
|
"@grpc/grpc-js": "^1.10.1",
|
|
11
33
|
"@grpc/proto-loader": "^0.7.10",
|