Fwd: Re: [PHP] log tailing
| From: | tamouse mailing lists | Date: | Sat, 30 Jun 2012 21:36:56 +0000 |
| Subject: | Fwd: Re: [PHP] log tailing | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318352@lists.php.net to get a copy of this message | ||
---------- Forwarded message ----------
From: "tamouse mailing lists" <tamouse.lists@gmail.com>
Date: Jun 30, 2012 4:35 PM
Subject: Re: [PHP] log tailing
To: "Daniel Brown" <danbrown@php.net>
On Jun 30, 2012 1:34 PM, "Daniel Brown" <danbrown@php.net> wrote:
>
> On Sat, Jun 30, 2012 at 2:30 PM, Daniel Brown <danbrown@php.net> wrote:
> >
> > <?php
> >
> > $ssh_entries = explode(PHP_EOL,trim(`tail /var/log/syslog | awk
> > {'print $1,$2,$3 "|" $5 "|" $11'}`));
>
> Actually, the above was intended to grab just sshd entries, so
> instead of 'tail' you should use 'grep sshd' in the line above.
>
>
> > foreach ($ssh_entries as $s) {
> > $l = explode('|',$s);
> >
> > // Remember to do whatever sanity necessary!
> > $sql = "INSERT INTO ssh_activity
> >
> > VALUES('".$l[0]."','".$l[1]."','".$l[2]."')";
> > }
> > ?>
> >
> > --
> > </Daniel P. Brown>
> > Network Infrastructure Manager
> > http://www.php.net/
>
>
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Crud-- sent to Dan instead of list:
Or just let awk do it:
tail /var/log/syslog | awk '/sshd/{print($1,$2,$3 "|" $5 "|" $11)}'