Projet

Général

Profil

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

root / plugins / virtualization / vserver / vserver_jiffies @ e5ce7492

Historique | Voir | Annoter | Télécharger (2,26 ko)

1
#!/bin/bash
2
#
3
# Created by Jan Rękorajski <baggins@pld-linux.org> based on vserver_cpu_ plugin.
4
#
5
# Graph Vserver cumulative cpu usage stats
6
#
7
# Configuration variables
8
#   vservers - specify the vservers to include in the graph (default: all)
9
#
10
# NOTE: If no configuration variable is set, the default will be used
11
#
12
# see vserver_resources for example uses of configuration files
13

    
14
VSERVERS="$vservers"
15

    
16
INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo '<none>'`)
17
KCIN="$[ 16#${INFO[2]} ]";
18

    
19
# If this is 1, then VCI_SPACES is present in the kernel (new in 2.6.19)
20
if [ $[ (KCIN >> 10) & 1 ] -eq 1 ]
21
then 
22
    NAMELOC="nsproxy"
23
else 
24
    NAMELOC="cvirt"
25
fi
26

    
27
if [ -z "$VSERVERS" ] ; then
28
    XIDS=`find /proc/virtual/* -type d -exec basename {} \;`
29
else
30
    # it's really more performant to specify vservers by ids or by linking but not in the configuration-file by name
31
    XIDS=""
32
    for i in $VSERVERS ; do
33
	if [ -d /proc/virtual/$i ] ; then
34
	    XIDS="${XIDS}${i} "
35
	else
36
	    for j in `find /proc/virtual/* -type d -exec basename {} \;` ; do
37
		if [ "$i" = "`cat /proc/virtual/$j/$NAMELOC |grep NodeName |cut -f2`" ] ; then
38
		    XIDS="${XIDS}${j} "
39
		fi
40
	    done
41
	fi
42
    done
43
fi
44

    
45
if [ "$1" = "config" ]; then
46
	echo 'graph_category vserver'
47
	echo 'graph_args --base 1000'
48
	echo 'graph_title Vserver cpu usage'
49
	echo 'graph_vlabel jiffies used per ${graph_period}'
50
	echo 'graph_info Shows jiffies used on each vserver.'
51

    
52
	for i in $XIDS ; do 
53
		LABEL=`grep NodeName /proc/virtual/$i/$NAMELOC | cut -f2`
54
		NAME=`echo $LABEL | tr '-' '_'`
55
		echo "${NAME}_hold.label on hold for cpu on $LABEL"
56
		echo "${NAME}_hold.info on hold for cpu on $LABEL."
57
		echo "${NAME}_hold.type COUNTER"
58
		echo "${NAME}_scpu.label system cpu usage for $LABEL"
59
		echo "${NAME}_scpu.info system cpu usage for $LABEL."
60
		echo "${NAME}_scpu.type COUNTER"
61
		echo "${NAME}_ucpu.label user cpu usage for $LABEL"
62
		echo "${NAME}_ucpu.info user cpu usage for $LABEL."
63
		echo "${NAME}_ucpu.type COUNTER"
64
	done
65
	exit 0
66
fi
67

    
68
for i in $XIDS ; do
69
	NAME=`grep NodeName /proc/virtual/$i/$NAMELOC | cut -f2 | tr '-' '_'`
70
	awk -v name=$NAME -v u=0 -v s=0 -v h=0 '
71
		/^cpu [0-9]+:/ { u+=$3; s+=$4; h+=$5}
72
		END {
73
			print name "_hold.value " h
74
			print name "_scpu.value " s
75
			print name "_ucpu.value " u
76
		}' /proc/virtual/$i/sched
77
done