Re: log tailing
| From: | Daniel Brown | Date: | Sat, 30 Jun 2012 18:32:03 +0000 |
| Subject: | Re: log tailing | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318350@lists.php.net to get a copy of this message | ||
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/