addHost: Reduce discovery event logs of existing devices and adds better error messages when adding hosts #3929

Merged
merged 3 commits into from Aug 3, 2016

Projects

None yet

3 participants

@murrant
Contributor
murrant commented Aug 2, 2016

Reconstruct addHost() so it is easier to understand
Update addHost() to return either device_id or a string
modify print_error(), print_message() to allow for $quiet variable
Only call addHost() once in addhost.php, if the snmp version isn't set, addHost will cope
Fix up snmp-scan.php and discovery-protocols.inc.php to detect when a device already exists
change in ip_exists() to make it more readable

Fixes #3315

@murrant murrant Reconstruct addHost() so it is easier to understand
Update addHost() to return either device_id or a string
modify print_error(), print_message() to allow for $quiet variable
Only call addHost() once in addhost.php, if the snmp version isn't set, addHost will cope
Fix up snmp-scan.php and discovery-protocols.inc.php to detect when a device already exists
change in ip_exists() to make it more readable
66bed27
@murrant murrant Accidental inclusion.
231bb52
@laf laf and 1 other commented on an outdated diff Aug 3, 2016
- if ($device_id) {
- $device = device_by_id_cache($device_id);
+ if (is_numeric($result)) {
+ $device = device_by_id_cache($result);
echo 'Added device '.$device['hostname'].' ('.$device_id.")\n";
@laf
laf Aug 3, 2016 Member

Does $device_id no longer exist now and you need $device['device_id']?

@murrant
murrant Aug 3, 2016 Contributor

oopsie, reverted that code and missed re-editing it.

@laf laf commented on an outdated diff Aug 3, 2016
}
else {
- print $console_color->convert("%rWe couldn't add this device, please check the snmp details%n\n");
+ print $console_color->convert("%rWe couldn't add this device:\n" . $result . "%n\n");
@laf
laf Aug 3, 2016 Member

Maybe add a couple of spaces or space-space before $result.

@murrant murrant changed the title from Reduce discovery event logs of existing devices and adds better error messages when adding hosts to addHost: Reduce discovery event logs of existing devices and adds better error messages when adding hosts Aug 3, 2016
@murrant murrant addHost.php output improvements/fixes
52d3136
@laf laf merged commit 507d706 into librenms:master Aug 3, 2016

2 checks passed

Auto-Deploy Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@murrant murrant deleted the murrant:discovery-events branch Aug 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment