Enjoy checking InterSystems IRIS performance with a useful tool ^mypButtons
Tags: beginners, tutorial, programming, performance
Published: 2024-04-14 14:13:00

<h2 data-line="0" dir="auto" id="mypbuttons">[Background]</h2>
<p data-line="4" dir="auto">InterSystems IRIS family has a nice utility&nbsp;<strong>^SystemPerformance</strong>&nbsp;(as known as&nbsp;<strong>^pButtons</strong>&nbsp;in Caché and Ensemble) which outputs the database performance information into a readable HTML file. When you run ^SystemPerformance on IRIS for Windows, a HTML file is created where both our own performance log&nbsp;<em>mgstat</em>&nbsp;and Windows performance log are included.</p>
<p data-line="4" dir="auto"><!--break--><strong>^SystemPeformance</strong> generates a great report, however, you need to extract log sections manually from a HTML file and paste them to a spreadsheet editor like Excel to create a performance visual graph. Many developers already share useful tips and utilities to do it&nbsp;<a data-href="https://community.intersystems.com/post/intersystems-data-platforms-capacity-planning-and-performance-series-index" href="https://community.intersystems.com/post/intersystems-data-platforms-capacity-planning-and-performance-series-index" title="InterSystems Data Platforms Capacity Planning and Performance Series Index">here</a>&nbsp;(This is a Developer Community great article by <span><a href="https://community.intersystems.com/user/murray-oldfield" target="_blank">&nbsp;@Murray.Oldfield</a><span>&nbsp;)</span></span></p>
<p data-line="8" dir="auto">Now I introduce a new utiltiy&nbsp;<strong>^mypButtons</strong>!</p>
<p data-line="8" dir="auto">&nbsp;</p>

