#
# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
##############################################
#
# WARNING: Don't edit the file manually unless you are not using the deployment.toml file.
#
##############################################

## This file contains the configuration parameters used by the Diagnostic tool

# Server Configurations
[server_configuration]
diagnostic_tool_enabled = "{{server_configuration.diagnostic_tool_enabled}}"
deployment_toml_path = "{{server_configuration.deployment_toml_path}}"
logs_directory = "{{server_configuration.logs_directory}}"
updates_config_path = "{{server_configuration.updates_config_path}}"
diagnostic_log_file_path = "{{server_configuration.diagnostic_log_file_path}}"
carbon_log_file_path = "{{server_configuration.carbon_log_file_path}}"
process_id_path = "{{server_configuration.process_id_path}}"
server_name = "@product.name@"
server_version = "@product.version@"

## Action Executor Configurations

# Example
#[[action_executor_configuration]]
#executor = "ActionExecutor"
#reload_time = "180" # in seconds

[[action_executor_configuration]]
executor = "MemoryDumper"
reload_time = "180"

[[action_executor_configuration]]
executor = "ThreadDumper"
count = "5"
delay = "2000"

[[action_executor_configuration]]
executor = "OpenFileFinder"

[[action_executor_configuration]]
executor = "Netstat"
command = "netstat -alt"

[[action_executor_configuration]]
executor = "ServerInfo"

[[action_executor_configuration]]
executor = "MetricsSnapshot"

[[action_executor_configuration]]
executor = "org.wso2.carbon.diagnostics.action.executor.MetricsSnapshot"

{%for action in action_executor_configuration %}
[[action_executor_configuration]]
executor = "{{action.executor}}"
{% endfor %}

# Watcher Configurations
[cpu_watcher]
enabled = "{{cpu_watcher.enabled}}"
threshold = "{{cpu_watcher.threshold}}"
attempts = "{{cpu_watcher.attempts}}"
interval = "{{cpu_watcher.interval}}"
action_executors = "{{cpu_watcher.action_executors}}"

[memory_watcher]
enabled = "{{memory_watcher.enabled}}"
threshold = "{{memory_watcher.threshold}}"
attempts = "{{memory_watcher.attempts}}"
interval = "{{memory_watcher.interval}}"
action_executors = "{{memory_watcher.action_executors}}"

[log_watcher]
enabled = "{{log_watcher.enabled}}"
interval = {{log_watcher.interval}}
max_pre_error_context_size = {{log_watcher.max_pre_error_context_size}}
max_post_error_context_size = {{log_watcher.max_post_error_context_size}}

[[custom_watchers]]
class = "org.wso2.carbon.diagnostics.trafficanalyzer.TrafficAnalyzer"

# Traffic Analyzer Configurations
[traffic_analyzer]
last_second_requests_enabled = "{{traffic_analyzer.last_second_requests_enabled}}"
last_second_requests_windows_size = "{{traffic_analyzer.last_second_requests_windows_size}}"
last_second_requests_delay = "{{traffic_analyzer.last_second_requests_delay}}"
last_second_requests_interval = "{{traffic_analyzer.last_second_requests_interval}}"
last_fifteen_seconds_requests_enabled = "{{traffic_analyzer.last_fifteen_seconds_requests_enabled}}"
last_fifteen_seconds_requests_window_size = "{{traffic_analyzer.last_fifteen_seconds_requests_window_size}}"
last_fifteen_seconds_requests_delay = "{{traffic_analyzer.last_fifteen_seconds_requests_delay}}"
last_fifteen_seconds_requests_interval = "{{traffic_analyzer.last_fifteen_seconds_requests_interval}}"
last_minutes_requests_enabled = "{{traffic_analyzer.last_minutes_requests_enabled}}"
last_minutes_requests_window_size = "{{traffic_analyzer.last_minutes_requests_window_size}}"
last_minutes_requests_delay = "{{traffic_analyzer.last_minutes_requests_delay}}"
last_minutes_requests_interval = "{{traffic_analyzer.last_minutes_requests_interval}}"
notify_interval = "{{traffic_analyzer.notify_interval}}"

{%for watcher in custom_watchers %}
[[custom_watchers]]
class = "{{watcher.class}}"
{% endfor %}

# Output data zip configurations
[zip_file_configuration]
output_directory = "{{zip_file_configuration.output_directory}}"
max_count = "{{zip_file_configuration.max_count}}"

# Error regex patterns and diagnosis
{%for pattern in log_pattern.patterns %}
[[log_pattern]]
regex = "{{pattern.pattern.regex}}"
executors = "{{pattern.pattern.executors}}"
reload_time = "{{pattern.pattern.reload_time}}"

{% endfor %}

{% if ftp_uploader is defined %}
## FTP Uploader configurations
[ftp_uploader]
enabled = "{{ftp_uploader.enabled}}"
host = "{{ftp_uploader.host}}"
port = "{{ftp_uploader.port}}"
username = "{{ftp_uploader.username}}"
password = "{{ftp_uploader.password}}"
directory = "{{ftp_uploader.directory}}"
{% endif %}

{% if sftp_uploader is defined %}
## SFTP Uploader configurations
[sftp_uploader]
enabled = "{{sftp_uploader.enabled}}"
host = "{{sftp_uploader.host}}"
port = "{{sftp_uploader.port}}"
username = "{{sftp_uploader.username}}"
password = "{{sftp_uploader.password}}"
directory = "{{sftp_uploader.directory}}"
known_hosts_path = "{{sftp_uploader.known_hosts_path}}"
strict_host_key_checking = "{{sftp_uploader.strict_host_key_checking}}"
{% endif %}