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-
189import os
1910import yaml
2011import time
2314import shutil
2415from pathlib import Path
2516from urllib .parse import urlencode
26- import tempfile
2717from zabbix_utils import Sender , ItemValue
2818
2919def 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