diff --git a/bin/netdisco-rancid-export b/bin/netdisco-rancid-export index 3eef962a..ef907f83 100755 --- a/bin/netdisco-rancid-export +++ b/bin/netdisco-rancid-export @@ -46,7 +46,7 @@ use App::Netdisco::Util::Permission ':all'; exit(0) unless setting('use_legacy_rancidexport'); my $settings = setting( 'rancid' ); -my $domain_suffix = setting( 'domain_suffix' ) || ''; +my $domain_suffix = setting( 'domain_suffix' ); my $delimiter = $settings->{ 'delimiter' } || ':'; my $down_age = $settings->{ 'down_age' } || '1 day'; my $rancidhome = $settings->{ 'rancid_home' } || '/var/lib/rancid'; @@ -110,7 +110,7 @@ foreach my $group (keys %$list) { $name = ($dev->dns || $dev->name); } if ($by_hostname->{$group}) { - $name =~ s/$domain_suffix$//; + $name =~ s/$domain_suffix//; } printf ROUTER "%s$delimiter%s$delimiter%s\n", $name, $vendor, $dev->get_column( 'old' ) ? "down" : "up"; diff --git a/lib/App/Netdisco/Util/Graph.pm b/lib/App/Netdisco/Util/Graph.pm index f8e8124a..7c06cd8b 100644 --- a/lib/App/Netdisco/Util/Graph.pm +++ b/lib/App/Netdisco/Util/Graph.pm @@ -298,8 +298,8 @@ sub graph_addnode { $devloc = $GRAPH{$ip}->{location}; $label = "($ip)" unless defined $label; - my $domain_suffix = setting('domain_suffix') || ''; - $label =~ s/$domain_suffix$//; + my $domain_suffix = setting('domain_suffix'); + $label =~ s/$domain_suffix//; $node{label} = $label; # Dereferencing the scalar by name below diff --git a/lib/App/Netdisco/Util/NodeMonitor.pm b/lib/App/Netdisco/Util/NodeMonitor.pm index ac695f6c..84c26160 100644 --- a/lib/App/Netdisco/Util/NodeMonitor.pm +++ b/lib/App/Netdisco/Util/NodeMonitor.pm @@ -5,6 +5,7 @@ use App::Netdisco; use Dancer qw/:syntax :script/; use Dancer::Plugin::DBIC 'schema'; +use Net::Domain 'hostfqdn'; use App::Netdisco::Util::DNS qw/hostname_from_ip ipv4_from_hostname/; use base 'Exporter'; @@ -16,8 +17,7 @@ our %EXPORT_TAGS = (all => \@EXPORT_OK); sub _email { my ($to, $subject, $body) = @_; return unless $to; - my $domain = setting('domain_suffix') || 'localhost'; - $domain =~ s/^\.//; + $domain =~ (hostfqdn || 'fqdn-undefined'); my $SENDMAIL = '/usr/sbin/sendmail'; open (SENDMAIL, "| $SENDMAIL -t") or die "Can't open sendmail at $SENDMAIL.\n"; diff --git a/lib/App/Netdisco/Worker/Plugin/MakeRancidConf.pm b/lib/App/Netdisco/Worker/Plugin/MakeRancidConf.pm index a43ac553..4a4df71d 100644 --- a/lib/App/Netdisco/Worker/Plugin/MakeRancidConf.pm +++ b/lib/App/Netdisco/Worker/Plugin/MakeRancidConf.pm @@ -18,7 +18,7 @@ register_worker({ phase => 'main' }, sub { my ($job, $workerconf) = @_; my $config = setting('rancid') || {}; - my $domain_suffix = setting('domain_suffix') || ''; + my $domain_suffix = setting('domain_suffix'); my $delimiter = $config->{delimiter} || ';'; my $down_age = $config->{down_age} || '1 day'; my $default_group = $config->{default_group} || 'default'; @@ -65,7 +65,7 @@ register_worker({ phase => 'main' }, sub { } my $name = check_acl_no($d, $config->{by_ip}) ? $d->ip : ($d->dns || $d->name); - $name =~ s/$domain_suffix$// if check_acl_no($d, $config->{by_hostname}); + $name =~ s/$domain_suffix// if check_acl_no($d, $config->{by_hostname}); my ($group) = (pairkeys pairfirst { check_acl_no($d, $b) } %{ $config->{groups} }) || $default_group;