<form script="modal.js" stylesheet="ui_simple.css,panel_decoration.css" isVisible="true" version="1.1" theme="dark">
    <label>UI TOP, AIX Processes System Resources statistics</label>
    <description>User Interface for the TOP monitor on AIX Systems</description>

    <fieldset autoRun="false" submitButton="false">

        <input type="time" token="timerange" searchWhenChanged="true">
            <label>Time Range:</label>
            <default>
                <earliest>-24h</earliest>
                <latest>now</latest>
            </default>
            <change>
				<unset token="form.refresh"></unset>
            </change>
        </input>

        <input type="dropdown" token="timefilter" searchWhenChanged="true">
            <label>Time Filtering:</label>
            <choice value="No_Filter">No Filter (24/24, 7/7)</choice>
            <choice value="Day_BusinessDays_8h-19h">Day Business (08h-19h)</choice>
            <choice value="Day_WeekEnd_8h-19h">Day WE (08h-19h)</choice>
            <choice value="Day_AllDays_8h-19h">Day Week (08h-19h)</choice>
            <choice value="Night_BusinessDays_19h-8h">Night Business (19h-08h)</choice>
            <choice value="Night_WeekEnd_19h-8h">Night WE (19h-08h)</choice>
            <choice value="Night_AllDays_19h-8h">Night All Days (19h-08h)</choice>
            <default>No_Filter</default>
        </input>

        <input type="dropdown" token="osfilter" searchWhenChanged="true">
            <label>Filter OS Type:</label>
            <default>AIX</default>
            <prefix>OStype="</prefix>
            <suffix>"</suffix>
            <choice value="">Any OS</choice>
            <choice value="AIX">AIX</choice>
        </input>

        <input id="frameID" type="multiselect" token="frameID" searchWhenChanged="true">
            <label>Frame IDs:</label>
            <!-- Populating Data Model Search -->
            <search base="populate">
                <query>stats count by frameID | dedup frameID | sort 0 frameID</query>
            </search>
            <valuePrefix>frameID=</valuePrefix>
            <delimiter> OR </delimiter>
            <choice value="*">Any</choice>
            <initialValue>*</initialValue>
            <fieldForLabel>frameID</fieldForLabel>
            <fieldForValue>frameID</fieldForValue>
        </input>

        <input type="text" token="host-prefilter" searchWhenChanged="true">
            <label>Optional: Filter hosts populating</label>
            <default>*</default>
        </input>

		<input id="host" type="multiselect" token="host" searchWhenChanged="true">
		    <label>Hosts Selection:</label>
		    <!-- Populating Data Model Search -->
		    <search base="populate">
		        <query>search $frameID$ host=$host-prefilter$
	| stats count by host | dedup host | sort 0 host</query>
		    </search>
		    <valuePrefix>host="</valuePrefix>
		    <valueSuffix>"</valueSuffix>
		    <delimiter> OR </delimiter>
		    <choice value="*">ALL Hosts</choice>
		    <fieldForLabel>host</fieldForLabel>
		    <fieldForValue>host</fieldForValue>
		    <change>
		        <condition>
		            <unset token="form.host_query_input"></unset>
		        </condition>
		    </change>
		</input>

		<!-- hidden form that handles the advanced definition of hosts selection -->

		<input id="host_query_input" type="dropdown" token="host_query" searchWhenChanged="true" depends="$hidden_form$">
		    <label>Hosts Selection:</label>
		    <search base="populate">
		        <query>search $host$ $frameID$
	| stats values(host) as host
	| format | fields - host | rename search as host</query>
		    </search>
		    <selectFirstChoice>true</selectFirstChoice>
		    <fieldForLabel>host</fieldForLabel>
		    <fieldForValue>host</fieldForValue>
		</input>

        <input type="dropdown" token="statsmode" searchWhenChanged="true">
            <label>Select a stats mode:</label>
            <default>max</default>
            <choice value="max">Max</choice>
            <choice value="avg">Avg</choice>
            <choice value="min">Min</choice>
            <choice value="median">Median</choice>
            <choice value="mode">Mode</choice>
            <choice value="range">Range</choice>
        </input>

        <input type="dropdown" token="aggregate_input" searchWhenChanged="true">
            <label>Aggregate:</label>
            <choice value="none">Single Series</choice>
            <choice value="sum">Sum by Time interval</choice>
            <choice value="avg">Average by Time interval</choice>
            <choice value="median">Median by Time interval</choice>
            <choice value="max">Max by Time interval</choice>
            <default>none</default>
            <change>
                <condition value="none">
                    <set token="aggregate">fields *</set>
                    <set token="form.timechart_by">key</set>
                    <set token="form.table_by">host,dimension_Command</set>
                </condition>
                <condition value="sum">
                    <set token="aggregate">stats sum(*) as &quot;*&quot; by _time, dimension_Command | eval host=&quot;aggreg_host&quot;</set>
                    <set token="form.timechart_by">dimension_Command</set>
                    <set token="form.table_by">dimension_Command</set>
                </condition>
                <condition value="avg">
                    <set token="aggregate">stats avg(*) as &quot;*&quot; by _time, dimension_Command | eval host=&quot;aggreg_host&quot;</set>
                    <set token="form.timechart_by">dimension_Command</set>
                    <set token="form.table_by">dimension_Command</set>
                </condition>
                <condition value="median">
                    <set token="aggregate">stats median(*) as &quot;*&quot; by _time, dimension_Command | eval host=&quot;aggreg_host&quot;</set>
                    <set token="form.timechart_by">dimension_Command</set>
                    <set token="form.table_by">dimension_Command</set>
                </condition>
                <condition value="max">
                    <set token="aggregate">stats max(*) as &quot;*&quot; by _time, dimension_Command | eval host=&quot;aggreg_host&quot;</set>
                    <set token="form.timechart_by">dimension_Command</set>
                    <set token="form.table_by">dimension_Command</set>
                </condition>
            </change>
        </input>

        <input type="dropdown" token="refresh" searchWhenChanged="true">
            <label>Auto-refresh:</label>
            <fieldForLabel>label</fieldForLabel>
            <fieldForValue>value</fieldForValue>
            <selectFirstChoice>true</selectFirstChoice>
            <search>
                <query>| `def_auto_refresh`</query>
                <earliest>$timerange.earliest$</earliest>
                <latest>$timerange.latest$</latest>
            </search>
        </input>

    </fieldset>

    <!-- Base Searches for PostProcessing -->

    <search id="populate">
        <query>| mcatalog values(metric_name) where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.*" $osfilter$ by host
