#use JSON;
use IO::Socket::INET;
use Regexp::Common qw/net/;
+use POSIX qw(strftime);
our $title;
sub menu {
- my $couch_url = $url;
- $couch_url =~ s{:\d+.+}{:5984/_utils/};
+ my $store_url = $url;
+ $store_url =~ s{:\d+.+}{:28017};
qq{
<div style="font-size: 80%; color: #888">
<a target=pids href=/ >home</a>
<a target=server href=/brctl >brctl</a>
<a target=server href=/ip >ip</a>
|
-<a target=couch href=$couch_url >couchdb</a>
+<a target=store href=$store_url >MongoDB</a>
+<a target=store href=/store/latest >latest</a>
|
<a target=client href=/nmap >nmap</a>
<a target=client href=/client >client</a>
|
;
+ } elsif ( $path =~ m{^/store/latest} ) {
+ print $client ok
+ , qq|
+<style type=text/css>
+ .z {
+ background: #eee;
+ }
+ td > pre {
+ margin: 0;
+ max-height: 3em;
+ overflow: hidden;
+ }
+ td:hover > pre {
+ max-height: 100%;
+ overflow: show;
+ }
+</style>
+ |
+ , qq|<table>|
+ ;
+ my ( $s1,$s2 ) = ( ' class=z', '' );
+ my @cols;
+
+ my $from_t = $param->{from_t};
+
+ store::query( $from_t, sub {
+ my $o = shift;
+ my $p = delete( $o->{package} );
+ delete( $o->{_id} );
+
+ if ( ! @cols ) {
+ #@cols = keys %$p;
+ @cols = qw( time name );
+ print $client qq|<tr><th>|
+ , join(qq|</th><th>|, @cols)
+ , qq|</th><th></th></tr>|
+ ;
+ }
+
+ # XXX sigh, dump dies if we don't do this
+# delete $o->{$_} foreach ( grep { ! defined $o->{$_} } keys %$o );
+
+ print $client qq|<tr$s1>|
+ , strftime( qq|<td title="%Y-%m-%d">%H:%M:%S</td>|, localtime($p->{time}) )
+ , map { qq|<td>$_<td>| } ( $p->{name} , html::pre_dump($o) )
+ , qq|</tr>\n|
+ ;
+ ( $s1, $s2 ) = ( $s2, $s1 );
+ $from_t = $p->{time};
+ });
+ print $client qq|</table>|,
+ qq|<a href="/store/latest?from_t=$from_t">more</a>|
+ ;
+
} elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) {
my $ip = $1;
$title = $ip if $ip;