<form script="Nmon_predict.js,modal.js" stylesheet="ui_simple.css,panel_decoration.css" isVisible="true" version="1.1" theme="dark">
    <label>NMON Predictive interface, Predictive analysis using the forecasting predict command</label>
    <description></description>

    <!-- Information panel -->

    <row>
        <panel>
            <html>

                <div class="imgheader custom-modal">
                    <img src="../../static/app/metricator-for-nmon/icons/dark_theme/predict.png" alt="Info"/>
                    <h4><a data-modal-name="Help_modal">Help, information and related links for predictive analysis</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/predict.png" alt="predict"/>
                                    <h1>Predictive analysis with the Splunk builtin predict command </h1>
                                </div>

                                <div>
                                    <br />
                                    The predictive analysis interface implements the builtin Splunk command "predict" to forecast time-series data of different main Nmon monitors such as CPU utilization.
                                    <br />
                                    By default, this interface will use last past 3 months of data to try predicting the next 3 months potential usage of th selected performance metric
                                    <br />
                                    Get more information of the predict command and its available options, see <a href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Predict" target="_blank">http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Predict</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 search for main dropdown populating for Servers
    -->

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

    <!--
    Retrieve the OStype values for each Server and define a token according to its values
    This token will be used to filter out added calculated metrics
    -->

    <search id="ostype_analysis">
        <query>| mcatalog values(OStype) as OStype_values where `nmon_metrics_index` metric_name="os.unix.nmon.cpu.cpu_all.logical_cpus" ($host$)
| rename OStype_values as OStype
| mvexpand OStype
| eval OStype="is_" . OStype . "==\"True\""
| mvcombine OStype | nomv OStype | rex field=OStype mode=sed "s/\" /\" OR /g"</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
        <progress>
            <condition>
                <set token="OStype">$result.OStype$</set>
            </condition>
        </progress>
    </search>

    <!--
    Base search for the metric catalog populating, avoid extending raw metrics with non relevant calculated metrics
    -->

    <search id="populate_metric">
        <query>| mcatalog values(metric_name) as metrics where `nmon_metrics_index` metric_name="os.unix.nmon.*" ($host$)
