Me and my workmate would like to fetch data from squid server via access.log to mysql server on another Debian server.
We've found sort of guide to that kind of things on the internet and made a script that will put data in mysql from string in access.log file. but this doesnt seems to be working, something might be with the insert thing, no idea here. Please help us to find out what we need to sort out.
Heres a script:
#!/bin/bash
cp /www/logs/squid/access.log /tmp/squidforparse.log
>/www/logs/squid/access.log
awk '{print "INSERT INTO squid (ip,bytes,link,trans,time) \
VALUES(\""$3"\","$5",\""$7"\",\""$9"\",from_unixtime("$1"));"};' \
< /tmp/squidforparse.log | mysql -D traffics -u root --password=my_sql_passwd
rm -f /tmp/squidforparse.log
I am not really that great at sql, though i do know most of the operators and functions at base level, still i can't figure out whats not making it work.
LOAD DATA INFILE? It's much more forgiving.