{"id":4646,"date":"2014-12-02T08:21:26","date_gmt":"2014-12-02T08:21:26","guid":{"rendered":"https:\/\/bodhost.com\/kb\/?p=4646"},"modified":"2026-02-26T14:04:31","modified_gmt":"2026-02-26T14:04:31","slug":"linux-process-cpu-usage-monitoring","status":"publish","type":"post","link":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/","title":{"rendered":"Linux Process CPU Usage Monitoring"},"content":{"rendered":"\n<p><strong>In this tutorial, we will see how to collect CPU usage of a Linux process.<\/strong><\/p>\n\n\n\n<p>The main purpose behind this query is supervision or debugging. It would be convenient if you know how to retrieve the CPU usage of a particular Linux process. It is often noticed people only check overall CPU usage on a machine. But don\u2019t bother to analyze, which process is consuming more CPU time. <\/p>\n\n\n\n<p>Once they start focusing on which process consumes more CPU. Then it will be helpful for them to optimize that process.<\/p>\n\n\n\n<p><strong>So in this tutorial,<\/strong> we will see how to check the usage of specific Linux processes<strong>:<\/strong><\/p>\n\n\n\n<p>There are several old-school ways to retrieve this value, one indeed wants to retrieve CPU usage by a process at them \u201cT\u201d and the second when retrieving a value called \u201cleveled\u201d. That is to say, that will represent an average CPU usage over its total life. <\/p>\n\n\n\n<p>Here, we will see the two methods which are both correct but can respond to situations and contexts.<\/p>\n\n\n\n<p>Note: here we are going to discuss the recovery of this information statically to the integration of the value in a script or an SNMP response metrology for example.<\/p>\n\n\n\n<p><strong>CPU usage at time T from the command line with the top<\/strong><\/p>\n\n\n\n<p>The administrative control \u201ctop\u201d command, which is present by default on most systems, is very useful. Usually, the \u201ctop\u201d command used dynamically. You will see the launch of an array with values that change dynamically based on the activities of each process:<\/p>\n\n\n\n<p>Now, we will look at using the top command statically, particularly you will be asked to show the best of values that can capture over a period of one second, which will be a non-responsive display. <\/p>\n\n\n\n<p>We will also use the optional command \u201c-b\u201d that allows a correct shaping of the output (especially in the case of multiple rows and columns). This is done via the following option to the command \u201ctop\u201d. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">top \u2013n1 \u2013b<\/pre>\n\n\n\n<p>This event will categorize which is to recovered by the name of the search process. For example, if you want to know the CPU consumption of \u201cMySQL\u201d. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">top \u2013n1 \u2013b |grep mysql<\/pre>\n\n\n\n<p><strong>Result<\/strong><\/p>\n\n\n\n<p>We will then search to recover only the value of columns for the CPU usage of each process and sub-process. Using the command \u201ccut\u201d to which we will indicate the range of characters to recover on each line. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">top \u2013n1 \u2013b |grep mysql |cut \u2013c46-49<\/pre>\n\n\n\n<p>This range of characters in the line (here the character from 46 to 49) tuned to your case (the length of the process name specified mainly). With this, we can have several lines (sub-processes), and add the different values. We will also replace commas with \u201cdots\u201d if \u201cbc\u201d doesn&#8217;t wish to process the values.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Note: Use \u201cpaste \u2013sd+ |sed 's\/,\/\\.\/g' |bc\u201d command line in front of \u201ctop \u2013n1 \u2013b |grep mysql |cut \u2013c46-49\u201d (change values according to your needs)<\/pre>\n\n\n\n<p>If the \u201cbc\u201d command is a problem then you must install it; use \u201capt-get install bc\u201d or \u201cyum install bc\u201d. This is a command to add more values.<\/p>\n\n\n\n<p>The command is particularly interesting here, it helps to make several lines that recovered (just the numbers in the column \u201cCPU\u201d in our case). Option \u201c-s\u201d allows this treatment, and option \u201cd\u201d then specifies a separator to be here \u201c+\u201d, which will give us the final transaction.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will see how to collect CPU usage of a Linux process. The main purpose behind this query is supervision or debugging. It would be convenient if&hellip;<\/p>\n<p><a href=\"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/\" class=\"more-link\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[297],"tags":[622,621,518],"class_list":["post-4646","post","type-post","status-publish","format-standard","hentry","category-faq","tag-linux-calculate-cpu-usage","tag-linux-get-cpu-usage","tag-linux-server-management"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Linux Process CPU Usage Monitoring<\/title>\n<meta name=\"description\" content=\"The main purpose behind this query is supervision or debugging. It would be convenient if you know how to retrieve the CPU usage of a particular Linux process.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux Process CPU Usage Monitoring\" \/>\n<meta property=\"og:description\" content=\"The main purpose behind this query is supervision or debugging. It would be convenient if you know how to retrieve the CPU usage of a particular Linux process.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowledge Base - bodHOST\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-02T08:21:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-26T14:04:31+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/c48414ad1536cea20e85282b0737a9f9\"},\"headline\":\"Linux Process CPU Usage Monitoring\",\"datePublished\":\"2014-12-02T08:21:26+00:00\",\"dateModified\":\"2026-02-26T14:04:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/\"},\"wordCount\":529,\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"keywords\":[\"linux calculate cpu usage\",\"linux get cpu usage\",\"linux server management\"],\"articleSection\":[\"FAQs\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/\",\"name\":\"Linux Process CPU Usage Monitoring\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\"},\"datePublished\":\"2014-12-02T08:21:26+00:00\",\"dateModified\":\"2026-02-26T14:04:31+00:00\",\"description\":\"The main purpose behind this query is supervision or debugging. It would be convenient if you know how to retrieve the CPU usage of a particular Linux process.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/linux-process-cpu-usage-monitoring\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"FAQs\",\"item\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/category\\\/faq\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux Process CPU Usage Monitoring\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"alternateName\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"contentUrl\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"width\":240,\"height\":240,\"caption\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\"},\"image\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/c48414ad1536cea20e85282b0737a9f9\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux Process CPU Usage Monitoring","description":"The main purpose behind this query is supervision or debugging. It would be convenient if you know how to retrieve the CPU usage of a particular Linux process.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/","og_locale":"en_US","og_type":"article","og_title":"Linux Process CPU Usage Monitoring","og_description":"The main purpose behind this query is supervision or debugging. It would be convenient if you know how to retrieve the CPU usage of a particular Linux process.","og_url":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/","og_site_name":"Knowledge Base - bodHOST","article_published_time":"2014-12-02T08:21:26+00:00","article_modified_time":"2026-02-26T14:04:31+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/#article","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/"},"author":{"name":"admin","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/c48414ad1536cea20e85282b0737a9f9"},"headline":"Linux Process CPU Usage Monitoring","datePublished":"2014-12-02T08:21:26+00:00","dateModified":"2026-02-26T14:04:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/"},"wordCount":529,"publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"keywords":["linux calculate cpu usage","linux get cpu usage","linux server management"],"articleSection":["FAQs"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/","url":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/","name":"Linux Process CPU Usage Monitoring","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/#website"},"datePublished":"2014-12-02T08:21:26+00:00","dateModified":"2026-02-26T14:04:31+00:00","description":"The main purpose behind this query is supervision or debugging. It would be convenient if you know how to retrieve the CPU usage of a particular Linux process.","breadcrumb":{"@id":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.bodhost.com\/kb\/linux-process-cpu-usage-monitoring\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"FAQs","item":"https:\/\/www.bodhost.com\/kb\/category\/faq\/"},{"@type":"ListItem","position":2,"name":"Linux Process CPU Usage Monitoring"}]},{"@type":"WebSite","@id":"https:\/\/www.bodhost.com\/kb\/#website","url":"https:\/\/www.bodhost.com\/kb\/","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","description":"","publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"alternateName":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bodhost.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.bodhost.com\/kb\/#organization","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","url":"https:\/\/www.bodhost.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","contentUrl":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","width":240,"height":240,"caption":"Web Hosting Knowledge Base | bodHOST Hosting FAQ"},"image":{"@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/c48414ad1536cea20e85282b0737a9f9","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/www.bodhost.com\/kb\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/4646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/comments?post=4646"}],"version-history":[{"count":32,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/4646\/revisions"}],"predecessor-version":[{"id":12178,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/4646\/revisions\/12178"}],"wp:attachment":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/media?parent=4646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/categories?post=4646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/tags?post=4646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}