]> git.refcnt.org Git - distdns.git/commitdiff
Record and list last updated time
authorSteven Schubiger <stsc@refcnt.org>
Mon, 18 Nov 2013 18:57:09 +0000 (19:57 +0100)
committerSteven Schubiger <stsc@refcnt.org>
Mon, 18 Nov 2013 18:57:09 +0000 (19:57 +0100)
client.pl
server.cgi

index aab5ea47f89691473f728b1ffd9b1c197e4ddd68..729663f51a3c9a0b37148fddb617b9aa26960326 100755 (executable)
--- a/client.pl
+++ b/client.pl
@@ -29,6 +29,7 @@ use FindBin qw($Bin);
 use Getopt::Long qw(:config no_auto_abbrev no_ignore_case);
 use JSON qw(decode_json);
 use LWP::UserAgent;
+use POSIX qw(strftime);
 use Sys::Hostname qw(hostname);
 use Tie::File;
 
@@ -130,13 +131,14 @@ if ($response->is_success) {
     }
     elsif ($opts{l}) {
         format STDOUT_TOP =
-IP                 Name               PC                      Netz
-=============================================================================
+IP                 Name               PC                      Netz               Aktualisiert
+====================================================================================================
 .
         foreach my $entry (sort { $a->{netz} cmp $b->{netz} } @{$data->{entries}}) {
+            my $updated = strftime '%Y-%m-%d %H:%M:%S', localtime $entry->{time};
             format STDOUT =
-@<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<
-@$entry{qw(ip name pc netz)}
+@<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<<<<<
+@$entry{qw(ip name pc netz)}, $updated
 .
             write;
         }
index 43bf0bd302489dc30ffac9de781f7f3bd7e53837..c2df36ba3ab20da78e1d84e211cfa265ea70199f 100755 (executable)
@@ -134,6 +134,7 @@ if (exists $access{$params{name}} && grep /^$params{pc}$/i, @{$access{$params{na
             }
         }
         push @$data, { map { $_ => $params{$_} } qw(netz pc name ip) };
+        $data->[-1]->{time} = time;
 
         seek($fh, 0, 0)  or die "Cannot seek to start of $json_file: $!\n";
         truncate($fh, 0) or die "Cannot truncate $json_file: $!\n";