| rename metrics as metric_name
| mvexpand metric_name
| append [ | inputlookup nmon_metric_catalog where ($OStype$) | fields metric_name ]
| rex field="metric_name" "os\.unix\.nmon\.(?&lt;metric_category&gt;\w*)\.(?&lt;nmon_section&gt;\w*)"
| sort 0 metric_name
| lookup nmon_metric_catalog metric_name
| eval metric_filter=if(isnull(metric_filter), ("metric_name=" . metric_name), metric_filter)
| eval metric_has_device=if(match(metric_name, "\.disk\w*|\.adapters|\.dg\w*|\.top\.|\.df_\w*|\.jfs\w*|\.network\.\w*"), "True", "False")
| eval metric_dimension_field=case(match(metric_name, "df_\w*|jfsfile|jfsinode"), "dimension_mount", match(metric_name, "\.top\.*"), "dimension_Command", metric_has_device=="True", "dimension_device")
| eval metric_volume_unit_choice=if(match(metric_name, "df_storage\.Used"), "True", "False")
| eval metric_rate_unit_choice=if(match(metric_name, "\.network\.net"), "True", "False")
| rex field="metric_name" "os\.unix\.nmon\.\w*\.\w*\.(?&lt;metric_shortname&gt;\w*)"
| rex field="metric_name" "os\.unix\.nmon\.\w*\.(?&lt;metric_shortname&gt;\w*)$"
| eval metric_calculation=if(isnotnull(metric_calculation), metric_calculation, "eval value=value")
| eval metric_type_of_calculation=if(isnotnull(metric_type_of_calculation), metric_type_of_calculation, "01 - raw metric")
| eval metric_data_field=if(isnotnull(metric_data_field), metric_data_field, "value")
| eval metric_by=if(isnotnull(metric_groupby), metric_groupby, metric_by) | eval metric_by=if(isnull(metric_by), "host", metric_by)
| eval metric_timechart_by=if(isnotnull(metric_timechart_by), metric_timechart_by, "host")
| eval metric_primary_statsmode=if(isnotnull(metric_primary_statsmode), metric_primary_statsmode, "avg")
| eval metric_charting_chart=if(isnotnull(metric_charting_chart), metric_charting_chart, "line")
| eval metric_charting_stackmode=if(isnotnull(metric_charting_stackmode), metric_charting_stackmode, "default")
        </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
    -->

    <!-- definition of metric related tokens -->

    <search id="basesearch_metric_definition" base="populate_metric">
        <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>

                <unset token="form.device"></unset>


            </condition>
        </progress>
    </search>

    <!-- analyse if the metric has a device dimension -->

    <search id="basesearch_metric_device" base="populate_metric">
        <query>search metric_name=$metric_name$</query>
        <progress>
            <condition match="'result.metric_has_device'==&quot;True&quot;">
                <set token="show_device">True</set>
            </condition>
            <condition match="'result.metric_has_device'==&quot;False&quot;">
                <unset token="show_device"></unset>
            </condition>
        </progress>
    </search>

    <!-- analyse if the metric has a volume unit choice option -->

    <search id="basesearch_metric_volume_unit" base="populate_metric">
        <query>search metric_name=$metric_name$</query>
        <progress>
            <condition match="'result.metric_volume_unit_choice'==&quot;True&quot;">
                <set token="show_unit">True</set>
            </condition>
            <condition match="'result.metric_volume_unit_choice'==&quot;False&quot;">
                <unset token="show_unit"></unset>
            </condition>
        </progress>
    </search>

    <!-- analyse if the metric has a rate unit choice option -->

    <search id="basesearch_metric_rate_unit" base="populate_metric">
        <query>search metric_name=$metric_name$</query>
        <progress>
            <condition match="'result.metric_rate_unit_choice'==&quot;True&quot;">
                <set token="show_unit_rate">True</set>
            </condition>
            <condition match="'result.metric_rate_unit_choice'==&quot;False&quot;">
                <unset token="show_unit_rate"></unset>
            </condition>
        </progress>
    </search>

    <!-- ################################ -->

    <row>
        <panel id="settings1">
            <title>Time range and server selection:</title>

            <input type="time" token="timerange" searchWhenChanged="true">
                <label>Time Range:</label>
                <default>
                    <earliest>-30d</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 type="dropdown" token="osfilter" searchWhenChanged="true">
                <label>Filter OS Type:</label>
                <default>*</default>
                <prefix>OStype="</prefix>
                <suffix>"</suffix>
                <choice value="*">Any OS</choice>
                <choice value="AIX">AIX</choice>
                <choice value="Linux">Linux</choice>
                <choice value="Solaris">Solaris</choice>
            </input>

            <input type="multiselect" token="frameID" searchWhenChanged="true">
                <label>frameID Selection:</label>
                <search base="populate_servers">
                    <query>stats count by frameID | fields frameID | dedup frameID | sort 0 frameID</query>
                </search>
                <initialValue>*</initialValue>
                <valuePrefix>frameID="</valuePrefix>
                <valueSuffix>"</valueSuffix>
                <delimiter> OR </delimiter>
                <fieldForLabel>frameID</fieldForLabel>
                <fieldForValue>frameID</fieldForValue>
                <choice value="*">Any</choice>
            </input>

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

            <input id="host" type="dropdown" token="host" searchWhenChanged="true">
                <label>hosts Selection:</label>
                <search base="populate_servers">
                    <query>search $frameID$ $host-prefilter$ | stats count by host | dedup host | sort 0 host</query>
                </search>
                <fieldForLabel>host</fieldForLabel>
                <fieldForValue>host</fieldForValue>
                <prefix>host="</prefix>
                <suffix>"</suffix>
                <!-- Enforce unset of token when host choice is done -->
                <change>
                    <unset token="form.holdback_choice"></unset>
                    <unset token="form.futurespan_choice"></unset>
                </change>
            </input>

            <input id="device" type="multiselect" token="device" searchWhenChanged="true" depends="$show_device$">
                <label>Dimensions:</label>
                <search>
                    <query>| mcatalog values($metric_dimension_field$) as $metric_dimension_field$_values where `nmon_metrics_index` $metric_filter$ $host-prefilter$ $host$ $osfilter$
