X-Git-Url: https://git.openstreetmap.org./dns.git/blobdiff_plain/e36e2f7683f9f3d6b2993b3f10146f5167bda1cc..776cc38b7646cbe6a6177cd0da7dd5d33d955e05:/bin/mkgeo diff --git a/bin/mkgeo b/bin/mkgeo index f5ecbd3..3a69d89 100755 --- a/bin/mkgeo +++ b/bin/mkgeo @@ -35,7 +35,7 @@ while (my($name,$cluster) = each %$clusters) push @servers, $server; } } - else + elsif ($cluster->{requests} > 0) { my $server = { cluster => $cluster, @@ -50,6 +50,10 @@ while (my($name,$cluster) = each %$clusters) push @servers, $server; } + else + { + $cluster->{servers} = []; + } $cluster->{name} = $name; $cluster->{status} = "down"; @@ -145,6 +149,9 @@ foreach my $server (@servers) } } +# Abort if no servers at all are up +exit 0 unless grep { $_->{status} eq "up" } values(%$clusters); + # Create target origins object my $targetorigins = {}; @@ -221,6 +228,25 @@ while (grep { !exists($_->{cluster}) } values %$origins) allocate_clusters(@mappings); } +# Report on allocation results +foreach my $name (sort keys %$clusters) +{ + my $cluster = $clusters->{$name}; + my $used = int($cluster->{requests_used} + 0.5); + my $limit = $cluster->{requests_limit}; + + if ($limit > 0) + { + my $proportion = int($used / $limit * 100 + 0.5); + + print "${name}: used ${used} of ${limit} (${proportion}%)\n"; + } + else + { + print "${name}: used ${used} of ${limit}\n"; + } +} + # Create JSON collection object my @json; @@ -329,7 +355,7 @@ if (defined($gdnsname)) my $continent = ""; $gdnsmapfile->print("${gdnsname} => {\n"); - $gdnsmapfile->print(" geoip2_db => /usr/share/GeoIP/GeoLite2-Country.mmdb\n"); + $gdnsmapfile->print(" geoip2_db => /etc/gdnsd/geoip/GeoLite2-Country.mmdb\n"); $gdnsmapfile->print(" datacenters => [" . join(",", sort(keys(%$clusters))) . "]\n"); $gdnsmapfile->print(" map => {\n"); $gdnsmapfile->print(" default => [" . join(",", sort(map { $_->{name} } grep { $_->{default} } values(%$clusters))) . "]\n");