{"id":11568,"library":"pm2-server-monit","title":"PM2 Server Monitor","description":"pm2-server-monit is a PM2 module designed to automatically monitor crucial server vital signs, integrating seamlessly into the PM2 ecosystem for process management. It tracks key metrics such as CPU average usage, free and used memory, drive space, network speed (input/output), total opened files, running processes, and active TTY/SSH sessions. The current stable version is 3.0.0. While no explicit release cadence is documented, the jump from v2.0 to v3.0 suggests periodic updates incorporating significant feature enhancements or internal changes. Its primary differentiator is its deep integration with PM2, allowing server monitoring to be managed and viewed alongside application processes, making it particularly useful for environments already leveraging PM2 for their Node.js applications. Unlike standalone monitoring agents, pm2-server-monit leverages the PM2 daemon to collect and report system statistics.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/pm2-hive/pm2-server-monit","tags":["javascript"],"install":[{"cmd":"npm install pm2-server-monit","lang":"bash","label":"npm"},{"cmd":"yarn add pm2-server-monit","lang":"bash","label":"yarn"},{"cmd":"pnpm add pm2-server-monit","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a PM2 module and requires PM2 to be installed globally to function.","package":"pm2","optional":false}],"imports":[{"note":"pm2-server-monit is a PM2 module, not a JavaScript library directly imported into application code. Interaction is primarily via the PM2 CLI.","wrong":"import pm2ServerMonit from 'pm2-server-monit'","symbol":"Installation","correct":"pm2 install pm2-server-monit"},{"note":"Module configuration is managed through PM2's `set` command or the PM2 Plus dashboard, not through programmatic access within application code.","wrong":"const config = require('pm2-server-monit').config;","symbol":"Configuration","correct":"pm2 set pm2-server-monit:drive /"},{"note":"Monitor the module's operational status and output via the PM2 CLI logs command, as there is no direct JavaScript API for retrieving metrics from user code.","wrong":"import { getStatus } from 'pm2-server-monit'","symbol":"Logs and Status","correct":"pm2 logs pm2-server-monit"}],"quickstart":{"code":"# First, ensure PM2 is installed globally if you haven't already\nnpm install -g pm2\n\n# Install the pm2-server-monit module into PM2\npm2 install pm2-server-monit\n\n# Configure the module to monitor multiple drives and adjust a refresh rate\n# Example: monitoring root '/' and a '/data' partition\npm2 set pm2-server-monit:drive \"/,/data\"\npm2 set pm2-server-monit:network_refresh_rate 5\n\n# View the status and initial logs of the module to verify operation\necho \"Waiting a few seconds for initial metrics to be collected...\"\nsleep 5\npm2 logs pm2-server-monit --lines 50\n\n# To view the collected metrics in a dashboard, use PM2 Plus\n# or other PM2 monitoring tools, as this module feeds data into PM2's ecosystem.\n","lang":"bash","description":"This quickstart demonstrates how to install the pm2-server-monit module, configure its monitoring parameters, and check its operational logs via the PM2 command-line interface."},"warnings":[{"fix":"Review the module's documentation for updated configuration options related to drive and network monitoring. Verify metrics post-upgrade using `pm2 logs pm2-server-monit`.","message":"Version 2.0 introduced significant changes to drive and network monitoring mechanisms. Users upgrading from earlier versions should review their configurations for compatibility and verify expected metric outputs.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Increase `disk_refresh_rate`, `memory_refresh_rate`, `cpu_refresh_rate`, and `network_refresh_rate` values to higher intervals (in seconds) to reduce the monitoring overhead. For example, `pm2 set pm2-server-monit:cpu_refresh_rate 10`.","message":"Configuring refresh rates for CPU, memory, disk, and network too low can lead to excessive CPU usage by the monitoring module itself.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always check the module's logs using `pm2 logs pm2-server-monit` for specific error messages or warnings that might indicate unsupported features or underlying issues on your operating system.","message":"Some system metrics might not appear in the monitoring output due to platform-specific incompatibilities or internal errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Increase the refresh rate configuration values for `disk_refresh_rate`, `memory_refresh_rate`, `cpu_refresh_rate`, and `network_refresh_rate` using `pm2 set` commands.","cause":"Refresh rates for system metrics (CPU, memory, disk, network) are set too low, causing frequent data collection.","error":"PM2 module consuming excessive CPU"},{"fix":"Check the module's logs using `pm2 logs pm2-server-monit` for specific error messages or warnings related to the missing metrics to diagnose platform support or runtime issues.","cause":"The specific system metric might not be supported on the operating system platform where the module is running, or an internal error occurred during data collection.","error":"Metrics are not displayed or missing from monitoring output"},{"fix":"Ensure PM2 is installed globally (`npm install -g pm2`) and then retry `pm2 install pm2-server-monit`. Check network connectivity and user permissions if the issue persists.","cause":"PM2 is either not installed globally, or the `pm2 install` command failed due to network issues or permissions.","error":"pm2-server-monit: command not found (or similar PM2 module installation error)"}],"ecosystem":"npm"}