| `mapping_frameID`
| stats count by frameID, host | sort 0 host</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
    </search>

    <search id="populate_command">
        <query>| mcatalog values(dimension_Command) as commands where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.*" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host
| rename commands as dimension_Command
| stats count by dimension_Command</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
    </search>

    <!--
    Dynamic configuration
    The following searches are being used to define various tokens using event handlers
    -->

    <!-- Help the user -->

    <row rejects="$host$">
        <panel>
            <html>
                <div class="red_help_user">
                    <p>- - - - - - - - - - ACTION REQUIRED: please select your server name(s) in the host selector above - - - - - - - - - -</p>
                </div>
            </html>
        </panel>
    </row>

    <!-- Information panel -->

    <row>
        <panel>
            <html>

                <div class="imgheader custom-modal">
                    <img src="../../static/app/metricator-for-nmon/icons/dark_theme/info.png" alt="Info"/>
                    <h4><a data-modal-name="Help_modal">Help, information and related links for TOP statistics</a></h4>
                </div>

                <!-- Modal -->
                <div class="modal custom-modal-60 fade" id="Help_modal" tabindex="-1" role="dialog" aria-labelledby="Help_modal_Label">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"></span></button>
                                <div style="text-align: left;">
                                    <h4 class="modal-title" id="Help_modal_Label">Integrated Navigation:</h4>
                                </div>
                            </div>
                            <div class="modal-body">

                                <div style="text-align: center;">
                                    <img src="../../static/app/metricator-for-nmon/icons/dark_theme/process.png" alt="CPU"/>
                                    <h1>Processes statistics (metric_name=os.unix.nmon.processes.top.*)
                                    </h1>
                                </div>

                                <div>
                                    The TOP monitor captures processes statistics for system resources metrics such as CPU, memory and more.
                                    <br />
                                    This section is available in any supported operating systems, but some metrics are specifics for some systems.
                                    <br />
                                    The <b>UARG monitor</b> is associated with the TOP monitor as it will capture the full list of processes arguments.
                                    <br />
                                    Processes statistics are generated at the PID level for a given "Command" invocation, as such, calculation will aggregate statistics of all PIDs for that given Command.
                                </div>

                                <div style="text-align: left;">

                                    <h1>raw metrics and dimensions:</h1>

                                    <div class="list">
                                        <lu>
                                            <li><b>dimension_Command:</b> The name of the global command that generated the process</li>
                                            <li><b>dimension_PID:</b> The PID number of the process</li>
                                            <li><b>pct_CPU:</b> (%) average amount of CPU used by this process</li>
                                            <li><b>pct_Usr:</b> (%) average amount of user-mode CPU used by this process</li>
                                            <li><b>pct_Sys:</b> (%) average amount of kernel-mode CPU used by this process</li>
                                        </lu>
                                    </div>

                                    <div class="list">
                                        <lu>
                                            <li><b>Size:</b> The size of the pages in kilobytes.</li>
                                            <li><b>ResSet:</b> The sum of real-memory data used by the process</li>
                                            <li><b>ResText:</b> The real-memory text size of the process.</li>
                                            <li><b>ResData:</b> The real-memory data size of the process.</li>
                                            <br />
                                        </lu>
                                    </div>

                                </div>

                                <div style="text-align:left;">
                                    <h1>Related links:</h1>
                                </div>

                                <div style="text-align: center;" class="cat_title">

                                    <a target="_blank" href="search?q=%7C%20mcatalog%20values(metric_name)%20as%20metrics%20where%20%60nmon_metrics_index%60%20metric_name%3D&quot;os.unix.nmon.processes.top.*&quot;%20host%3D&quot;*&quot;" class="tryitbtnxl">mcatalog »
                                    </a>

                                    <a target="_blank" href="search?q=%7C%20mstats%20avg(_value)%20as%20value%20where%20%60nmon_metrics_index%60%20metric_name%3Dos.unix.nmon.processes.top.*%20host%3D*%20dimension_Command%3D*%20dimension_PID%3D*%20by%20metric_name%2C%20host%20span%3D1m" class="tryitbtnxl">mstats raw query»
                                    </a>

                                    <a target="_blank" href="search?q=%7C%20mstats%20sum(_value)%20as%20pct_CPU%20where%20%60nmon_metrics_index%60%20metric_name%3Dos.unix.nmon.processes.top.pct_CPU%20host%3D*%20dimension_Command%3D*%20by%20dimension_Command%20span%3D1m%0A%7C%20eval%20usage_per_core%3D(pct_CPU%2F100)%0A%7C%20timechart%20%60nmon_span%60%20useother%3Df%20limit%3D50%20max(usage_per_core)%20as%20usage_per_core%20by%20dimension_Command" class="tryitbtnxl">mstats pre-built query »
                                    </a>

                                    <a target="_blank" href="Howto_TOP_spl" class="tryitbtnxl">HOWTO Interface »
                                    </a>

                                    <a target="_blank" href="UI_data_dictionary?&amp;form.itemfilter=PROCESSES%20STATISTICS" class="tryitbtnxl">Processes Data Dictionary »
                                    </a>

                                    <a target="_blank" href="Dashboard_Bubblechart_top_processes?form.osfilter=Linux" class="tryitbtnxl">Bubblechart dashboard »
                                    </a>

                                </div>

                                <div style="text-align:left;">
                                    <h1>Related metrics:</h1>
                                </div>

                                <div style="text-align: center;" class="cat_title">

                                    <a target="_blank" href="search?q=%7C%20mstats%20avg(_value)%20as%20value%20where%20%60nmon_metrics_index%60%20metric_name%3Dos.unix.nmon.cpu.cpu_all.*%20host%3D*%20by%20metric_name%2C%20host%20span%3D1m" class="tryitbtnxl">os.unix.nmon.cpu.cpu_all.* »
                                    </a>

                                    <a target="_blank" href="search?q=%7C%20mstats%20avg(_value)%20as%20value%20where%20%60nmon_metrics_index%60%20metric_name%3Dos.unix.nmon.cpu.cpunn.*%20host%3D*%20by%20metric_name%2C%20host%20span%3D1m" class="tryitbtnxl">os.unix.nmon.cpu.cpunn.* »
                                    </a>

                                    <a target="_blank" href="search?q=search%20eventtype%3Dnmon%3Aevents%20type%3DUARG" class="tryitbtnxl">UARG events »
                                    </a>

                                </div>

                            </div>

                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                            </div>

                        </div>
                    </div>
                </div>

            </html>
        </panel>
    </row>

    <row>
        <panel>

        <title>Processes filtering:</title>

            <input type="text" token="Command" searchWhenChanged="true">
                <label>Optional: Filter by Command</label>
                <default>*</default>
            </input>

            <input type="text" token="PID" searchWhenChanged="true">
                <label>Optional: Filter by PIDs</label>
                <default>*</default>
            </input>

            <input type="multiselect" token="Command_multiselect" searchWhenChanged="true">
                <label>Command(s):</label>
                <search base="populate_command">
                    <query>sort 0 dimension_Command</query>
                </search>
                <iniialValue>*</iniialValue>
                <valuePrefix>dimension_Command="</valuePrefix>
                <valueSuffix>"</valueSuffix>
                <delimiter> OR </delimiter>
                <choice value="*">Any</choice>
                <fieldForLabel>dimension_Command</fieldForLabel>
                <fieldForValue>dimension_Command</fieldForValue>
            </input>

        </panel>
    </row>

    <row>
        <panel id="settings">
            <title>Charting parameters</title>
            <input type="dropdown" token="chart" searchWhenChanged="true">
                <label>Select a type of chart:</label>
                <default>area</default>
                <choice value="area">Area</choice>
                <choice value="line">Line</choice>
                <choice value="column">Column</choice>
                <choice value="bar">Bar</choice>
            </input>
            <input type="dropdown" token="charting.chart.nullValueMode" searchWhenChanged="true">
                <label>Missing Data:</label>
                <default>zero</default>
                <choice value="gaps">Gaps</choice>
                <choice value="connect">Connect</choice>
                <choice value="zero">Zero</choice>
            </input>
            <input type="dropdown" token="chart.stackingmode" searchWhenChanged="true">
                <label>Select a stacking mode:</label>
                <default>stacked</default>
                <choice value="stacked">stacked (lines excluded)</choice>
                <choice value="stacked100">100% stacked (lines excluded)</choice>
                <choice value="unstacked">unstacked</choice>
            </input>
            <input type="dropdown" token="charting.legend.placement" searchWhenChanged="true">
                <label>Legend placement:</label>
                <default>bottom</default>
                <choice value="bottom">Bottom</choice>
                <choice value="top">Top</choice>
                <choice value="left">left</choice>
                <choice value="right">right</choice>
                <choice value="none">none</choice>
            </input>
            <input type="dropdown" token="span" searchWhenChanged="true">
                <label>Span:</label>
                <default>`nmon_span`</default>
                <choice value="`nmon_span`">auto</choice>
                <choice value="span=1m">1 minute</choice>
                <choice value="span=2m">2 minutes</choice>
                <choice value="span=3m">3 minutes</choice>
                <choice value="span=4m">4 minutes</choice>
                <choice value="span=5m">5 minutes</choice>
                <choice value="span=10m">10 minutes</choice>
                <choice value="span=15m">15 minutes</choice>
                <choice value="span=30m">30 minutes</choice>
                <choice value="span=1h">1 hour</choice>
                <choice value="span=2h">2 hours</choice>
                <choice value="span=12h">12 hours</choice>
                <choice value="span=4h">4 hours</choice>
                <choice value="span=1d">1 day</choice>
                <choice value="span=2d">2 days</choice>
                <choice value="span=1w">7 days</choice>
                <choice value="span=1mon">1 month</choice>
            </input>
        </panel>
    </row>

    <row>
        <panel id="process">
            <title>Active drilldown: click on a command invocation to get detailed PIDs statistics of that command (may be truncated with large number of PIDs)</title>

            <input type="text" token="valuefilter" searchWhenChanged="true" depends="$top_chart1$">
                <label>Filter values:</label>
                <default>usage_per_core>0</default>
            </input>

            <input type="text" token="limit" searchWhenChanged="true">
                <label>Max series:</label>
                <default>50</default>
                <prefix>limit=</prefix>
            </input>

            <input type="dropdown" token="timechart_by" searchWhenChanged="true">
                <label>group by statement:</label>
                <default>key</default>
                <choice value="key">host:Command</choice>
                <choice value="dimension_Command">Command</choice>
            </input>

            <input type="link" token="top_linkinput">
                <label></label>
                <choice value="top_chart1">CPU Usage per logical core</choice>
                <choice value="top_chart2">Memory Usage per command invocation</choice>
                <choice value="top_chart3">Read / Write System Calls</choice>
                <choice value="top_chart4">Paging, Sum of page faults</choice>
                <choice value="top_chart5">Threads per Command invocation</choice>
                <choice value="uarg">UARG: commands arguments</choice>
                <default>top_chart1</default>
                <change>
                    <condition value="top_chart1">
                        <set token="top_chart1">true</set>
                        <unset token="top_chart2"></unset>
                        <unset token="top_chart3"></unset>
                        <unset token="top_chart4"></unset>
                        <unset token="top_chart5"></unset>
                        <unset token="uarg"></unset>
                    </condition>
                    <condition value="top_chart2">
                        <set token="top_chart2">true</set>
                        <unset token="top_chart1"></unset>
                        <unset token="top_chart3"></unset>
                        <unset token="top_chart4"></unset>
                        <unset token="top_chart5"></unset>
                        <unset token="uarg"></unset>
                    </condition>
                    <condition value="top_chart3">
                        <set token="top_chart3">true</set>
                        <unset token="top_chart2"></unset>
                        <unset token="top_chart1"></unset>
                        <unset token="top_chart4"></unset>
                        <unset token="top_chart5"></unset>
                        <unset token="uarg"></unset>
                    </condition>
                    <condition value="top_chart4">
                        <set token="top_chart4">true</set>
                        <unset token="top_chart2"></unset>
                        <unset token="top_chart3"></unset>
                        <unset token="top_chart1"></unset>
                        <unset token="top_chart5"></unset>
                        <unset token="uarg"></unset>
                    </condition>
                    <condition value="top_chart5">
                        <set token="top_chart5">true</set>
                        <unset token="top_chart2"></unset>
                        <unset token="top_chart3"></unset>
                        <unset token="top_chart4"></unset>
                        <unset token="top_chart1"></unset>
                        <unset token="uarg"></unset>
                    </condition>
                    <condition value="uarg">
                        <set token="uarg">true</set>
                        <unset token="top_chart1"></unset>
                        <unset token="top_chart2"></unset>
                        <unset token="top_chart3"></unset>
                        <unset token="top_chart4"></unset>
                        <unset token="top_chart5"></unset>
                    </condition>
                </change>
            </input>

            <chart depends="$top_chart1$">
                <title></title>
                <search depends="$top_chart1$">
                    <query>| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.pct_CPU" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| stats sum(value) as pct_CPU by _time, host, dimension_Command
