# Linux by Zabbix agent ## Overview New official Linux template. Requires agent of Zabbix 7.0 or newer. ## Requirements Zabbix version: 7.0 and higher. ## Tested versions This template has been tested on: - Linux OS ## 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 Zabbix agent on Linux OS following Zabbix [documentation](https://www.zabbix.com/documentation/7.0/manual/concepts/agent#agent-on-unix-like-systems). ### Macros used |Name|Description|Default| |----|-----------|-------| |{$AGENT.TIMEOUT}|
Timeout after which agent is considered unavailable. Works only for agents reachable from Zabbix server/proxy (passive mode).
|`3m`| |{$CPU.UTIL.CRIT}||`90`| |{$LOAD_AVG_PER_CPU.MAX.WARN}|The CPU load per core is considered sustainable. If necessary, it can be tuned.
|`1.5`| |{$VFS.FS.FSNAME.NOT_MATCHES}|This macro is used for discovery of the filesystems. It can be overridden on host level or its linked template level.
|`^(/dev\|/sys\|/run\|/proc\|.+/shm$)`| |{$VFS.FS.FSNAME.MATCHES}|This macro is used for discovery of the filesystems. It can be overridden on host level or its linked template level.
|`.+`| |{$VFS.FS.FSTYPE.MATCHES}|This macro is used for discovery of the filesystems. It can be overridden on host level or its linked template level.
|`Macro too long. Please see the template.`| |{$VFS.FS.FSTYPE.NOT_MATCHES}|This macro is used for discovery of the filesystems. It can be overridden on host level or its linked template level.
|`^\s$`| |{$VFS.FS.FREE.MIN.CRIT}|The critical threshold for utilization of the filesystem.
|`5G`| |{$VFS.FS.FREE.MIN.WARN}|The warning threshold for utilization of the filesystem.
|`10G`| |{$VFS.FS.INODE.PFREE.MIN.CRIT}|The critical threshold of the filesystem metadata utilization.
|`10`| |{$VFS.FS.INODE.PFREE.MIN.WARN}|The warning threshold of the filesystem metadata utilization.
|`20`| |{$VFS.FS.PUSED.MAX.CRIT}|The critical threshold of the filesystem utilization.
|`90`| |{$VFS.FS.PUSED.MAX.WARN}|The warning threshold of the filesystem utilization.
|`80`| |{$MEMORY.UTIL.MAX}|This macro is used as a threshold in the memory utilization trigger.
|`90`| |{$MEMORY.AVAILABLE.MIN}|This macro is used as a threshold in the memory available trigger.
|`20M`| |{$SWAP.PFREE.MIN.WARN}||`50`| |{$VFS.DEV.READ.AWAIT.WARN}|The average response time (in ms) of disk read before the trigger would fire.
|`20`| |{$VFS.DEV.WRITE.AWAIT.WARN}|The average response time (in ms) of disk write before the trigger would fire.
|`20`| |{$VFS.DEV.DEVNAME.NOT_MATCHES}|This macro is used for a discovery of block devices. It can be overridden on host level or its linked template level.
|`Macro too long. Please see the template.`| |{$VFS.DEV.DEVNAME.MATCHES}|This macro is used for a discovery of block devices. It can be overridden on host level or its linked template level.
|`.+`| |{$IF.ERRORS.WARN}||`2`| |{$IFCONTROL}||`1`| |{$NET.IF.IFNAME.MATCHES}||`^.*$`| |{$NET.IF.IFNAME.NOT_MATCHES}|It filters out `loopbacks`, `nulls`, `docker veth` links and `docker0 bridge` by default.
|`Macro too long. Please see the template.`| |{$IF.UTIL.MAX}|This macro is used as a threshold in the interface utilization trigger.
|`90`| |{$SYSTEM.FUZZYTIME.MAX}||`60`| |{$KERNEL.MAXPROC.MIN}||`1024`| |{$KERNEL.MAXFILES.MIN}||`256`| ### Items |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Linux: Version of Zabbix agent running||Zabbix agent|agent.version**Preprocessing**
Discard unchanged with heartbeat: `1d`
**Preprocessing**
Discard unchanged with heartbeat: `1d`
The agent always returns 1 for this item. It could be used in combination with nodata() for availability check.
|Zabbix agent|agent.ping| |Linux: Zabbix agent availability|Monitoring the availability status of the agent.
|Zabbix internal|zabbix[host,agent,available]| |Linux: Number of CPUs||Zabbix agent|system.cpu.num**Preprocessing**
Discard unchanged with heartbeat: `1d`
The CPU utilization expressed in %.
|Dependent item|system.cpu.util**Preprocessing**
JavaScript: `//Calculate utilization
return (100 - value)`
The time the CPU has spent doing nothing.
|Zabbix agent|system.cpu.util[,idle]| |Linux: CPU system time|The time the CPU has spent running the kernel and its processes.
|Zabbix agent|system.cpu.util[,system]| |Linux: CPU user time|The time the CPU has spent running users' processes that are not niced.
|Zabbix agent|system.cpu.util[,user]| |Linux: CPU nice time|The time the CPU has spent running users' processes that have been niced.
|Zabbix agent|system.cpu.util[,nice]| |Linux: CPU iowait time|The amount of time the CPU has been waiting for I/O to complete.
|Zabbix agent|system.cpu.util[,iowait]| |Linux: CPU steal time|The amount of "stolen" CPU from this virtual machine by the hypervisor for other tasks, such as running another virtual machine.
|Zabbix agent|system.cpu.util[,steal]| |Linux: CPU interrupt time|The amount of time the CPU has been servicing hardware interrupts.
|Zabbix agent|system.cpu.util[,interrupt]| |Linux: CPU softirq time|The amount of time the CPU has been servicing software interrupts.
|Zabbix agent|system.cpu.util[,softirq]| |Linux: CPU guest time|Guest time - the time spent on running a virtual CPU for a guest operating system.
|Zabbix agent|system.cpu.util[,guest]| |Linux: CPU guest nice time|The time spent on running a niced guest (a virtual CPU for guest operating systems under the control of the Linux kernel).
|Zabbix agent|system.cpu.util[,guest_nice]| |Linux: Context switches per second||Zabbix agent|system.cpu.switches**Preprocessing**
**Preprocessing**
The `vfs.fs.get` key acquires raw information set about the file systems. Later to be extracted by preprocessing in dependent items.
|Zabbix agent|vfs.fs.get| |Linux: Memory utilization|The percentage of used memory is calculated as `100-pavailable`.
|Dependent item|vm.memory.utilization**Preprocessing**
JavaScript: `return (100-value);`
The available memory as percentage of the total. See also Appendixes in Zabbix Documentation about parameters of the `vm.memory.size` item.
|Zabbix agent|vm.memory.size[pavailable]| |Linux: Total memory|The total memory expressed in bytes.
|Zabbix agent|vm.memory.size[total]| |Linux: Available memory|The available memory:
- in Linux - available = free + buffers + cache;
- on other platforms calculation may vary.
See also Appendixes in Zabbix Documentation about parameters of the `vm.memory.size` item.
|Zabbix agent|vm.memory.size[available]| |Linux: Total swap space|The total space of the swap volume/file expressed in bytes.
|Zabbix agent|system.swap.size[,total]| |Linux: Free swap space|The free space of the swap volume/file expressed in bytes.
|Zabbix agent|system.swap.size[,free]| |Linux: Free swap space in %|The free space of the swap volume/file expressed in %.
|Zabbix agent|system.swap.size[,pfree]| |Linux: System uptime|The system uptime expressed in the following format: "N days, hh:mm:ss".
|Zabbix agent|system.uptime| |Linux: System boot time||Zabbix agent|system.boottime**Preprocessing**
Discard unchanged with heartbeat: `1h`
The local system time of the host.
|Zabbix agent|system.localtime| |Linux: System name|The host name of the system.
|Zabbix agent|system.hostname**Preprocessing**
Discard unchanged with heartbeat: `12h`
The information as normally returned by `uname -a`.
|Zabbix agent|system.uname**Preprocessing**
Discard unchanged with heartbeat: `12h`
The number of users who are currently logged in.
|Zabbix agent|system.users.num| |Linux: Maximum number of open file descriptors|It could be increased by using `sysctl` utility or modifying the file `/etc/sysctl.conf`.
|Zabbix agent|kernel.maxfiles**Preprocessing**
Discard unchanged with heartbeat: `1d`
It could be increased by using `sysctl` utility or modifying the file `/etc/sysctl.conf`.
|Zabbix agent|kernel.maxproc**Preprocessing**
Discard unchanged with heartbeat: `1d`
**Preprocessing**
Discard unchanged with heartbeat: `1h`
**Preprocessing**
Discard unchanged with heartbeat: `1d`
The architecture of the operating system.
|Zabbix agent|system.sw.arch**Preprocessing**
Discard unchanged with heartbeat: `1d`
**Preprocessing**
JSON Path: `$.length()`
Discard unchanged with heartbeat: `12h`
For passive only agents, host availability is used with {$AGENT.TIMEOUT} as time threshold.
|`max(/Linux by Zabbix agent/zabbix[host,agent,available],{$AGENT.TIMEOUT})=0`|Average|**Manual close**: Yes| |Linux: Load average is too high|The load average per CPU is too high. The system may be slow to respond.
|`min(/Linux by Zabbix agent/system.cpu.load[all,avg1],5m)/last(/Linux by Zabbix agent/system.cpu.num)>{$LOAD_AVG_PER_CPU.MAX.WARN} and last(/Linux by Zabbix agent/system.cpu.load[all,avg5])>0 and last(/Linux by Zabbix agent/system.cpu.load[all,avg15])>0`|Average|| |Linux: High CPU utilization|The CPU utilization is too high. The system might be slow to respond.
|`min(/Linux by Zabbix agent/system.cpu.util,5m)>{$CPU.UTIL.CRIT}`|Warning|**Depends on**:The system is running out of free memory.
|`min(/Linux by Zabbix agent/vm.memory.utilization,5m)>{$MEMORY.UTIL.MAX}`|Average|**Depends on**:If there is no swap configured, this trigger is ignored.
|`max(/Linux by Zabbix agent/system.swap.size[,pfree],5m)<{$SWAP.PFREE.MIN.WARN} and last(/Linux by Zabbix agent/system.swap.size[,total])>0`|Warning|**Depends on**:The host uptime is less than 10 minutes.
|`last(/Linux by Zabbix agent/system.uptime)<10m`|Warning|**Manual close**: Yes| |Linux: System time is out of sync|The host's system time is different from Zabbix server time.
|`fuzzytime(/Linux by Zabbix agent/system.localtime,{$SYSTEM.FUZZYTIME.MAX})=0`|Warning|**Manual close**: Yes| |Linux: System name has changed|The name of the system has changed. Acknowledge to close the problem manually.
|`change(/Linux by Zabbix agent/system.hostname) and length(last(/Linux by Zabbix agent/system.hostname))>0`|Info|**Manual close**: Yes| |Linux: Configured max number of open filedescriptors is too low||`last(/Linux by Zabbix agent/kernel.maxfiles)<{$KERNEL.MAXFILES.MIN}`|Info|| |Linux: Configured max number of processes is too low||`last(/Linux by Zabbix agent/kernel.maxproc)<{$KERNEL.MAXPROC.MIN}`|Info|**Depends on**:The description of the operating system has changed. Possible reasons are that the system has been updated or replaced. Acknowledge to close the problem manually.
|`change(/Linux by Zabbix agent/system.sw.os) and length(last(/Linux by Zabbix agent/system.sw.os))>0`|Info|**Manual close**: YesThe discovery of mounted filesystems with different types.
|Dependent item|vfs.fs.dependent.discovery| ### Item prototypes for Mounted filesystem discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |{#FSNAME}: Get filesystem data||Dependent item|vfs.fs.dependent[{#FSNAME},data]**Preprocessing**
JSON Path: `$.[?(@.fsname=='{#FSNAME}')].first()`
The filesystem is mounted as read-only. It is available only for Zabbix agents 6.4 and higher.
|Dependent item|vfs.fs.dependent[{#FSNAME},readonly]**Preprocessing**
JSON Path: `$.options`
⛔️Custom on fail: Discard value
Regular expression: `(?:^|,)ro\b 1`
⛔️Custom on fail: Set value to: `0`
Used storage expressed in bytes.
|Dependent item|vfs.fs.dependent.size[{#FSNAME},used]**Preprocessing**
JSON Path: `$.bytes.used`
The total space expressed in bytes.
|Dependent item|vfs.fs.dependent.size[{#FSNAME},total]**Preprocessing**
JSON Path: `$.bytes.total`
Space utilization expressed in % for `{#FSNAME}`.
|Dependent item|vfs.fs.dependent.size[{#FSNAME},pused]**Preprocessing**
JSON Path: `$.bytes.pused`
**Preprocessing**
JSON Path: `$.inodes.pfree`
The filesystem has become read-only. A possible reason is an I/O error. It is available only for Zabbix agents 6.4 and higher.
|`last(/Linux by Zabbix agent/vfs.fs.dependent[{#FSNAME},readonly],#2)=0 and last(/Linux by Zabbix agent/vfs.fs.dependent[{#FSNAME},readonly])=1`|Average|**Manual close**: Yes| |{#FSNAME}: Disk space is critically low|Two conditions should match:
1. The first condition - utilization of the space should be above `{$VFS.FS.PUSED.MAX.CRIT:"{#FSNAME}"}`.
2. The second condition should be one of the following:
- the disk free space is less than `{$VFS.FS.FREE.MIN.CRIT:"{#FSNAME}"}`;
- the disk will be full in less than 24 hours.
Two conditions should match:
1. The first condition - utilization of the space should be above `{$VFS.FS.PUSED.MAX.WARN:"{#FSNAME}"}`.
2. The second condition should be one of the following:
- the disk free space is less than `{$VFS.FS.FREE.MIN.WARN:"{#FSNAME}"}`;
- the disk will be full in less than 24 hours.
It may become impossible to write to a disk if there are no index nodes left.
The following error messages may be returned as symptoms, even though the free space is available:
- 'No space left on device';
- 'Disk is full'.
It may become impossible to write to a disk if there are no index nodes left.
The following error messages may be returned as symptoms, even though the free space is available:
- 'No space left on device';
- 'Disk is full'.
**Preprocessing**
Discard unchanged with heartbeat: `1h`
The contents of get `/sys/block/{#DEVNAME}/stat` to get the disk statistics.
|Zabbix agent|vfs.file.contents[/sys/block/{#DEVNAME}/stat]**Preprocessing**
JavaScript: `return JSON.stringify(value.trim().split(/ +/));`
r/s (read operations per second) - the number (after merges) of read requests completed per second for the device.
|Dependent item|vfs.dev.read.rate[{#DEVNAME}]**Preprocessing**
JSON Path: `$[0]`
w/s (write operations per second) - the number (after merges) of write requests completed per second for the device.
|Dependent item|vfs.dev.write.rate[{#DEVNAME}]**Preprocessing**
JSON Path: `$[4]`
The rate of total read time counter; used in `r_await` calculation.
|Dependent item|vfs.dev.read.time.rate[{#DEVNAME}]**Preprocessing**
JSON Path: `$[3]`
Custom multiplier: `0.001`
The rate of total write time counter; used in `w_await` calculation.
|Dependent item|vfs.dev.write.time.rate[{#DEVNAME}]**Preprocessing**
JSON Path: `$[7]`
Custom multiplier: `0.001`
This formula contains two Boolean expressions that evaluate to 1 or 0 in order to set the calculated metric to zero and to avoid the exception - division by zero.
|Calculated|vfs.dev.read.await[{#DEVNAME}]| |{#DEVNAME}: Disk write request avg waiting time (w_await)|This formula contains two Boolean expressions that evaluate to 1 or 0 in order to set the calculated metric to zero and to avoid the exception - division by zero.
|Calculated|vfs.dev.write.await[{#DEVNAME}]| |{#DEVNAME}: Disk average queue size (avgqu-sz)|The current average disk queue; the number of requests outstanding on the disk while the performance data is being collected.
|Dependent item|vfs.dev.queue_size[{#DEVNAME}]**Preprocessing**
JSON Path: `$[10]`
Custom multiplier: `0.001`
This item is the percentage of elapsed time during which the selected disk drive was busy while servicing read or write requests.
|Dependent item|vfs.dev.util[{#DEVNAME}]**Preprocessing**
JSON Path: `$[9]`
Custom multiplier: `0.1`
This trigger might indicate the disk `{#DEVNAME}` saturation.
|`min(/Linux by Zabbix agent/vfs.dev.read.await[{#DEVNAME}],15m) > {$VFS.DEV.READ.AWAIT.WARN:"{#DEVNAME}"} or min(/Linux by Zabbix agent/vfs.dev.write.await[{#DEVNAME}],15m) > {$VFS.DEV.WRITE.AWAIT.WARN:"{#DEVNAME}"}`|Warning|**Manual close**: Yes| ### LLD rule Network interface discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Network interface discovery|The discovery of network interfaces.
|Zabbix agent|net.if.discovery| ### Item prototypes for Network interface discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Interface {#IFNAME}: Bits received||Zabbix agent|net.if.in["{#IFNAME}"]**Preprocessing**
Custom multiplier: `8`
**Preprocessing**
Custom multiplier: `8`
**Preprocessing**
**Preprocessing**
**Preprocessing**
**Preprocessing**
Reference: https://www.kernel.org/doc/Documentation/networking/operstates.txt
|Zabbix agent|vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"]**Preprocessing**
JavaScript: `The text is too long. Please see the template.`
It indicates the interface protocol type as a decimal value.
See `include/uapi/linux/if_arp.h` for all possible values.
Reference: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
|Zabbix agent|vfs.file.contents["/sys/class/net/{#IFNAME}/type"]**Preprocessing**
Discard unchanged with heartbeat: `1d`
It indicates the latest or current speed value of the interface. The value is an integer representing the link speed expressed in bits/sec.
This attribute is only valid for the interfaces that implement the ethtool `get_link_ksettings` method (mostly Ethernet).
Reference: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
|Zabbix agent|vfs.file.contents["/sys/class/net/{#IFNAME}/speed"]**Preprocessing**
Custom multiplier: `1000000`
Discard unchanged with heartbeat: `1h`
The utilization of the network interface is close to its estimated maximum bandwidth.
|`(avg(/Linux by Zabbix agent/net.if.in["{#IFNAME}"],15m)>({$IF.UTIL.MAX:"{#IFNAME}"}/100)*last(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/speed"]) or avg(/Linux by Zabbix agent/net.if.out["{#IFNAME}"],15m)>({$IF.UTIL.MAX:"{#IFNAME}"}/100)*last(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/speed"])) and last(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/speed"])>0`|Warning|**Manual close**: YesIt recovers when it is below 80% of the `{$IF.ERRORS.WARN:"{#IFNAME}"}` threshold.
|`min(/Linux by Zabbix agent/net.if.in["{#IFNAME}",errors],5m)>{$IF.ERRORS.WARN:"{#IFNAME}"} or min(/Linux by Zabbix agent/net.if.out["{#IFNAME}",errors],5m)>{$IF.ERRORS.WARN:"{#IFNAME}"}`|Warning|**Manual close**: YesThis trigger expression works as follows:
1. It can be triggered if the operations status is down.
2. `{$IFCONTROL:"{#IFNAME}"}=1` - a user can redefine context macro to value - 0. That marks this interface as not important. No new trigger will be fired if this interface is down.
3. `{TEMPLATE_NAME:METRIC.diff()}=1` - the trigger fires only if the operational status was up to (1) sometime before (so, do not fire for the 'eternal off' interfaces.)
WARNING: if closed manually - it will not fire again on the next poll, because of .diff.
This Ethernet connection has transitioned down from its known maximum speed. This might be a sign of autonegotiation issues. Acknowledge to close the problem manually.
|`change(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/speed"])<0 and last(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/speed"])>0 and (last(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/type"])=6 or last(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/type"])=1) and (last(/Linux by Zabbix agent/vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"])<>2)`|Info|**Manual close**: Yes