#!/bin/bash

source_path='./soruce.access.log'

function rand(){
min=$1
max=$(($2-$min+1))
num=$(date +%s%N)
echo $(($num%$max+$min))
}

while true
do
while read line
do
source_rnd=$(rand 0 1)
source_http_code=(200 404)

 rnd=$(rand 0 2)
 http_code=(200 403 404)

 ip_rand=$(rand 0 2)
 ip_list=(192. 168. 11.)

 n_ip=$(rand 100 254)

 month_date="$(date '+%b')"
 last_time=`date -d '-1 minutes' +"%Y:%H:%M"`

new_log=`echo $line| sed "s/20181235/${last_time}/g;s/${ip_list[$ip_rand]}/${n_ip}./g;s/${source_http_code[$source_rnd]}/${http_code[$rnd]}/g"`
echo ${new_log} >> auto_access.log

sleep_rand=$(rand 0 1 2 3)

sleep ${sleep_rand}

done < ${source_path}
done