<h2 data-line="10" dir="auto" id="whats-new-compared-to-other-tools">[What's new compared to other tools]</h2>
<p dir="auto">Download mypButtons.mac from OpenExchange.</p>

<ul data-line="11" dir="auto">
<li data-line="11" dir="auto"><strong>^mypButtons</strong>&nbsp;combines mgstat and Windows performnace logs in one line. For instance, you can create a graph includes both "PhyWrs" (mgstat) and "Disk Writes/sec" (Win perfmon) in the same time frame.</li>
<li data-line="12" dir="auto"><strong>^mypButtons</strong>&nbsp;reads multiple HTML files at once and generates a single combined CSV file.</li>
<li data-line="13" dir="auto"><strong>^mypButtons</strong>&nbsp;generates a single CSV file into your laptop so it's much easier to crete your graph as you like.</li>
<li data-line="14" dir="auto"><strong>^mypButtons</strong>&nbsp;generates a CSV and it includes columns which I strongly recommend to check as the first step to see the performance of InterSystems product. So everyone can enjoy a peformance graph with this utility so easily!</li>
</ul>
<p data-line="16" dir="auto"><em><strong>Please Note!</strong></em>&nbsp;If you want to play mypButtons.csv, please load SystemPerformance HTML files with <span style="color:#e74c3c;">"every 1 second" profile</span>.</p>

<h1 data-line="18" dir="auto">&nbsp;</h1>
<h2 data-line="18" dir="auto" id="how-to-run">[How to run]</h2>
<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos"><span class="hljs-keyword">do</span> readone<span class="hljs-symbol">^mypButtons</span>(<span class="hljs-string">"C:\temp\dir\myserver_IRIS_20230522_130000_8hours.html"</span>,<span class="hljs-string">"^||naka"</span>)</code></pre>
<p data-line="21" dir="auto">It reads one SystemPerformance HTML file and store the information into a given global. In this sample, it reads&nbsp;<em>myserver_IRIS_20230522_130000_8hours.html</em>&nbsp;and store it into&nbsp;<em>^||naka</em>.</p>

<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos"><span class="hljs-keyword">do</span> readdir<span class="hljs-symbol">^mypButtons</span>(<span class="hljs-string">"C:\temp\dir"</span>,<span class="hljs-string">"^||naka"</span>)</code></pre>
<p data-line="25" dir="auto">It reads all of SystemPerformance HTML files under a given folder and store the information into a given global. In this sample, it reads all HTML files under&nbsp;<em>C:\temp\dir</em>&nbsp;and store it into&nbsp;<em>^||naka</em>.</p>

<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos"><span class="hljs-keyword">do</span> writecsv<span class="hljs-symbol">^mypButtons</span>(<span class="hljs-string">"C:\temp\csv"</span>,<span class="hljs-string">"^||naka"</span>)</code></pre>
<p data-line="29" dir="auto">It generates the following three csv files under a given folder from a given global.</p>

<ul data-line="30" dir="auto">
<li data-line="30" dir="auto">mgstat.csv</li>
<li data-line="31" dir="auto">perfmon.csv</li>
<li data-line="32" dir="auto">mypButtons.csv</li>
</ul>
<p data-line="34" dir="auto">Here, mypButtons.csv includes the following columns by default, which I strongly recommend to check first to see the performance:</p>

<ul data-line="35" dir="auto">
<li data-line="35" dir="auto">mgstat: Glorefs, PhyRds, Gloupds, PhyWrs, WDQsz, WDphase</li>
<li data-line="36" dir="auto">perfmon: Available MBytes, Disk Reads/sec, Disk Writes/sec, % Processor Time</li>
</ul>
<p data-line="38" dir="auto">This utility works for InterSystems IRIS, InterSystems IRIS for Health, Caché and Ensemble for Windows.</p>

<h1 data-line="40" dir="auto">&nbsp;</h1>
<h2 data-line="40" dir="auto" id="example-steps-to-create-your-iris-servers-performance-graph-with-mypbuttons">[Example steps to create your IRIS server's performance graph with ^mypButtons]</h2>
<p data-line="41" dir="auto">(1) First, run ^SystemPerformance to record both our own performance tool&nbsp;<em>mgstat</em>&nbsp;and Windows peformance monitor&nbsp;<em>perfmon</em>. By default, InterSystems IRIS has some profiles so you can enjoy it soon. Try this from IRIS terminal.</p>

<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos"><span class="hljs-built_in">%SYS</span>&gt;&nbsp;<span class="hljs-keyword">do</span> <span class="hljs-symbol">^SystemPerformance</span>
Current log directory: c:\intersystems\iris\mgr\
Windows Perfmon data will be left in raw format.
Available profiles:
　　<span class="hljs-number">1</span> <span class="hljs-number">12</span>hours - <span class="hljs-number">12</span>-hour run sampling every <span class="hljs-number">10</span> seconds
　　<span class="hljs-number">2</span> <span class="hljs-number">24</span>hours - <span class="hljs-number">24</span>-hour run sampling every <span class="hljs-number">10</span> seconds
　　<span class="hljs-number">3</span> <span class="hljs-number">30</span>mins - <span class="hljs-number">30</span>-minute run sampling every <span class="hljs-number">1</span> second
　　<span class="hljs-number">4</span> <span class="hljs-number">4</span>hours - <span class="hljs-number">4</span>-hour run sampling every <span class="hljs-number">5</span> seconds
　　<span class="hljs-number">5</span> <span class="hljs-number">8</span>hours - <span class="hljs-number">8</span>-hour run sampling every <span class="hljs-number">10</span> seconds
　　<span class="hljs-number">6</span> test - <span class="hljs-number">5</span>-minute TEST run sampling every <span class="hljs-number">30</span> seconds
select profile number to run:&nbsp;<span class="hljs-number">3</span></code></pre>
<p data-line="54" dir="auto"><em><strong>Please Note!</strong></em>&nbsp;If you want to play mypButtons.csv, please use "every 1 second" profile. By default, you will see "30 mins" profile which samples every 1 second. If you want to create another profiles, see&nbsp;<a data-href="https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GCM_systemperf" href="https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GCM_systemperf" title="Monitoring Performance Using ^SystemPerformance">our documentation</a>&nbsp;for more details.</p>
<p data-line="56" dir="auto">(2) After sampling, one HTML will be generated under&nbsp;<em>irisdir</em>\mgr, whose name is like&nbsp;<em>JP7320NAKAHASH_IRIS_20231115_100708_30mins.html</em>. Open a generated HTML, and you will see a lot of performance comma separated data under&nbsp;<strong>mgstat</strong>&nbsp;and&nbsp;<strong>perfmon</strong>&nbsp;section.&nbsp;</p>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/guvrjngmq1e2aevn6mhk.png) 
<p data-line="59" dir="auto">(3) Load it with&nbsp;<em>^mypButtons</em>&nbsp;as below.</p>

<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos">USER&gt;&nbsp;<span class="hljs-keyword">do</span> readone<span class="hljs-symbol">^mypButtons</span>(<span class="hljs-string">"C:\InterSystems\IRIS\mgr\JP7320NAKAHASH_IRIS_20231115_100708_30mins.html"</span>,<span class="hljs-string">"^||naka"</span>)</code></pre>
<p data-line="62" dir="auto">This will load HTML in the first parameter and save the performance data into the global in the second parameter.</p>
<p data-line="64" dir="auto">(4) Generate CSV witl&nbsp;<em>^mypButtons</em>&nbsp;as below.</p>

<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos">USER&gt;&nbsp;<span class="hljs-keyword">do</span> writecsv<span class="hljs-symbol">^mypButtons</span>(<span class="hljs-string">"C:\temp"</span>,<span class="hljs-string">"^||naka"</span>)</code></pre>
<p data-line="67" dir="auto">This will output three CSV files under the folder in the first parameter from the global in the second parameter. Open mypButtons.csv in the excel, and you can see mgstat and perfmon is in the same line every second. See this screenshot - yellow highlighted columns are mgstat and blue highlighted columns are perfmon.</p>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pxhzq0its67tvlosq3c.png)

