# Daggy Sources

## Supported formats

**Daggy** supports `yaml` and `json` formats. In yaml repeated nodes can be grouped by [yaml standard](https://yaml.org/spec/1.2/spec.html#id2785586).

## Data sources template

{% tabs %}
{% tab title="YAML" %}

```yaml
sources:
    host1:
        #....
    host2:
        #....
    #....
    hostN:
        #....
    
```

{% endtab %}
{% endtabs %}

Each config conatins map of hosts. Host (data source) parameters is next:

|    Parameter   |   Type  | Description                                                                             | Is Requiered                             |
| :------------: | :-----: | --------------------------------------------------------------------------------------- | ---------------------------------------- |
|    **type**    |  string | Type of connection to host. **Daggy** supportes `local` and `ssh` host connection types | Yes                                      |
|  **commands**  |  array  | Array of commands for simultaneous launch                                               | Yes                                      |
| **parameters** |   map   | Connection parameters                                                                   | Required for **ssh2** **type**           |
|    **host**    |  string | Host address                                                                            | No. For **ssh2** is 127.0.0.1 by default |
|  **reconnect** | boolean | true, if need reconnect connection                                                      | No                                       |

## Daggy Sources Types

**Daggy** supportes `local` and `ssh2` (remote) host connection types.

### Local type

Data aggregation via local processes

{% tabs %}
{% tab title="YAML" %}

```yaml
sources:
    localhost:
        type: local
        commands:
            pingYa:
                exec: ping ya.ru
                extension: log
```

{% endtab %}
{% endtabs %}

### SSH type

Data aggregation via ssh process

```yaml
remotehost:
    type: ssh
    host: hostname # hostname from config
    parameters:
      config: ~/.ssh/config # default path
    commands:
      pingYa:
        command: ping ya.ru
        extension: log
```

#### SSH parameters

* **config** - ssh config. By default is \~/.ssh/config
* c**ontrol** - ssh master control path. If not setted new master connection wiil created in Linux/Macos. Windows ignored this parameter
* **passphrase** - password for ssh connection if needed

### SSH2 type

Data aggregation via ssh2 lib

{% tabs %}
{% tab title="YAML" %}

```yaml
remotehost:
    type: ssh2
    host: 192.168.1.9
    parameters:
      user: muxa
      key: /home/muxa/.ssh/id_rsa
    commands:
      pingYa:
        command: ping ya.ru
        extension: log
```

{% endtab %}
{% endtabs %}

#### SSH2 type additional parameters

* **host** - remote host ip address or url
* **connection** - map of ssh connection parameters. Includes next parameters

| Connection Parameter |   Type  | Description                                                                                                                                                               | Default value   |
| :------------------: | :-----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
|       **user**       |  string | *ssh2* connection login                                                                                                                                                   | Current user    |
|    **passphrase**    |  string | *ssh2* connection password. If field is not empty, then will be used password authentication for *ssh2* connection. In other case, will be used public key authentication |                 |
|        **key**       |  string | path to private key for *ssh2* connection                                                                                                                                 | `~/.ssh/id_rsa` |
|     **keyphrase**    |  string | passphrase for private key file                                                                                                                                           |                 |
|       **port**       | integer | *ssh2* connection port                                                                                                                                                    | 22              |
|      **timeout**     | integer | limit to establish *ssh2* connection, in milliseconds                                                                                                                     | 1000            |

### Commands

{% tabs %}
{% tab title="YAML" %}

```yaml
commands:
      pingYa:
        exec: ping ya.ru
        extension: log
        restart: false
```

{% endtab %}
{% endtabs %}

Each command must contain:

* **name -** unique within host command identifier, using in **command output file** name template.
* **exec** - shell script
* **extension** - extension for **command output file**
* **restart** - restart command if it finished

## Using environment and other variables in **Data Aggregation Sources**

### Mustache syntax

YAML/JSON **Data Aggregation Sources** are support [mustache syntax](https://mustache.github.io):

* *env\_\** - template for environment variable, where \* is environment variable name.
* *output\_folder* - output folder path

### Example of **using** mustache syntax in **Daggy Sources**

{% tabs %}
{% tab title="YAML" %}

```yaml
aliases:  
    - &my_commands
        pingYa:
            exec: ping ya.ru
            extension: log
        pingGoo:
            exec: ping goo.gl
            extension: log
        
    - &ssh_auth
        user: {{env_USER}}
        passphrase: {{env_PASSWORD}}
            
sources:
    localhost:
        type: local
        commands: *my_commands
    remotehost:
        host: 192.168.1.9
        type: ssh2
        parameters: *ssh_auth
        commands: *my_commands
    remotehost2:
        host: 192.168.1.9
        type: ssh2
        parameters: *ssh_auth
        commands: *my_commands
    remotehost3:
        host: 192.168.1.9
        type: ssh2
        parameters: *ssh_auth
        commands: *my_commands
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://daggy.gitbook.io/docs/daggy-console-application/daggy-sources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
