hpcpack-linux-agent/nodemanager/scripts/Statistics.sh

67 строки
1.3 KiB
Bash
Исходник Постоянная ссылка Обычный вид История

2015-05-05 10:35:29 +03:00
#!/bin/bash
# collect the statistics of the cgroup
. common.sh
[ -z "$1" ] && echo "task id not specified" && exit 202
2017-08-03 11:27:32 +03:00
[ -z "$2" ] && echo "task folder not specified" && exit 202
2015-05-05 10:35:29 +03:00
taskId=$1
2017-07-21 19:34:42 +03:00
taskFolder=$2
2017-08-03 11:27:32 +03:00
isDockerTask=$(CheckDockerEnvFileExist $taskFolder)
2017-07-21 19:34:42 +03:00
2015-05-05 10:35:29 +03:00
userTime10Ms=0
kernelTime10Ms=0
processes=""
workingSetBytes=0
function GetCpuStatFile
{
local groupName=$1
2015-07-15 10:59:01 +03:00
GetGroupFile "$groupName" cpuacct cpuacct.stat
2015-05-05 10:35:29 +03:00
}
function GetCpuacctTasksFile
{
local groupName=$1
2015-07-23 14:05:09 +03:00
GetGroupFile "$groupName" cpuacct tasks
2015-05-05 10:35:29 +03:00
}
function GetMemoryMaxusageFile
{
local groupName=$1
2015-07-23 14:05:09 +03:00
GetGroupFile "$groupName" memory memory.max_usage_in_bytes
2015-05-05 10:35:29 +03:00
}
if $CGInstalled; then
2017-07-21 19:34:42 +03:00
if [ "$isDockerTask" == "1" ]; then
2017-08-03 11:27:32 +03:00
containerId=$(GetContainerId $taskFolder)
groupName=$(GetCGroupNameOfDockerTask $containerId)
2017-07-21 19:34:42 +03:00
else
groupName=$(GetCGroupName "$taskId")
fi
2015-07-15 10:59:01 +03:00
statFile=$(GetCpuStatFile "$groupName")
tasksFile=$(GetCpuacctTasksFile "$groupName")
workingSetFile=$(GetMemoryMaxusageFile "$groupName")
cut -d" " -f2 "$statFile"
cat "$workingSetFile"
2017-07-21 19:34:42 +03:00
if [ "$isDockerTask" == "1" ]; then
containerPlaceholder=$(GetContainerPlaceholder $taskFolder)
cat $tasksFile | sed "/^$(cat $containerPlaceholder)$/d" | tr "\\n" " "
else
tr "\\n" " " < "$tasksFile"
fi
2015-05-05 10:35:29 +03:00
echo
else
echo $userTime10Ms
echo $kernelTime10Ms
echo $workingSetBytes
echo $processes
echo
fi