The previous posts within this series guided you through the topics of process management, how to display currently managed app instance processes and how to restart your applications after system reboots. With PM2, you can also monitor your app processes in respect of CPU and memory utilization. This article will show you how to use this built-in monitoring feature.
PM2 Series Overview
Monitoring With PM2
Actually, the PM2 command line utility makes it very easy to show the current CPU and memory utilization for each of your managed application processes. The only command you need to remember is:
You’ll see a real-time overview of your managed apps and respectively the process name, CPU and memory utilization in MB. To illustrate the monitoring command, we’ve started our Future Studio homepage and maintenance servers side by side locally. Since currently nobody accesses any of both apps, they’re idling and waiting for work. The default memory consumption is about 50M for the maintenance and 70M for the homepage project.
$ pm2 monit ⌬ PM2 monitoring (To go further check out https://app.keymetrics.io) ● maintenance [ ] 0 %  [fork_mode] [|||||||| ] 48.281 MB ● homepage [ ] 0 %  [fork_mode] [|||||||||||| ] 68.777 MB
That’s all the magic. Keymetrics (the developers of PM2) uses this feature to report the current process utilization directly to their dashboard which is accessible via web interface. If you don’t have any other system utilization mechanism in place, PM2’s monitoring feature will at least give you a sense of your apps utilization levels.
What Comes Next
This article describes how to use PM2’s built-in monitoring utility to show the app’s real-time utilization for CPU and memory.
The upcoming article will guide you through the required steps to run your app instances in cluster mode. Additionally, we’ll show you how to use the cluster mode to deploy app updates with 0s downtimes. You don’t need to worry about unavailability anymore!
If you’ve questions about PM2 and the integrated monitoring, leave a comment below or reach out @futurestud_io.