Permalink
Browse files

tweaks from the prod server

edit command for the pool tool

add a "180 days ago" count

add a 3.{zone} zone


git-svn-id: https://svn.develooper.com/projects/ntppool/trunk@358 e01dd7d5-6be1-0310-aa60-dbbdb055a346
  • Loading branch information...
1 parent c31d20c commit b942f01defa1deb6499b131f72a1564f25b7312a @abh committed Mar 18, 2006
Showing with 54 additions and 26 deletions.
  1. +2 −2 bin/populate_zones
  2. +1 −0 docs/ntppool/robots.txt
  3. +1 −1 docs/ntppool/tpl/zone.html
  4. +1 −1 header
  5. +2 −2 lib/NTPPool/Control/Manage.pm
  6. +46 −19 pool
  7. +1 −1 web
View
@@ -15,7 +15,7 @@ my ($global) = NTPPool::Zone->search(name => '@')
or die "No global zone setup in the zones table";
while (my $zone = $zones->next) {
- next if $zone->name eq '@';
+ next if length($zone->name) == 1;
if (length($zone->name) > 2) {
my $name = $zone->name;
$name =~ s/-/ /;
@@ -30,7 +30,7 @@ while (my $zone = $zones->next) {
my $country = Locale::Object::Country->new( code_alpha2 => $cc );
my $country_name = $country->name;
$country_name =~ s/,.*//;
- $zone->description($country_name);
+ $zone->description($country_name) if $country_name;
my ($continent) = NTPPool::Zone->search(description => $country->continent->name);
$zone->parent($continent) if $continent;
}
@@ -0,0 +1 @@
+# Hello Robot!
@@ -62,7 +62,7 @@
<p>
-[% FOR days = [1,7,14,30,90,365,730];
+[% FOR days = [1,7,14,30,90,180,365,730];
st = zone.stats_days_ago(days);
NEXT UNLESS st;
diff = zone.server_count - st.count_active;
View
@@ -30,7 +30,7 @@ Zpool.ntp.org:ns1.us.bitnames.com:pool.ntp.org:@VERSION@:1200:600:604800:300
Cweb.pool.ntp.org:x3.develooper.com:28800
Cwww.pool.ntp.org:x3.develooper.com:28800
-
++pool.ntp.org:216.52.237.153:2100
@@ -132,7 +132,7 @@ sub handle_update_netspeed {
return NOT_FOUND unless $server and $server->admin == $self->user;
if (my $netspeed = $self->req_param('netspeed')) {
$server->netspeed($netspeed) if $netspeed =~ m/^\d+$/;
- if ($server->netspeed < 1000) {
+ if ($server->netspeed < 768) {
$server->leave_zone('@');
}
else {
@@ -145,7 +145,7 @@ sub handle_update_netspeed {
my $return = {
netspeed => $self->netspeed_human($server->netspeed),
- zones => join ", ", map { join "",
+ zones => join " ", map { join "",
'<a href="/zone/',
$_->name, '">',
$_->name,
View
@@ -70,6 +70,25 @@ sub logsay {
close LOG;
}
+sub server_information {
+ my $server = shift;
+ my @zones = $server->zones;
+ my @r;
+ push @r, sprintf "IP: %s, ID: %i, username: %s email: %s\n",
+ $server->ip,
+ $server->id,
+ $server->admin->username ? $server->admin->username : "-",
+ $server->admin->email;
+ push @r, sprintf "score: %.1f, in pool: %i, in server list: %i\n", $server->score, $server->in_pool, $server->in_server_list;
+ my $gi = Geo::IP->new(GEOIP_STANDARD);
+ my $country = $gi->country_code_by_addr($server->ip);
+ $country = lc $country if $country;
+ push @r, "Country: $country\n" if $country;
+ push @r, "Zones: ", join (", ", map { $_->name } @zones), "\n";
+ push @r, sprintf "in_pool: %i, in_server_list: %i\n", $server->in_pool, $server->in_server_list;
+ @r;
+}
+
if ($#ARGV < 0) {
die "pool add|report|scores|zone [<args>]\n";
}
@@ -137,21 +156,30 @@ if ($cmd eq "add") {
logsay($s->id . " add $email $hostname $z");
}
+elsif ($cmd eq "edit") {
+ my $arg = shift @ARGV or die "pool zones <host or IP>\n";
+ my $server = NTPPool::Server->find_server($arg);
+ die "Could not find server $arg\n" unless $server;
+ print server_information($server);
+ while (my $k = shift @ARGV) {
+ my $v = shift @ARGV;
+ last unless defined $v;
+ print "Set $k -> $v\n";
+ if ($server->can($k)) {
+ $server->$k($v);
+ }
+ else {
+ die "Don\'t know how to set $k\n";
+ }
+ }
+ $server->update;
+ print server_information($server);
+}
elsif ($cmd eq "zones") {
my $arg = shift @ARGV or die "pool zones <host or IP>\n";
my $server = NTPPool::Server->find_server($arg);
die "Could not find server $arg\n" unless $server;
- my @zones = $server->zones;
- printf "IP: %s, ID: %i, username: %s email: %s\n",
- $server->ip,
- $server->id,
- $server->admin->username ? $server->admin->username : "-",
- $server->admin->email;
- printf "score: %.1f, in pool: %i, in server list: %i\n", $server->score, $server->in_pool, $server->in_server_list;
- my $gi = Geo::IP->new(GEOIP_STANDARD);
- my $country = $gi->country_code_by_addr($server->ip);
- $country = lc $country if $country;
- print "Country: $country\n" if $country;
+ print server_information($server);
my @zones = $server->zones;
for my $zone_name (@ARGV) {
my @locations = $server->locations;
@@ -315,7 +343,7 @@ elsif ($cmd eq "zone") {
open(my $fh, ">$file.tmp") or die "Could not open $file.tmp: $!";
open HEAD, "<header"
- or die "Opening DNS zone file header ($ENV{HOME}/db/header): $!\n";
+ or die "Opening DNS zone file header (header): $!\n";
print $fh "# ATTENTION\n# This is a generated file\n#\n";
my $t = time;
while (<HEAD>) {
@@ -340,17 +368,16 @@ elsif ($cmd eq "zone") {
next unless $entries and @$entries;
-
- my $min_non_duplicate_size = 5;
- $min_non_duplicate_size = int(@$entries / 4)
- if (@$entries / 4 > $min_non_duplicate_size);
+ my $min_non_duplicate_size = 4;
+ $min_non_duplicate_size = int(@$entries / 5)
+ if (@$entries / 5 > $min_non_duplicate_size);
$min_non_duplicate_size = 12 if $min_non_duplicate_size > 12;
print $fh "# " . scalar @$entries . " active servers in ", $zone->name, "\n";
- if ($#$entries < ($min_non_duplicate_size*4 - 1)) {
+ if ($#$entries < ($min_non_duplicate_size*5 - 1)) {
print $fh "# possible duplicates in the zones below (", $zone->name, ")\n";
- foreach my $z (("", "0.", "1.", "2.")) {
+ foreach my $z (("", "0.", "1.", "2.", "3.")) {
@$entries = shuffle(@$entries);
my $i;
foreach my $e (@$entries) {
@@ -363,7 +390,7 @@ elsif ($cmd eq "zone") {
else {
print $fh "# 'big' zone without duplicates below (", $zone->name, ")\n";
@$entries = shuffle(@$entries);
- foreach my $z (("", "0.", "1.", "2.")) {
+ foreach my $z (("", "0.", "1.", "2.", "3.")) {
for (my $i = 0 ; $i < $min_non_duplicate_size; $i++) {
print $fh "+$z${name}pool.ntp.org:", ${shift @$entries}[0], ":$ttl\n";
}
View

0 comments on commit b942f01

Please sign in to comment.