Révision 0853d409
docker_cpu: fix data for container names starting with numbers
| plugins/docker/docker_cpu | ||
|---|---|---|
| 62 | 62 |
my @fields = split / +/, $containers[$i]; |
| 63 | 63 |
my $id = $fields[0]; |
| 64 | 64 |
my $name = $fields[$#fields]; |
| 65 |
my $label = $name; |
|
| 65 | 66 |
# manage container name containing arithmetic operators and dots. E.g, my-container. |
| 66 | 67 |
$name =~ s/[-\+*\/\.]/_/g; |
| 67 | 68 |
# truncate container name with "," character. |
| 68 | 69 |
$name =~ s/,.*//g; |
| 70 |
# prefix if container starts with 0-9 |
|
| 71 |
$name =~ s/^([0-9])/c$1/; |
|
| 69 | 72 |
if (open(my $file, '<', "/sys/fs/cgroup/cpuacct/docker/$id/cpuacct.usage")) |
| 70 | 73 |
{
|
| 71 | 74 |
my $total_cpu_ns = <$file>; |
| ... | ... | |
| 75 | 78 |
{
|
| 76 | 79 |
my @ncpu = split / /, <$file>; |
| 77 | 80 |
close $file; |
| 78 |
push @result, {'name'=>$name, 'total_cpu_ns'=>$total_cpu_ns, 'ncpu'=>$#ncpu};
|
|
| 81 |
push @result, {'name'=>$name, 'label'=>$label, 'total_cpu_ns'=>$total_cpu_ns, 'ncpu'=>$#ncpu};
|
|
| 79 | 82 |
} |
| 80 | 83 |
} |
| 81 | 84 |
} |
| ... | ... | |
| 100 | 103 |
|
| 101 | 104 |
foreach(@result) |
| 102 | 105 |
{
|
| 103 |
print "$$_{'name'}.label $$_{'name'}\n";
|
|
| 106 |
print "$$_{'name'}.label $$_{'label'}\n";
|
|
| 104 | 107 |
print "$$_{'name'}.draw LINE2\n";
|
| 105 | 108 |
print "$$_{'name'}.min 0\n";
|
| 106 | 109 |
print "$$_{'name'}.type DERIVE\n";
|
Formats disponibles : Unified diff