| eval usage_per_core=(pct_CPU/100)
| lookup nmon_inventory hostname as host OUTPUT AIX_logicalcores as logical_cpus, AIX_virtualcpus as virtual_cpus
| eval usage_per_core=(pct_CPU/100), smt_threads=(logical_cpus/virtual_cpus)
| eval usage_per_core=case(isnum(smt_threads) AND smt_threads&gt;="2", usage_per_core*1.2, isnum(smt_threads) AND smt_threads&gt;="4", usage_per_core*1.4, isnum(usage_per_core), usage_per_core)
| fields _time, host,dimension_Command,usage_per_core
| $aggregate$
| where ($valuefilter$)
| eval key=host . ":" . dimension_Command
| timechart $span$ $limit$ useother=f $statsmode$(usage_per_core) as "CPU Usage per core" by $timechart_by$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="charting.axisTitleX.visibility">visible</option>
                <option name="charting.axisTitleY.visibility">visible</option>
                <option name="charting.axisX.scale">linear</option>
                <option name="charting.axisY.scale">linear</option>
                <option name="charting.chart">$chart$</option>
                <option name="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">$chart.stackingmode$</option>
                <option name="charting.chart.style">shiny</option>
                <option name="charting.drilldown">all</option>
                <option name="charting.layout.splitSeries">0</option>
                <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
                <option name="charting.legend.placement">$charting.legend.placement$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisY.minimumNumber">0</option>
                <option name="charting.axisTitleY.text">Logical Core</option>
                <option name="refresh.display">none</option>
                <drilldown target="search">
                    <link>
                        <![CDATA[
                            search?&earliest=$earliest$&latest=$latest$&q=| mstats max(_value) as pct_CPU where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.pct_CPU" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| eval usage_per_core=(pct_CPU/100)
| lookup nmon_inventory hostname as host OUTPUT AIX_logicalcores as logical_cpus, AIX_virtualcpus as virtual_cpus
| eval usage_per_core=(pct_CPU/100), smt_threads=(logical_cpus/virtual_cpus)
| eval usage_per_core=case(isnum(smt_threads) AND smt_threads&gt;="2", usage_per_core*1.2, isnum(smt_threads) AND smt_threads&gt;="4", usage_per_core*1.4, isnum(usage_per_core), usage_per_core)
| fields _time, host,dimension_Command,usage_per_core
| $aggregate$
| where ($valuefilter$)
| eval key=host . ":" . dimension_Command . ":" . dimension_PID
| timechart $span$ limit=0 useother=f $statsmode$(usage_per_core) as "CPU Usage per core" by key | rename "aggreg:*" AS "*" | fields _time,$click.name2$*&display.page.search.tab=visualizations&display.general.type=visualizations&display.visualizations.charting.chart=column&display.visualizations.charting.chart.stackMode=stacked
                        ]]>
                    </link>
                </drilldown>
            </chart>

            <chart depends="$top_chart2$">
                <title></title>
                <search depends="$top_chart2$">
                    <query>| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.ResSet" OR metric_name="os.unix.nmon.processes.top.ResData" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| stats sum(value) as value by _time, host, dimension_Command
