From c755edea3c50cf15a808e4bbdb154f5d69640856 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Tue, 24 Oct 2023 13:54:00 +0200 Subject: [PATCH 1/4] Update zabbix_container.conf Remove the need for a special template --- zabbix_container.conf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zabbix_container.conf b/zabbix_container.conf index 3bfbff5..8a185d5 100644 --- a/zabbix_container.conf +++ b/zabbix_container.conf @@ -1,4 +1,11 @@ UserParameter=ct.memory.size[*],free -b | awk 'NR==2 {total=$ 2; used=($ 3+$ 5); pused=(($ 3+$ 5)*100/$ 2); free=$ 4; pfree=($ 4*100/$ 2); shared=$ 5; buffers=$ 6; cached=$ 6; available=$ 7; pavailable=($ 7*100/$ 2); if("$1" == "") {printf("%.0f", total )} else {printf("%.0f", $1 "" )} }' +Alias=vm.memory.size:ct.memory.size + UserParameter=ct.swap.size[*],free -b | awk 'NR==3 {total=$ 2; used=$ 3; free=$ 4; pfree=($ 4*100/$ 2); pused=($ 3*100/$ 2); if("$1" == "") {printf("%.0f", free )} else {printf("%.0f", $1 "" )} }' +Alias=system.swap.size:ct.swap.size + UserParameter=ct.cpu.load[*],cut -d" " -f1-3 /proc/loadavg | awk -F'[, ]+' '{avg1=$(NF-2); avg5=$(NF-1); avg15=$(NF)}{print $2/'$(nproc)'}' +Alias=system.cpu.load:ct.cpu.load + UserParameter=ct.uptime,cut -d"." -f1 /proc/uptime +Alias=system.uptime:ct.uptime From ee9bd21ab979bc3c9cc4ebfdde28ceab48c7dec7 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Tue, 24 Oct 2023 13:55:07 +0200 Subject: [PATCH 2/4] Delete zbx_linux_container_template.xml Remove now-redundant template --- zbx_linux_container_template.xml | 2487 ------------------------------ 1 file changed, 2487 deletions(-) delete mode 100644 zbx_linux_container_template.xml diff --git a/zbx_linux_container_template.xml b/zbx_linux_container_template.xml deleted file mode 100644 index 017bcd3..0000000 --- a/zbx_linux_container_template.xml +++ /dev/null @@ -1,2487 +0,0 @@ - - - 3.4 - 2018-01-25T15:03:17Z - - - Templates - - - - - - - - {Template Linux Container:vfs.file.cksum[/etc/passwd].diff(0)}>0 - 0 - - /etc/passwd has been changed on {HOST.NAME} - 0 - - - 0 - 2 - - 0 - 0 - - - - - {Template Linux Container:kernel.maxfiles.last(0)}<1024 - 0 - - Configured max number of opened files is too low on {HOST.NAME} - 0 - - - 0 - 1 - - 0 - 0 - - - - - {Template Linux Container:kernel.maxproc.last(0)}<256 - 0 - - Configured max number of processes is too low on {HOST.NAME} - 0 - - - 0 - 1 - - 0 - 0 - - - - - {Template Linux Container:system.cpu.util[,iowait].avg(5m)}>75 - 0 - - Disk I/O is overloaded on {HOST.NAME} - 0 - - - 0 - 2 - OS spends significant time waiting for I/O (input/output) operations. It could be indicator of performance issues with storage system. - 0 - 0 - - - - - {Template Linux Container:system.uname.diff(0)}>0 - 0 - - Host information was changed on {HOST.NAME} - 0 - - - 0 - 1 - - 0 - 0 - - - - - {Template Linux Container:system.hostname.diff(0)}>0 - 0 - - Hostname was changed on {HOST.NAME} - 0 - - - 0 - 1 - - 0 - 0 - - - - - {Template Linux Container:ct.memory.size[available].last(0)}<20M - 0 - - Lack of available memory on server {HOST.NAME} - 0 - - - 0 - 3 - - 0 - 0 - - - - - {Template Linux Container:ct.swap.size[pused].last(0)}>50 - 0 - - Lack of free swap space on {HOST.NAME} - 0 - - - 1 - 2 - It probably means that the systems requires more physical memory. - 0 - 0 - - - - - {Template Linux Container:ct.cpu.load[percpu,avg1].avg(5m)}>20 - 0 - - Processor load is too high on {HOST.NAME} - 0 - - - 0 - 2 - - 0 - 0 - - - - - {Template Linux Container:proc.num[].avg(5m)}>1000 - 0 - - Too many processes on {HOST.NAME} - 0 - - - 0 - 2 - - 0 - 0 - - - - - {Template Linux Container:proc.num[,,run].avg(5m)}>100 - 0 - - Too many processes running on {HOST.NAME} - 0 - - - 0 - 2 - - 0 - 0 - - - - - {Template Linux Container:system.uptime.change(0)}<0 - 0 - - {HOST.NAME} has just been restarted - 0 - - - 0 - 1 - - 0 - 0 - - - - - - - CPU jumps - 900 - 200 - 0.0000 - 100.0000 - 1 - 1 - 0 - 1 - 0 - 0.0000 - 0.0000 - 0 - 0 - 0 - 0 - - - 0 - 0 - 009900 - 0 - 2 - 0 - - Template Linux Container - system.cpu.switches - - - - 1 - 0 - 000099 - 0 - 2 - 0 - - Template Linux Container - system.cpu.intr - - - - - - CPU load - 900 - 200 - 0.0000 - 100.0000 - 1 - 1 - 0 - 1 - 0 - 0.0000 - 0.0000 - 1 - 0 - 0 - 0 - - - 0 - 0 - 009900 - 0 - 2 - 0 - - Template Linux Container - ct.cpu.load[percpu,avg1] - - - - 1 - 0 - 000099 - 0 - 2 - 0 - - Template Linux Container - ct.cpu.load[percpu,avg5] - - - - 2 - 0 - 990000 - 0 - 2 - 0 - - Template Linux Container - ct.cpu.load[percpu,avg15] - - - - - - CPU utilization - 900 - 200 - 0.0000 - 100.0000 - 1 - 0 - 1 - 1 - 0 - 0.0000 - 0.0000 - 1 - 1 - 0 - 0 - - - 0 - 1 - FF5555 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,steal] - - - - 1 - 1 - 55FF55 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,softirq] - - - - 2 - 1 - 009999 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,interrupt] - - - - 3 - 1 - 990099 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,nice] - - - - 4 - 1 - 999900 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,iowait] - - - - 5 - 1 - 990000 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,system] - - - - 6 - 1 - 000099 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,user] - - - - 7 - 1 - 009900 - 0 - 2 - 0 - - Template Linux Container - system.cpu.util[,idle] - - - - - - Memory usage - 900 - 200 - 0.0000 - 100.0000 - 1 - 1 - 0 - 1 - 0 - 0.0000 - 0.0000 - 1 - 2 - 0 - - Template Linux Container - ct.memory.size[total] - - - - 0 - 1 - BB0000 - 0 - 2 - 0 - - Template Linux Container - ct.memory.size[total] - - - - 1 - 1 - 00C800 - 0 - 2 - 0 - - Template Linux Container - ct.memory.size[available] - - - - - - Swap usage - 600 - 340 - 0.0000 - 0.0000 - 0 - 0 - 2 - 1 - 0 - 0.0000 - 0.0000 - 0 - 0 - 0 - 0 - - - 0 - 0 - AA0000 - 0 - 2 - 0 - - Template Linux Container - ct.swap.size[used] - - - - 1 - 0 - 00AA00 - 0 - 2 - 2 - - Template Linux Container - ct.swap.size[total] - - - - - - From 9a81d6f7cbee747861420d7704d7c076c502edd9 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Tue, 24 Oct 2023 13:58:33 +0200 Subject: [PATCH 3/4] Update README.md Update with new simplified instructions --- README.md | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index b4ef760..3e658e4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ collected worng without calculating buffers and cache memory.
Zabbix have [bug report]([https://support.zabbix.com/browse/ZBX-12164](https://support.zabbix.com/browse/ZBX-12164)), but it seems that no one don’t want to fix it soon.
So let’s fix it together -byself. +by ourselves. First we need to create new user parameter for zabbix, I used `ct.memory.size` name similarly built-in `vm.memory.size` parameter, but with my own single line @@ -74,6 +74,13 @@ It will provide you support for next parameters: ct.cpu.load[percpu,avg5] ct.cpu.load[percpu,avg15] +Now add aliases to make the new/correct data available under the standard item names: + + Alias=vm.memory.size:ct.memory.size + Alias=system.swap.size:ct.swap.size + Alias=system.cpu.load:ct.cpu.load + Alias=system.uptime:ct.uptime + Don’t forget to restart `zabbix-agent.service` after Ok, now we can check is our parameter working from zabbix server: @@ -81,26 +88,12 @@ Ok, now we can check is our parameter working from zabbix server: $ zabbix_get -s -k ct.memory.size[available] 1709940736 -Ok it’s working. - -Now let’s configure zabbix for use them. In Zabbix Interface: - -Go Configuration → Templtes +This new value should now also be available under the standard name: -* Make full copy “Template OS Linux” to “Template Linux Container” -* Open “Template Linux Container” → Items -* Replace all `vm.memory.size` items to `ct.memory.size`. -* Replace all `system.swap.size` items to `ct.swap.size`:
You also need to -remove commas in key filed here. Example:
replace `system.swap.size[,free]` -to `ct.swap.size[free]` -* Replace all `system.cpu.load[percpu,*]` items to `ct.cpu.load[percpu,*]`. - -Or just download and import [my zabbix template](https://github.com/kvaps/zabbix-linux-container-template/blob/master/zbx_linux_container_template.xml). - -Next, go to the Configuration → Hosts + $ zabbix_get -s -k vm.memory.size[available] + 1709940736 -* Unlink and clear “Template OS Linux” from your hosts -* Attach “Template Linux Container” +Ok it’s working. Wait some time and check the graphics: From e6bf6518a68251e3980fb1ebedb01fe8871b5185 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Tue, 24 Oct 2023 16:18:18 +0200 Subject: [PATCH 4/4] Update zabbix_container.conf Fix missing aliases, and make swap compatible with agent --- zabbix_container.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zabbix_container.conf b/zabbix_container.conf index 8a185d5..02cf75e 100644 --- a/zabbix_container.conf +++ b/zabbix_container.conf @@ -1,11 +1,14 @@ UserParameter=ct.memory.size[*],free -b | awk 'NR==2 {total=$ 2; used=($ 3+$ 5); pused=(($ 3+$ 5)*100/$ 2); free=$ 4; pfree=($ 4*100/$ 2); shared=$ 5; buffers=$ 6; cached=$ 6; available=$ 7; pavailable=($ 7*100/$ 2); if("$1" == "") {printf("%.0f", total )} else {printf("%.0f", $1 "" )} }' Alias=vm.memory.size:ct.memory.size +Alias=vm.memory.size[*]:ct.memory.size[*] -UserParameter=ct.swap.size[*],free -b | awk 'NR==3 {total=$ 2; used=$ 3; free=$ 4; pfree=($ 4*100/$ 2); pused=($ 3*100/$ 2); if("$1" == "") {printf("%.0f", free )} else {printf("%.0f", $1 "" )} }' +UserParameter=ct.swap.size[*],free -b | awk 'NR==3 {total=$ 2; used=$ 3; free=$ 4; pfree=($ 4*100/$ 2); pused=($ 3*100/$ 2); if("$2" == "") {printf("%.0f", free )} else {printf("%.0f", $2 "" )} }' Alias=system.swap.size:ct.swap.size +Alias=system.swap.size[*]:ct.swap.size[*] UserParameter=ct.cpu.load[*],cut -d" " -f1-3 /proc/loadavg | awk -F'[, ]+' '{avg1=$(NF-2); avg5=$(NF-1); avg15=$(NF)}{print $2/'$(nproc)'}' Alias=system.cpu.load:ct.cpu.load +Alias=system.cpu.load[*]:ct.cpu.load[*] UserParameter=ct.uptime,cut -d"." -f1 /proc/uptime Alias=system.uptime:ct.uptime