{"id":467620,"date":"2025-07-18T23:29:47","date_gmt":"2025-07-18T23:29:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=467620"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=467620","title":{"rendered":"<span>Bash vs Python: \u0431\u0438\u0442\u0432\u0430, \u0433\u0434\u0435 \u043d\u0435\u0442 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u0432\u0448\u0438\u0445<\/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<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0412 \u043c\u0438\u0440\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 Bash \u0438\u043b\u0438 \u043d\u0430 Python? \u041e\u0431\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0435. Bash &#8212; \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e &#171;\u0441\u043a\u043e\u0440\u043e\u043f\u0438\u0441\u044c&#187;, \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u044c. Python \u0436\u0435 &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u0438\u043d, \u0430 \u043a\u043e\u0433\u0434\u0430 &#8212; \u0434\u0440\u0443\u0433\u043e\u0439?<\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 Bash \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u043a\u043e\u0433\u0434\u0430 \u0436\u0435 \u043d\u0430 Python \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u044f\u0442\u043e\u043a \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041f\u0440\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f &#8212; Bash \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043e\u043b\u043e\u0432\u043e\u043b\u043e\u043c\u043a\u0443 \u0438\u0437 <code>awk<\/code>, <code>sed<\/code> \u0438 \u043f\u0440\u043e\u0447\u0438\u0445, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u043a\u043e\u0433\u0434\u0430 \u0438 \u043a\u0430\u043a\u043e\u0439 \u044f\u0437\u044b\u043a \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>Python &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 Bash \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432 \u0440\u0430\u0437\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u0435\u0435. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 (\u043f\u043e\u0438\u0441\u043a, \u0437\u0430\u043c\u0435\u043d\u0430, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430)<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 (<code>grep<\/code>, <code>awk<\/code>, <code>sed<\/code>, <code>find<\/code> \u0438 \u0442\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u043c\u0438 (<code>systemctl<\/code>, <code>top<\/code> \u0438 \u0442\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u044b, \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u0430)<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u0438 \u0443 Bash \u0435\u0441\u0442\u044c \u0441\u043b\u0430\u0431\u044b\u0435 \u043c\u0435\u0441\u0442\u0430: \u043e\u043d \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (JSON, XML), \u0441\u043b\u043e\u0436\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430 \u043a\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c.<\/p>\n<h3>\u0410\u043d\u0430\u043b\u0438\u0437: \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 Bash, \u0430 \u043a\u043e\u0433\u0434\u0430 Python \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c<\/h3>\n<h4>1. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043b\u043e\u0433\u043e\u0432: \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432<\/h4>\n<p>Bash:<\/p>\n<pre><code class=\"bash\">grep ' 500 ' \/var\/log\/nginx\/access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -5 <\/code><\/pre>\n<p><strong>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445)<\/p>\n<\/li>\n<li>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 (\u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430)<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0425\u0440\u0443\u043f\u043a\u043e\u0441\u0442\u044c (\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043b\u043e\u0433\u043e\u0432)<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 \u043f\u043e \u0434\u0430\u0442\u0435)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u043e\u0445\u0430\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0438 \u043b\u043e\u0433\u0438\u043a\u0438<\/p>\n<\/li>\n<\/ul>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">from collections import defaultdict import re  log_file = \"\/var\/log\/nginx\/access.log\" ip_counts = defaultdict(int) log_pattern = re.compile(r'^(\\S+) \\S+ \\S+ \\[(.*?)\\] \"(.*?)\" (\\d+)')  with open(log_file) as f:     for line in f:         match = log_pattern.match(line)         if match and match.group(4) == \"500\":             ip = match.group(1)             ip_counts[ip] += 1  top_ips = sorted(ip_counts.items(), key=lambda x: x[1], reverse=True)[:5] for ip, count in top_ips:     print(f\"{count}\\t{ip}\") <\/code><\/pre>\n<p><strong>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0427\u0435\u0442\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 (\u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u0434\u0430\u0442\u0435, URL \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u041b\u0443\u0447\u0448\u0430\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u044a\u0435\u043c \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u041e\u0449\u0443\u0442\u0438\u043c\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong>: \u0434\u043b\u044f \u0440\u0430\u0437\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043b\u043e\u0433\u0430\u0445 Bash \u044f\u0432\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435. \u0414\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0436\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e &#8212; Python.<\/p>\n<h4>2. \u041c\u0430\u0441\u0441\u043e\u0432\u043e\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/h4>\n<p><strong>Bash:<\/strong><\/p>\n<pre><code class=\"bash\"># \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 find . -maxdepth 1 -name \"*.txt\" -print0 | while IFS= read -r -d '' file; do     new_name=\"${file\/\/ \/_}\"     [ \"$file\" != \"$new_name\" ] &amp;&amp; mv -- \"$file\" \"$new_name\" done <\/code><\/pre>\n<p><strong>\u041d\u044e\u0430\u043d\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438 \u0438 \u0441\u043f\u0435\u0446\u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 <code>-print0<\/code><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0442\u043e \u0436\u0435 \u0438\u043c\u044f<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 <code>find<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">import os from pathlib import Path  for item in Path('.').glob('*.txt'):     new_name = item.name.replace(' ', '_')     if new_name != item.name:         item.rename(item.with_name(new_name)) <\/code><\/pre>\n<p><strong>\u041d\u044e\u0430\u043d\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041d\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 pathlib \u0432\u043c\u0435\u0441\u0442\u043e os<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u043e\u0441\u0441-\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong> (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 +-0,1\u0441):<\/p>\n<ul>\n<li>\n<p>\u041d\u0430 1000 \u0444\u0430\u0439\u043b\u0430\u0445: Bash &#8212; 0,2\u0441, Python &#8212; 0,5\u0441<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 10000 \u0444\u0430\u0439\u043b\u0430\u0445: Bash &#8212; 2,1\u0441, Python &#8212; 4,8\u0441<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong>: \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 Bash \u0432 \u0440\u0430\u0437\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e Python \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<h4>3. \u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u0438\u0441\u043a\u0430<\/h4>\n<p><strong>Bash:<\/strong><\/p>\n<pre><code class=\"bash\">#!\/bin\/bash  threshold=90 recipient=\"admin@example.com\" partition=\"\/\"  usage=$(df --output=pcent \"$partition\" | tail -1 | tr -d '% ') message=\"Disk usage on $(hostname) for $partition: ${usage}%\"  if [ \"$usage\" -ge \"$threshold\" ]; then     echo \"$message\" | mail -s \"Disk Alert\" \"$recipient\"     # \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e: \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432     logger -t disk_alert \"$message\" fi <\/code><\/pre>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">import smtplib import socket from email.mime.text import MIMEText from shutil import disk_usage  def send_alert(usage):     host = socket.gethostname()     msg = MIMEText(f\"Disk usage on {host}: {usage}%\")     msg['Subject'] = 'Disk Alert'     msg['From'] = 'monitoring@example.com'     msg['To'] = 'admin@example.com'          with smtplib.SMTP('smtp.example.com') as server:         server.send_message(msg)  def main():     threshold = 90     partition = '\/'          total, used, _ = disk_usage(partition)     usage_percent = (used \/ total) * 100          if usage_percent &gt;= threshold:         send_alert(round(usage_percent, 1))         # \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:         # - \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435         # - \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439         # - \u041f\u043e\u0432\u0442\u043e\u0440\u044b \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u0445  if __name__ == '__main__':     main() <\/code><\/pre>\n<p><strong>\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0432\u044b\u0431\u043e\u0440\u0430:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">Bash<\/p>\n<\/th>\n<th>\n<p align=\"left\">Python<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041b\u0435\u0433\u0447\u0435 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0425\u0440\u0443\u043f\u043a\u0438\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e Unix<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>4. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 CSV-\u0444\u0430\u0439\u043b\u043e\u0432<\/h4>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443: \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0443 CSV<\/p>\n<p><strong>Bash:<\/strong><\/p>\n<pre><code class=\"bash\">awk -F',' 'NR&gt;1 {sum+=$2; count++} END {print sum\/count}' data.csv <\/code><\/pre>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">import pandas as pd  df = pd.read_csv('data.csv') print(df.iloc[:, 1].mean()) <\/code><\/pre>\n<p><strong>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>Bash: 0.8\u0441 \u043f\u0440\u0438 \u0444\u0430\u0439\u043b\u0435 \u0432 100\u041c\u0412<\/p>\n<\/li>\n<li>\n<p>Python: 1.2\u0441, \u043d\u043e \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 CSV<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h4>5. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p><strong>\u0414\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0442\u0435\u043d\u0434:<\/strong><\/p>\n<ul>\n<li>\n<p>Ubuntu 20.04<\/p>\n<\/li>\n<li>\n<p>Intel Core i7-10750H<\/p>\n<\/li>\n<li>\n<p>32GB RAM<\/p>\n<\/li>\n<li>\n<p>SSD NVMe<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">Bash<\/p>\n<\/th>\n<th>\n<p align=\"left\">Python<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0438\u0441\u043a \u0432 \u043b\u043e\u0433\u0430\u0445 (1GB)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.2\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.8\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python \u0432 3.2 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 10k \u0444\u0430\u0439\u043b\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">2.1\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">5.4\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python \u0432 2.6 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0410\u043d\u0430\u043b\u0438\u0437 CSV (100MB)<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.8\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.2\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python \u0432 1.5 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043b\u043e\u0436\u043d\u0430\u044f ETL-\u0437\u0430\u0434\u0430\u0447\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<td>\n<p align=\"left\">4.2\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Bash \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Bash \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 Unix-\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0442\u044c Python, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0436\u043d\u0430 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 (JSON, XML, CSV)<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043e \u0441\u0432\u043e\u0435\u0439 \u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044e. \u042f \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e &#171;\u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439&#187; \u043f\u043e\u0434\u0445\u043e\u0434. \u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0434\u0430\u0451\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c: Bash &#8212; \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, Python &#8212; \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<p><em>P.S. \u042f \u0432\u0435\u0434\u0443 \u0441\u0432\u043e\u044e \u0433\u0440\u0443\u043f\u043f\u0443 \u0432<\/em>\u00a0<a href=\"https:\/\/t.me\/automate_today\" rel=\"noopener noreferrer nofollow\"><em>\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c<\/em><\/a><em>, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043c\u0438\u0440\u0435 IT.<\/em>  <\/p>\n<\/div>\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\/927406\/\"> https:\/\/habr.com\/ru\/articles\/927406\/<\/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<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0412 \u043c\u0438\u0440\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 Bash \u0438\u043b\u0438 \u043d\u0430 Python? \u041e\u0431\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0435. Bash &#8212; \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e &#171;\u0441\u043a\u043e\u0440\u043e\u043f\u0438\u0441\u044c&#187;, \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u044c. Python \u0436\u0435 &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u0438\u043d, \u0430 \u043a\u043e\u0433\u0434\u0430 &#8212; \u0434\u0440\u0443\u0433\u043e\u0439?<\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 Bash \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u043a\u043e\u0433\u0434\u0430 \u0436\u0435 \u043d\u0430 Python \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u044f\u0442\u043e\u043a \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041f\u0440\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f &#8212; Bash \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043e\u043b\u043e\u0432\u043e\u043b\u043e\u043c\u043a\u0443 \u0438\u0437 <code>awk<\/code>, <code>sed<\/code> \u0438 \u043f\u0440\u043e\u0447\u0438\u0445, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u043a\u043e\u0433\u0434\u0430 \u0438 \u043a\u0430\u043a\u043e\u0439 \u044f\u0437\u044b\u043a \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>Python &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 Bash \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432 \u0440\u0430\u0437\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u0435\u0435. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 (\u043f\u043e\u0438\u0441\u043a, \u0437\u0430\u043c\u0435\u043d\u0430, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430)<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 (<code>grep<\/code>, <code>awk<\/code>, <code>sed<\/code>, <code>find<\/code> \u0438 \u0442\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u043c\u0438 (<code>systemctl<\/code>, <code>top<\/code> \u0438 \u0442\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u044b, \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u0430)<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u0438 \u0443 Bash \u0435\u0441\u0442\u044c \u0441\u043b\u0430\u0431\u044b\u0435 \u043c\u0435\u0441\u0442\u0430: \u043e\u043d \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (JSON, XML), \u0441\u043b\u043e\u0436\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430 \u043a\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c.<\/p>\n<h3>\u0410\u043d\u0430\u043b\u0438\u0437: \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 Bash, \u0430 \u043a\u043e\u0433\u0434\u0430 Python \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c<\/h3>\n<h4>1. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043b\u043e\u0433\u043e\u0432: \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432<\/h4>\n<p>Bash:<\/p>\n<pre><code class=\"bash\">grep ' 500 ' \/var\/log\/nginx\/access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -5 <\/code><\/pre>\n<p><strong>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445)<\/p>\n<\/li>\n<li>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 (\u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430)<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0425\u0440\u0443\u043f\u043a\u043e\u0441\u0442\u044c (\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043b\u043e\u0433\u043e\u0432)<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 \u043f\u043e \u0434\u0430\u0442\u0435)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u043e\u0445\u0430\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0438 \u043b\u043e\u0433\u0438\u043a\u0438<\/p>\n<\/li>\n<\/ul>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">from collections import defaultdict import re  log_file = \"\/var\/log\/nginx\/access.log\" ip_counts = defaultdict(int) log_pattern = re.compile(r'^(\\S+) \\S+ \\S+ \\[(.*?)\\] \"(.*?)\" (\\d+)')  with open(log_file) as f:     for line in f:         match = log_pattern.match(line)         if match and match.group(4) == \"500\":             ip = match.group(1)             ip_counts[ip] += 1  top_ips = sorted(ip_counts.items(), key=lambda x: x[1], reverse=True)[:5] for ip, count in top_ips:     print(f\"{count}\\t{ip}\") <\/code><\/pre>\n<p><strong>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0427\u0435\u0442\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 (\u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u0434\u0430\u0442\u0435, URL \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u041b\u0443\u0447\u0448\u0430\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u044a\u0435\u043c \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u041e\u0449\u0443\u0442\u0438\u043c\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong>: \u0434\u043b\u044f \u0440\u0430\u0437\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043b\u043e\u0433\u0430\u0445 Bash \u044f\u0432\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435. \u0414\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0436\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e &#8212; Python.<\/p>\n<h4>2. \u041c\u0430\u0441\u0441\u043e\u0432\u043e\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/h4>\n<p><strong>Bash:<\/strong><\/p>\n<pre><code class=\"bash\"># \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 find . -maxdepth 1 -name \"*.txt\" -print0 | while IFS= read -r -d '' file; do     new_name=\"${file\/\/ \/_}\"     [ \"$file\" != \"$new_name\" ] &amp;&amp; mv -- \"$file\" \"$new_name\" done <\/code><\/pre>\n<p><strong>\u041d\u044e\u0430\u043d\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438 \u0438 \u0441\u043f\u0435\u0446\u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 <code>-print0<\/code><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0442\u043e \u0436\u0435 \u0438\u043c\u044f<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 <code>find<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">import os from pathlib import Path  for item in Path('.').glob('*.txt'):     new_name = item.name.replace(' ', '_')     if new_name != item.name:         item.rename(item.with_name(new_name)) <\/code><\/pre>\n<p><strong>\u041d\u044e\u0430\u043d\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041d\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 pathlib \u0432\u043c\u0435\u0441\u0442\u043e os<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u043e\u0441\u0441-\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong> (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 +-0,1\u0441):<\/p>\n<ul>\n<li>\n<p>\u041d\u0430 1000 \u0444\u0430\u0439\u043b\u0430\u0445: Bash &#8212; 0,2\u0441, Python &#8212; 0,5\u0441<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 10000 \u0444\u0430\u0439\u043b\u0430\u0445: Bash &#8212; 2,1\u0441, Python &#8212; 4,8\u0441<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong>: \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 Bash \u0432 \u0440\u0430\u0437\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e Python \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<h4>3. \u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u0438\u0441\u043a\u0430<\/h4>\n<p><strong>Bash:<\/strong><\/p>\n<pre><code class=\"bash\">#!\/bin\/bash  threshold=90 recipient=\"admin@example.com\" partition=\"\/\"  usage=$(df --output=pcent \"$partition\" | tail -1 | tr -d '% ') message=\"Disk usage on $(hostname) for $partition: ${usage}%\"  if [ \"$usage\" -ge \"$threshold\" ]; then     echo \"$message\" | mail -s \"Disk Alert\" \"$recipient\"     # \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e: \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432     logger -t disk_alert \"$message\" fi <\/code><\/pre>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">import smtplib import socket from email.mime.text import MIMEText from shutil import disk_usage  def send_alert(usage):     host = socket.gethostname()     msg = MIMEText(f\"Disk usage on {host}: {usage}%\")     msg['Subject'] = 'Disk Alert'     msg['From'] = 'monitoring@example.com'     msg['To'] = 'admin@example.com'          with smtplib.SMTP('smtp.example.com') as server:         server.send_message(msg)  def main():     threshold = 90     partition = '\/'          total, used, _ = disk_usage(partition)     usage_percent = (used \/ total) * 100          if usage_percent &gt;= threshold:         send_alert(round(usage_percent, 1))         # \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:         # - \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435         # - \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439         # - \u041f\u043e\u0432\u0442\u043e\u0440\u044b \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u0445  if __name__ == '__main__':     main() <\/code><\/pre>\n<p><strong>\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0432\u044b\u0431\u043e\u0440\u0430:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">Bash<\/p>\n<\/th>\n<th>\n<p align=\"left\">Python<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041b\u0435\u0433\u0447\u0435 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0425\u0440\u0443\u043f\u043a\u0438\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e Unix<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>4. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 CSV-\u0444\u0430\u0439\u043b\u043e\u0432<\/h4>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443: \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0443 CSV<\/p>\n<p><strong>Bash:<\/strong><\/p>\n<pre><code class=\"bash\">awk -F',' 'NR&gt;1 {sum+=$2; count++} END {print sum\/count}' data.csv <\/code><\/pre>\n<p><strong>Python:<\/strong><\/p>\n<pre><code class=\"python\">import pandas as pd  df = pd.read_csv('data.csv') print(df.iloc[:, 1].mean()) <\/code><\/pre>\n<p><strong>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>Bash: 0.8\u0441 \u043f\u0440\u0438 \u0444\u0430\u0439\u043b\u0435 \u0432 100\u041c\u0412<\/p>\n<\/li>\n<li>\n<p>Python: 1.2\u0441, \u043d\u043e \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 CSV<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h4>5. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p><strong>\u0414\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0442\u0435\u043d\u0434:<\/strong><\/p>\n<ul>\n<li>\n<p>Ubuntu 20.04<\/p>\n<\/li>\n<li>\n<p>Intel Core i7-10750H<\/p>\n<\/li>\n<li>\n<p>32GB RAM<\/p>\n<\/li>\n<li>\n<p>SSD NVMe<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">Bash<\/p>\n<\/th>\n<th>\n<p align=\"left\">Python<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0438\u0441\u043a \u0432 \u043b\u043e\u0433\u0430\u0445 (1GB)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.2\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.8\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python \u0432 3.2 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 10k \u0444\u0430\u0439\u043b\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">2.1\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">5.4\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python \u0432 2.6 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0410\u043d\u0430\u043b\u0438\u0437 CSV (100MB)<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.8\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.2\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python \u0432 1.5 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043b\u043e\u0436\u043d\u0430\u044f ETL-\u0437\u0430\u0434\u0430\u0447\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<td>\n<p align=\"left\">4.2\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">Bash \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Bash \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 Unix-\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0442\u044c Python, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0436\u043d\u0430 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 (JSON, XML, CSV)<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043e \u0441\u0432\u043e\u0435\u0439 \u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044e. \u042f \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e &#171;\u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439&#187; \u043f\u043e\u0434\u0445\u043e\u0434. \u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0434\u0430\u0451\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c: Bash &#8212; \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, Python &#8212; \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<p><em>P.S. \u042f \u0432\u0435\u0434\u0443 \u0441\u0432\u043e\u044e \u0433\u0440\u0443\u043f\u043f\u0443 \u0432<\/em>\u00a0<a href=\"https:\/\/t.me\/automate_today\" rel=\"noopener noreferrer nofollow\"><em>\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c<\/em><\/a><em>, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043c\u0438\u0440\u0435 IT.<\/em>  <\/p>\n<\/div>\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\/927406\/\"> https:\/\/habr.com\/ru\/articles\/927406\/<\/a><br \/><\/br><\/br><\/p>\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-467620","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467620","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=467620"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467620\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=467620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=467620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=467620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}