refactor: Allow setting the target shorthost length. (#7453)

* Create a target shorthost length. Addresses #7452.

* Update defaults.inc.php
This commit is contained in:
Jonathan Lassoff
2017-11-09 20:47:52 +00:00
committed by Neil Lathwood
parent 3f27357951
commit fe8d011dce
2 changed files with 9 additions and 0 deletions

View File

@@ -298,6 +298,14 @@ $config['percentile_value'] = X;
```
Show the `X`th percentile in the graph instead of the default 95th percentile.
```php
$config['shorthost_target_length'] = X;
```
The target maximum hostname length when applying the shorthost() function.
You can increase this if you want to try and fit more of the hostname in graph titles.
The default value is 12
However, this can possibly break graph generation if this is very long.
### Add host settings
The following setting controls how hosts are added. If a host is added as an ip address it is checked to ensure the ip is not already present. If the ip is present the host is not added.
If host is added by hostname this check is not performed. If the setting is true hostnames are resolved and the check is also performed. This helps prevents accidental duplicate hosts.

View File

@@ -86,6 +86,7 @@ function shorthost($hostname, $len = 12)
if (filter_var($hostname, FILTER_VALIDATE_IP)) {
return $hostname;
}
$len = Config::get('shorthost_target_length', $len);
$parts = explode(".", $hostname);
$shorthost = $parts[0];