{"id":347515,"date":"2023-05-16T09:02:22","date_gmt":"2023-05-16T09:02:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347515"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347515","title":{"rendered":"<span>\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0412\u041f\u041d \u0447\u0430\u0441\u0442\u044c 3. \u041a\u0430\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0440\u0435\u043c\u044f \u0442\u044b\u0441\u044f\u0447\u0430\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e8\/2bc\/162\/2e82bc1620ebceb0ceb466cdeda3aaad.png\" alt=\"\u0432\u0430\u0443!\" title=\"\u0432\u0430\u0443!\" width=\"800\" height=\"500\"><\/p>\n<div><figcaption>\u0432\u0430\u0443!<\/figcaption><\/div>\n<\/figure>\n<h4>\u0425\u0430\u0431\u0440\u0430\u044d\u0444\u0444\u0435\u043a\u0442 \u0438\u043b\u0438 \u043a\u0430\u043a \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0441 \u0443\u043c\u043e\u043c- \u0447\u0442\u043e \u0431\u044b \u0434\u0435\u043d\u044c\u0433\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435<\/h4>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0440\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e, \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 VPN \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445. \u041c\u043d\u043e\u0433\u0438\u0435 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b\u0438 \u043a\u0430\u043a \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0436\u0438\u0442\u044c \u0438 \u043a\u0442\u043e \u0437\u0430 \u044d\u0442\u043e \u043f\u043b\u0430\u0442\u0438\u0442. \u0412\u044b\u0448\u043b\u043e \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043f\u043b\u0430\u0442\u0430 \u043e\u0434\u043d\u043e\u0433\u043e VPS \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c 250 \u0440\u0443\u0431\u043b\u0435\u0439 \u0432 \u043c\u0435\u0441\u044f\u0446, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u043d\u0430 75 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0438 \u0442\u0430\u043a\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043c\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0439. \u0418 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u043d\u0430 \u043d\u0430\u0448 \u043a\u0430\u043d\u0430\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u0435\u0435 1000 \u0447\u0435\u043b\u043e\u0432\u0435\u043a &#8212; \u0430 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0439 \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 8 \u0442\u044b\u0441\u044f\u0447 \u0440\u0443\u0431\u043b\u0435\u0439 \u0437\u0430 \u0441\u0443\u0442\u043a\u0438.<\/p>\n<p> \u0418\u0442\u043e\u0433 &#8212; \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043a\u043e\u043b\u043e 3 \u0442\u044b\u0441\u044f\u0447 \u0447\u0435\u043b\u043e\u0432\u0435\u043a &#8212; \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u0432 10 \u0442\u044b\u0441\u044f\u0447 \u0440\u0443\u0431\u043b\u0435\u0439 &#8212; \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30 \u0434\u043d\u0435\u0439 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 16 \u0442\u044b\u0441\u044f\u0447 \u0440\u0443\u0431\u043b\u0435\u0439 \u0447\u0442\u043e \u043f\u043e\u043a\u0440\u044b\u043b\u043e \u0441 \u0433\u043e\u0440\u043a\u043e\u0439 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u043c\u0435\u0441\u044f\u0446 &#8212; \u043c\u0430\u0439 &#8212; \u0438 \u0434\u0430\u0436\u0435 \u0447\u0430\u0441\u0442\u044c \u0438\u044e\u043d\u044f!<\/p>\n<p><strong>\u0412&nbsp;\u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c&nbsp;\u2014 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/strong><\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0435\u043c \u0430\u0434\u043c\u0438\u043d\u0430<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u043e\u043d VDS<\/p>\n<\/li>\n<\/ol>\n<h4>TimeWeb API \u0438\u043b\u0438 \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c<\/h4>\n<p>\u0414\u043b\u044f&nbsp;\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e&nbsp;\u0431\u044b \u043f\u0440\u0438&nbsp;\u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0432\u044b\u0441\u043a\u043e\u0432\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043e\u043d\u043b\u0430\u0439\u043d \u0432&nbsp;\u0442\u0435\u0447\u0435\u043d\u0438\u0438 3\u20134&nbsp;\u0447\u0430\u0441\u043e\u0432, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0430\u0440\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 VDS \u0434\u0435\u043b\u0430\u044f \u0438\u0437&nbsp;\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043a\u043b\u043e\u043d.<\/p>\n<p>\u0414\u043b\u044f&nbsp;\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441\u0435\u0439\u0447\u0430\u0441 \u0432&nbsp;\u0441\u0435\u0442\u0438.<\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c subprocess, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432&nbsp;\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0438\u0437&nbsp;Python\u2011\u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<p>2. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>wg show<\/code> \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>subprocess.run()<\/code>, \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044f \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>capture_output=True<\/code> \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u044f \u0435\u0433\u043e \u0432&nbsp;\u0441\u0442\u0440\u043e\u043a\u0443 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>text=True<\/code>.<\/p>\n<p>3. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0415\u0441\u043b\u0438 \u043e\u043d \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430&nbsp;\u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434. \u0415\u0441\u043b\u0438 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043d\u0435&nbsp;\u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0438 \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431&nbsp;\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<p>4. \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434 \u043d\u0430&nbsp;\u0441\u0442\u0440\u043e\u043a\u0438 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>split('\\n')<\/code>.<\/p>\n<p>5. \u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0432&nbsp;\u0432\u044b\u0432\u043e\u0434\u0435 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432), \u0432\u044b\u0447\u0438\u0442\u0430\u044f 1&nbsp;\u0434\u043b\u044f&nbsp;\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>6. \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432&nbsp;\u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>print()<\/code>. <\/p>\n<pre><code class=\"python\">import subprocess  result = subprocess.run(['wg', 'show'], capture_output=True, text=True)  if result.returncode == 0:     output = result.stdout.strip().split('\\n')     clients = len(output) - 1  # subtract 1 for the header line     print(f\"Number of connected clients: {clients}\") else:     print(\"Error:\", result.stderr) <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0447\u0442\u043e&nbsp;\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0442\u0441\u043e\u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0437\u0430 12&nbsp;\u0447\u0430\u0441\u043e\u0432 \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435&nbsp;\u2014 \u0430\u0440\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u043e\u043d vds \u0438\u043b\u0438&nbsp;\u043d\u0435\u0442.<\/p>\n<p>1. \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <code>avg_clients<\/code>, <code>count<\/code> \u0438 <code>max_count<\/code>. <code>avg_clients<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f&nbsp;\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, <code>count<\/code>&nbsp;\u2014 \u0434\u043b\u044f&nbsp;\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0430 <code>max_count<\/code>&nbsp;\u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c.<\/p>\n<p>2. \u041c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b <code>while count &lt; max_count<\/code>, \u0432&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c <code>count<\/code>.<\/p>\n<p>3. \u041c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>wg show<\/code>, \u043a\u0430\u043a&nbsp;\u0438 \u0432&nbsp;\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435, \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434.<\/p>\n<p>4. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043a <code>avg_clients<\/code> \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c <code>count<\/code> \u043d\u0430 1.<\/p>\n<p>5. \u041c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0436\u0434\u0435\u043c 10&nbsp;\u043c\u0438\u043d\u0443\u0442 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>time.sleep(600)<\/code>.<\/p>\n<p>6. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0432 <code>avg_clients<\/code> \u043d\u0430 <code>count<\/code>.<\/p>\n<p>7. \u0415\u0441\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438&nbsp;\u0440\u0430\u0432\u043d\u043e 75, \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u00abServer is overloaded\u00bb, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u00abServer is running fine\u00bb.<\/p>\n<p><em>\u041a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 Wireguard \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0435\u0433\u043e \u0432&nbsp;\u0442\u0435\u0447\u0435\u043d\u0438\u0435 12&nbsp;\u0447\u0430\u0441\u043e\u0432: <\/em>  <\/p>\n<pre><code class=\"python\">import subprocess import time  avg_clients = 0 count = 0 max_count = 72  # 12 hours with a check every 10 minutes  while count &lt; max_count:     result = subprocess.run(['wg', 'show'], capture_output=True, text=True)      if result.returncode == 0:         output = result.stdout.strip().split('\\n')         clients = len(output) - 1  # subtract 1 for the header line         avg_clients += clients         count += 1         print(f\"Number of connected clients: {clients}\")         time.sleep(600)  # wait for 10 minutes     else:         print(\"Error:\", result.stderr)  avg_clients \/\/= count  if avg_clients &gt;= 75:     print(\"Server is overloaded\") else:     print(\"Server is running fine\") <\/code><\/pre>\n<p><em>\u041a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 Wireguard \u0432&nbsp;\u0442\u0435\u0447\u0435\u043d\u0438\u0435 12&nbsp;\u0447\u0430\u0441\u043e\u0432 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442&nbsp;\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 75:<\/em>  <\/p>\n<pre><code class=\"python\">python import subprocess import time  clients = []  for i in range(0, 144):  # 12 hours * 12 updates per hour = 144 updates     result = subprocess.run(['wg', 'show'], capture_output=True, text=True)      if result.returncode == 0:         output = result.stdout.strip().split('\\n')         clients.append(len(output) - 1)  # subtract 1 for the header line     else:         print(\"Error:\", result.stderr)         clients.append(0)  # add 0 to the list to maintain the length      time.sleep(300)  # wait 5 minutes between updates  average_clients = sum(clients) \/ len(clients)  if average_clients &gt; 75:     print(\"Server is overloaded\") else:     print(f\"Number of connected clients: {clients[-1]}\") ```<\/code><\/pre>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a <code>clients<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u0446\u0438\u043a\u043b\u0430.<\/p>\n<p>2. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0446\u0438\u043a\u043b <code>for<\/code> \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f 144 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 (12 \u0447\u0430\u0441\u043e\u0432 * 12 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u0447\u0430\u0441).<\/p>\n<p>3. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>wg show<\/code> \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0443.<\/p>\n<p>4. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>clients<\/code>.<\/p>\n<p>5. \u0415\u0441\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c 0 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>clients<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>6. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>time.sleep()<\/code> \u0434\u043b\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f 5 \u043c\u0438\u043d\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>7. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 <code>clients<\/code>.<\/p>\n<p>8. \u0415\u0441\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 75, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &#171;Server is overloaded&#187;.<\/p>\n<p>9. \u0418\u043d\u0430\u0447\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 <code>clients<\/code> \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>print()<\/code>.  <\/p>\n<p><strong>\u0412\u0441\u0435 \u0442\u0430\u043a\u0438 \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043e\u0432\u0440\u0430\u043b, \u043d\u0435&nbsp;\u0432\u0441\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u043c\u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432&nbsp;\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c, \u0447\u0442\u043e&nbsp;\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d, \u0438 \u0443\u0436\u0435 \u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0440\u0435\u0448\u0430\u0435\u0442, \u0445\u0432\u0430\u0442\u0438\u0442&nbsp;\u043b\u0438 \u043d\u0430\u043c \u0434\u0435\u043d\u0435\u0433 \u043d\u0430&nbsp;\u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043b\u0438&nbsp;\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0430\u0447\u0443 \u043a\u043b\u044e\u0447\u0435\u0439 \u043a&nbsp;WG.<\/p>\n<p><\/strong>\u0414\u043b\u044f&nbsp;\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>python-telegram-bot<\/code>. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441&nbsp;\u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d. \u0414\u043b\u044f&nbsp;\u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a&nbsp;BotFather \u0432&nbsp;Telegram \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c: <\/p>\n<pre><code class=\"python\">import telegram  bot_token = 'YOUR_BOT_TOKEN_HERE' chat_id = 'YOUR_CHAT_ID_HERE'  bot = telegram.Bot(token=bot_token) message = \"Server is overloaded\" bot.send_message(chat_id=chat_id, text=message) <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441&nbsp;\u043a\u043e\u0434\u043e\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c, \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d: <\/p>\n<pre><code class=\"python\">import subprocess import time import telegram  bot_token = 'YOUR_BOT_TOKEN_HERE' chat_id = 'YOUR_CHAT_ID_HERE'  clients = []  for i in range(0, 144):  # 12 hours * 12 updates per hour = 144 updates     result = subprocess.run(['wg', 'show'], capture_output=True, text=True)      if result.returncode == 0:         output = result.stdout.strip().split('\\n')         clients.append(len(output) - 1)  # subtract 1 for the header line     else:         print(\"Error:\", result.stderr)         clients.append(0)  # add 0 to the list to maintain the length      time.sleep(300)  # wait 5 minutes between updates  average_clients = sum(clients) \/ len(clients)  if average_clients &gt; 75:     message = \"Server is overloaded\"     bot = telegram.Bot(token=bot_token)     bot.send_message(chat_id=chat_id, text=message) else:     print(f\"Number of connected clients: {clients[-1]}\") <\/code><\/pre>\n<p>\u041a\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432&nbsp;\u0431\u043b\u043e\u043a \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442&nbsp;\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 75. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u00abServer is overloaded\u00bb \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043a\u0430\u043a&nbsp;\u0438 \u0440\u0430\u043d\u0435\u0435. <\/p>\n<p><strong>\u00abServer is overloaded\u00bb<\/strong> &nbsp;\u2014 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c VPS \u0438 \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0435\u0433\u043e.<\/p>\n<h4>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a timeweb api  (api key \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435)<\/h4>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 VPS \u0432&nbsp;Timeweb \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432&nbsp;\u0441\u0435\u0431\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432:<\/p>\n<p>1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 VPS.<\/p>\n<p>2. \u0412\u044b\u0431\u0440\u0430\u0442\u044c VPS, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>3. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u044e VPS.<\/p>\n<p>4. \u0414\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u043a\u043e\u043f\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430.<\/p>\n<p>5. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 VPS.<\/p>\n<p>6. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432&nbsp;\u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Wireguard.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b Python\u2011\u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438:<\/p>\n<pre><code class=\"python\">import requests import json  # \u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0439 \u043a\u043b\u044e\u0447 API api_key = \"YOUR_API_KEY_HERE\"  # 1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 VPS. url = \"https:\/\/api.timeweb.com\/v1\/vps\" headers = {     \"Content-Type\": \"application\/json\",     \"Authorization\": f\"Bearer {api_key}\" } response = requests.get(url, headers=headers) vps_list = response.json()[\"data\"] print(\"Available VPS:\", vps_list)  # 2. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 VPS, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c. vps_to_clone = None for v in vps_list:     if v[\"hostname\"] == \"VPS_TO_CLONE\":         vps_to_clone = v         break if vps_to_clone is None:     print(\"VPS to clone not found.\")     exit(1) print(\"VPS to clone:\", vps_to_clone)  # 3. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043e\u043f\u0438\u044e VPS. url = \"https:\/\/api.timeweb.com\/v1\/vps\/clone\" data = {     \"vps_id\": vps_to_clone[\"id\"] } response = requests.post(url, headers=headers, data=json.dumps(data)) clone_id = response.json()[\"data\"][\"id\"] print(\"Clone created:\", clone_id)  # 4. \u0414\u043e\u0436\u0434\u0438\u0442\u0435\u0441\u044c, \u043f\u043e\u043a\u0430 \u043a\u043e\u043f\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430. url = f\"https:\/\/api.timeweb.com\/v1\/vps\/clone\/{clone_id}\" while True:     response = requests.get(url, headers=headers)     status = response.json()[\"data\"][\"status\"]     if status == \"completed\":         print(\"Clone processed.\")         break     elif status == \"failed\":         print(\"Clone failed.\")         exit(1)     print(\"Clone status:\", status)     time.sleep(10)  # 5. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 VPS. url = f\"https:\/\/api.timeweb.com\/v1\/vps\/{clone_id}\" response = requests.get(url, headers=headers) clone_vps = response.json()[\"data\"] print(\"Clone details:\", clone_vps)  # 6. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Wireguard. with open(\"wg0.conf\", \"a\") as f:     f.write(f\"[Peer]\\n\")     f.write(f\"PublicKey = {clone_vps['wireguard_public_key']}\\n\")     f.write(f\"AllowedIPs = {clone_vps['wireguard_allowed_ips']}\\n\")     f.write(f\"Endpoint = {clone_vps['wireguard_endpoint']}\\n\") <\/code><\/pre>\n<h4>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/h4>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e&nbsp;\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043d\u0430&nbsp;\u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0447\u0442\u043e&nbsp;\u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442&nbsp;\u043b\u0438\u043c\u0438\u0442, \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430&nbsp;\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u043e\u043d \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0430\u0435\u0442 \u043a\u043b\u044e\u0447\u0438&nbsp;\u2014 \u0432\u044b\u0434\u0430\u0447\u0443 \u043d\u0430&nbsp;\u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<p>\u0422\u0430\u043a&nbsp;\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0442\u043e&nbsp;\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0443\u0441\u0442\u0435\u0442\u044c, \u0432&nbsp;\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0433\u043e\u0434\u0430 \u0442\u0430\u043a\u043e\u0435 \u0443\u0436\u0435&nbsp;\u0431\u044b\u043b\u043e, \u043c\u044b \u0437\u0430\u043c\u0435\u0447\u0430\u043b\u0438 \u0447\u0442\u043e&nbsp;\u043b\u044e\u0434\u0438 \u0437\u0430\u0447\u0435\u043c \u0442\u043e \u0431\u0435\u0440\u0443\u0442 \u043d\u043e\u0432\u044b\u0435 \u043a\u043b\u044e\u0447\u0438, \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0442 wireguard \u0438\u043b\u0438&nbsp;\u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435&nbsp;\u043f\u043e\u043b\u044c\u044e\u0442\u0441\u044f \u0432\u043f\u043d, \u0432&nbsp;\u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e&nbsp;\u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043d\u043e&nbsp;\u043f\u043e\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043d\u0435&nbsp;\u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0431\u043e\u0442\u0430 \u043d\u0430&nbsp;\u0432\u044b\u0434\u0430\u0447\u0443 \u043a\u043b\u044e\u0447\u0435\u0439 \u043d\u0430&nbsp;\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f&nbsp;\u0434\u043e&nbsp;\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043a\u0443\u0441\u0442\u0430\u0440\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043c\u044b \u043d\u0435&nbsp;\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u0431\u044b\u043b\u0438 \u0441&nbsp;\u044d\u0442\u043e\u0439 \u0443\u0441\u043b\u0443\u0433\u0438, \u043d\u043e&nbsp;\u0432&nbsp;\u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438 \u043f\u0430\u043d\u0435\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430&nbsp;\u0446\u043f\u0443, \u0441\u0435\u0442\u044c.<\/p>\n<p>\u042d\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435&nbsp;\u0440\u0435\u043a\u043b\u0430\u043c\u0430, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0431\u0440\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0442\u0435\u043c \u0447\u0442\u043e&nbsp;\u0443&nbsp;\u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043e\u043f\u044b\u0442 \u0434\u043b\u044f&nbsp;\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0435\u0439 \u0443\u0441\u043b\u0443\u0433\u0438 \u0432\u043f\u043d. \u0420\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0434\u043b\u044f&nbsp;\u0434\u0443\u0448\u0438!<\/p>\n<p><strong>\u041c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0434\u044b, \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043a\u0430\u043d\u0430\u043b\u0435 <\/strong><a href=\"https:\/\/t.me\/blacktemple_space\" rel=\"noopener noreferrer nofollow\"><strong>https:\/\/t.me\/blacktemple_space<\/strong><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/735334\/\"> https:\/\/habr.com\/ru\/articles\/735334\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<figure class=\"full-width\">\n<div><figcaption>\u0432\u0430\u0443!<\/figcaption><\/div>\n<\/figure>\n<h4>\u0425\u0430\u0431\u0440\u0430\u044d\u0444\u0444\u0435\u043a\u0442 \u0438\u043b\u0438 \u043a\u0430\u043a \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0441 \u0443\u043c\u043e\u043c- \u0447\u0442\u043e \u0431\u044b \u0434\u0435\u043d\u044c\u0433\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435<\/h4>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0440\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e, \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 VPN \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445. \u041c\u043d\u043e\u0433\u0438\u0435 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b\u0438 \u043a\u0430\u043a \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0436\u0438\u0442\u044c \u0438 \u043a\u0442\u043e \u0437\u0430 \u044d\u0442\u043e \u043f\u043b\u0430\u0442\u0438\u0442. \u0412\u044b\u0448\u043b\u043e \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043f\u043b\u0430\u0442\u0430 \u043e\u0434\u043d\u043e\u0433\u043e VPS \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c 250 \u0440\u0443\u0431\u043b\u0435\u0439 \u0432 \u043c\u0435\u0441\u044f\u0446, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u043d\u0430 75 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0438 \u0442\u0430\u043a\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043c\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0439. \u0418 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u043d\u0430 \u043d\u0430\u0448 \u043a\u0430\u043d\u0430\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u0435\u0435 1000 \u0447\u0435\u043b\u043e\u0432\u0435\u043a &#8212; \u0430 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0439 \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 8 \u0442\u044b\u0441\u044f\u0447 \u0440\u0443\u0431\u043b\u0435\u0439 \u0437\u0430 \u0441\u0443\u0442\u043a\u0438.<\/p>\n<p> \u0418\u0442\u043e\u0433 &#8212; \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043a\u043e\u043b\u043e 3 \u0442\u044b\u0441\u044f\u0447 \u0447\u0435\u043b\u043e\u0432\u0435\u043a &#8212; \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u0432 10 \u0442\u044b\u0441\u044f\u0447 \u0440\u0443\u0431\u043b\u0435\u0439 &#8212; \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30 \u0434\u043d\u0435\u0439 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 16 \u0442\u044b\u0441\u044f\u0447 \u0440\u0443\u0431\u043b\u0435\u0439 \u0447\u0442\u043e \u043f\u043e\u043a\u0440\u044b\u043b\u043e \u0441 \u0433\u043e\u0440\u043a\u043e\u0439 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u043c\u0435\u0441\u044f\u0446 &#8212; \u043c\u0430\u0439 &#8212; \u0438 \u0434\u0430\u0436\u0435 \u0447\u0430\u0441\u0442\u044c \u0438\u044e\u043d\u044f!<\/p>\n<p><strong>\u0412&nbsp;\u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c&nbsp;\u2014 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/strong><\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0435\u043c \u0430\u0434\u043c\u0438\u043d\u0430<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u043e\u043d VDS<\/p>\n<\/li>\n<\/ol>\n<h4>TimeWeb API \u0438\u043b\u0438 \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c<\/h4>\n<p>\u0414\u043b\u044f&nbsp;\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e&nbsp;\u0431\u044b \u043f\u0440\u0438&nbsp;\u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0432\u044b\u0441\u043a\u043e\u0432\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043e\u043d\u043b\u0430\u0439\u043d \u0432&nbsp;\u0442\u0435\u0447\u0435\u043d\u0438\u0438 3\u20134&nbsp;\u0447\u0430\u0441\u043e\u0432, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0430\u0440\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 VDS \u0434\u0435\u043b\u0430\u044f \u0438\u0437&nbsp;\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043a\u043b\u043e\u043d.<\/p>\n<p>\u0414\u043b\u044f&nbsp;\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441\u0435\u0439\u0447\u0430\u0441 \u0432&nbsp;\u0441\u0435\u0442\u0438.<\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c subprocess, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432&nbsp;\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0438\u0437&nbsp;Python\u2011\u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<p>2. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>wg show<\/code> \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>subprocess.run()<\/code>, \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044f \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>capture_output=True<\/code> \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u044f \u0435\u0433\u043e \u0432&nbsp;\u0441\u0442\u0440\u043e\u043a\u0443 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>text=True<\/code>.<\/p>\n<p>3. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0415\u0441\u043b\u0438 \u043e\u043d \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430&nbsp;\u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434. \u0415\u0441\u043b\u0438 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043d\u0435&nbsp;\u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0438 \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431&nbsp;\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<p>4. \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434 \u043d\u0430&nbsp;\u0441\u0442\u0440\u043e\u043a\u0438 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>split('\\n')<\/code>.<\/p>\n<p>5. \u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0432&nbsp;\u0432\u044b\u0432\u043e\u0434\u0435 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432), \u0432\u044b\u0447\u0438\u0442\u0430\u044f 1&nbsp;\u0434\u043b\u044f&nbsp;\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>6. \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432&nbsp;\u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>print()<\/code>. <\/p>\n<pre><code class=\"python\">import subprocess  result = subprocess.run(['wg', 'show'], capture_output=True, text=True)  if result.returncode == 0:     output = result.stdout.strip().split('\\n')     clients = len(output) - 1  # subtract 1 for the header line     print(f\"Number of connected clients: {clients}\") else:     print(\"Error:\", result.stderr) <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0447\u0442\u043e&nbsp;\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0442\u0441\u043e\u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0437\u0430 12&nbsp;\u0447\u0430\u0441\u043e\u0432 \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435&nbsp;\u2014 \u0430\u0440\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u043e\u043d vds \u0438\u043b\u0438&nbsp;\u043d\u0435\u0442.<\/p>\n<p>1. \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <code>avg_clients<\/code>, <code>count<\/code> \u0438 <code>max_count<\/code>. <code>avg_clients<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f&nbsp;\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, <code>count<\/code>&nbsp;\u2014 \u0434\u043b\u044f&nbsp;\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0430 <code>max_count<\/code>&nbsp;\u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c.<\/p>\n<p>2. \u041c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b <code>while count &lt; max_count<\/code>, \u0432&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c <code>count<\/code>.<\/p>\n<p>3. \u041c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>wg show<\/code>, \u043a\u0430\u043a&nbsp;\u0438 \u0432&nbsp;\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435, \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434.<\/p>\n<p>4. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043a <code>avg_clients<\/code> \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c <code>count<\/code> \u043d\u0430 1.<\/p>\n<p>5. \u041c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0436\u0434\u0435\u043c 10&nbsp;\u043c\u0438\u043d\u0443\u0442 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>time.sleep(600)<\/code>.<\/p>\n<p>6. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0432 <code>avg_clients<\/code> \u043d\u0430 <code>count<\/code>.<\/p>\n<p>7. \u0415\u0441\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438&nbsp;\u0440\u0430\u0432\u043d\u043e 75, \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u00abServer is overloaded\u00bb, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u00abServer is running fine\u00bb.<\/p>\n<p><em>\u041a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 Wireguard \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0435\u0433\u043e \u0432&nbsp;\u0442\u0435\u0447\u0435\u043d\u0438\u0435 12&nbsp;\u0447\u0430\u0441\u043e\u0432: <\/em>  <\/p>\n<pre><code class=\"python\">import subprocess import time  avg_clients = 0 count = 0 max_count = 72  # 12 hours with a check every 10 minutes  while count &lt; max_count:     result = subprocess.run(['wg', 'show'], capture_output=True, text=True)      if result.returncode == 0:         output = result.stdout.strip().split('\\n')         clients = len(output) - 1  # subtract 1 for the header line         avg_clients += clients         count += 1         print(f\"Number of connected clients: {clients}\")         time.sleep(600)  # wait for 10 minutes     else:         print(\"Error:\", result.stderr)  avg_clients \/\/= count  if avg_clients &gt;= 75:     print(\"Server is overloaded\") else:     print(\"Server is running fine\") <\/code><\/pre>\n<p><em>\u041a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 Wireguard \u0432&nbsp;\u0442\u0435\u0447\u0435\u043d\u0438\u0435 12&nbsp;\u0447\u0430\u0441\u043e\u0432 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442&nbsp;\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 75:<\/em>  <\/p>\n<pre><code class=\"python\">python import subprocess import time  clients = []  for i in range(0, 144):  # 12 hours * 12 updates per hour = 144 updates     result = subprocess.run(['wg', 'show'], capture_output=True, text=True)      if result.returncode == 0:         output = result.stdout.strip().split('\\n')         clients.append(len(output) - 1)  # subtract 1 for the header line     else:         print(\"Error:\", result.stderr)         clients.append(0)  # add 0 to the list to maintain the length      time.sleep(300)  # wait 5 minutes between updates  average_clients = sum(clients) \/ len(clients)  if average_clients &gt; 75:     print(\"Server is overloaded\") else:     print(f\"Number of connected clients: {clients[-1]}\") ```<\/code><\/pre>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a <code>clients<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u0446\u0438\u043a\u043b\u0430.<\/p>\n<p>2. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0446\u0438\u043a\u043b <code>for<\/code> \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f 144 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 (12 \u0447\u0430\u0441\u043e\u0432 * 12 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u0447\u0430\u0441).<\/p>\n<p>3. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>wg show<\/code> \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0443.<\/p>\n<p>4. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>clients<\/code>.<\/p>\n<p>5. \u0415\u0441\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c 0 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>clients<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>6. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>time.sleep()<\/code> \u0434\u043b\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f 5 \u043c\u0438\u043d\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>7. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 <code>clients<\/code>.<\/p>\n<p>8. \u0415\u0441\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 75, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &#171;Server is overloaded&#187;.<\/p>\n<p>9. \u0418\u043d\u0430\u0447\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 <code>clients<\/code> \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>print()<\/code>.  <\/p>\n<p><strong>\u0412\u0441\u0435 \u0442\u0430\u043a\u0438 \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043e\u0432\u0440\u0430\u043b, \u043d\u0435&nbsp;\u0432\u0441\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u043c\u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432&nbsp;\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c, \u0447\u0442\u043e&nbsp;\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d, \u0438 \u0443\u0436\u0435 \u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0440\u0435\u0448\u0430\u0435\u0442, \u0445\u0432\u0430\u0442\u0438\u0442&nbsp;\u043b\u0438 \u043d\u0430\u043c \u0434\u0435\u043d\u0435\u0433 \u043d\u0430&nbsp;\u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043b\u0438&nbsp;\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0430\u0447\u0443 \u043a\u043b\u044e\u0447\u0435\u0439 \u043a&nbsp;WG.<\/p>\n<p><\/strong>\u0414\u043b\u044f&nbsp;\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>python-telegram-bot<\/code>. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441&nbsp;\u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d. \u0414\u043b\u044f&nbsp;\u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a&nbsp;BotFather \u0432&nbsp;Telegram \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c: <\/p>\n<pre><code class=\"python\">import telegram  bot_token = 'YOUR_BOT_TOKEN_HERE' chat_id = 'YOUR_CHAT_ID_HERE'  bot = telegram.Bot(token=bot_token) message = \"Server is overloaded\" bot.send_message(chat_id=chat_id, text=message) <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441&nbsp;\u043a\u043e\u0434\u043e\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c, \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d: <\/p>\n<pre><code class=\"python\">import subprocess import time import telegram  bot_token = 'YOUR_BOT_TOKEN_HERE' chat_id = 'YOUR_CHAT_ID_HERE'  clients = []  for i in range(0, 144):  # 12 hours * 12 updates per hour = 144 updates     result = subprocess.run(['wg', 'show'], capture_output=True, text=True)      if result.returncode == 0:         output = result.stdout.strip().split('\\n')         clients.append(len(output) - 1)  # subtract 1 for the header line     else:         print(\"Error:\", result.stderr)         clients.append(0)  # add 0 to the list to maintain the length      time.sleep(300)  # wait 5 minutes between updates  average_clients = sum(clients) \/ len(clients)  if average_clients &gt; 75:     message = \"Server is overloaded\"     bot = telegram.Bot(token=bot_token)     bot.send_message(chat_id=chat_id, text=message) else:     print(f\"Number of connected clients: {clients[-1]}\") <\/code><\/pre>\n<p>\u041a\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432&nbsp;\u0431\u043b\u043e\u043a \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442&nbsp;\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 75. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u00abServer is overloaded\u00bb \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432&nbsp;\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043a\u0430\u043a&nbsp;\u0438 \u0440\u0430\u043d\u0435\u0435. <\/p>\n<p><strong>\u00abServer is overloaded\u00bb<\/strong> &nbsp;\u2014 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c VPS \u0438 \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0435\u0433\u043e.<\/p>\n<h4>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a timeweb api  (api key \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435)<\/h4>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 VPS \u0432&nbsp;Timeweb \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432&nbsp;\u0441\u0435\u0431\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432:<\/p>\n<p>1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 VPS.<\/p>\n<p>2. \u0412\u044b\u0431\u0440\u0430\u0442\u044c VPS, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>3. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u044e VPS.<\/p>\n<p>4. \u0414\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u043a\u043e\u043f\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430.<\/p>\n<p>5. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 VPS.<\/p>\n<p>6. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432&nbsp;\u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Wireguard.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b Python\u2011\u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438:<\/p>\n<pre><code class=\"python\">import requests import json  # \u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0439 \u043a\u043b\u044e\u0447 API api_key = \"YOUR_API_KEY_HERE\"  # 1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 VPS. url = \"https:\/\/api.timeweb.com\/v1\/vps\" headers = {     \"Content-Type\": \"application\/json\",     \"Authorization\": f\"Bearer {api_key}\" } response = requests.get(url, headers=headers) vps_list = response.json()[\"data\"] print(\"Available VPS:\", vps_list)  # 2. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 VPS, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c. vps_to_clone = None for v in vps_list:     if v[\"hostname\"] == \"VPS_TO_CLONE\":         vps_to_clone = v         break if vps_to_clone is None:     print(\"VPS to clone not found.\")     exit(1) print(\"VPS to clone:\", vps_to_clone)  # 3. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043e\u043f\u0438\u044e VPS. url = \"https:\/\/api.timeweb.com\/v1\/vps\/clone\" data = {     \"vps_id\": vps_to_clone[\"id\"] } response = requests.post(url, headers=headers, data=json.dumps(data)) clone_id = response.json()[\"data\"][\"id\"] print(\"Clone created:\", clone_id)  # 4. \u0414\u043e\u0436\u0434\u0438\u0442\u0435\u0441\u044c, \u043f\u043e\u043a\u0430 \u043a\u043e\u043f\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430. url = f\"https:\/\/api.timeweb.com\/v1\/vps\/clone\/{clone_id}\" while True:     response = requests.get(url, headers=headers)     status = response.json()[\"data\"][\"status\"]     if status == \"completed\":         print(\"Clone processed.\")         break     elif status == \"failed\":         print(\"Clone failed.\")         exit(1)     print(\"Clone status:\", status)     time.sleep(10)  # 5. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 VPS. url = f\"https:\/\/api.timeweb.com\/v1\/vps\/{clone_id}\" response = requests.get(url, headers=headers) clone_vps = response.json()[\"data\"] print(\"Clone details:\", clone_vps)  # 6. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Wireguard. with open(\"wg0.conf\", \"a\") as f:     f.write(f\"[Peer]\\n\")     f.write(f\"PublicKey = {clone_vps['wireguard_public_key']}\\n\")     f.write(f\"AllowedIPs = {clone_vps['wireguard_allowed_ips']}\\n\")     f.write(f\"Endpoint = {clone_vps['wireguard_endpoint']}\\n\") <\/code><\/pre>\n<h4>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/h4>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e&nbsp;\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043d\u0430&nbsp;\u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0447\u0442\u043e&nbsp;\u0441\u0440\u0435\u0434\u043d\u0435\u0435<\/p>\n<\/p>\n<p><\/strong><\/p>\n<p><\/br><\/br><\/br><\/p>\n<p><\/br><\/p>\n<p><\/br><\/p>\n<p><\/br><\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-347515","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347515"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347515\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}