<p data-line="70" dir="auto">(5) Let's create a simple graph from this CSV. It's so easy. Choose column B&nbsp;<em>Time</em>&nbsp;and column C&nbsp;<em>Glorefs</em>, select&nbsp;<em>Insert</em>&nbsp;menu, 2-D Line graphs as below.&nbsp;</p>


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12gbmhtwu6xxmm0ofxjy.png) 

<p data-line="73" dir="auto">This graph will show you "Global Refernce numbers per second" information. Sorry, there were very few activities in my IRIS instance so my sample graph does not excite you, but I do believe this graph from the production server will tell you a lot of useful information!</p>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bbnxo7viesz1tyoxxd3.png) 

<p data-line="76" dir="auto">(6) mypButtons.csv includes selected columns which I think you should check first.&nbsp;<a data-href="https://community.intersystems.com/post/intersystems-data-platforms-capacity-planning-and-performance-series-index" href="https://community.intersystems.com/post/intersystems-data-platforms-capacity-planning-and-performance-series-index" title="https://community.intersystems.com/post/intersystems-data-platforms-capacity-planning-and-performance-series-index">Murray's article series</a>&nbsp;will tell you why these columns are important to see the performance.</p>

<h2 data-line="78" dir="auto">&nbsp;</h2>
<h2 data-line="78" dir="auto" id="edit-mypbuttons-for-reporting-columns">[Edit&nbsp;<strong>^mypButtons</strong>&nbsp;for reporting columns]</h2>
<p data-line="79" dir="auto">If you want to change columns which are reported into mypButtons.csv, please modify writecsv label manually. It reports columns which are defined in this area.&nbsp;</p>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqgqoptlatrkqmqeau5o.png)

<p data-line="79" dir="auto">&nbsp;</p>
<p data-line="79" dir="auto">I hope my article and utility will make you encourage to check the performance of InterSystems IRIS. Happy SystemPeformance&nbsp;&#x1f606;</p>