I have a few access points that are syslog capable and have them sending logs to my syslog server. It gets dumped into the main log file, messages, but would like to split it to a separate file so that it is slightly easier to discern what is coming from where.
I looked at the man pages and saw that I can pipe output to a cmd, so I was thinking I could easily write a shell script that does the matching there, but am wondering if that is a bad idea. This is a rough draft of what I was contemplating:
I looked at the man pages and saw that I can pipe output to a cmd, so I was thinking I could easily write a shell script that does the matching there, but am wondering if that is a bad idea. This is a rough draft of what I was contemplating:
#!/bin/sh
_LINE=$(cat -)
case "$_LINE" in
*[0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \<*.*\>\ 192.168.0.1\ *)
_LOGFILE=ap/192.168.0.1
;;
*[0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \<*.*\>\ 192.168.0.2\ *)
_LOGFILE=ap/192.168.0.2
;;
*)
_LOGFILE=log
;;
esac
mkdir -p $(dirname $_LOGFILE)
printf '%s\n' "$_LINE" >> $_LOGFILE