| eval Used_Mem_MB=((value)/1024)
| $aggregate$
| eval key=host . ":" . dimension_Command
| timechart $span$ $limit$ useother=f $statsmode$(Used_Mem_MB) as "memory usage (MB)" by $timechart_by$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="charting.axisTitleX.visibility">visible</option>
                <option name="charting.axisTitleY.visibility">visible</option>
                <option name="charting.axisX.scale">linear</option>
                <option name="charting.axisY.scale">linear</option>
                <option name="charting.chart">$chart$</option>
                <option name="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">$chart.stackingmode$</option>
                <option name="charting.chart.style">shiny</option>
                <option name="charting.drilldown">all</option>
                <option name="charting.layout.splitSeries">0</option>
                <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
                <option name="charting.legend.placement">$charting.legend.placement$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisY.minimumNumber">0</option>
                <option name="charting.axisTitleY.text">Megabytes (MB)</option>
                <option name="refresh.display">none</option>
                <drilldown target="search">
                    <link>
                        <![CDATA[
                            search?&earliest=$earliest$&latest=$latest$&q=| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.ResSet" OR metric_name="os.unix.nmon.processes.top.ResData" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| eval Used_Mem_MB=((value)/1024)
| $aggregate$
| eval key=host . ":" . dimension_Command . ":" . dimension_PID
| timechart $span$ limit=0 useother=f $statsmode$(Used_Mem_MB) as "memory usage (MB)" by $timechart_by$ | rename "aggreg:*" AS "*" | fields _time,$click.name2$*&display.page.search.tab=visualizations&display.general.type=visualizations&display.visualizations.charting.chart=column&display.visualizations.charting.chart.stackMode=stacked
                        ]]>
                    </link>
                </drilldown>
            </chart>

            <chart depends="$top_chart3$">
                <title></title>
                <search depends="$top_chart3$">
                    <query>| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.CharIO" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| stats sum(value) as value by _time, host, dimension_Command
