{"id":528,"date":"2023-10-11T10:05:48","date_gmt":"2023-10-11T10:05:48","guid":{"rendered":"https:\/\/www.aixperts.co.uk\/?p=528"},"modified":"2023-10-11T10:50:36","modified_gmt":"2023-10-11T10:50:36","slug":"graphing-ilcs-in-grafana","status":"publish","type":"post","link":"https:\/\/www.aixperts.co.uk\/?p=528","title":{"rendered":"Graphing ilcs in Grafana"},"content":{"rendered":"\n<p>Graphing of ilcs in AIX is not included in the nimon data output because ilcs comes from the mpstat command and ilcs is not part of the perfstat library that njmon uses.<\/p>\n\n\n\n<p>ilcs is &#8220;Involuntary Logical CPU switches&#8221; and occurs when the LPAR is running on processor time in the shared pool, but is suddenly kicked off the processor due to contention. This seriously hurts performance.<\/p>\n\n\n\n<p>The script below will run mpstat -d in the background and send the data to the &#8216;mpstat&#8217; database and &#8216;mpstat&#8217; measurements table. You will need to adopt this to your environment.<\/p>\n\n\n\n<p>Run as &#8216;python mpstat.py 5 17420&#8217; to get 5 second data points for 24h.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nfrom influxdb import InfluxDBClient     # For InfluxDB connection\nimport subprocess       # For background process piping\nimport re               # For regexp matching\nimport sys              # For reading command line arguments\nimport socket           # For gethostname function\n\n\"\"\"\nProgram name : mpstat.py\n\nSyntax       : mpstat.py {interval} {count}\n\nAuthor       : Henrik Morsing\n\nDate         : 09\/10\/2023\n\nDescription  : Script starts mpstat in the background and\n               Sends ilcs data to the \"mpstat\" database for Grafana,\n               in the \"mpstat\" measurements.\n\n               It sends data with the tag \"cswitch=ilcs\" and\n               parameter \"switches\".\n\n               The interval parameter is in seconds.\n\"\"\"\n\nhost=socket.gethostname()\nserver=&lt;server&gt;\n\n# Load command arguments\ncount = sys.argv&#091;2]\ninterval = sys.argv&#091;1]  # In seconds\n\n# Define the connection string\nconn = InfluxDBClient(host=server, port='8086', username='user', password='password123')\n\n# Define function to run and return mpstat values continuously\ndef mpstat(interval, count):\n    \"\"\"\n    This function calls mpstat to pick out ilcs values.\n    It then returns them via 'yield', which enables the function\n    to continue listening, and returning, mpstat output.\n    \"\"\"\n\n    # Define process handle\n    popen = subprocess.Popen(&#091;\"\/usr\/bin\/mpstat\", \"-d\", str(interval), str(count)], stdout=subprocess.PIPE, universal_newlines=True)\n\n    # Now we can read the output lines from the mpstat function.\n    for line in iter(popen.stdout.readline, \"\"):\n        match = re.search(\"ALL\", line)          # \"match\" becomes true if line contains the word \"ALL\"\n\n        if match:\n            list = line.split() # Split the string line into a list of words\n            ilcs = list&#091;15]     # Field 15 in mpstat output is ilcs\n            yield ilcs          # Return ilcs\n\n    popen.stdout.close()\n\n\n\nfor ilcs in mpstat(interval, count):\n    line = 'mpstat,host=%s,cswitch=ilcs switches=%s' % (host,ilcs)\n    conn.write(&#091;line], {'db': 'mpstat'}, 204, 'line')\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p>The guideline for performance impact is given in Earl Jew&#8217;s POWER VUG presentation &#8216;<strong>Simplest starting tactic for Power10 AIX exploitation V1.2<\/strong>&#8216;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.aixperts.co.uk\/wordpress\/wp-content\/uploads\/2023\/10\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"669\" height=\"110\" src=\"https:\/\/www.aixperts.co.uk\/wordpress\/wp-content\/uploads\/2023\/10\/image.png\" alt=\"\" class=\"wp-image-531\" srcset=\"https:\/\/www.aixperts.co.uk\/wordpress\/wp-content\/uploads\/2023\/10\/image.png 669w, https:\/\/www.aixperts.co.uk\/wordpress\/wp-content\/uploads\/2023\/10\/image-300x49.png 300w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\" \/><\/a><\/figure>\n\n\n\n<p>Relieving the performance impact is done by increasing processor entitlement until the ilcs numbers drop.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Graphing of ilcs in AIX is not included in the nimon data output because ilcs comes from the mpstat command and ilcs is not part of the perfstat library that njmon uses. ilcs is &#8220;Involuntary Logical CPU switches&#8221; and occurs &hellip; <a href=\"https:\/\/www.aixperts.co.uk\/?p=528\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,147,146,148],"tags":[7,182,178,177,141,179,180,181],"class_list":["post-528","post","type-post","status-publish","format-standard","hentry","category-aix","category-ibm-power","category-performance-tuning","category-scripting","tag-aix","tag-ibm-power","tag-ilcs","tag-perfomance","tag-power","tag-processor-pool","tag-processor-switches","tag-shared-processor-pools"],"_links":{"self":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=528"}],"version-history":[{"count":5,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/528\/revisions"}],"predecessor-version":[{"id":534,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/528\/revisions\/534"}],"wp:attachment":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}