-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_cgattach
More file actions
executable file
·46 lines (35 loc) · 895 Bytes
/
create_cgattach
File metadata and controls
executable file
·46 lines (35 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
#write by shuali
cgarg=$1
tmpfile=$(mktemp)
att_id=$2
echo $cgarg | tr " " "\n" | sort >$tmpfile
error_message()
{
echo $1
exit $2
}
uuid || yum install -y uuid ||apt-get install -y uuid
gro=$(uuid |awk -F '-' '{print $1}')
for i in $(cat $tmpfile)
do
value=${i##*=}
j=${i%%=*}
subsys=${j%%.*}
pro=${j#*.}
cgget -g $subsys / |grep -q "$subsys.$pro:" || error_message "$subsys.$pro is not found in $subsys" 23
done
for i in $(cat $tmpfile)
do
value=${i##*=}
j=${i%%=*}
subsys=${j%%.*}
pro=${j#*.}
#echo subsys=$subsys pro=$pro value=$value
cgcreate -g $subsys:$gro
cgset -r $subsys.$pro=$value /$gro
done
pidlist=`ps -eLf |awk -v pid=$att_id '{if($2==pid){print $4}}'`
arg=$(cat $tmpfile | awk -F '.' '{print $1}'|uniq|awk -v gro="$gro" -F '.' '{print "-g "$1":"gro}')
cgclassify $arg --sticky $att_id $pidlist
rm $tmpfile