0% found this document useful (0 votes)
7 views

SHELL

The document defines various targets using Make syntax to extract and format data from a log file called statistic.log. The targets are grouped into three examples: 1) log data to the terminal, 2) save data to a file called output.txt, and 3) sort and display time and transactions per second (tps) data in increasing and decreasing order. Awk commands combined with pipes, redirection, and sorting/selection utilities like sort and head are used to parse, filter, and format the log file data.

Uploaded by

Hiền Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

SHELL

The document defines various targets using Make syntax to extract and format data from a log file called statistic.log. The targets are grouped into three examples: 1) log data to the terminal, 2) save data to a file called output.txt, and 3) sort and display time and transactions per second (tps) data in increasing and decreasing order. Awk commands combined with pipes, redirection, and sorting/selection utilities like sort and head are used to parse, filter, and format the log file data.

Uploaded by

Hiền Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#SHELL := /bin/bash

#ex1: log data to terminal

.PHONY: logQuerySuccess

logQuerySuccess:

awk -F '|' '/QuerySuccess/ {print $$5}' ./statistic.log

.PHONY: logQueryFail

logQueryFail:

awk -F '|' '/QueryFail/ {print $$6}' ./statistic.log

.PHONY: logUpdateSuccess

logUpdateSuccess:

awk -F '|' '/UpdateSuccess/ {print $$7}' ./statistic.log

.PHONY: logUpdateFail

logUpdateFail:

awk -F '|' '/UpdateFail/ {print $$8}' ./statistic.log

.PHONY: logAvgResTime

logAvgResTime:

awk '/Avg Res Time/ {split($$0,a,"|"); split(a[11],b,"\t"); print b[2]}' ./statistic.log

Kết quả khi chạy lệnh


Kết quả mong muốn
.PHONY: logtps

logtps:

awk -F '|' '/tps/ {print $$14}' ./statistic.log

#ex2: save data to log file output.txt

.PHONY: saveQuerySuccess

saveQuerySuccess:
awk -F '|' '/QuerySuccess/ {print $$5}' ./statistic.log | tee output.txt

.PHONY: saveQueryFail

saveQueryFail:

awk -F '|' '/QueryFail/ {print $$6}' ./statistic.log | tee output.txt

.PHONY: saveUpdateSuccess

saveUpdateSuccess:

awk -F '|' '/UpdateSuccess/ {print $$7}' ./statistic.log | tee output.txt

.PHONY: saveUpdateFail

saveUpdateFail:

awk -F '|' '/UpdateFail/ {print $$8}' ./statistic.log | tee output.txt

.PHONY: saveAvgResTime

saveAvgResTime:

awk '/Avg Res Time/ {split($$0,a,"|"); split(a[11],b,"\t"); print b[2]}' ./statistic.log | tee
output.txt

.PHONY: savetps

savetps:

awk -F '|' '/tps/ {print $$14}' ./statistic.log | tee output.txt

#ex3: time and tpsmax sorted decrease

.PHONY: timeDecrease

timeDecrease:

awk -F ' ' '{print $$1 " " $$2}' ./statistic.log | sort -k 2 -r | head -n 10

.PHONY: tpsMaxDecrease
tpsMaxDecrease:

awk -F '|' '/max/ {print $$20}' ./statistic.log | sort -k 2 -r | head -n 10

Kết quả khi chạy lệnh

Mong muốn

#ex4: time and tpsmax sorted increase

.PHONY: timeIncrease

timeIncrease:

awk -F ' ' '{print $$1 " " $$2}' ./statistic.log | sort -k 2 | head -n 10

.PHONY: tpsMaxIncrease

tpsMaxIncrease:

awk -F '|' '/max/ {print $$20}' ./statistic.log | sort -k 2 | head -n 10

You might also like