mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Docker Plugin
Ignore containers in weird state.
This commit is contained in:
parent
ae03bc6fb8
commit
0a5f6adf2c
2 changed files with 18 additions and 12 deletions
|
@ -66,14 +66,18 @@ for my $i (1 .. $#containers)
|
||||||
$name =~ s/[-\+*\/\.]/_/g;
|
$name =~ s/[-\+*\/\.]/_/g;
|
||||||
# truncate container name with "," character.
|
# truncate container name with "," character.
|
||||||
$name =~ s/,.*//g;
|
$name =~ s/,.*//g;
|
||||||
open(my $file, '<', "/sys/fs/cgroup/cpuacct/docker/$id/cpuacct.usage") or die "Unable to open file, $!";
|
if (open(my $file, '<', "/sys/fs/cgroup/cpuacct/docker/$id/cpuacct.usage"))
|
||||||
my $total_cpu_ns = <$file>;
|
{
|
||||||
$total_cpu_ns =~ s/\s+$//;
|
my $total_cpu_ns = <$file>;
|
||||||
close $file;
|
$total_cpu_ns =~ s/\s+$//;
|
||||||
open($file, '<', "/sys/fs/cgroup/cpuacct/docker/$id/cpuacct.usage_percpu") or die "Unable to open file, $!";
|
close $file;
|
||||||
my @ncpu = split / /, <$file>;
|
if (open($file, '<', "/sys/fs/cgroup/cpuacct/docker/$id/cpuacct.usage_percpu"))
|
||||||
close $file;
|
{
|
||||||
push @result, {'name'=>$name, 'total_cpu_ns'=>$total_cpu_ns, 'ncpu'=>$#ncpu};
|
my @ncpu = split / /, <$file>;
|
||||||
|
close $file;
|
||||||
|
push @result, {'name'=>$name, 'total_cpu_ns'=>$total_cpu_ns, 'ncpu'=>$#ncpu};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||||
|
|
|
@ -66,10 +66,12 @@ for my $i (1 .. $#containers)
|
||||||
$name =~ s/[-\+*\/\.]/_/g;
|
$name =~ s/[-\+*\/\.]/_/g;
|
||||||
# truncate container name with "," character.
|
# truncate container name with "," character.
|
||||||
$name =~ s/,.*//g;
|
$name =~ s/,.*//g;
|
||||||
open(my $file, '<', "/sys/fs/cgroup/memory/docker/$id/memory.usage_in_bytes") or die "Unable to open file, $!";
|
if (open(my $file, '<', "/sys/fs/cgroup/memory/docker/$id/memory.usage_in_bytes"))
|
||||||
my $memory_bytes = <$file>;
|
{
|
||||||
$memory_bytes =~ s/\s+$//;
|
my $memory_bytes = <$file>;
|
||||||
push @result, {'name'=>$name, 'memory_bytes'=>$memory_bytes};
|
$memory_bytes =~ s/\s+$//;
|
||||||
|
push @result, {'name'=>$name, 'memory_bytes'=>$memory_bytes};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue