From 9035834948df49733aea048350f48390d1c3b036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=88=98=EC=A4=80?= Date: Fri, 20 Oct 2023 10:21:40 +0900 Subject: [PATCH] Frist: init code. --- HWconfig.json | 6 ++++++ config.json | 10 ++++++++++ install.sh | 9 +++++++++ load-test.service | 10 ++++++++++ main.py | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+) create mode 100644 HWconfig.json create mode 100644 config.json create mode 100755 install.sh create mode 100644 load-test.service create mode 100644 main.py diff --git a/HWconfig.json b/HWconfig.json new file mode 100644 index 0000000..4a478a0 --- /dev/null +++ b/HWconfig.json @@ -0,0 +1,6 @@ +{ + "hw": "intel", + "cpu": 12, + "memory": 32, + "gpu": "2080TI" +} diff --git a/config.json b/config.json new file mode 100644 index 0000000..a0fff27 --- /dev/null +++ b/config.json @@ -0,0 +1,10 @@ +{ + "topic": "performance", + "id": "sdt", + "cpu": 2, + "password": "11223344", + "host": { + "address": "192.168.100.200", + "hostname": "sdt" + } +} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..17bb71f --- /dev/null +++ b/install.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +sudo sed -i "s/appName/$1/g" /usr/local/sdt/app/$1/load-test.service +sudo cp /usr/local/sdt/app/$1/load-test.service /etc/systemd/system/$1.service +sudo systemctl start $1 +sudo systemctl enable $1 + diff --git a/load-test.service b/load-test.service new file mode 100644 index 0000000..00f7a9f --- /dev/null +++ b/load-test.service @@ -0,0 +1,10 @@ +[Unit] +Description=awx-perfermance + +[Service] +ExecStart=/usr/bin/python3 /usr/local/sdt/app/appName/main.py -config appName +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/main.py b/main.py new file mode 100644 index 0000000..7a03f8f --- /dev/null +++ b/main.py @@ -0,0 +1,39 @@ +import argparse +from multiprocessing import Pool +from multiprocessing import cpu_count + +import signal + + + + +parser = argparse.ArgumentParser() +parser.add_argument('-config',help='') +args = parser.parse_args() + +with open(f'/usr/local/sdt/app/{args.config}/config.json', encoding='UTF-8') as f: + jsonData = json.load(f) + +stop_loop = 0 + +def exit_chld(x, y): + global stop_loop + stop_loop = 1 + + +def f(x): + global stop_loop + while not stop_loop: + x*x + + +signal.signal(signal.SIGINT, exit_chld) + +if __name__ == '__main__': + processes = jsonData["cpu"] + print('-' * 20) + print('Running load on CPU(s)') + print('Utilizing %d cores' % processes) + print('-' * 20) + pool = Pool(processes) + pool.map(f, range(processes))