{"id":226,"date":"2012-02-03T23:49:47","date_gmt":"2012-02-03T19:49:47","guid":{"rendered":"http:\/\/samara-it.ru\/?p=226"},"modified":"2012-04-06T16:14:04","modified_gmt":"2012-04-06T12:14:04","slug":"%d0%97%d0%b0%d0%b3%d1%80%d1%83%d0%b7%d0%ba%d0%b0-cpu-%d1%87%d0%b5%d1%80%d0%b5%d0%b7-powershell","status":"publish","type":"post","link":"https:\/\/www.samara-it.ru\/?p=226","title":{"rendered":"\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 CPU \u0447\u0435\u0440\u0435\u0437 PowerShell"},"content":{"rendered":"<p><strong>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043f\u0440\u043e PowerShell<\/strong><\/p>\n<p><strong><\/strong>\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0430 PowerShell<\/p>\n<pre lang=\"powershell\" escaped=\"true\">Get-Process<\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre lang=\"dos\" escaped=\"true\">Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName\r\n-------  ------    -----      ----- -----   ------     -- -----------\r\n     72       8     1180         52    42     0,02   1548 armsvc\r\n   1968      10     2248       2592    64     4,92   1104 atieclxx\r\n    118       7     1436        988    33     0,06    816 atiesrxx<\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043e\u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043d\u043e \u0432\u043e\u0442 \u0434\u043e\u0441\u0430\u0434\u0430, \u043e\u043d\u0430 \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 CPU \u0432 %\u00a0 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u00a0 CPU(s). \u0427\u0442\u043e \u0436\u0435 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435? \u0414\u0430\u0432\u0430\u0439 \u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u00a0CPU(s) &#8212; \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a. \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0442.\u0435. \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u00a0 7zFM <strong>\u0432\u0441\u0435\u0433\u043e\u00a0<\/strong>\u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b 0,45 \u0441\u0435\u043a. \u043d\u0430 \u0432\u0441\u0435 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 % ? \u0414\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c 2 \u0437\u0430\u043c\u0435\u0440\u0430, \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043c\u0435\u0440\u0430\u043c\u0438 \u0438 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c. \u0414\u0430\u0432\u0430\u0439 \u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434:<\/p>\n<pre lang=\"powershell\" escaped=\"true\">cls\r\n\r\n#\u0423\u0437\u043d\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u044f\u0434\u0435\u0440\r\n$core = Get-WmiObject -Class Win32_ComputerSystem | Select-Object NumberOfLogicalProcessors\r\n\r\n#\u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043c\u0435\u0440\r\n$data_start = Get-Date\r\n$process_start = Get-Process | Where-Object {$_.Name -contains \"7zFM\"} | Select-Object TotalProcessorTime\r\n\r\n# \"\u041f\u043e\u0441\u043f\u0438\u043c\" \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438 \"\u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c\" \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435\r\nstart-sleep -Seconds 5\r\n\r\n#\u0412\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043c\u0435\u0440\r\n$data_stop = Get-Date\r\n$process_stop = Get-Process | where-Object {$_.Name -contains \"7zFM\"}\r\n\r\n#\u041f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443\r\n$Data_delta = $data_stop.Ticks - $data_start.Ticks\r\n$CPU_delta = $process_stop.TotalProcessorTime.Ticks - $process_start.TotalProcessorTime.Ticks\r\n\r\nif ($Data_delta -gt 0 -and $CPU_delta -gt 0){\r\n    $CPU_Load = ($CPU_delta * 100) \/ ($Data_delta * $core.NumberOfLogicalProcessors)\r\n}else{\r\n    $CPU_Load = 0\r\n}\r\n# \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\r\nWrite-Host $CPU_Load<\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0432 %. \u041f\u0440\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u043e \u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043f\u0440\u043e PowerShell \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0430 PowerShell Get-Process \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442: Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName &#8212;&#8212;- &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212; &#8212;&#8212;&#8212;&#8212; 72 8 1180 52 42 0,02 1548 armsvc 1968 10 2248 2592 64 4,92 1104 atieclxx 118 7 1436 988 33 0,06 816 atiesrxx \u041a\u0430\u043a\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.samara-it.ru\/?p=226\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":306,"comment_status":"close","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,1],"tags":[],"class_list":["post-226","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","category-win"],"_links":{"self":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=226"}],"version-history":[{"count":20,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":342,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts\/226\/revisions\/342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/media\/306"}],"wp:attachment":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}