96

Monitor: Self-Hosted pm2 Key Metrics System

 6 years ago
source link: https://www.tuicool.com/articles/hit/BzmiYbN
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Monitor

Example preview

Y36zain.jpg!web

To configure settings you need to set up environment variables for each process.

Start a master monitor

node lib/socket-master.js

Available master settings

Name Example LOG_LEVEL INITIAL_DATA_SLOTS DEFAULT_REFRESH_INTERVAL SLACK_REFRESH_INTERVAL SLACK_WEBHOOK_URL https://hooks.slack.com/services/... TRANSPORT_ADDONS ./transport/mail.js;./transport/slack.js EMAIL_REFRESH_INTERVAL EMAIL_CONFIG_transport_service gmail EMAIL_CONFIG_transport_auth_user *** EMAIL_CONFIG_transport_auth_pass *** EMAIL_OPTIONS_from [email protected] EMAIL_OPTIONS_to [email protected]

Start a slave monitor

node lib/socket-slave.js

Available slave settings

Name Example LOG_LEVEL DEFAULT_REFRESH_INTERVAL ADDONS ./addon/pm2.js;./addon/cpu.js;./addon/memory.js;./addon/storage.js;./addon/mongodb.js;./addon/elastic-search.js MONGODB_URIS `mongodb://localhost:27017/; ELASTICSEARCH_URIS http://localhost:9200;http://localhost:9200

LOG_LEVEL

LOG_LEVEL_NAME Description fatal The service/app is going to stop or become unusable now. An operator should definitely look into this soon. error Fatal for a particular request, but the service/app warn A note on something that should probably be looked at by info Detail on regular operation. debug Anything else, i.e. too verbose to be included in info trace Logging from external libraries used by your app or very detailed application logging.

Setting a logger instance (or one of its streams) to a particular level implies that all log records at that level and above are logged. E.g. a logger set to level "info" will log records at level info and above (warn, error, fatal).

INITIAL_DATA_SLOTS

[
        {
                "computername":"server 1",
                "names":["MAIL", "SLACK", "API"]
        },
        {
                "computername":"server 1",
                "names":["CPU", "C:\"]
        }
]

REFRESH_INTERVAL

Cron expression examples

0 */20 * * * * // 20 minutes.

*/3 * * * * * // trhre seconds.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK