First off you need the server access logs to be readable by the script. Also if you have a lot of virtual hosts and all those use one access log file you need to split them up in a log file for each domain name.
That is done in the apache httpd.conf or in the file where you have configured your virtual host:
LogFormat "%h %l %u %t "%r" %>s %b" common
<virtualhost *:80>
DocumentRoot "/var/www/html/example.com"
ServerName example.com
ErrorLog logs/example.error.log
CustomLog logs/example.access.log common
</virtualhost>
CustomLog is the access log you will be needing.