Process monitoring is the continuous observation of running programs on a host to confirm that each required process is alive, healthy and within its resource budget, and to alert or act when it is not. In the field of services & processes on servers, it covers daemons, worker processes and long-running jobs, from a single web server to hundreds of containerized workers.
Effective process monitoring answers three questions at all times: is the process running, is it doing useful work, and is it consuming a reasonable share of CPU, memory and file descriptors. Tools range from process supervisors such as Supervisord, PM2, Monit and systemd to full observability platforms that collect metrics, logs and traces.
How process monitoring observes a running process
Process monitoring works by sampling the state of each process at regular intervals or by receiving events from the operating system. On Linux the raw data comes from the /proc filesystem, which exposes the process ID, state, CPU ticks, resident memory, open file descriptors and thread count for every process.
Monitoring agents identify the target process in one of several ways: by a PID file written at startup, by matching the command line, by cgroup membership under systemd, or by being the direct parent process. The parent approach is the most reliable, because a supervisor that started the child receives the SIGCHLD signal the instant it exits and cannot be fooled by a stale PID file pointing to a recycled process ID.
The table below compares the main detection methods and their trade-offs.
| Method | How it works | Main weakness |
|---|---|---|
| Parent supervision | Supervisor forks the process and waits on it | Works only for processes it started |
| PID file check | Reads a stored PID and tests if it exists | Stale files and PID reuse cause false results |
| Command-line matching | Searches the process table by name or arguments | Similar processes may match by mistake |
| Cgroup tracking | Counts all processes in a control group | Requires systemd or a container runtime |
| Health endpoint polling | Requests a status URL or socket | Adds network load and needs application support |
Liveness, readiness and resource health
A process that exists is not necessarily working. Mature process monitoring therefore distinguishes several layers of health, each answering a different question and triggering a different response.
| Layer | Question answered | Typical signal | Usual response |
|---|---|---|---|
| Existence | Is the process running | PID present, state not zombie | Restart the process |
| Liveness | Is it responsive | Heartbeat, watchdog ping, health check | Kill and restart |
| Readiness | Can it accept traffic | Readiness endpoint, port binding | Remove from load balancer |
| Resource health | Is usage within limits | CPU, memory, file descriptors | Alert or graceful restart |
| Functional health | Is it producing correct output | Queue depth, error rate, latency | Alert an operator |
The distinction matters because a hung process passes the existence test while serving nothing. Liveness checks catch deadlocks and infinite loops, while resource checks catch slow memory leaks and descriptor exhaustion before they crash the service or the whole server.
Process supervisors and monitoring tools compared
Process monitoring is implemented either by a supervisor that owns the process or by an external monitor that observes it. Many production setups combine both: a supervisor keeps the process alive, while a metrics system records trends and notifies people.
| Tool | Model | Typical use |
|---|---|---|
| systemd | Init system and supervisor | Native Linux services with restart policies |
| Supervisord | User-space supervisor | Several application workers on one host |
| PM2 | Supervisor for Node.js | JavaScript applications and clusters |
| Monit | External checker with actions | Resource thresholds and simple restarts |
| Prometheus exporters | Metrics collection | Trends, dashboards and alert rules |
| Kubernetes probes | Orchestrator health checks | Containers with liveness and readiness probes |
Supervisors apply a service restart policy, such as restarting always, only on failure, or never, often with a backoff delay. Without backoff, a process that fails immediately at startup can enter a crash loop, consuming CPU and flooding logs while never becoming healthy.
Designing alerts and automatic actions
Good process monitoring automates the routine recovery and escalates to humans only when automation cannot help. The thresholds and actions should reflect the cost of a false alarm versus the cost of a missed failure.
| Condition | Threshold | Action |
|---|---|---|
| Worker process exits | Any unexpected exit | Restart with exponential backoff |
| Restarts in a short window | More than 5 in 10 minutes | Stop restarting and page on-call |
| Resident memory | Above 90% of the limit for 5 minutes | Graceful restart and warning |
| Open file descriptors | Above 80% of the ulimit | Alert with process details |
| Heartbeat missing | No signal for 3 intervals | Kill and restart the process |
Thresholds should use sustained conditions rather than single samples, because short spikes in CPU or memory are normal. Alerts should carry the process name, host, PID and recent log lines, so that the responder can act without logging in to gather context.
Common pitfalls in process monitoring
Most failures of process monitoring come from checking too little or acting too aggressively. The following mistakes appear frequently in production environments.
- Monitoring only existence: a deadlocked worker keeps its PID and silently stops serving requests.
- Relying on stale PID files: after a crash, the stored PID may belong to an unrelated process.
- Restarting without limits: unbounded restarts hide configuration errors and create crash loops.
- Double supervision: two supervisors managing the same process fight each other and cause duplicate instances.
- Monitoring from the same host only: if the host fails, the monitor fails with it, so an external check is still needed.
A further risk is alert fatigue. When every brief restart sends a notification, operators learn to ignore alerts, and a genuine outage goes unnoticed. Grouping related events and alerting on user-facing symptoms keeps the signal useful.
Understanding it simply
A server runs many programs in the background, much like a building runs elevators, heating and lights. Process monitoring is the caretaker who walks the building, checking that each system is switched on, actually working and not overheating.
When something stops, the caretaker restarts it right away. When something keeps breaking, the caretaker calls a specialist instead of restarting it forever. The key idea is that problems are noticed and handled before visitors notice them.
Applied in practice
A small software company runs its customer portal on two Linux servers. Each server hosts a Node.js application managed by PM2 with four worker processes, plus a background queue worker supervised by systemd with a restart-on-failure policy and a 5-second backoff.
One evening a new release introduces a memory leak in the queue worker. Resident memory grows by roughly 50 MB per hour. Monit detects memory above 90% of the configured limit for five minutes, performs a graceful restart and sends a warning that includes the process name and recent logs.
The restarts keep the queue running overnight, and the alert history shows a clear pattern. The next morning engineers trace the leak to an unclosed database cursor, ship a fix and avoid any customer-facing outage.