-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/measure ram cpu #1
base: develop
Are you sure you want to change the base?
Changes from all commits
3e19eb3
d68e498
281890f
0bd5e7a
58f7051
f53dbb0
ffd93f5
f4e6511
6475816
1256c78
46ea684
7be57c4
87d0a3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM ubuntu:18.04 | ||
|
||
ENV TZ=Europe/Minsk | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
|
||
RUN apt-get update && apt-get -q -y install locales sudo | ||
|
||
RUN apt-get update && apt-get -q -y install libssl1.0.0 libusb-1.0-0 libbluetooth3 \ | ||
libssl-doc- libusb-1.0-doc- manpages- manpages-dev- | ||
|
||
RUN apt-get update && apt-get -q -y install openssl liblua5.2-0 psmisc \ | ||
autotools-dev- binutils- build-essential- bzip2- cpp- cpp-5- dpkg-dev- fakeroot- \ | ||
manpages- manpages-dev- | ||
|
||
RUN apt-get update && apt-get -q -y install sqlite3 libqt5websockets5 net-tools iproute2 \ | ||
qttranslations5-l10n- xdg-user-dirs- xml-core- dbus- | ||
|
||
RUN apt-get update && apt install -y netcat cpipe gnuplot sysstat python3-pip docker.io | ||
RUN apt-get update && apt install -y python3-numpy python3-scipy python3-matplotlib | ||
|
||
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 | ||
|
||
ENV LC_ALL en_US.UTF-8 | ||
|
||
RUN chmod u+s /sbin/ifconfig /sbin/ip && mkdir /home/developer | ||
|
||
COPY entrypoint.sh /usr/bin/ | ||
|
||
ENTRYPOINT ["/bin/bash", "-e", "/usr/bin/entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker build . -t remote_atf_server | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Add local user | ||
# Either use the LOCAL_USER_ID if passed in at runtime or | ||
# fallback | ||
|
||
USER_ID=${LOCAL_USER_ID:-9001} | ||
|
||
useradd --shell /bin/bash -u $USER_ID -o -c "" developer | ||
usermod -aG docker developer | ||
sudo chmod 666 /var/run/docker.sock | ||
echo "developer ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
chown developer /home/developer | ||
chgrp developer /home/developer | ||
|
||
export HOME=/home/developer | ||
export LANG=en_US.UTF-8 | ||
|
||
echo "Remote adapter server available by following ip adresses : " | ||
ip addr | grep -E "inet " | tr -s " " | cut -d ' ' -f 3| cut -d '/' -f 1 | ||
|
||
echo " ls /home/developer " | ||
ls /home/developer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LuxoftAKutsan What is purpose to display this list of files on start? |
||
|
||
echo "SDL bin dir : /home/developer/sdlbin"; ls -la /home/developer/sdlbin | ||
echo "ATF bin dir : /home/developer/atfbin"; ls -la /home/developer/atfbin | ||
echo "Third party /home/developer/thirdparty"; ls -la /home/developer/thirdparty | ||
|
||
cd /home/developer/atfbin/RemoteTestingAdapterServer | ||
|
||
echo "Third party contents" | ||
LIB="/home/developer/thirdparty/lib/" | ||
LIB64="/home/developer/thirdparty/x86_64/lib/" | ||
|
||
sudo LD_LIBRARY_PATH="$LIB:$LIB64:." -u developer "./RemoteTestingAdapterServer" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
PATH_TO_SDLBIN=$1 | ||
PATH_TO_ATFBIN=$2 | ||
PATH_TO_THIRDPARTY=$3 | ||
|
||
if [ -z "$PATH_TO_SDLBIN" ]; then | ||
echo "Path to SDL binaries is not defined as 1st argument" | ||
exit 1; | ||
fi | ||
|
||
if [ -z "$PATH_TO_ATFBIN" ]; then | ||
echo "Path to ATF binaries is not defined as 2nd argument" | ||
exit 1; | ||
fi | ||
|
||
if [ -z "$PATH_TO_THIRDPARTY" ]; then | ||
echo "Path to 3rd party libraries is not defined as 3rd argument" | ||
exit 1; | ||
fi | ||
|
||
CONTAINER_NAME=remote_sdl | ||
IMAGE_NAME=remote_atf_server | ||
MEMORY_CONSTRAINS=4G | ||
CPUS=2 | ||
docker rm $CONTAINER_NAME | ||
|
||
echo $1 $2 $3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LuxoftAKutsan I would propose to add some description to these variables or do not display them at all. |
||
docker run -e LOCAL_USER_ID=$UID \ | ||
-e CONTAINER_NAME=$CONTAINER_NAME\ | ||
-e LOCAL_USER_ID=$(id -u)\ | ||
--net=host\ | ||
--name=$CONTAINER_NAME\ | ||
-v /var/run/docker.sock:/var/run/docker.sock\ | ||
-v $PATH_TO_SDLBIN:/home/developer/sdlbin\ | ||
-v $PATH_TO_ATFBIN:/home/developer/atfbin\ | ||
-v $PATH_TO_THIRDPARTY:/home/developer/thirdparty\ | ||
-m=$MEMORY_CONSTRAINS\ | ||
-it $IMAGE_NAME |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,11 @@ class UtilsManager : public remote_adapter::UtilsPlugin { | |
static std::pair<std::string, int> | ||
ExecuteCommand(const std::string &bash_command); | ||
|
||
static | ||
std::pair<std::string, int> | ||
ExecuteCommandBg(const std::string &bash_command); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LuxoftAKutsan Please remove the redundant empty line. |
||
private: | ||
static std::vector<int> GetAppPids(const std::string &app_name); | ||
static std::string GetAppStatus(int pid, int *num_threads = 0); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
# apt-get install sysstat linux-tools-common | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LuxoftAKutsan Could this commented instruction be removed from the script? |
||
|
||
SDL_PID=$(pidof smartDeviceLinkCore) | ||
REMOTE=false | ||
OUTPUT_DIR="measure"/$1 | ||
OUTPUT_PIDSTAT_FILE=$OUTPUT_DIR/pidstat.log | ||
OUTPUT_PS_FILE=$OUTPUT_DIR/ps.log | ||
OUTPUT_DOCKER_FILE=$OUTPUT_DIR/docker.log | ||
CONTAINTER_NAME=$(docker inspect --format='{{.Name}}' $HOSTNAME | cut -c2-) | ||
|
||
STEP=1 | ||
|
||
if [ -n $2 ] && [ "$2" = "--remote" ]; then REMOTE=true; fi | ||
|
||
rm -rf $OUTPUT_DIR | ||
mkdir -p $OUTPUT_DIR | ||
pwd | ||
echo $OUTPUT_DIR | ||
function ps_formated() { | ||
ps --no-headers --format "start %cpu cp cputime %mem sz thcount " -p $SDL_PID | ||
} | ||
|
||
function measure_ps() { | ||
PS_OUTPUT=$(ps_formated) | ||
TIME=$(date +'%T:%N') | ||
echo $TIME $PS_OUTPUT >> $OUTPUT_PS_FILE | ||
} | ||
|
||
function measure_pid_stat() { | ||
export S_TIME_FORMAT=ISO | ||
STAT_OUTPUT=$(pidstat -urdlv -h -p $SDL_PID | grep $SDL_PID) | ||
echo $STAT_OUTPUT >> $OUTPUT_PIDSTAT_FILE | ||
} | ||
|
||
function measure_docker() { | ||
RECORD=$(docker stats --format "{{.Name}} {{.CPUPerc}} {{.MemUsage}} {{.PIDs}}" --no-stream | grep $CONTAINTER_NAME) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LuxoftAKutsan This line too long and contains redundant whitespaces. Could it be fixed? |
||
echo $RECORD | ||
TIME=$(date +'%T:%N') | ||
echo $TIME $RECORD >> $OUTPUT_DOCKER_FILE | ||
} | ||
|
||
echo "Wait for SDL start" | ||
until SDL_PID=$(pidof smartDeviceLinkCore) | ||
do | ||
sleep $STEP | ||
printf "." | ||
done | ||
|
||
while SDL_PID=$(pidof smartDeviceLinkCore) | ||
do | ||
measure_pid_stat | ||
measure_ps | ||
if [ $REMOTE = true ]; then measure_docker; fi | ||
sleep $STEP | ||
done | ||
|
||
PARAMS="--pidstat_file=$OUTPUT_PIDSTAT_FILE --ps_file=$OUTPUT_PS_FILE --output_dir=$OUTPUT_DIR --title=$1" | ||
if [ $REMOTE = true ]; then PARAMS="$PARAMS --docker_file=$OUTPUT_DOCKER_FILE"; fi | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
python3 $DIR/sdl_graphs.py $PARAMS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LuxoftAKutsan I would propose to add next line to script