{"id":772,"date":"2023-04-19T16:54:40","date_gmt":"2023-04-19T16:54:40","guid":{"rendered":"http:\/\/vickistan.com\/?p=772"},"modified":"2024-05-24T16:27:27","modified_gmt":"2024-05-24T16:27:27","slug":"determine-the-number-of-cores-on-a-vm","status":"publish","type":"post","link":"https:\/\/vickistan.com\/?p=772","title":{"rendered":"Determine the Number of Cores on a VM"},"content":{"rendered":"\n<p>Since RedHat\/Ubuntu\/Debian&#8217;s\u00a0<code>\/proc\/cpuinfo<\/code>\u00a0has a separate entry for each CPU core, you can use this command to count them:<br \/><code>cat \/proc\/cpuinfo | grep processor | wc -l<\/code><br \/><br \/>Or do it with the following Python script:<br \/>&#8212;-<br \/>!\/usr\/bin\/env python3<\/p>\n\n\n\n<p>import os<br \/>import psutil<\/p>\n\n\n\n<p>l1, l2, l3 = psutil.getloadavg()<br \/>CPU_use = (l3\/os.cpu_count()) * 100<\/p>\n\n\n\n<p>print(&#8220;CPU_use as computed by psutil.getloadavg: &#8221; + str(CPU_use))<\/p>\n\n\n\n<p>print(&#8220;cpu percent reported by psutil: &#8221; + str(psutil.cpu_percent()))<br \/>print(&#8220;cpu count reported by psutil: &#8221; + str(psutil.cpu_count()))<br \/>print(&#8220;cpu count reported by psutil with logical set to False: &#8221; + str(psutil.cpu_count(logical=False)))<\/p>\n\n\n\n<p>current_process = psutil.Process()<br \/>print(&#8220;cpu percent reported by psutil.Process &#8221; + str(current_process.cpu_percent()))<br \/>&#8212;-<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since RedHat\/Ubuntu\/Debian&#8217;s\u00a0\/proc\/cpuinfo\u00a0has a separate entry for each CPU core, you can use this command to count them:cat \/proc\/cpuinfo | grep processor | wc -l Or do it with the following Python script:&#8212;-!\/usr\/bin\/env python3 import osimport psutil l1, l2, l3 = &hellip; <a href=\"https:\/\/vickistan.com\/?p=772\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-772","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=772"}],"version-history":[{"count":5,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/772\/revisions"}],"predecessor-version":[{"id":859,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/772\/revisions\/859"}],"wp:attachment":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}