mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Merge pull request #1365 from ap-wtioit/master-fix_docker_memory_github
docker_memory: add total memory used
This commit is contained in:
commit
541c7d76b0
2 changed files with 12 additions and 1 deletions
|
@ -55,6 +55,7 @@ $docker =~ s/\s+$//;
|
|||
|
||||
my @containers = split "\n" , `$docker ps --no-trunc=true`;
|
||||
my $result;
|
||||
my $total = 0;
|
||||
|
||||
for my $i (1 .. $#containers)
|
||||
{
|
||||
|
@ -82,6 +83,7 @@ for my $i (1 .. $#containers)
|
|||
my $memory_bytes = <$file>;
|
||||
$memory_bytes =~ s/\s+$//;
|
||||
push @result, {'name'=>$name, 'memory_bytes'=>$memory_bytes};
|
||||
$total = $total + $memory_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,11 +95,19 @@ if (defined $ARGV[0] and $ARGV[0] eq "config")
|
|||
print "graph_category virtualization\n";
|
||||
print "graph_info This graph shows docker container memory usage.\n";
|
||||
|
||||
my $first = 1;
|
||||
foreach(@result)
|
||||
{
|
||||
print "$$_{'name'}.label $$_{'name'}\n";
|
||||
print "$$_{'name'}.draw LINE2\n";
|
||||
if ($first) {
|
||||
print "$$_{'name'}.draw AREA\n";
|
||||
$first = 0
|
||||
} else {
|
||||
print "$$_{'name'}.draw STACK\n";
|
||||
}
|
||||
}
|
||||
print "total.label Total Memory\n";
|
||||
print "total.draw LINE2\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
@ -105,5 +115,6 @@ foreach(@result)
|
|||
{
|
||||
print "$$_{'name'}.value $$_{'memory_bytes'}\n";
|
||||
}
|
||||
print "total.value $total\n";
|
||||
|
||||
# vim:syntax=perl
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 29 KiB |
Loading…
Add table
Add a link
Reference in a new issue