무작위 테스트 로그 데이터를 생성하는 스크립트를 작성해야 합니다.
로그 데이터는 "|"(파이프)로 구분되어야 하며 총 10,000줄이며 각 줄은 500바이트이며 각 줄에는 다음 형식의 임의 데이터가 포함됩니다.
date|time|pid|status|data|comment
각 열의 범위:
date : 20130101
time : 09:00:00-11:59:59
pid : 3000-5000
status : OK || TEMP || PERM
data : refer words/sentences used in whichever of the following pages and set them randomly - https://en.wikipedia.org/wiki/Amazon_S3
comment : fill in with "X" to fit one line as 500 bytes.
(예) 무작위 테스트 로그 데이터는 다음과 같습니다.
20120101|09:00:00|4887|TEMP|Amazon S3 (Simple Storage Service) is an online file storage web service offered by Amazon Web Services. Amazon S3 provides storage through web services interfaces (REST, SOAP, and BitTorrent).[1] Amazon launched S3, its first publicly available web service, in the United States in March 2006[2] and in Europe in November 2007.[3]|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
20120101|09:00:00|4418|TEMP|At its inception, Amazon charged end users US$0.15 per gigabyte-month, with additional charges for bandwidth used in sending and receiving data, and a per-request (get or put) charge.[4] On November 1, 2008, pricing moved to tiers where end users storing more than 50 terabytes receive discounted pricing.[5] Amazon says that S3 uses the same scalable storage infrastructure that Amazon.com uses to run its own global e-commerce network.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
20120101|09:00:01|4124|PERM|Amazon S3 is reported to store more than 2 trillion objects as of April 2013.[7] This is up from 102 billion objects as of March 2010,[8] 64 billion objects in August 2009,[9] 52 billion in March 2009,[10] 29 billion in October 2008,[5] 14 billion in January 2008, and 10 billion in October 2007.[11]|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
20120101|09:00:02|3977|OK|S3 uses include web hosting, image hosting, and storage for backup systems. S3 guarantees 99.9% monthly uptime service-level agreement (SLA),[12] that is, not more than 43 minutes of downtime per month.[13]|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
20120101|09:00:02|4020|OK|Details of S3's design are not made public by Amazon, though it clearly manages data with an object storage architecture. According to Amazon, S3's design aims to provide scalability, high availability, and low latency at commodity costs.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
답변1
이는 데이터에 대한 추가 변경 사항을 구현하기 위해 쉽게 확장할 수 있는 간단한 셸 스크립트입니다.
#!/bin/bash
count=0
hash='####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################'
while [ "$count" -lt 10000 ]
do
case $((RANDOM % 3)) in
(0) status=OK
;;
(1) status=TEMP
;;
(2) status=PERM
;;
esac
case $((RANDOM % 4)) in
(0) data=\
'Amazon S3 (Simple Storage Service) is an online file storage web service offered by Amazon Web Services. Amazon S3 provides storage through web services interfaces (REST, SOAP, and BitTorrent).[1] Amazon launched S3, its first publicly available web service, in the United States in March 2006[2] and in Europe in November 2007.[3]'
;;
(1) data=\
'Amazon S3 is reported to store more than 2 trillion objects as of April 2013.[7] This is up from 102 billion objects as of March 2010,[8] 64 billion objects in August 2009,[9] 52 billion in March 2009,[10] 29 billion in October 2008,[5] 14 billion in January 2008, and 10 billion in October 2007.[11]'
;;
(2) data=\
'S3 uses include web hosting, image hosting, and storage for backup systems. S3 guarantees 99.9% monthly uptime service-level agreement (SLA),[12] that is, not more than 43 minutes of downtime per month.[13]'
;;
(3) data=\
'Details of S3'\''s design are not made public by Amazon, though it clearly manages data with an object storage architecture. According to Amazon, S3'\''s design aims to provide scalability, high availability, and low latency at commodity costs.'
;;
esac
part=$(
printf '%s|%s|%d|%s|%s' \
"20130101" \
$(printf '%02d:%02d:%02d' $((RANDOM % 3 + 9)) $((RANDOM % 60)) $((RANDOM % 60)) ) \
$((RANDOM % 2000 + 3000)) \
"$status" \
"$data"
)
printf '%.500s\n' "$part"'|'"$hash"
count=$((count + 1))
done
이 count
변수를 사용하면 10,000번 반복할 수 있습니다. 이 hash
변수는 일종의 마스크입니다. 최종 문자열을 500자로 채우는 데 사용됩니다(값은 다음과 같이 500개의 해시 표시입니다).아이디어:) printf %500s | tr " " "#"
.
case
루프 내의 두 명령문은 샘플 데이터에서 의사 무작위 문자열을 선택합니다. data
여기에서 해당 섹션을 확장하여 더 많은 옵션을 볼 수 있습니다.
변수 할당은 처음 5개 필드(정적 날짜 문자열, 9시에서 11시 59분 59초 사이의 의사 무작위 타임스탬프, 의사 무작위 pid, 선택된 상태 코드 및 선택된 데이터 문자열)를 결합하는 part
데 사용됩니다 .printf
그런 다음 printf에 연결된 문자열을 인쇄하도록 요청합니다.
- 위의
part
문자열 - 구분 기호
|
및 hash
그 위에 흔적
...그런 다음 전체 인쇄 문자열을 500자로 자릅니다..500
형식 너비 지정자.