Smokeping menu and title use device displayname (#15387)

* Menu and title use displayname

* Fix empty strings

* Fix array creation

* Use groupby instead of loop

* Change one forgotten var

* Revert to working simple changes

* Change test data to include displayname

* Fix bad copy paste in test data
This commit is contained in:
Félix Bouynot 2023-10-31 14:38:51 +01:00 committed by GitHub
parent 6134d9c153
commit 7a6ef2491e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -127,7 +127,10 @@ class SmokepingGenerateCommand extends LnmsCommand
// Take the devices array and build it into a hierarchical list
$smokelist = [];
foreach ($devices as $device) {
$smokelist[$device->type][$device->hostname] = ['transport' => $device->transport];
$smokelist[$device->type][$device->hostname] = [
'transport' => $device->transport,
'displayname' => $device->displayName(),
];
}
$targets = $this->buildTargets($smokelist, Config::get('smokeping.probes'), $this->option('single-process'));
@ -315,8 +318,8 @@ class SmokepingGenerateCommand extends LnmsCommand
foreach ($devices as $hostname => $config) {
if (! $this->dnsLookup || $this->deviceIsResolvable($hostname)) {
$lines[] = sprintf('++ %s', $this->buildMenuEntry($hostname));
$lines[] = sprintf(' menu = %s', $hostname);
$lines[] = sprintf(' title = %s', $hostname);
$lines[] = sprintf(' menu = %s', $config['displayname']);
$lines[] = sprintf(' title = %s', $config['displayname']);
if (! $singleProcess) {
$lines[] = sprintf(' probe = %s', $this->balanceProbes($config['transport'], $probeCount));

View File

@ -39,43 +39,55 @@ class SmokepingCliTest extends DBTestCase
'Le23HKVMvN' => [
'Cl09bZU4sn' => [
'transport' => 'udp',
'displayname' => 'Cl09bZU4sn',
],
'c559TvthzY' => [
'transport' => 'udp6',
'displayname' => 'c559TvthzY',
],
'sNtzSdxdw8' => [
'transport' => 'udp6',
'displayname' => 'sNtzSdxdw8',
],
'10.0.0.3' => [
'transport' => 'udp',
'displayname' => '10.0.0.3',
],
'2600::' => [
'transport' => 'udp',
'displayname' => '2600::',
],
],
'Psv9oZcxdC' => [
'oHiPfLzrmU' => [
'transport' => 'udp',
'displayname' => 'oHiPfLzrmU',
],
'kEn7hZ7N37' => [
'transport' => 'udp6',
'displayname' => 'kEn7hZ7N37',
],
'PcbZ5FKtS3' => [
'transport' => 'udp6',
'displayname' => 'PcbZ5FKtS3',
],
'192.168.1.1' => [
'transport' => 'udp',
'displayname' => '192.168.1.1',
],
'fe80::' => [
'transport' => 'udp',
'displayname' => 'fe80::',
],
],
'4diY0pWFik' => [
'example.org' => [
'transport' => 'udp',
'displayname' => 'example.org',
],
'host_with_under_score.example.org' => [
'transport' => 'udp6',
'displayname' => 'host_with_under_score.example.org',
],
],
];