{"id":1365,"date":"2026-01-15T05:49:48","date_gmt":"2026-01-15T05:49:48","guid":{"rendered":"https:\/\/monkey.ploogie.co.uk\/?page_id=1365"},"modified":"2026-01-15T05:52:48","modified_gmt":"2026-01-15T05:52:48","slug":"mwnci-pidstat-function","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-pidstat-function\/","title":{"rendered":"Mwnci pidstat() Function"},"content":{"rendered":"<h2>Syntax<\/h2>\n<p>pidstat<strong>(<em>[string]<\/em>)<\/strong><\/p>\n<h2>Description<\/h2>\n<p>The <i>pidstat()<\/i> function returns a hash keyed on process id&#8217;s containing CPU usage for each process.<\/p>\n<p>If a process name is given, then <i>pidstat()<\/i> will return a hash of processes containing the named process.<\/p>\n<h2>Example<\/h2>\n<pre>include(\"sysstat\")\r\nData=pidstat()\r\nprintln(Data,\"\\n\")\r\nData=pidstat(\"pluma\")\r\nforeach Pid in keys(Data) {\r\n    PidHash=Data[Pid]\r\n    printf(\"Pid %d is running at %.2f%% on CPU %d\\n\", Pid, PidHash[\"pc_cpu\"], PidHash[\"cpu\"])\r\n}\r\n\r\n18: {\"cpu\": 1, \"cmd\": \"rcu_preempt\", \"uid\": 0, \"pc_usr\": 0, \"pc_sys\": 0.02, \"pc_guest\": 0, \"pc_wait\": 0.16, \"pc_cpu\": 0.02}, 1556: {\"pc_sys\": 0, \"pc_guest\": 0, \"pc_wait\": 0, \"pc_cpu\": 0, \"cpu\": 2, \"cmd\": \"\/usr\/libexec\/gvfsd\", \"uid\": 1000, \"pc_usr\": 0}, 349735: {\"pc_cpu\": 0, \"cpu\": 0, \"cmd\": \"kworker\/u17:0-events_unbound\", \"uid\": 0, \"pc_usr\": 0, \"pc_sys\": 0, \"pc_guest\": 0, \"pc_wait\": 0.01}...........}\r\n\r\nPid 353539 is running at 0.00% on CPU 1\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Syntax pidstat([string]) Description The pidstat() function returns a hash keyed on process id&#8217;s containing CPU usage for each process. If a process name is given, then pidstat() will return a hash of processes containing the named process. Example include(&#8220;sysstat&#8221;) Data=pidstat() println(Data,&#8221;\\n&#8221;) Data=pidstat(&#8220;pluma&#8221;) foreach Pid in keys(Data) { PidHash=Data[Pid] printf(&#8220;Pid %d is running at %.2f%% on &hellip; <a href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-pidstat-function\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Mwnci pidstat() Function&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1365","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=1365"}],"version-history":[{"count":3,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1365\/revisions"}],"predecessor-version":[{"id":1368,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1365\/revisions\/1368"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}