| $aggregate$
| eval key=host . ":" . dimension_Command . ":"
| timechart $span$ $limit$ useother=f $statsmode$(value) as "CharIO" by $timechart_by$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="charting.axisTitleX.visibility">visible</option>
                <option name="charting.axisTitleY.visibility">visible</option>
                <option name="charting.axisX.scale">linear</option>
                <option name="charting.axisY.scale">linear</option>
                <option name="charting.chart">$chart$</option>
                <option name="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">$chart.stackingmode$</option>
                <option name="charting.chart.style">shiny</option>
                <option name="charting.drilldown">all</option>
                <option name="charting.layout.splitSeries">0</option>
                <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
                <option name="charting.legend.placement">$charting.legend.placement$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisY.minimumNumber">0</option>
                <option name="charting.axisTitleY.text">Megabytes (MB)</option>
                <option name="refresh.display">none</option>
                <drilldown target="search">
                    <link>
                        <![CDATA[
                            search?&earliest=$earliest$&latest=$latest$&q=| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.CharIO" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by dimension_Command dimension_PID span=1m
| $aggregate$
| eval key=host . ":" . dimension_Command . ":" . dimension_PID
| timechart $span$ limit=0 useother=f $statsmode$(value) as "CharIO" by $timechart_by$ | rename "aggreg:*" AS "*" | fields _time,$click.name2$*&display.page.search.tab=visualizations&display.general.type=visualizations&display.visualizations.charting.chart=column&display.visualizations.charting.chart.stackMode=stacked
                        ]]>
                    </link>
                </drilldown>
            </chart>

            <chart depends="$top_chart4$">
                <title></title>
                <search depends="$top_chart4$">
                    <query>| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.Paging" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| stats sum(value) as value by _time, host, dimension_Command
