@vladonv/pm2-postgres 0.1.1 → 0.1.2
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 +29 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pm2-postgres
|
|
2
2
|
PostgreSQL module for Keymetrics
|
|
3
3
|
|
|
4
|
-

|
|
5
5
|
|
|
6
6
|
## Description
|
|
7
7
|
|
|
@@ -16,16 +16,36 @@ PM2 module to monitor key PostgreSQL server metrics:
|
|
|
16
16
|
|
|
17
17
|
## Requirements
|
|
18
18
|
|
|
19
|
-
This module requires a PostgreSQL install (v9.3+, including SCRAM-SHA-256 auth on PostgreSQL 10-
|
|
19
|
+
This module requires a PostgreSQL install (v9.3+, including SCRAM-SHA-256 auth on PostgreSQL 10-18).
|
|
20
20
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
$ npm install pm2 -g
|
|
25
25
|
|
|
26
|
-
$ pm2 install pm2-postgres
|
|
26
|
+
$ pm2 install @vladonv/pm2-postgres
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
## Setting up a monitoring user
|
|
30
|
+
|
|
31
|
+
Instead of using a superuser account, it's recommended to create a dedicated, restricted user for monitoring. Connect to your database as an administrator (`psql -U postgres`) and run:
|
|
32
|
+
|
|
33
|
+
```sql
|
|
34
|
+
-- 1. Create a dedicated monitoring user
|
|
35
|
+
CREATE USER pm2_monitor WITH ENCRYPTED PASSWORD 'your_strong_password';
|
|
36
|
+
|
|
37
|
+
-- 2. Allow it to connect to your specific database
|
|
38
|
+
GRANT CONNECT ON DATABASE your_database_name TO pm2_monitor;
|
|
39
|
+
|
|
40
|
+
-- 3. Grant the built-in role for reading system statistics. This is a safe,
|
|
41
|
+
-- built-in role: it lets the user read system views (such as pg_stat_activity,
|
|
42
|
+
-- pg_stat_database) to see connection counts, database load, and file sizes,
|
|
43
|
+
-- without granting access to table data (no SELECT, INSERT, or DELETE on tables).
|
|
44
|
+
GRANT pg_monitor TO pm2_monitor;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then use `pm2_monitor` and its password as the `username`/`password` config values below.
|
|
48
|
+
|
|
29
49
|
## Config
|
|
30
50
|
|
|
31
51
|
The default connection details are :
|
|
@@ -37,17 +57,17 @@ The default connection details are :
|
|
|
37
57
|
|
|
38
58
|
To modify the config values you can use the commands:
|
|
39
59
|
```bash
|
|
40
|
-
$ pm2 set pm2-postgres:hostname localhost
|
|
41
|
-
$ pm2 set pm2-postgres:port 5432
|
|
42
|
-
$ pm2 set pm2-postgres:username guest
|
|
43
|
-
$ pm2 set pm2-postgres:password guest
|
|
44
|
-
$ pm2 set pm2-postgres:database postgres
|
|
60
|
+
$ pm2 set @vladonv/pm2-postgres:hostname localhost
|
|
61
|
+
$ pm2 set @vladonv/pm2-postgres:port 5432
|
|
62
|
+
$ pm2 set @vladonv/pm2-postgres:username guest
|
|
63
|
+
$ pm2 set @vladonv/pm2-postgres:password guest
|
|
64
|
+
$ pm2 set @vladonv/pm2-postgres:database postgres
|
|
45
65
|
```
|
|
46
66
|
|
|
47
67
|
## Uninstall
|
|
48
68
|
|
|
49
69
|
```bash
|
|
50
|
-
$ pm2 uninstall pm2-postgres
|
|
70
|
+
$ pm2 uninstall @vladonv/pm2-postgres
|
|
51
71
|
```
|
|
52
72
|
|
|
53
73
|
# License
|
package/package.json
CHANGED