Révision 137913e3
lxc_guests: Monitor randomly generated virtual ethernet devices
| plugins/lxc/lxc_guests | ||
|---|---|---|
| 38 | 38 |
lx2 (on Debian buster and Debian jessie, |
| 39 | 39 |
respectively). |
| 40 | 40 |
|
| 41 |
For the network graphs to work, you need |
|
| 42 |
to have in every container's config file |
|
| 43 |
a line defining the virtual network interface |
|
| 44 |
path (else lxc will use a random name at |
|
| 45 |
each container's start); see the lxc_netdev() |
|
| 46 |
function below. |
|
| 47 |
|
|
| 48 | 41 |
If using lxc 2, make sure you do not have cruft |
| 49 | 42 |
in your container config files, you can test |
| 50 | 43 |
it with: |
| ... | ... | |
| 116 | 109 |
} |
| 117 | 110 |
|
| 118 | 111 |
|
| 119 |
lxc_netdev() {
|
|
| 120 |
local guest_name="$1" |
|
| 121 |
|
|
| 122 |
if [ -f "$lxcpath/$guest_name/config" ]; then |
|
| 123 |
# lxc 3 vs < 3 |
|
| 124 |
(grep -E '^lxc.net.0.veth.pair' "$lxcpath/$guest_name/config" 2>/dev/null \ |
|
| 125 |
|| grep -E '^lxc.network.veth.pair' "$lxcpath/$guest_name/config" |
|
| 126 |
) | awk '{print $NF;}'
|
|
| 127 |
fi |
|
| 128 |
} |
|
| 129 |
|
|
| 130 |
|
|
| 131 | 112 |
# find proper sysfs and count it |
| 132 | 113 |
# Debian 6.0: /sys/fs/cgroup/<container>/tasks |
| 133 | 114 |
# Ubuntu 12.04 with fstab: /sys/fs/cgroup/lxc/<container>/tasks |
| ... | ... | |
| 259 | 240 |
|
| 260 | 241 |
for guest_name in $active_guests |
| 261 | 242 |
do |
| 262 |
device=$(lxc_netdev "$guest_name")
|
|
| 243 |
device=$(lxc-info -n "$guest_name" | grep Link | sed 's/Link:\ \+//g')
|
|
| 263 | 244 |
if [ -z "$device" ]; then |
| 264 | 245 |
continue |
| 265 | 246 |
fi |
| ... | ... | |
| 362 | 343 |
echo "multigraph lxc_net" |
| 363 | 344 |
for guest_name in $active_guests |
| 364 | 345 |
do |
| 365 |
device=$(lxc_netdev "$guest_name")
|
|
| 346 |
device=$(lxc-info -n "$guest_name" | grep Link | sed 's/Link:\ \+//g')
|
|
| 366 | 347 |
if [ -z "$device" ]; then |
| 367 | 348 |
value_up="U" |
| 368 | 349 |
value_down="U" |
Formats disponibles : Unified diff