| rename $metric_dimension_field$_values as $metric_dimension_field$
| mvexpand $metric_dimension_field$ | dedup $metric_dimension_field$ | sort 0 $metric_dimension_field$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                </search>
                <initialValue>*</initialValue>
                <valuePrefix>$metric_dimension_field$=</valuePrefix>
                <delimiter> OR </delimiter>
                <choice value="*">Any</choice>
                <fieldForLabel>$metric_dimension_field$</fieldForLabel>
                <fieldForValue>$metric_dimension_field$</fieldForValue>
            </input>

            <!-- help boxes -->

            <html depends="$host$" rejects="$OStype$">
                <div class="red_help_user">
                    <p> - - - - - - - - - - Please wait while identifying the operating system... - - - - - - - - - - </p>
                </div>
            </html>

        </panel>
    </row>

    <!-- Help the user -->

    <row>
        <panel rejects="$host$">
            <html>
                <div class="red_help_user">
                    <p>- - - - - - - - - - ACTION REQUIRED: please select one or more servers in the host selector above - - - - - - - - - -</p>
                </div>
            </html>
        </panel>
    </row>

    <row depends="$host$ $metric_name$ $show_device$">
        <panel>
            <html>
                <div class="blue_help_user">
                    <p>- - - - - - - - - - INFORMATION: the metric $metric_name$ has dimensions that can filtered out in the dimensions selector above - - - - - - - - - -</p>
                </div>
            </html>
        </panel>
    </row>

    <row>
        <panel id="settings2">
            <title>Metric selection and parameters:</title>

            <input token="metric_category" type="dropdown" searchWhenChanged="true">
                <label>METRIC CATEGORY:</label>
                <search base="populate_metric">
                    <query>stats count by metric_category | sort 0 metric_category</query>
                </search>
                <choice value="*">Any</choice>
                <default>*</default>
                <fieldForLabel>metric_category</fieldForLabel>
                <fieldForValue>metric_category</fieldForValue>
            </input>

            <input token="nmon_section" type="dropdown" searchWhenChanged="true">
                <label>NMON SECTION:</label>
                <search base="populate_metric">
                    <query>search metric_category="$metric_category$" | stats count by nmon_section | sort 0 nmon_section</query>
                </search>
                <choice value="*">Any</choice>
                <default>*</default>
                <fieldForLabel>nmon_section</fieldForLabel>
                <fieldForValue>nmon_section</fieldForValue>
            </input>

            <input token="metric_type_of_calculation" type="dropdown" searchWhenChanged="true">
                <label>TYPE OF METRIC CALCULATION:</label>
                <search base="populate_metric">
                    <query>search metric_category="$metric_category$" | stats count by metric_type_of_calculation | sort 0 metric_type_of_calculation</query>
                </search>
                <choice value="*">Any</choice>
                <default>*</default>
                <fieldForLabel>metric_type_of_calculation</fieldForLabel>
                <fieldForValue>metric_type_of_calculation</fieldForValue>
            </input>

            <!-- the metric_name dropdown size will be increased using css -->

            <input id="metric_name" token="metric_name" type="dropdown" searchWhenChanged="true">
                <label>PERFORMANCE METRIC:</label>
                <search base="populate_metric">
                    <query>search metric_category="$metric_category$" nmon_section="$nmon_section$" metric_type_of_calculation="$metric_type_of_calculation$" | table metric_name | sort 0 metric_name</query>
                </search>
                <fieldForLabel>metric_name</fieldForLabel>
                <fieldForValue>metric_name</fieldForValue>

                <change>
                    <condition value="os.unix.nmon.storage.df_storage.Used">
                        <set token="storage_metric">true</set>
                        <unset token="show_processing_saturation_predicted"></unset>
                        <unset token="show_null_saturation_predicted"></unset>
                        <unset token="show_saturation_predicted"></unset>
                    </condition>
                    <condition>
                        <unset token="storage_metric"></unset>
                    </condition>
                </change>

            </input>

            <!-- help boxes -->

            <html depends="$is_detected$" rejects="$metric_name$">
                <div class="red_help_user">
                    <p> - - - - - - - - - - ACTION REQUIRED: please select a performance monitor in the selector above - - - - - - - - - - </p>
                </div>
            </html>

        </panel>
    </row>

    <row depends="$show_device$ $show_unit$">
        <panel>

            <input type="dropdown" token="storage_unit">
                <label>Unit:</label>
                <choice value="MB">MB</choice>
                <choice value="GB">GB</choice>
                <choice value="TB">TB</choice>
                <default>GB</default>
                <change>
                    <condition value="MB">
                        <set token="metric_math">value</set>
                        <set token="storage_metric_unit">MB</set>
                    </condition>
                    <condition value="GB">
                        <set token="metric_math">value/1024</set>
                        <set token="storage_metric_unit">GB</set>
                    </condition>
                    <condition value="TB">
                        <set token="metric_math">value/1024/1204</set>
                        <set token="storage_metric_unit">TB</set>
                    </condition>
                    <condition value="pct">
                        <set token="metric_math">value</set>
                        <set token="storage_metric_unit">pct</set>
                    </condition>
                </change>
            </input>

        </panel>
    </row>

    <row depends="$show_device$ $show_unit_rate$">
        <panel>

            <input type="dropdown" token="rate_unit">
                <label>Unit:</label>
                <choice value="KBps">KBps</choice>
                <choice value="MBps">MBps</choice>
                <choice value="GBps">GBps</choice>
                <default>KBps</default>
                <change>
                    <condition value="KBps">
                        <set token="metric_math">value</set>
                        <set token="rate_metric_unit">KBps</set>
                    </condition>
                    <condition value="MBps">
                        <set token="metric_math">value/1000</set>
                        <set token="rate_metric_unit">MBps</set>
                    </condition>
                    <condition value="GBps">
                        <set token="metric_math">value/1000/1000</set>
                        <set token="rate_metric_unit">GBps</set>
                    </condition>
                </change>
            </input>

        </panel>
    </row>

    <!-- Help the user -->

    <row depends="$host$" rejects="$metric_name$">
        <panel>
            <html>
                <div class="red_help_user">
                    <p>- - - - - - - - - - ACTION REQUIRED: please select the performance metric to be explore in the metric selector above - - - - - - - - - -</p>
                </div>
            </html>
        </panel>
    </row>

    <row>
        <panel id="predict1">
            <title>Prediction parameters:</title>

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

            <input type="dropdown" token="algo">
                <label>Prediction algorithm:</label>
                <choice value="LL">LL (Local Level)</choice>
                <choice value="LLP">LLP (Seasonal local level)</choice>
                <choice value="LLP5">LLP5 (Combines LLT and LLP models)</choice>
                <choice value="LLT">LLT (Local level trend)</choice>
                <default>LLP5</default>
            </input>

            <input type="text" token="interval">
                <prefix>span="</prefix>
                <suffix>"</suffix>
                <default>1d</default>
                <label>Time span value (ex: 1d for 1 day)</label>
            </input>

            <input type="dropdown" token="holdback_choice">
                <label>Holdback:</label>
                <choice value="auto">auto (none)</choice>
                <choice value="custom">custom</choice>
                <default>auto</default>
                <change>
                    <condition value="auto">
                        <unset token="show_holdback"></unset>
                        <set token="holdback">holdback=0</set>
                    </condition>
                    <condition value="custom">
                        <set token="show_holdback">true</set>
                        <unset token="holdback"></unset>
                    </condition>
                </change>
            </input>
            <input type="text" token="holdback" depends="$show_holdback$">
                <prefix>holdback="</prefix>
                <suffix>"</suffix>
                <label>Nb of last points to ignore</label>
            </input>

            <input type="dropdown" token="futurespan_choice">
                <label>Futurespan:</label>
                <choice value="auto">auto (90)</choice>
                <choice value="custom">custom</choice>
                <default>auto</default>
                <change>
                    <condition value="auto">
                        <unset token="show_futurespan"></unset>
                        <set token="futurespan">future_timespan=90</set>
                    </condition>
                    <condition value="custom">
                        <set token="show_futurespan">true</set>
                        <unset token="futurespan"></unset>
                    </condition>
                </change>
            </input>
            <input type="text" token="futurespan" depends="$show_futurespan$">
                <prefix>future_timespan="</prefix>
                <suffix>"</suffix>
                <label>Nb of time points in future</label>
            </input>

            <input type="dropdown" token="upperlower_choice">
                <label>Upper/Lower:</label>
                <choice value="auto">auto (upper75=high lower75=low)</choice>
                <choice value="custom">custom</choice>
                <default>auto</default>
                <change>
                    <condition value="auto">
                        <unset token="show_upperlower"></unset>
                        <set token="upperlower">upper75=high lower75=low</set>
                    </condition>
                    <condition value="custom">
                        <set token="show_upperlower">true</set>
                        <unset token="upperlower"></unset>
                    </condition>
                </change>
            </input>
            <input type="text" token="upperlower" depends="$show_upperlower$">
                <default></default>
                <label>Enter upper and lower settings:</label>
            </input>

            <html depends="$show_holdback$" rejects="$holdback$">
                <div class="red_help_user">
                    <p> - - - - - - - - - - ACTION REQUIRED: please enter the number of data points from the end that are not to be used, and press Enter - - - - - - - - - - </p>
                </div>
            </html>

            <html depends="$show_futurespan$" rejects="$futurespan$">
                <div class="red_help_user">
                    <p> - - - - - - - - - - ACTION REQUIRED: please enter the number of data points to be predicted, depending on the interval value this will influence the future prediction (for example with 1d as the interval, 90 means predicting for next 90 days), and press Enter - - - - - - - - - - </p>
                </div>
            </html>

            <html depends="$show_upperlower$" rejects="$upperlower$">
                <div class="red_help_user">
                    <p> - - - - - - - - - - ACTION REQUIRED: please enter lower and upper settings under the form  "upperXX=high lowerXX=high" and press Enter - - - - - - - - - - </p>
                </div>
            </html>

        </panel>
    </row>

    <search id="predicted_storage_saturation" depends="$storage_metric$">
        <query>| mstats $metric_primary_statsmode$(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.storage.df_storage.Used OR metric_name=os.unix.nmon.storage.df_storage.Available $host-prefilter$ $host$ $osfilter$ $device$ by metric_name, host span=1m
| eval storage_used=case(metric_name=="os.unix.nmon.storage.df_storage.Used", value), storage=case(metric_name=="os.unix.nmon.storage.df_storage.Available", value)
| stats latest(storage_used) as storage_used, latest(storage) as storage by _time, host
| `$timefilter$`
| eval storage_metric_unit="$storage_metric_unit$", metric_volume_unit_choice="$metric_volume_unit_choice$"
| eval storage_used=case(storage_metric_unit=="MB", storage_used, storage_metric_unit=="GB", storage_used/1024, storage_metric_unit=="TB", storage_used/1024/1024)
| eval storage=case(storage_metric_unit=="MB", storage, storage_metric_unit=="GB", storage/1024, storage_metric_unit=="TB", storage/1024/1024)
| timechart $interval$ $statsmode$(storage_used) AS storage_used latest(storage) as storage
| predict storage_used As predict algorithm=$algo$ $holdback$ $futurespan$ $upperlower$
| filldown storage
| eval now=now()
| where (predict&gt;=storage AND _time>now) | sort 0 _time | head 1
| stats count, min(_time) as predicted_saturation, latest(predict) as predict, latest(storage) as storage
| eval predicted_saturation=strftime(predicted_saturation, "%d %b %Y"), storage_needs=(predict-storage), storage_margin_90pct=(storage*0.1), storage_margin_80pct=(storage*0.2)
| eval storage_needs_90pct=round((storage_needs+storage_margin_90pct), 2), storage_needs_80pct=round((storage_needs+storage_margin_80pct), 2)
| eval prediction_saturation_found=if(predict>storage, "true", "false")</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
        <progress>
                <set token="storage_prediction_is_processing">true</set>
                <unset token="storage_prediction_will_be_satured"></unset>
                <unset token="storage_prediction_has_no_prediction"></unset>
        </progress>
        <finalized>
            <condition match="'result.prediction_saturation_found'==&quot;false&quot;">
                <set token="storage_prediction_has_no_prediction">true</set>
                <unset token="storage_prediction_is_processing"></unset>
                <unset token="storage_prediction_will_be_satured"></unset>
            </condition>
            <condition match="'result.prediction_saturation_found'==&quot;true&quot;">
                <set token="storage_prediction_will_be_satured">true</set>
                <unset token="storage_prediction_is_processing"></unset>
                <unset token="storage_prediction_has_no_prediction"></unset>
                <set token="predicted_saturation">$result.predicted_saturation$</set>
                <set token="storage_needs_80pct">$result.storage_needs_80pct$</set>
                <set token="storage_needs_90pct">$result.storage_needs_90pct$</set>
            </condition>
        </finalized>

    </search>

    <row>
        <panel>
            <title>Metrics rendering</title>

            <html depends="$metric_name$">
                <div style="font-size: 18px; margin: 10px 0; font-weight: bold; text-align: center; color: black;">
                    <p>
                        <span style="color: #aec6cf; font-size: 200%;">$metric_name$</span>
                    </p>
                </div>
            </html>

            <html depends="$storage_metric$ $storage_prediction_is_processing$">
                <div style="font-size: 18px; margin: 10px 0; font-weight: bold; text-align: center; color: black;">
                    <h2>Please wait while processing the file-system saturation predictive analysis...</h2>
                </div>
            </html>

            <html depends="$storage_metric$ $storage_prediction_has_no_prediction$" rejects="$storage_prediction_is_processing$">
                <div style="font-size: 18px; margin: 10px 0; font-weight: bold; text-align: center; color: black;">
                    <p>PREDICTIVE ANALYSIS: no saturation prediction could be detected for file-system: <span style="color: #aec6cf; font-size: 200%;">$device$</span></p>
                </div>
            </html>

            <html depends="$storage_metric$ $storage_prediction_will_be_satured$" rejects="$storage_prediction_is_processing$">
                <div style="font-size: 18px; margin: 10px 0; font-weight: bold; text-align: center; color: black;">
                    <p>PREDICTIVE ANALYSIS: starting date of
                        <span style="color: #ff6961; font-size: 200%;">$predicted_saturation$</span>
                        the file-system:
                        <span style="color: #aec6cf; font-size: 200%;">$device$</span>
                        might be saturated
                        <br /><br />
                        <lu>
                            <li>Approx. <span style="color: #aec6cf; font-size: 150%;">$storage_needs_90pct$ $storage_metric_unit$</span> of supplementary storage would be needed to keep the storage at 90% of used space</li>
                            <br />
                            <li>Approx. <span style="color: #aec6cf; font-size: 150%;">$storage_needs_80pct$ $storage_metric_unit$</span> of supplementary storage would be needed to keep the storage at 80% of used space</li>
                        </lu>
                    </p>
                </div>
            </html>

            <input type="dropdown" token="statsmode" searchWhenChanged="true">
                <label>Statistic 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>

            <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>

            <input type="dropdown" token="chart_settings" searchWhenChanged="true">
                <label></label>
                <choice value="0">Show charting parameters</choice>
                <choice value="1">Hide charting parameters</choice>
                <default>1</default>
                <change>
                    <condition value="0">
                        <set token="chart_customize">True</set>
                    </condition>
                    <condition value="1">
                        <unset token="chart_customize"></unset>
                    </condition>
                </change>
            </input>

            <input type="dropdown" token="chart" depends="$chart_customize$" searchWhenChanged="true">
                <label>Select a type of chart:</label>
                <default>line</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" depends="$chart_customize$" searchWhenChanged="true">
                <label>Missing Data:</label>
                <default>gaps</default>
                <choice value="gaps">Gaps</choice>
                <choice value="connect">Connect</choice>
                <choice value="zero">Zero</choice>
            </input>

            <input type="dropdown" token="charting.legend.placement" depends="$chart_customize$" 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="checkbox" token="chart_min_scale" depends="$chart_customize$" searchWhenChanged="true">
                <label></label>
                <initialValue>0</initialValue>
                <choice value="0">Starts scale at 0</choice>
            </input>

            <input type="checkbox" token="chart_max_scale" depends="$chart_customize$" searchWhenChanged="true">
                <label></label>
                <choice value="101">Max scale at 100</choice>
            </input>

            <chart rejects="$show_device$">
                <title></title>
                <search rejects="$show_device$">
                    <query>| mstats $metric_primary_statsmode$(_value) as value where `nmon_metrics_index` $metric_filter$ $host-prefilter$ $host$ $osfilter$ by $metric_by$ span=1m
| $metric_calculation$
| `$timefilter$`
| timechart $interval$ $statsmode$($metric_data_field$) As $metric_shortname$
| predict $metric_shortname$ As predict algorithm=$algo$ $holdback$ $futurespan$ $upperlower$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                </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.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">default</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="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisTitleY.text">$metric_shortname$</option>
                <option name="charting.axisY.minimumNumber">$chart_min_scale$</option>
                <option name="charting.axisY.maximumNumber">$chart_max_scale$</option>
                <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
                <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
                <option name="charting.axisTitleY2.visibility">visible</option>
                <option name="charting.axisY2.enabled">false</option>
                <option name="charting.axisY2.scale">inherit</option>
                <option name="charting.fieldColors">{"predict": 0x9d0eaf}</option>
            </chart>

            <chart depends="$show_device$" rejects="$storage_metric$">
                <title></title>
                <search depends="$show_device$" rejects="$storage_metric$">
                    <query>| mstats $metric_primary_statsmode$(_value) as value where `nmon_metrics_index` $metric_filter$ $host-prefilter$ $host$ $osfilter$ $device$ by $metric_by$ span=1m
| $metric_calculation$
| `$timefilter$`
| eval storage_metric_unit="$storage_metric_unit$", metric_volume_unit_choice="$metric_volume_unit_choice$"
| eval rate_metric_unit="$rate_metric_unit$", metric_rate_unit_choice="$metric_rate_unit_choice$"
| eval $metric_data_field$=case(metric_volume_unit_choice=="True" AND storage_metric_unit=="MB", $metric_data_field$, metric_volume_unit_choice=="True" AND storage_metric_unit=="GB", $metric_data_field$/1024, metric_volume_unit_choice=="True" AND storage_metric_unit=="TB", $metric_data_field$/1024/1024, metric_volume_unit_choice=="False", $metric_data_field$)
| eval $metric_data_field$=case(metric_rate_unit_choice=="True" AND rate_metric_unit=="KBps", $metric_data_field$, metric_rate_unit_choice=="True" AND rate_metric_unit=="MBps", $metric_data_field$/1000, metric_rate_unit_choice=="True" AND rate_metric_unit=="GBps", $metric_data_field$/1000/1000, metric_rate_unit_choice=="False", $metric_data_field$)
| timechart $interval$ $statsmode$($metric_data_field$) AS $metric_shortname$
| predict $metric_shortname$ As predict algorithm=$algo$ $holdback$ $futurespan$ $upperlower$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                </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.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">default</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="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisTitleY.text">$metric_shortname$</option>
                <option name="charting.axisY.minimumNumber">$chart_min_scale$</option>
                <option name="charting.axisY.maximumNumber">$chart_max_scale$</option>
                <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
                <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
                <option name="charting.axisTitleY2.visibility">visible</option>
                <option name="charting.axisY2.enabled">false</option>
                <option name="charting.axisY2.scale">inherit</option>
                <option name="charting.fieldColors">{"predict": 0x9d0eaf}</option>
            </chart>

            <chart depends="$show_device$ $storage_metric$">
                <title></title>
                <search depends="$show_device$ $storage_metric$">
                    <query>| mstats $metric_primary_statsmode$(_value) as value where `nmon_metrics_index` metric_name=os.unix.nmon.storage.df_storage.Used OR metric_name=os.unix.nmon.storage.df_storage.Available $host-prefilter$ $host$ $osfilter$ $device$ by metric_name, host span=1m
| eval storage_used=case(metric_name=="os.unix.nmon.storage.df_storage.Used", value), storage=case(metric_name=="os.unix.nmon.storage.df_storage.Available", value)
| stats latest(storage_used) as storage_used, latest(storage) as storage by _time, host
| `$timefilter$`
| eval storage_metric_unit="$storage_metric_unit$", metric_volume_unit_choice="$metric_volume_unit_choice$"
| eval storage_used=case(storage_metric_unit=="MB", storage_used, storage_metric_unit=="GB", storage_used/1024, storage_metric_unit=="TB", storage_used/1024/1024)
| eval storage=case(storage_metric_unit=="MB", storage, storage_metric_unit=="GB", storage/1024, storage_metric_unit=="TB", storage/1024/1024)
| timechart $interval$ $statsmode$(storage_used) AS storage_used latest(storage) as storage
| predict storage_used As predict algorithm=$algo$ $holdback$ $futurespan$ $upperlower$</query>
                    <earliest>$timerange.earliest$</earliest>
                    <latest>$timerange.latest$</latest>
                </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.sliceCollapsingThreshold">0.01</option>
                <option name="charting.chart.stackMode">default</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="charting.chart.nullValueMode">$charting.chart.nullValueMode$</option>
                <option name="height">680</option>
                <option name="charting.axisTitleX.text">Time</option>
                <option name="charting.axisTitleY.text">$metric_shortname$</option>
                <option name="charting.axisY.minimumNumber">$chart_min_scale$</option>
                <option name="charting.axisY.maximumNumber">$chart_max_scale$</option>
                <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
                <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
                <option name="charting.axisTitleY2.visibility">visible</option>
                <option name="charting.axisY2.enabled">false</option>
                <option name="charting.axisY2.scale">inherit</option>
                <option name="charting.fieldColors">{"storage": 0xFF0000, "predict": 0x9d0eaf}</option>
            </chart>

        </panel>
    </row>

</form>
