use store::audit proxy all over the place
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 23 Jan 2010 18:31:14 +0000 (18:31 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 23 Jan 2010 18:31:14 +0000 (18:31 +0000)
13 files changed:
lib/PXElator/CouchDB.pm
lib/PXElator/amt.pm
lib/PXElator/daemons.pm
lib/PXElator/dhcpd.pm
lib/PXElator/dnsd.pm
lib/PXElator/httpd.pm
lib/PXElator/nmap.pm
lib/PXElator/ping.pm
lib/PXElator/shell.pm
lib/PXElator/ssh.pm
lib/PXElator/syslogd.pm
lib/PXElator/tftpd.pm
lib/PXElator/wol.pm

index efb15b5..91e90a8 100644 (file)
@@ -124,7 +124,7 @@ sub audit {
 
        my $time = time();
 
-       my @caller = caller(0);
+       my @caller = caller(1); # skip store wrapper
        $caller[3] = (caller(1))[3];
        $caller[3] =~ s{^.+::}{}; # stip package name from sub
        $data->{package} = {
index 1e23d80..c424f6f 100644 (file)
@@ -12,7 +12,7 @@ use Regexp::Common qw/net/;
 
 use html;
 use ping;
-use CouchDB;
+use store;
 use Carp qw/confess/;
 
 sub ip {
@@ -36,7 +36,7 @@ sub ip {
 
 sub power_state {
        my $state = eval { Intel::AMT::RemoteControl::SystemPowerState };
-       CouchDB::audit('SystemPowerState', { ip => $ENV{AMT_HOST}, SystemPowerState => $state });
+       store::audit('SystemPowerState', { ip => $ENV{AMT_HOST}, SystemPowerState => $state });
        return $state;
 }
 
@@ -54,7 +54,7 @@ sub network {
                warn "ERROR $@";
        } else {
                $amt->{ip} = $ENV{AMT_HOST};
-               CouchDB::audit('log', $amt );
+               store::audit('log', $amt );
        }
        $amt;
 }
@@ -67,7 +67,7 @@ sub log {
                warn "ERROR $@";
        } else {
                $amt->{ip} = $ENV{AMT_HOST};
-               CouchDB::audit('log', $amt );
+               store::audit('log', $amt );
        }
        $amt;
 }
@@ -76,7 +76,7 @@ sub RemoteControl {
        ip shift;
        my $command = shift;
        eval { Intel::AMT::RemoteControl::run( $command ) };
-       CouchDB::audit( $command, { ip => $ENV{AMT_HOST}, error => $@ } );
+       store::audit( $command, { ip => $ENV{AMT_HOST}, error => $@ } );
        warn "ERROR $@" if $@;
 }
 
index 7cd92f2..3efac68 100644 (file)
@@ -7,7 +7,7 @@ use File::Slurp;
 use Data::Dump qw/dump/;
 
 use x11;
-use CouchDB;
+use store;
 
 our $pids;
 $pids = {
@@ -29,7 +29,7 @@ $SIG{CHLD} = 'IGNORE';
 sub audit {
        my $msg = shift;
        my $daemon = shift;
-       CouchDB::audit( $msg, $daemon, { daemon => $daemon, message => $msg, @_ } );
+       store::audit( $msg, $daemon, { daemon => $daemon, message => $msg, @_ } );
 }
 
 mkdir "$server::conf/pid" unless -d "$server::conf/pid";
index 6276ff2..fe1c65c 100644 (file)
@@ -23,7 +23,7 @@ use lib '..';
 use Net::DHCP::Packet;
 use Net::DHCP::Constants 0.67;
 
-use CouchDB;
+use store;
 use format;
 
 use server;
@@ -230,7 +230,7 @@ sub process_packet {
                warn $audit->{error};
        }
 
-       CouchDB::audit( @type, $audit );
+       store::audit( @type, $audit );
 
 #      system("arp -s $ip $mac"),
 
@@ -252,7 +252,7 @@ sub start {
 
        print "DHCP listen on ",$sock->sockhost,":",$sock->sockport,"\n";
 
-       CouchDB::audit( 'start', { addr => $sock->sockhost, port => $sock->sockport } );
+       store::audit( 'start', { addr => $sock->sockhost, port => $sock->sockport } );
 
        while (1) {
                server->refresh;
index 2afeda4..2a68c71 100644 (file)
@@ -6,7 +6,7 @@ use strict;
 use Net::DNS::Nameserver;
 use Net::DNS::Resolver;
 use Data::Dump qw/dump/;
-use CouchDB;
+use store;
 
 use server;
 use client;
@@ -106,7 +106,7 @@ warn "## no $qname in ",dump( $ptr_cache );
                $data;
        } @ans ];
 
-       CouchDB::audit( 'response', $audit );
+       store::audit( 'response', $audit );
 
        # mark the answer as authoritive (by setting the 'aa' flag
        return ($rcode, \@ans, \@auth, \@add, { aa => 1 });
@@ -122,7 +122,7 @@ sub start {
                Verbose      => $debug,
        ) || die "couldn't create nameserver object\n";
 
-       CouchDB::audit('start', { port => 53, domain => $server::domain });
+       store::audit('start', { port => 53, domain => $server::domain });
        warn "DNS $server::domain";
 
        $ns->main_loop;
index fb88e10..531dd47 100644 (file)
@@ -63,7 +63,7 @@ use nmap;
 use ping;
 use wol;
 
-use CouchDB;
+use store;
 
 
 sub menu {
@@ -117,7 +117,7 @@ sub static {
        my $buff;
        my $pos = 0;
 
-       CouchDB::audit( 'static', { pid => $$, path => $path, type => $type, size => $size, block => $block, peerhost => $client->peerhost });
+       store::audit( 'static', { pid => $$, path => $path, type => $type, size => $size, block => $block, peerhost => $client->peerhost });
 
        progress_bar::start;
 
@@ -150,7 +150,7 @@ sub get_request {
 
        server->refresh;
 
-       CouchDB::audit( 'request', { path => $path, param => $param, peerhost => $client->peerhost } );
+       store::audit( 'request', { path => $path, param => $param, peerhost => $client->peerhost } );
 
        $title = $path;
 
index c7754a5..6759cee 100644 (file)
@@ -5,7 +5,7 @@ use strict;
 
 use XML::Simple;
 use Data::Dump qw/dump/;
-use CouchDB;
+use store;
 
 use client;
 
@@ -28,7 +28,7 @@ sub scan {
                ForceArray => [ 'host', 'address', 'osmatch', 'port' ],
        );
 
-       CouchDB::audit( $what, $nmap );
+       store::audit( $what, $nmap );
 
        my $count = 0;
 
index cf3319a..0e1ae2f 100644 (file)
@@ -7,7 +7,7 @@ use Net::Ping;
 use Data::Dump qw/dump/;
 use Time::HiRes;
 use client;
-use CouchDB;
+use store;
 
 sub host {
        my $ip = shift;
@@ -37,7 +37,7 @@ sub fping {
                $rtt *= 1000; # ms
                client::conf( $ip => 'hostname', default => $host ) if $host ne $ip;
                $status->{$host} = { host => $host, rtt => $rtt, ip => $ip };
-               CouchDB::audit( $ip, $status->{$host});
+               store::audit( $ip, $status->{$host});
        }
 
        warn "# fping ",dump($status);
index e6eeef6..1fe2be2 100644 (file)
@@ -5,7 +5,7 @@ use strict;
 
 use autodie;
 use Data::Dump qw/dump/;
-use CouchDB;
+use store;
 
 our $command;
 
@@ -47,7 +47,7 @@ warn "command $command key $key";
                if ( $key ) {
                        my $k = $cols[$key - 1];
                        $info->{$k} = $hash;
-                       CouchDB::audit( $command, $k, $hash );
+                       store::audit( $command, $k, $hash );
                } else {
                        push @$info, $hash;
                }
index 7895593..608be37 100644 (file)
@@ -7,7 +7,7 @@ use Net::OpenSSH;
 use English;
 use Data::Dump qw/dump/;
 use client;
-use CouchDB;
+use store;
 
 my $id = 3;
 my $id_rsa = '/root/.ssh/id_rsa';
@@ -70,7 +70,7 @@ sub shell {
                my ($out,$err) = $ssh->capture2( $command ) or die "$command ", $ssh->error;
                warn "$out\n$err";
 
-               CouchDB::audit( $ip, $command, { ip => $ip, command => $command, out => $out, err => $err } );
+               store::audit( $ip, $command, { ip => $ip, command => $command, out => $out, err => $err } );
 
                $html .= qq|<tt style="color: grey">root\@$ip:# <b>$command</b></tt><pre>$out</pre>|;
                $html .= qq|<pre style="color: red">$err</pre>| if $err;
index debb3c4..6499855 100644 (file)
@@ -5,7 +5,7 @@ use strict;
 
 use IO::Socket;
 use Data::Dump qw/dump/;
-use CouchDB;
+use store;
 use File::Slurp;
 
 use server;
@@ -67,7 +67,7 @@ sub message {
        }
 
        warn "log ",dump( $log );
-       CouchDB::audit( $log->{tag}, $log );
+       store::audit( $log->{tag}, $log );
 }
 
 sub start {
@@ -78,7 +78,7 @@ sub start {
                ReuseAddr => 1,
        ) || die "can't listen to $port: $!";
 
-       CouchDB::audit('start', { port => $port });
+       store::audit('start', { port => $port });
 
        while(1) {
                message($sock);
index 1a8ca0b..f4a8fde 100644 (file)
@@ -6,7 +6,7 @@ use strict;
 use Net::TFTPd 0.03 qw(%OPCODES);
 use IO::Socket::INET;
 use Data::Dump qw/dump/;
-use CouchDB;
+use store;
 
 use server;
 
@@ -62,7 +62,7 @@ sub tftp_request {
                path => $file,
                state => 'start',
        };
-       CouchDB::audit( $opcode, $audit );
+       store::audit( $opcode, $audit );
 
        progress_bar::start;
 
@@ -71,11 +71,11 @@ sub tftp_request {
                my $size = -s "$dir/$file";
                $audit->{state} = 'finish';
                $audit->{size} = $size;
-               CouchDB::audit( $opcode, $audit );
+               store::audit( $opcode, $audit );
        } else {
                $audit->{state} = 'error';
                $audit->{error} = Net::TFTPd->error;
-               CouchDB::audit( $opcode, $audit );
+               store::audit( $opcode, $audit );
        }
 
 }
@@ -118,7 +118,7 @@ sub start {
 
        warn 'listener: ',dump( $listener ) if $debug;
 
-       CouchDB::audit( 'start', {
+       store::audit( 'start', {
                addr => $listener->{LocalAddr},
                port => $listener->{LocalPort},
                timeout => $listener->{Timeout},
index 823ba45..253e72f 100644 (file)
@@ -5,7 +5,7 @@ use strict;
 
 use IO::Socket::INET;
 use Regexp::Common qw/net/;
-use CouchDB;
+use store;
 
 use client;
 use server;
@@ -38,7 +38,7 @@ sub power_on {
        send($sock, $packet, 0, $sock_addr);
        close ($sock);
 
-       CouchDB::audit( $target, { ip => $target, mac => $mac } );
+       store::audit( $target, { ip => $target, mac => $mac } );
 }
 
 1;