<form script="autodiscover.js,custom_layout.js" stylesheet="ui_simple.css" isVisible="true" version="1.1" theme="dark">
    <label>NMON Solaris WLM: CPU and Memory Statistics of Projects / Zones / Tasks / Users</label>
    <description>WLM Statistics dashboard for Solaris 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>
        </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 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>
            <valueSuffix>"</valueSuffix>
            <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 id="device" type="multiselect" token="device" searchWhenChanged="true">
            <label>Project / Zone / Task / User:</label>
            <!-- Populating Data Model Search -->
            <search base="populate">
                <query>search $frameID$ $host$
| stats count by dimension_device | dedup dimension_device | sort 0 dimension_device</query>
            </search>
            <valuePrefix>dimension_device="</valuePrefix>
            <valueSuffix>"</valueSuffix>
            <delimiter> OR </delimiter>
            <choice value="*">ALL</choice>
            <initialValue>*</initialValue>
            <fieldForLabel>dimension_device</fieldForLabel>
            <fieldForValue>dimension_device</fieldForValue>
        </input>

        <input type="dropdown" token="monitor" searchWhenChanged="true">
            <label>Type:</label>
            <choice value="project">project</choice>
            <choice value="zone">zone</choice>
            <choice value="task">task</choice>
            <choice value="user">user</choice>
            <default>zone</default>
        </input>

        <input type="dropdown" token="statsmode" searchWhenChanged="true">
            <label>Stats mode:</label>
            <default>avg</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>

    </fieldset>

    <!-- Search based for post processing -->

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

    <search id="tablestats_cpu_per_monitor">
        <query>| mstats avg(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.processes.wlm$monitor$cpu host=$host-prefilter$ $host_query$ ($device$) by host dimension_device span=1m
| `$timefilter$`
| stats min(value) as min_value avg(value) as avg_value max(value) as max_value by dimension_device
| foreach "*_value" [ eval "&lt;&lt;FIELD&gt;&gt;"=round('&lt;&lt;FIELD&gt;&gt;', 2) ] | sort - avg_value | rename "*_value" AS "*"</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
    </search>

    <search id="tablestats_cpu_per_host">
        <query>| mstats avg(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.processes.wlm$monitor$cpu host=$host-prefilter$ $host_query$ ($device$) by host dimension_device span=1m
| `$timefilter$`
| stats min(value) as min_value avg(value) as avg_value max(value) as max_value by host, dimension_device
| foreach "*_value" [ eval "&lt;&lt;FIELD&gt;&gt;"=round('&lt;&lt;FIELD&gt;&gt;', 2) ] | sort - avg_value | rename "*_value" AS "*"</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
    </search>

    <row>
        <panel>
            <html>
                <div class="custom">
                    <h1>CPU Usage Statistics of Solaris Projects / Zones / Tasks / Users</h1>
                </div>
            </html>
        </panel>
    </row>

    <row>
        <panel id="panela1_setWidth_50">
            <title>Graphical Representation by $monitor$</title>
            <html>
                <div id="bubbleSearch"
                     class="splunk-manager"
                     data-require="splunkjs/mvc/searchmanager"
                     data-options="{&quot;search&quot;:
                     {
                     &quot;type&quot;:
                     &quot;token_safe&quot;,
                     &quot;value&quot;: &quot;| mstats avg(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.processes.wlm$$monitor$$cpu host=$$host-prefilter$$ $$host_query$$ ($$device$$) by host dimension_device span=1m
| `$$timefilter$$`
| stats $$statsmode$$(value) as value by dimension_device
| sort limit=0 dimension_device
| eval value=round(value,2)
| sort - avg_value | head 100&quot;},
                    &quot;earliest_time&quot;:
                    {&quot;type&quot;: &quot;token_safe&quot;,
                    &quot;value&quot;: &quot;$$timerange.earliest$$&quot;
                    },
                    &quot;latest_time&quot;: {&quot;type&quot;: &quot;token_safe&quot;,
                    &quot;value&quot;: &quot;$$timerange.latest$$&quot;
                    },
                    &quot;auto_cancel&quot;: 90,
                    &quot;preview&quot;: true
                    }">
                </div>
                <div id="bubbleChart" class="splunk-view" data-require="app/metricator-for-nmon/components/bubblechart/bubblechart" data-options="{
                &quot;managerid&quot;: &quot;bubbleSearch&quot;,
                &quot;nameField&quot;: &quot;dimension_device&quot;,
                &quot;categoryField&quot;: &quot;dimension_device&quot;,
                &quot;valueField&quot;: &quot;value&quot;,
                &quot;height&quot;: 600
                }">
                </div>
            </html>
        </panel>
        <panel id="panela2_setWidth_25">
            <title>Stats by $monitor$</title>
            <table>
                <search base="tablestats_cpu_per_monitor">
                    <query></query>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">row</option>
                <option name="count">20</option>
            </table>
        </panel>
        <panel id="panela3_setWidth_25">
            <title>Stats by Hosts,$monitor$</title>
            <table>
                <search base="tablestats_cpu_per_host">
                    <query></query>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">row</option>
                <option name="count">20</option>
            </table>
        </panel>
    </row>

    <row>
        <panel>
            <html>
                <div class="custom">
                    <h1>Memory % Usage Statistics of Solaris Projects / Zones / Tasks / Users</h1>
                </div>
            </html>
        </panel>
    </row>

    <!-- Search based for post processing -->

    <search id="tablestats_memory_per_monitor">
        <query>| mstats avg(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.processes.wlm$monitor$mem host=$host-prefilter$ $host_query$ ($device$) by host dimension_device span=1m
| `$timefilter$`
| stats min(value) as min_value avg(value) as avg_value max(value) as max_value by dimension_device
| foreach "*_value" [ eval "&lt;&lt;FIELD&gt;&gt;"=round('&lt;&lt;FIELD&gt;&gt;', 2) ] | sort - avg_value | rename "*_value" AS "*"</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
    </search>

    <search id="tablestats_memory_per_host">
        <query>| mstats avg(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.processes.wlm$monitor$mem host=$host-prefilter$ $host_query$ ($device$) by host dimension_device span=1m
| `$timefilter$`
| stats min(value) as min_value avg(value) as avg_value max(value) as max_value by host, dimension_device
| foreach "*_value" [ eval "&lt;&lt;FIELD&gt;&gt;"=round('&lt;&lt;FIELD&gt;&gt;', 2) ] | sort - avg_value | rename "*_value" AS "*"</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
    </search>

    <row>
        <panel id="panelb1_setWidth_50">
            <title>Graphical Representation by $monitor$</title>
            <html>
                <div id="bubbleSearch2"
                     class="splunk-manager"
                     data-require="splunkjs/mvc/searchmanager"
                     data-options="{&quot;search&quot;:
                     {
                     &quot;type&quot;:
                     &quot;token_safe&quot;,
                     &quot;value&quot;: &quot;| mstats avg(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.processes.wlm$$monitor$$mem host=$$host-prefilter$$ $$host_query$$ ($$device$$) by host dimension_device span=1m
| `$$timefilter$$`
| stats $$statsmode$$(value) as value by dimension_device
| sort limit=0 dimension_device
| eval value=round(value,2)
| sort - avg_value | head 100&quot;},
                    &quot;earliest_time&quot;:
                    {&quot;type&quot;: &quot;token_safe&quot;,
                    &quot;value&quot;: &quot;$$timerange.earliest$$&quot;
                    },
                    &quot;latest_time&quot;: {&quot;type&quot;: &quot;token_safe&quot;,
                    &quot;value&quot;: &quot;$$timerange.latest$$&quot;
                    },
                    &quot;auto_cancel&quot;: 90,
                    &quot;preview&quot;: true
                    }">
                </div>
                <div id="bubbleChart2" class="splunk-view" data-require="app/metricator-for-nmon/components/bubblechart/bubblechart" data-options="{
                &quot;managerid&quot;: &quot;bubbleSearch2&quot;,
                &quot;nameField&quot;: &quot;dimension_device&quot;,
                &quot;categoryField&quot;: &quot;dimension_device&quot;,
                &quot;valueField&quot;: &quot;value&quot;,
                &quot;height&quot;: 600
                }">
                </div>
            </html>
        </panel>
        <panel id="panelb2_setWidth_25">
            <title>Stats by $monitor$</title>
            <table>
                <search base="tablestats_memory_per_monitor">
                    <query></query>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">row</option>
                <option name="count">20</option>
            </table>
        </panel>
        <panel id="panelb3_setWidth_25">
            <title>Stats by Hosts,$monitor$</title>
            <table>
                <search base="tablestats_memory_per_host">
                    <query></query>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">row</option>
                <option name="count">20</option>
            </table>
        </panel>
    </row>

</form>
