{"id":17526775,"url":"https://github.com/kvaps/zabbix-linux-container-template","last_synced_at":"2026-02-26T03:49:06.523Z","repository":{"id":38214219,"uuid":"112537437","full_name":"kvaps/zabbix-linux-container-template","owner":"kvaps","description":"Zabbix template for LXC container","archived":false,"fork":false,"pushed_at":"2024-07-30T05:35:09.000Z","size":27,"stargazers_count":71,"open_issues_count":10,"forks_count":32,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-07-30T08:59:54.939Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kvaps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-29T22:58:27.000Z","updated_at":"2024-07-30T05:35:13.000Z","dependencies_parsed_at":"2024-07-30T09:11:22.961Z","dependency_job_id":null,"html_url":"https://github.com/kvaps/zabbix-linux-container-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvaps%2Fzabbix-linux-container-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvaps%2Fzabbix-linux-container-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvaps%2Fzabbix-linux-container-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvaps%2Fzabbix-linux-container-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kvaps","download_url":"https://codeload.github.com/kvaps/zabbix-linux-container-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239550283,"owners_count":19657541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-20T15:02:25.356Z","updated_at":"2026-02-26T03:49:01.491Z","avatar_url":"https://github.com/kvaps.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Zabbix: solve memory monitoring issue inside LXC containers\n\nZabbix-agent (NOT zabbix-agent2) has some problems with memory collecting from cgroups limited \ncontainers.\u003cbr\u003e If you are using Proxmox, you know what I mean: The available memory\nis collected wrongly without calculating buffers and cache memory.\n\n\u003cbr\u003e Note: This issue only affects zabbix-agent and has been fixed in zabbix-agent2.\u003cbr\u003e\n\u003cbr\u003e Zabbix have\n[bug\nreport]([https://support.zabbix.com/browse/ZBX-12164](https://support.zabbix.com/browse/ZBX-12164)),\nbut it seems that no one don’t want to fix it soon.\u003cbr\u003e So let’s fix it together\nbyself.\n\nFirst we need to create new user parameter for zabbix, I used `ct.memory.size`\nname similarly built-in `vm.memory.size` parameter, but with my own single line\nscript.\n\nPlease be sure that you have newest version of `free` tool, `3.3.10` and higher,\nbecause old one have different output format.\n\n    $ free -V\n    free from procps-ng 3.3.10\n\nEdit `/etc/zabbix/zabbix_agentd.d/zabbix_container.conf`:\n\nNOTE: Depending on the OS that you are working with, the path could change.\n\nPlease verify in `/etc/zabbix/zabbix_agentd.conf` the \"include\" path.\n\nExample With Debian 12\n\n```\n  cat /etc/zabbix/zabbix_agentd.conf | grep ^Include\n  Include=/etc/zabbix/zabbix_agentd.conf.d/*.conf\n```\n\nThis is the path to add the new user parameter. \n\n```\n  ls /etc/zabbix/zabbix_agentd.conf.d/\n  zabbix_container.conf \n```\n\nAdd user parameter for retrieve memory information:\n\n    UserParameter=ct.memory.size[*],free -b | awk '$ 1 == \"Mem:\" {total=$ 2; used=($ 3+$ 5); pused=(($ 3+$ 5)*100/$ 2); free=$ 4; pfree=($ 4*100/$ 2); shared=$ 5; buffers=$ 6; cache=$ 6; available=($ 6+$ 7); pavailable=(($ 6+$ 7)*100/$ 2); if(\"$1\" == \"\") {printf(\"%.0f\", total )} else {printf(\"%.0f\", $1 \"\" )} }'\n\nAdd another one for retrieve swap information:\n\n    UserParameter=ct.swap.size[*],free -b | awk '$ 1 == \"Swap:\" {total=$ 2; used=$ 3; free=$ 4; pfree=($ 4*100/$ 2); pused=($ 3*100/$ 2); if(\"$1\" == \"\") {printf(\"%.0f\", free )} else {printf(\"%.0f\", $1 \"\" )} }'\n\nAdd another one for retrieve right CPU load information:\n\n    UserParameter=ct.cpu.load[*],uptime | awk -F'[, ]+' '{avg1=$(NF-2); avg5=$(NF-1); avg15=$(NF)}{print $2/'$(nproc)'}'\n\nOr just download and copy my [zabbix_container.conf](https://github.com/kvaps/zabbix-linux-container-template/blob/master/zabbix_container.conf).\n\nIt will provide you support for next parameters:\n\n    ct.memory.size[total]\n    ct.memory.size[free]\n    ct.memory.size[buffers]\n    ct.memory.size[cached]\n    ct.memory.size[shared]\n    ct.memory.size[used]\n    ct.memory.size[pused]\n    ct.memory.size[available]\n    ct.memory.size[pavailable]\n    ct.swap.size[total]\n    ct.swap.size[free]\n    ct.swap.size[shared]\n    ct.swap.size[used]\n    ct.swap.size[pused]\n    ct.swap.size[available]\n    ct.swap.size[pavailable]\n    ct.cpu.load[percpu,avg1]\n    ct.cpu.load[percpu,avg5]\n    ct.cpu.load[percpu,avg15]\n\nDon’t forget to restart `zabbix-agent.service` after\n\nOk, now we can check is our parameter working from zabbix server:\n\n    $ zabbix_get -s \u003ccontainer_ip\u003e -k ct.memory.size[available]\n    1709940736\n\nOk it’s working.\n\nNow let’s configure zabbix for use them. In Zabbix Interface:\n\nGo Configuration → Templtes\n\n* Make full copy “Template OS Linux” to “Template Linux Container”\n* Open “Template Linux Container” → Items\n* Replace all `vm.memory.size` items to `ct.memory.size`.\n* Replace all `system.swap.size` items to `ct.swap.size`:\u003cbr\u003e You also need to\nremove commas in key filed here. Example:\u003cbr\u003e replace `system.swap.size[,free]`\nto `ct.swap.size[free]`\n* Replace all `system.cpu.load[percpu,*]` items to `ct.cpu.load[percpu,*]`.\n\nOr just download and import [my zabbix template](https://github.com/kvaps/zabbix-linux-container-template/blob/master/zbx_linux_container_template.xml).\n\nNext, go to the Configuration → Hosts\n\n* Unlink and clear “Template OS Linux” from your hosts\n* Attach “Template Linux Container”\n\nWait some time and check the graphics:\n\n![](https://cdn-images-1.medium.com/max/1000/1*SEX-o7e65BWT1G98qLNnHg.png)\n\nJob is done!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkvaps%2Fzabbix-linux-container-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkvaps%2Fzabbix-linux-container-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkvaps%2Fzabbix-linux-container-template/lists"}