| $aggregate$
| eval key=host . ":" . dimension_Command
| timechart $span$ $limit$ useother=f $statsmode$(value) as Paging by $timechart_by$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="charting.axisTitleX.visibility">visible</option>
                <option name="charting.axisTitleY.visibility">visible</option>
                <option name="charting.axisX.scale">linear</option>
                <option name="charting.axisY.scale">linear</option>
                <option name="charting.chart">$chart$</option>
                <option name="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">$chart.stackingmode$</option>
                <option name="charting.chart.style">shiny</option>
                <option name="charting.drilldown">all</option>
                <option name="charting.layout.splitSeries">0</option>
                <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
                <option name="charting.legend.placement">$charting.legend.placement$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisY.minimumNumber">0</option>
                <option name="charting.axisTitleY.text">Pages/sec</option>
                <option name="refresh.display">none</option>
                <drilldown target="search">
                    <link>
                        <![CDATA[
                            search?&earliest=$earliest$&latest=$latest$&q=| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.Paging" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| $aggregate$
| eval key=host . ":" . dimension_Command . ":" . dimension_PID
| timechart $span$ limit=0 useother=f $statsmode$(value) as Paging by $timechart_by$ | rename "aggreg:*" AS "*" | fields _time,$click.name2$*
| fields _time,$click.name2$*&display.page.search.tab=visualizations&display.general.type=visualizations&display.visualizations.charting.chart=column&display.visualizations.charting.chart.stackMode=stacked
                        ]]>
                    </link>
                </drilldown>
            </chart>

            <chart depends="$top_chart5$">
                <title></title>
                <search depends="$top_chart5$">
                    <query>| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.Threads" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| stats sum(value) as value by _time, host, dimension_Command
