
# OS processes by Zabbix agent

## Overview

This template is designed to monitor processes by Zabbix that work without any external scripts.
Most of the metrics are collected in one go, thanks to Zabbix bulk data collection.
For example, by specifying "zabbix" as macro value, you can monitor all zabbix processes.

## Requirements

Zabbix version: 7.0 and higher.

## Tested versions

This template has been tested on:
- CentOS Linux 8
- Ubuntu 22.04.1 LTS

## Configuration

> Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section.

## Setup

Install and setup [Zabbix agent](https://www.zabbix.com/documentation/7.0/manual/installation/install_from_packages).

Custom processes set in macros:

- {$PROC.NAME.MATCHES}
- {$PROC.NAME.NOT_MATCHES}

### Macros used

|Name|Description|Default|
|----|-----------|-------|
|{$PROC.NAME.MATCHES}|
This macro is used in the discovery of processes. It can be overridden on a host-level or on a linked template-level.
|`<CHANGE VALUE>`|
|{$PROC.NAME.NOT_MATCHES}|
This macro is used in the discovery of processes. It can be overridden on a host-level or on a linked template-level.
|`<CHANGE VALUE>`|

### Items

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Get process summary|
The summary of data metrics for all processes.
|Zabbix agent|proc.get[,,,summary]|

### LLD rule Processes discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Processes discovery|
Discovery of OS summary processes.
|Dependent item|custom.proc.discovery|

### Item prototypes for Processes discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Process [{#NAME}]: Get data|
Summary metrics collected during the process {#NAME}.
|Dependent item|custom.proc.get[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.[?(@["name"]=="{#NAME}")].first()`

⛔️Custom on fail: Set value to: `Failed to retrieve process {#NAME} data`

|
|Process [{#NAME}]: Memory usage (rss)|
The summary of Resident Set Size (RSS) memory used by the process {#NAME} in bytes.
|Dependent item|custom.proc.rss[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.rss`

⛔️Custom on fail: Discard value

|
|Process [{#NAME}]: Memory usage (vsize)|
The summary of virtual memory used by process {#NAME} in bytes.
|Dependent item|custom.proc.vmem[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.vsize`

⛔️Custom on fail: Discard value

|
|Process [{#NAME}]: Memory usage, %|
The percentage of real memory used by the process {#NAME}.
|Dependent item|custom.proc.pmem[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.pmem`

⛔️Custom on fail: Discard value

|
|Process [{#NAME}]: Number of running processes|
The number of running processes {#NAME}.
|Dependent item|custom.proc.num[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.processes`

⛔️Custom on fail: Set value to: `0`

- 
Discard unchanged with heartbeat: `1h`

|
|Process [{#NAME}]: Number of threads|
The number of threads {#NAME}.
|Dependent item|custom.proc.thread[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.threads`

⛔️Custom on fail: Discard value

|
|Process [{#NAME}]: Number of page faults|
The number of page faults {#NAME}.
|Dependent item|custom.proc.page[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.page_faults`

⛔️Custom on fail: Discard value

|
|Process [{#NAME}]: Size of locked memory|
The size of locked memory {#NAME}.
|Dependent item|custom.proc.mem.locked[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.lck`

⛔️Custom on fail: Discard value

|
|Process [{#NAME}]: Swap space used|
The swap space used by {#NAME}.
|Dependent item|custom.proc.swap[{#NAME}]
**Preprocessing**

- 
JSON Path: `$.swap`

⛔️Custom on fail: Discard value

|

### Trigger prototypes for Processes discovery

|Name|Description|Expression|Severity|Dependencies and additional info|
|----|-----------|----------|--------|--------------------------------|
|OS: Process [{#NAME}]: Process is not running||`last(/OS processes by Zabbix agent/custom.proc.num[{#NAME}])=0`|High|**Manual close**: Yes|

## Feedback

Please report any issues with the template at [`https://support.zabbix.com`](https://support.zabbix.com)

You can also provide feedback, discuss the template, or ask for help at [`ZABBIX forums`](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback)

