Skip to content

Commit 04eb8aa

Browse files
committed
dockerfile
1 parent cd2918f commit 04eb8aa

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

perf_checks/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#############################################
2+
# Install uv
3+
FROM ghcr.io/astral-sh/uv:latest
4+
# Change the working directory to the `app` directory
5+
WORKDIR /app
6+
COPY webscenarios_perfcheck.py .
7+
RUN uv sync --script webscenarios_perfcheck.py
8+
CMD uv run --script webscenarios_perfcheck.py

perf_checks/webscenarios_perfcheck.py

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
# /// script
2-
# requires-python = ">=3.12"
2+
# requires-python = ">=3.13"
33
# dependencies = [
4-
# "itemvalue",
5-
# "os",
6-
# "path",
4+
# "pyyaml",
75
# "requests",
8-
# "sender",
9-
# "shutil",
10-
# "subprocess",
11-
# "tempfile",
12-
# "time",
13-
# "urlencode",
14-
# "yaml",
6+
# "zabbix-utils",
157
# ]
168
# ///
17-
189
import os
1910
import yaml
2011
import time
@@ -23,7 +14,6 @@
2314
import shutil
2415
from pathlib import Path
2516
from urllib.parse import urlencode
26-
import tempfile
2717
from zabbix_utils import Sender, ItemValue
2818

2919
def clone_repository():
@@ -110,19 +100,11 @@ def make_request(url):
110100
# download full content with get
111101
response = requests.get(url, headers=headers, timeout=60, allow_redirects=True)
112102

113-
# create temp files
114-
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
115-
temp_file.write(response.content)
116-
temp_file_path = temp_file.name
117-
118103
end_time = time.time()
119104
response_time = round((end_time - start_time) * 1000, 2)
120105

121106
# get size file
122-
content_size = os.path.getsize(temp_file_path)
123-
124-
# delete tmp file
125-
os.unlink(temp_file_path)
107+
content_size = len(response.content)
126108

127109
return {
128110
'status_code': response.status_code,
@@ -133,8 +115,6 @@ def make_request(url):
133115

134116
# exceltions timeout
135117
except requests.exceptions.Timeout:
136-
if temp_file_path and os.path.exists(temp_file_path):
137-
os.unlink(temp_file_path)
138118
return {
139119
'status_code': 'TIMEOUT',
140120
'response_time_ms': 60000,
@@ -143,8 +123,6 @@ def make_request(url):
143123
}
144124
# exception connection error
145125
except requests.exceptions.ConnectionError:
146-
if temp_file_path and os.path.exists(temp_file_path):
147-
os.unlink(temp_file_path)
148126
return {
149127
'status_code': 'CONNECTION_ERROR',
150128
'response_time_ms': 0,
@@ -153,8 +131,6 @@ def make_request(url):
153131
}
154132
# eception request exception
155133
except requests.exceptions.RequestException as e:
156-
if temp_file_path and os.path.exists(temp_file_path):
157-
os.unlink(temp_file_path)
158134
return {
159135
'status_code': 'REQUEST_ERROR',
160136
'response_time_ms': 0,
@@ -163,8 +139,6 @@ def make_request(url):
163139
'url': url
164140
}
165141
except Exception as e:
166-
if temp_file_path and os.path.exists(temp_file_path):
167-
os.unlink(temp_file_path)
168142
return {
169143
'status_code': 'ERROR',
170144
'response_time_ms': 0,

0 commit comments

Comments
 (0)