Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / lxc / lxc_cpu_time @ 17f78427

Historique | Voir | Annoter | Télécharger (1,27 ko)

1
#!/bin/bash
2
# -*- sh -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
lxc_cpu_time - Plugin to monitor LXC CPU time usage
9

    
10
=head1 CONFIGURATION
11

    
12
  [lxc_*]
13
    user root
14

    
15
=head1 INTERPRETATION
16

    
17
This plugin needs root privilege.
18

    
19
=head1 AUTHOR
20

    
21
vajtsz vajtsz@gmail.com
22
mitty   mitty@mitty.jp
23

    
24
=head1 LICENSE
25

    
26
Unknown license
27

    
28
=head1 MAGIC MARKERS
29

    
30
 #%# family=auto
31
 #%# capabilities=autoconf
32

    
33
=cut
34

    
35
. $MUNIN_LIBDIR/plugins/plugin.sh
36

    
37
guest_names=`lxc-ls | sort -u`
38
for guest in $guest_names; do
39
 if lxc-info -n $guest 2>&1 | grep -qs RUNNING ; then
40
  active="$active $guest"
41
 fi
42
done
43
guest_names="$active"
44

    
45

    
46
f_comm='lxc-cgroup  '
47

    
48
if [ "$1" = "autoconf" ]; then
49
	if [ -r /proc/stat ]; then
50
		echo yes
51
		exit 0
52
	else
53
		echo "no (no /proc/stat)"
54
		exit 0
55
	fi
56
fi
57

    
58
if [ "$1" = "config" ]; then
59

    
60
 echo 'graph_title CPU time '
61
 echo 'graph_args -l 0 --base 1000'
62
 echo 'graph_vlabel nanosec'
63
 echo 'graph_category cpu'
64

    
65
 for guest_name in $guest_names;
66
  do
67
   guest="$(clean_fieldname $guest_name)"
68
   echo 'cpu_time_'$guest'.label '$guest_name': CPU time'
69
   echo 'cpu_time_'$guest'.type DERIVE'
70
   echo 'cpu_time_'$guest'.min 0'
71
  done
72
 exit 0
73
fi
74

    
75
 for guest_name in $guest_names;
76
  do
77
   guest="$(clean_fieldname $guest_name)"
78
   tmp_g=`$f_comm -n $guest_name cpuacct.usage `
79
   echo 'cpu_time_'$guest'.value '$tmp_g
80
  done
81