| $aggregate$
| eval key=host . ":" . dimension_Command
| timechart $span$ $limit$ useother=f $statsmode$(value) as Threads by $timechart_by$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="charting.axisTitleX.visibility">visible</option>
                <option name="charting.axisTitleY.visibility">visible</option>
                <option name="charting.axisX.scale">linear</option>
                <option name="charting.axisY.scale">linear</option>
                <option name="charting.chart">$chart$</option>
                <option name="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">$chart.stackingmode$</option>
                <option name="charting.chart.style">shiny</option>
                <option name="charting.drilldown">all</option>
                <option name="charting.layout.splitSeries">0</option>
                <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
                <option name="charting.legend.placement">$charting.legend.placement$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisY.minimumNumber">0</option>
                <option name="charting.axisTitleY.text">Pages/sec</option>
                <option name="refresh.display">none</option>
                <drilldown target="search">
                    <link>
                        <![CDATA[
                            search?&earliest=$earliest$&latest=$latest$&q=| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.Threads" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host dimension_Command dimension_PID span=1m
| $aggregate$
| eval key=host . ":" . dimension_Command . ":" . dimension_PID
| timechart $span$ limit=0 useother=f $statsmode$(value) as Threads by $timechart_by$ | rename "aggreg:*" AS "*" | fields _time,$click.name2$*&display.page.search.tab=visualizations&display.general.type=visualizations&display.visualizations.charting.chart=column&display.visualizations.charting.chart.stackMode=stacked
                        ]]>
                    </link>
                </drilldown>
            </chart>

            <input type="text" token="Command" depends="$uarg$" searchWhenChanged="true">
                <label>Optional: Filter by Command</label>
                <default>*</default>
            </input>

            <input type="text" token="PID" depends="$uarg$" searchWhenChanged="true">
                <label>Optional: Filter by PIDs</label>
                <default>*</default>
            </input>

            <input type="multiselect" token="Command_multiselect" depends="$uarg$" searchWhenChanged="true">
                <label>Command(s):</label>
                <search base="populate_command">
                    <query>sort 0 dimension_Command</query>
                </search>
                <initialValue>*</initialValue>
                <valuePrefix>COMM="</valuePrefix>
                <valueSuffix>"</valueSuffix>
                <delimiter> OR </delimiter>
                <choice value="*">Any</choice>
                <fieldForLabel>dimension_Command</fieldForLabel>
                <fieldForValue>dimension_Command</fieldForValue>
            </input>

            <event depends="$uarg$">
                <title></title>
                <search depends="$uarg$">
                    <query>eventtype=nmon:events type=UARG host=$host-prefilter$ $host_query$ ($frameID$) (COMM=$Command$) (PID=$PID$)</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="count">10</option>
                <option name="list.drilldown">full</option>
                <option name="list.wrap">1</option>
                <option name="maxLines">0</option>
                <option name="raw.drilldown">full</option>
                <option name="rowNumbers">0</option>
                <option name="table.drilldown">1</option>
                <option name="table.wrap">1</option>
                <option name="type">list</option>
                <option name="refresh.display">none</option>
                <fields>[]</fields>
            </event>

        </panel>

    </row>

    <search id="uarg_definition">
        <query>search metric_name=$metric_name$</query>
        <progress>
            <condition>
                <set token="metric_filter">$result.metric_filter$</set>
                <set token="metric_calculation">$result.metric_calculation$</set>
                <set token="metric_has_device">$result.metric_has_device$</set>
                <set token="metric_dimension_field">$result.metric_dimension_field$</set>
                <set token="metric_shortname">$result.metric_shortname$</set>
                <set token="metric_data_field">$result.metric_data_field$</set>
                <set token="metric_primary_statsmode">$result.metric_primary_statsmode$</set>
                <set token="metric_by">$result.metric_by$</set>
                <set token="metric_timechart_by">$result.metric_timechart_by$</set>
                <set token="metric_volume_unit_choice">$result.metric_volume_unit_choice$</set>
                <set token="metric_rate_unit_choice">$result.metric_rate_unit_choice$</set>
                <set token="form.chart">$result.metric_charting_chart$</set>
                <set token="form.chart.stackingmode">$result.metric_charting_stackmode$</set>
            </condition>
        </progress>
    </search>


    <row>
        <panel>
            <input type="dropdown" token="table_by" searchWhenChanged="true">
                <label>group by statement:</label>
                <default>host,dimension_Command</default>
                <choice value="host,dimension_Command">host:Command</choice>
                <choice value="dimension_Command">Command</choice>
            </input>
            <table>
                <title>Table stats: CPU Usage per logical core</title>
                <search>
                    <query>| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.pct_CPU" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host, dimension_Command, dimension_PID span=1m
