# systemd-syslog() source options

The `systemd-syslog()` driver has the following options:

## check-hostname()

|   
---|---  
Type: | boolean (`yes` or `no`)  
Default: | Use the global `check-hostname()` option, which defaults to `no`.  
  
_Description:_

When receiving messages, AxoSyslog can check whether the hostname contains valid characters.

Valid characters are:

  * alphanumeric characters (A-Z, a-z, 0-9)
  * the dash (`-`) and underscore (`_`) characters
  * the dot (`.`) and the colon (`:`) characters
  * the `@` and slash (`/`)



If the hostname contains invalid characters, AxoSyslog sets the `syslog.invalid_hostname` tag for the message, and doesn’t parse the `${HOST}` field from the message.

Uses the value of the [global option](../../../docs/axosyslog-core/chapter-global-options/reference-options/index.md#global-option-check-hostname) if not specified.

## hook-commands()

_Description:_ This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The `hook-commands()` can be used with all source and destination drivers with the exception of the `usertty()` and `internal()` drivers.

Note The AxoSyslog application must be able to start and restart the external program, and have the necessary permissions to do so. For example, if your host is running AppArmor or SELinux, you might have to modify your AppArmor or SELinux configuration to enable AxoSyslog to execute external applications. 

### Using `hook-commands()` when AxoSyslog starts or stops

To execute an external program when AxoSyslog starts or stops, use the following options:

#### `startup()`

Type: | string  
---|---  
Default: | N/A  
  
_Description:_ Defines the external program that is executed as AxoSyslog starts.

#### `shutdown()`

Type: | string  
---|---  
Default: | N/A  
  
_Description:_ Defines the external program that is executed as AxoSyslog stops.

### Using the hook-commands() when AxoSyslog reloads

To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:

#### `setup()`

Type: | string  
---|---  
Default: | N/A  
  
_Description:_ Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.

#### `teardown()`

Type: | string  
---|---  
Default: | N/A  
  
_Description:_ Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.

### Example: Using hook-commands() with a network source

In the following example, the `hook-commands()` is used with the `network()` driver and it opens an [iptables](<https://en.wikipedia.org/wiki/Iptables> "https://en.wikipedia.org/wiki/Iptables") port automatically as AxoSyslog is started/stopped.

The assumption in this example is that the `LOGCHAIN` chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
```
 
    source {
        network(transport(udp)
        hook-commands(
              startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
              shutdown("iptables -D LOGCHAIN 1")
            )
         );
    };
    
```

## idle-timeout()

|   
---|---  
Accepted values: | number [seconds]  
Default: | `0` (disabled)  
  
Available in AxoSyslog 4.9 and later.

If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).

Last modified November 8, 2024: [[4.9] Adds idle-timeout source option (14eab5a3)](<https://github.com/axoflow/axosyslog-core-docs/commit/14eab5a38d2064f72d771cf64bd477e01b8884fa>)