/[sysplogd]/sysplogd
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sysplogd

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 18 by dpavlin, Tue Apr 14 14:19:59 2009 UTC revision 19 by dpavlin, Fri Apr 17 10:03:00 2009 UTC
# Line 47  CREATE TABLE log ( Line 47  CREATE TABLE log (
47          id              serial,          id              serial,
48          timestamp       timestamp default now(),          timestamp       timestamp default now(),
49          ip              inet not null,          ip              inet not null,
         hostname        text,  
50          message         text,          message         text,
51          level           int,          level           int,
52          facility        int,          facility        int,
# Line 88  if ( $schema ) { Line 87  if ( $schema ) {
87    
88  my $sth_log_full = $dbh->prepare(qq{  my $sth_log_full = $dbh->prepare(qq{
89          insert into log          insert into log
90          (ip,hostname,message,level,facility,program,pid)          (ip,message,level,facility,program,pid)
91          values (?,?,?,?,?,?,?)          values (?,?,?,?,?,?)
92  });  });
93    
94  my $sth_log_unparsed = $dbh->prepare(qq{  my $sth_log_unparsed = $dbh->prepare(qq{
95          insert into log (ip,hostname,message) values (?,?,?)          insert into log (ip,message) values (?,?)
96  });  });
97    
98    
# Line 116  my $buf; Line 115  my $buf;
115  while(1) {  while(1) {
116          $sock->recv($buf, $MAXLEN);          $sock->recv($buf, $MAXLEN);
117          my ($port, $ipaddr) = sockaddr_in($sock->peername);          my ($port, $ipaddr) = sockaddr_in($sock->peername);
118          my $hostname = gethostbyaddr($ipaddr, AF_INET);  #       my $hostname = gethostbyaddr($ipaddr, AF_INET);
119          my $ip = join('.', unpack('C4',$ipaddr));          my $ip = join('.', unpack('C4',$ipaddr));
120          my @values = ( $ip, $hostname, $buf );          my @values = ( $ip, $buf );
121    
122          if ( $buf =~ s/<(\d+)>// ) {          if ( $buf =~ s/<(\d+)>// ) {
123                  my $level    = $1 % 8;                  my $level    = $1 % 8;
# Line 133  while(1) { Line 132  while(1) {
132                          $pid      = $1 if $program =~ s/\[(\d+)\]$//;                          $pid      = $1 if $program =~ s/\[(\d+)\]$//;
133                  }                  }
134    
135                  $values[2] = $buf;                  $values[1] = $buf;
136                  push @values, ( $level, $facility, $program, $pid );                  push @values, ( $level, $facility, $program, $pid );
137                  $sth_log_full->execute( @values );                  $sth_log_full->execute( @values );
138          } else {          } else {

Legend:
Removed from v.18  
changed lines
  Added in v.19

  ViewVC Help
Powered by ViewVC 1.1.26