| stats sum(value) as pct_CPU by _time, host, dimension_Command
| $aggregate$
| eval usage_per_core=(pct_CPU/100)
| stats $statsmode$(usage_per_core) as "CPU Usage per Logical Cores", sparkline($statsmode$(usage_per_core)) As sparkline by $table_by$
| rename dimension_Command as Command
| eval "CPU Usage per Logical Cores"=round('CPU Usage per Logical Cores', 3)
| sort - "CPU Usage per Logical Cores"</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">cell</option>
                <option name="count">10</option>
                <option name="refresh.display">none</option>
                <option name="percentagesRow">false</option>
                <!-- Set sparkline options here; make sure that field matches field name of the search results -->
                <format type="sparkline" field="sparkline">
                    <option name="lineColor">#5379af</option>
                    <option name="fillColor">#CCDDFF</option>
                    <option name="lineWidth">1</option>
                    <option name="height">25</option>
                </format>
                <format type="color" field="CPU Usage per Logical Cores">
                    <colorPalette type="minMidMax" maxColor="#31A35F" minColor="#353535"></colorPalette>
                    <scale type="minMidMax"></scale>
                </format>
            </table>
        </panel>
        <panel>
            <input type="dropdown" token="table_by" searchWhenChanged="true">
                <label>group by statement:</label>
                <default>host,dimension_Command</default>
                <choice value="host,dimension_Command">host:Command</choice>
                <choice value="dimension_Command">Command</choice>
            </input>
            <table>
                <title>Table stats: Memory Usage per command invocation</title>
                <search>
                    <query>| mstats max(_value) as value where `nmon_metrics_index` metric_name="os.unix.nmon.processes.top.ResSet" OR metric_name="os.unix.nmon.processes.top.ResData" host=$host-prefilter$ $host_query$ (dimension_Command=$Command$) (dimension_PID=$PID$) by host, dimension_Command, dimension_PID span=1m
| stats sum(value) as value by _time, host, dimension_Command
| eval Used_Mem_MB=((value)/1024)
| stats sum(Used_Mem_MB) As Used_Mem_MB by _time, host, dimension_Command
| $aggregate$
| stats $statsmode$(Used_Mem_MB) as "Used Memory per Command (MB)", sparkline($statsmode$(Used_Mem_MB)) as sparkline by $table_by$
| rename dimension_Command as Command
| eval "Used Memory per Command (MB)"=round('Used Memory per Command (MB)', 3)
| sort - "Used Memory per Command (MB)"</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                    <refresh>$refresh$</refresh>
                    <refreshType>delay</refreshType>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">cell</option>
                <option name="count">10</option>
                <option name="refresh.display">none</option>
                <option name="percentagesRow">false</option>
                <!-- Set sparkline options here; make sure that field matches field name of the search results -->
                <format type="sparkline" field="sparkline">
                    <option name="lineColor">#5379af</option>
                    <option name="fillColor">#CCDDFF</option>
                    <option name="lineWidth">1</option>
                    <option name="height">25</option>
                </format>
                <format type="color" field="Used Memory per Command (MB)">
                    <colorPalette type="minMidMax" maxColor="#31A35F" minColor="#353535"></colorPalette>
                    <scale type="minMidMax"></scale>
                </format>
            </table>
        </panel>
    </row>
</form>
