From 0f55e33fabd2b726ac69dd8b35b6426da64e2cf8 Mon Sep 17 00:00:00 2001 From: Patrik Majer Date: Tue, 21 Oct 2014 14:44:53 +0200 Subject: [PATCH] add Memory advanced items --- README.md | 14 ++ Template_Linux_LXC.xml | 328 ++++++++++++++++++++++++++++++++++++++++- conf/zabbix-lxc.conf | 8 + scripts/lxc.handler.pl | 18 +++ 4 files changed, 367 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b547931..377fab1 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,20 @@ through Discovery: * Memory Usage Max. of "{#NAME}" +Memory advanced items: + +* Memory cache + +* Memory swap + +* Memory rss + +* Memory mapped_file + +* Memory pgfault + +* Memory pgmajfault + D. License -- diff --git a/Template_Linux_LXC.xml b/Template_Linux_LXC.xml index ebe7ae1..42d6085 100644 --- a/Template_Linux_LXC.xml +++ b/Template_Linux_LXC.xml @@ -1,7 +1,7 @@ 2.0 - 2014-10-21T11:28:59Z + 2014-10-21T12:36:42Z Templates @@ -55,6 +55,240 @@ 7 + + Memory Usage: cache of "{#NAME}" + 0 + + 0 + + custom.lxc.memory.cache["{#NAME}"] + 120 + 30 + 365 + 0 + 3 + + + 0 + + 0 + + + 1 + + + + 0 + 0 + + + + + + + 0 + + + LXC - Memory + + + + + + Memory Usage: mapped_file of "{#NAME}" + 0 + + 0 + + custom.lxc.memory.mapped_file["{#NAME}"] + 120 + 30 + 365 + 0 + 3 + + + 0 + + 0 + + + 1 + + + + 0 + 0 + + + + + + + 0 + + + LXC - Memory + + + + + + Memory Usage: pgfault of "{#NAME}" + 0 + + 0 + + custom.lxc.memory.pgfault["{#NAME}"] + 120 + 30 + 365 + 0 + 3 + + + 0 + + 0 + + + 1 + + + + 0 + 0 + + + + + + + 0 + + + LXC - Memory + + + + + + Memory Usage: pgmajfault of "{#NAME}" + 0 + + 0 + + custom.lxc.memory.pgmajfault["{#NAME}"] + 120 + 30 + 365 + 0 + 3 + + + 0 + + 0 + + + 1 + + + + 0 + 0 + + + + + + + 0 + + + LXC - Memory + + + + + + Memory Usage: rss of "{#NAME}" + 0 + + 0 + + custom.lxc.memory.rss["{#NAME}"] + 120 + 30 + 365 + 0 + 3 + + + 0 + + 0 + + + 1 + + + + 0 + 0 + + + + + + + 0 + + + LXC - Memory + + + + + + Memory Usage: swap of "{#NAME}" + 0 + + 0 + + custom.lxc.memory.swap["{#NAME}"] + 120 + 30 + 365 + 0 + 3 + + + 0 + + 0 + + + 1 + + + + 0 + 0 + + + + + + + 0 + + + LXC - Memory + + + + CPU acct USAGE - system - "{#NAME}" 0 @@ -311,6 +545,98 @@ + + LXC - Memory Adv. Usage of "{#NAME}" + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 0 + 1 + 0 + 0.0000 + 0.0000 + 1 + 0 + 0 + 0 + + + 0 + 0 + C80000 + 0 + 2 + 0 + + Template_Linux_LXC + custom.lxc.memory.cache["{#NAME}"] + + + + 1 + 0 + 00C800 + 0 + 2 + 0 + + Template_Linux_LXC + custom.lxc.memory.mapped_file["{#NAME}"] + + + + 2 + 0 + 0000C8 + 0 + 2 + 0 + + Template_Linux_LXC + custom.lxc.memory.rss["{#NAME}"] + + + + 3 + 0 + C800C8 + 0 + 2 + 0 + + Template_Linux_LXC + custom.lxc.memory.swap["{#NAME}"] + + + + 4 + 0 + 00C8C8 + 0 + 2 + 0 + + Template_Linux_LXC + custom.lxc.memory.pgfault["{#NAME}"] + + + + 5 + 0 + C8C800 + 0 + 2 + 0 + + Template_Linux_LXC + custom.lxc.memory.pgmajfault["{#NAME}"] + + + + LXC - CPU acct USAGE of "{#NAME}" 900 diff --git a/conf/zabbix-lxc.conf b/conf/zabbix-lxc.conf index 49bf669..c9d258a 100644 --- a/conf/zabbix-lxc.conf +++ b/conf/zabbix-lxc.conf @@ -13,3 +13,11 @@ UserParameter=custom.lxc.cpuacct.user[*],sudo /etc/zabbix/scripts/lxc.handler.pl #MEMORY UserParameter=custom.lxc.memory.usage[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-usage $1 UserParameter=custom.lxc.memory.maxusage[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-max-usage $1 +#MEMORY advanced +UserParameter=custom.lxc.memory.cache[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-cache $1 +UserParameter=custom.lxc.memory.rss[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-rss $1 +UserParameter=custom.lxc.memory.mapped_file[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-mapped_file $1 +UserParameter=custom.lxc.memory.swap[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-swap $1 +UserParameter=custom.lxc.memory.pgfault[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-pgfault $1 +UserParameter=custom.lxc.memory.pgmajfault[*],sudo /etc/zabbix/scripts/lxc.handler.pl MEM-pgmajfault $1 + diff --git a/scripts/lxc.handler.pl b/scripts/lxc.handler.pl index 861edb8..8ce8b1c 100755 --- a/scripts/lxc.handler.pl +++ b/scripts/lxc.handler.pl @@ -60,6 +60,24 @@ sub print_result { elsif($mode eq "MEM-max-usage"){ (`cat /sys/fs/cgroup/lxc/$name/memory.max_usage_in_bytes 2>&1` =~ m/([0-9]+)/) ? print_result("$1") : print_error("ERROR! Wrong results"); } +elsif($mode eq "MEM-cache"){ + (`cat /sys/fs/cgroup/lxc/$name/memory.stat 2>&1` =~ m/cache([[:space:]]*)([0-9]+)/) ? print_result("$2") : print_error("ERROR! Wrong results"); +} +elsif($mode eq "MEM-rss"){ + (`cat /sys/fs/cgroup/lxc/$name/memory.stat 2>&1` =~ m/rss([[:space:]]*)([0-9]+)/) ? print_result("$2") : print_error("ERROR! Wrong results"); +} +elsif($mode eq "MEM-mapped_file"){ + (`cat /sys/fs/cgroup/lxc/$name/memory.stat 2>&1` =~ m/mapped_file([[:space:]]*)([0-9]+)/) ? print_result("$2") : print_error("ERROR! Wrong results"); +} +elsif($mode eq "MEM-swap"){ + (`cat /sys/fs/cgroup/lxc/$name/memory.stat 2>&1` =~ m/swap([[:space:]]*)([0-9]+)/) ? print_result("$2") : print_error("ERROR! Wrong results"); +} +elsif($mode eq "MEM-pgfault"){ + (`cat /sys/fs/cgroup/lxc/$name/memory.stat 2>&1` =~ m/pgfault([[:space:]]*)([0-9]+)/) ? print_result("$2") : print_error("ERROR! Wrong results"); +} +elsif($mode eq "MEM-pgmajfault"){ + (`cat /sys/fs/cgroup/lxc/$name/memory.stat 2>&1` =~ m/pgmajfault([[:space:]]*)([0-9]+)/) ? print_result("$2") : print_error("ERROR! Wrong results"); +} elsif($mode eq "NEXT"){ }