{"id":688,"date":"2021-05-21T16:27:37","date_gmt":"2021-05-21T13:27:37","guid":{"rendered":"https:\/\/datadigging.ru\/?p=688"},"modified":"2023-04-06T15:42:26","modified_gmt":"2023-04-06T12:42:26","slug":"%d1%84-%d1%8f-%d0%bf%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d1%8f-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85-%d0%be-%d1%81%d0%be%d1%81%d1%82%d0%be%d1%8f%d0%bd%d0%b8%d0%b8-%d1%81%d0%b8%d1%81%d1%82%d0%b5","status":"publish","type":"post","link":"https:\/\/datadigging.ru\/?p=688","title":{"rendered":"\u0424-\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/datadigging.ru\/wp-content\/uploads\/2023\/04\/image-5.png\" alt=\"\" class=\"wp-image-1490\" width=\"355\" height=\"355\" srcset=\"https:\/\/datadigging.ru\/wp-content\/uploads\/2023\/04\/image-5.png 1024w, https:\/\/datadigging.ru\/wp-content\/uploads\/2023\/04\/image-5-300x300.png 300w, https:\/\/datadigging.ru\/wp-content\/uploads\/2023\/04\/image-5-150x150.png 150w, https:\/\/datadigging.ru\/wp-content\/uploads\/2023\/04\/image-5-768x768.png 768w\" sizes=\"auto, (max-width: 355px) 100vw, 355px\" \/><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\"><strong>import <\/strong>psutil\n<strong>import <\/strong>datetime\n<strong>import <\/strong>platform\n\n\n<strong>def get_system_info():\n\n    <\/strong>result <strong>= {}\n\n    <\/strong># \u041e\u0421\n    os_platform <strong>= <\/strong>platform.system<strong>()\n    <\/strong># \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\n    processor <strong>= <\/strong>platform.processor<strong>()\n    <\/strong>result.update<strong>({'platform': <\/strong>os_platform, <strong>'processor': <\/strong>processor<strong>})\n    <\/strong># \u0434\u0438\u0441\u043a\u0438\n    disks <strong>= <\/strong>psutil.disk_partitions<strong>()\n    for <\/strong>i <strong>in <\/strong>disks<strong>:\n        try:\n            <\/strong>disk_usage <strong>= <\/strong>psutil.disk_usage<strong>(<\/strong>i.device<strong>)\n            <\/strong>total <strong>= <\/strong>int<strong>(<\/strong>disk_usage .total<strong>) \/ <\/strong>1048576\n            used <strong>= <\/strong>int<strong>(<\/strong>disk_usage .used<strong>) \/ <\/strong>1048576\n            free <strong>= <\/strong>int<strong>(<\/strong>disk_usage .free<strong>) \/ <\/strong>1048576\n            percent <strong>= <\/strong>float<strong>(<\/strong>disk_usage .percent<strong>)\n            <\/strong>disk_dict <strong>= {'total_space': <\/strong>total, <strong>'used_space': <\/strong>used, <strong>'free_space': <\/strong>free, <strong>'free_percent': <\/strong>percent<strong>}\n            <\/strong>result.update<strong>({'disk_space': <\/strong>disk_dict<strong>})\n\n        except:\n            pass\n\n    <\/strong># \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\n    cpu_percent <strong>= <\/strong>psutil.cpu_percent<strong>()\n    <\/strong>result.update<strong>({'cpu_percent': <\/strong>cpu_percent<strong>})\n\n    <\/strong># \u0430\u043f\u0442\u0430\u0439\u043c\n    boot_time <strong>= <\/strong>psutil.boot_time<strong>()\n    <\/strong>uptime <strong>= <\/strong>datetime.datetime.now<strong>()<\/strong>.timestamp<strong>() - <\/strong>boot_time\n    result.update<strong>({'uptime': <\/strong>uptime<strong>})\n\n    <\/strong># \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043a\u0430:\n    mem_status <strong>= <\/strong>psutil.virtual_memory<strong>()\n    <\/strong>m_total <strong>= <\/strong>int<strong>(<\/strong>mem_status.total<strong>) \/ <\/strong>1048576\n    m_available <strong>= <\/strong>int<strong>(<\/strong>mem_status.available<strong>) \/ <\/strong>1048576\n    m_used <strong>= <\/strong>int<strong>(<\/strong>mem_status.used<strong>) \/ <\/strong>1048576\n    m_free <strong>= <\/strong>int<strong>(<\/strong>mem_status.free<strong>) \/ <\/strong>1048576\n    m_percent <strong>= <\/strong>float<strong>(<\/strong>mem_status.percent<strong>)\n    <\/strong>memory_dict <strong>= {'total_mem': <\/strong>m_total, <strong>'available_mem': <\/strong>m_available, <strong>'used_mem': <\/strong>m_used,\n                   <strong>'free_mem': <\/strong>m_free, <strong>'free_percent_mem': <\/strong>m_percent<strong>}\n    <\/strong>result.update<strong>({'memory_space': <\/strong>memory_dict<strong>})\n\n    <\/strong># \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430:\n    <strong>try:\n        <\/strong># <strong><em>ToDo \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0447\u043d\u044f  \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432\n        <\/em><\/strong>proc_temp <strong>= <\/strong>float<strong>(<\/strong>psutil.sensors_temperatures<strong>()<\/strong>.current<strong>)\n    except:\n        <\/strong>proc_temp <strong>= None\n\n    <\/strong>result.update<strong>({'proc_temp': <\/strong>proc_temp<strong>})\n\n    return <\/strong>result\n\n\n<strong>if <\/strong>__name__ <strong>== \"__main__\":\n    <\/strong>res <strong>= <\/strong>get_system_info<strong>()\n    for <\/strong>i <strong>in <\/strong>res.keys<strong>():\n        <\/strong>print<strong>(<\/strong>i, res<strong>[<\/strong>i<strong>])<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438:<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/proglib.io\/p\/psutil-in-python\/\">https:\/\/proglib.io\/p\/psutil-in-python\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/psutil.readthedocs.io\/en\/latest\/\">https:\/\/psutil.readthedocs.io\/en\/latest\/<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-techarks-ru wp-block-embed-techarks-ru\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"BREL2Yfg4D\"><a href=\"https:\/\/techarks.ru\/qa\/python\/kak-poluchit-informaciyu-o-si-6F\/\">\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441 Python?<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"\u00ab\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441 Python?\u00bb &#8212; TechArks.Ru\" src=\"https:\/\/techarks.ru\/qa\/python\/kak-poluchit-informaciyu-o-si-6F\/embed\/#?secret=QU7N7kbjcU#?secret=BREL2Yfg4D\" data-secret=\"BREL2Yfg4D\" width=\"584\" height=\"329\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>import psutil import datetime import platform def get_system_info(): result = {} # \u041e\u0421 os_platform = platform.system() # \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 processor = platform.processor() result.update({&#8216;platform&#8217;: os_platform, &#8216;processor&#8217;: processor}) # \u0434\u0438\u0441\u043a\u0438 disks = psutil.disk_partitions() for i in disks: try: disk_usage = psutil.disk_usage(i.device) total = &hellip; <a href=\"https:\/\/datadigging.ru\/?p=688\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"footnotes":""},"categories":[1],"tags":[9,16,8,79],"class_list":["post-688","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-python","tag-16","tag-8","tag-79"],"_links":{"self":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts\/688","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=688"}],"version-history":[{"count":5,"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts\/688\/revisions"}],"predecessor-version":[{"id":1492,"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts\/688\/revisions\/1492"}],"wp:attachment":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}