<form script="modal.js" stylesheet="ui_simple.css,panel_decoration.css" isVisible="true" version="1.1" theme="dark">
    <label>UI UARG, Search Commands Arguments</label>
    <description>User Interface for the UARG data on Linux systems</description>

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

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

        <input type="dropdown" token="osfilter" searchWhenChanged="true">
            <label>Filter OS Type:</label>
            <default>Linux</default>
            <choice value="*">Any OS</choice>
            <choice value="Linux">Linux</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="text" token="ProgName" searchWhenChanged="true">
            <label>Optional: Filter Command name</label>
            <prefix>ProgName="</prefix>
            <suffix>"</suffix>
            <default>*</default>
        </input>

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

        <input type="text" token="FullCommand" searchWhenChanged="true">
            <label>Optional: Filter FullCommand</label>
            <prefix>FullCommand="</prefix>
            <suffix>"</suffix>
            <default>*</default>
        </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>

    <!--
    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 UARG data</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 full arguments (UARG)</h1>
                                </div>

                                <div>
                                    <br />
                                    The UARG monitor captures the full argument line of processes on a per PID level, it is highly related to the TOP monitor which contains performance metrics for theses processes.
                                    <br />
                                </div>

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

                                    <h1>Main fields:</h1>

                                    <div class="list">
                                        <lu>
                                            <li><b>PID:</b> The PID number of the process</li>
                                            <li><b>ProgName:</b> The name of the main command invocation. (equivalent to Command in TOP data)</li>
                                            <li><b>FullCommand:</b> List of arguments that were associated with this PID</li>
                                        </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=search%20eventtype%3Dnmon:performance:process%20type%3DUARG%20OStype%3DLinux" class="tryitbtnxl">Explore RAW DATA »
                                    </a>

                                    <a target="_blank" href="Howto_TOP_spl" class="tryitbtnxl">HOWTO Interface for TOP »
                                    </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.processes.top.*%20host%3D*%20by%20metric_name%2C%20host%2C%20dimension_Command%20span%3D1m" class="tryitbtnxl">os.unix.nmon.processes.top.* »
                                    </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>

    <!-- Base Searches for PostProcessing -->

    <search id="populate">
        <query>| tstats count where `nmon_events_index` type=UARG OStype=$osfilter$ by host
| `mapping_frameID`
| stats count by frameID, host | sort 0 host</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
    </search>

    <row>
        <panel id="process">
            <title>Commands arguments</title>
            <input type="text" token="customsearch">
                <label>Search for a pattern (Will be highlighted):</label>
                <default/>
                <suffix>*</suffix>
            </input>
            <event>
                <title>Events:</title>
                <search>
                    <query>eventtype=nmon:events type=UARG $frameID$ host=$host-prefilter$ $host_query$ $ProgName$ $PID$ $FullCommand$ | search $customsearch$</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>
            <table>
                <title>Table:</title>
                <search>
                    <query>eventtype=nmon:events type=UARG $frameID$ host=$host-prefilter$ $host_query$ $ProgName$ $PID$ $FullCommand$ | table _time,host,PID,ProgName,FullCommand</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>
            </table>
        </panel>
    </row>
</form>
