From fa66a7b92a0d4a34ef0d95424e7a29270a264222 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 23 Jan 2010 20:47:17 +0000 Subject: [PATCH] simple and ugly viewer for store data --- lib/PXElator/httpd.pm | 23 ++++++++++++++++++++--- lib/PXElator/store.pm | 11 +++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/PXElator/httpd.pm b/lib/PXElator/httpd.pm index 8348b09..90c6469 100644 --- a/lib/PXElator/httpd.pm +++ b/lib/PXElator/httpd.pm @@ -18,6 +18,7 @@ use File::Slurp; #use JSON; use IO::Socket::INET; use Regexp::Common qw/net/; +use YAML; our $title; @@ -66,8 +67,8 @@ use store; sub menu { - my $couch_url = $url; - $couch_url =~ s{:\d+.+}{:5984/_utils/}; + my $store_url = $url; + $store_url =~ s{:\d+.+}{:28017}; qq{
home @@ -76,7 +77,8 @@ qq{ brctl ip | -couchdb +store +query | nmap client @@ -268,6 +270,21 @@ warn "XXX pids = ", dump( $daemons::pids ); | ; + } elsif ( $path =~ m{^/store/query} ) { + print $client ok + , qq|| + ; + store::query( sub { + my $o = shift; + my $p = delete( $o->{package} ); + delete( $o->{_id} ); + # XXX sigh, dump dies if we don't do this + my $tmp = delete( $o->{param} ); + $o->{param} = $tmp if defined $tmp; + print $client qq|\n|; + }); + print $client qq|
|, join(qq||, map { $p->{$_} } keys %$p ), qq|
|, dump( $o ), qq|
|; + } elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) { my $ip = $1; $title = $ip if $ip; diff --git a/lib/PXElator/store.pm b/lib/PXElator/store.pm index e1d4fef..a326621 100644 --- a/lib/PXElator/store.pm +++ b/lib/PXElator/store.pm @@ -59,5 +59,16 @@ sub audit { $audit->insert( $data ); } +use Data::Dumper; + +sub query { + my $callback = shift; + my $cursor = $audit->query->sort({ '$natural' => -1 })->limit( 25 ); + while( my $o = $cursor->next ) { +# $callback->( $o ); +warn Dumper( $o ); + $callback->( $o ); + } +} 1; -- 2.20.1