Skip to content

Instantly share code, notes, and snippets.

@EikeDehling
Last active February 17, 2017 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EikeDehling/9cce7826f2627968df08ab2772aea218 to your computer and use it in GitHub Desktop.
Save EikeDehling/9cce7826f2627968df08ab2772aea218 to your computer and use it in GitHub Desktop.
Bash script to generate a random (apache) log line every random seconds
#!/usr/bin/env bash
while true
do
random_ip=$(dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -An -tu1 | sed -e 's/^ *//' -e 's/ */./g')
random_size=$(( (RANDOM % 65535) + 1 ))
current_date_time=$(date '+%d/%b/%Y:%H:%M:%S %z')
echo "$random_ip - - [$current_date_time] \"GET /data.php HTTP/1.1\" 200 $random_size" | tee -a 'random_log'
sleep $[ ( $RANDOM % 10 ) + 1 ]s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment