1. 程式人生 > >yanlove_jing的專欄

yanlove_jing的專欄

1,高亮顯示查詢結果

cat dubbo-access-provider.2016-08-25.log  |grep '2016-08-25 01:06:38'  | grep loadCustom --color

2,求該介面(loadCustom)的某天平均響應時間

cat dubbo-access-provider.2016-08-25.log |grep loadCustom| cut -d ':' -f8|cut -d 'm' -f1 |awk '{sum+=$1} END {print "平均值 = ", sum/NR}'

3,第38秒介面響應總和

cat dubbo-access-provider.2016-08-25.log |grep loadCustom |grep '2016-08-25 01:06:38'| cut -d ':' -f8|cut -d 'm' -f1 |awk '{sum+=$1} END {print "Sum = ", sum}'

4,某個分鐘的最大響應時間(凌晨一點6分)

cat dubbo-access-provider.2016-08-25.log |grep loadCustom |grep '2016-08-2501:06'| cut -d ':' -f8|cut -d 'm' -f1 |awk  'BEGIN {max = 0} {if ($1>max) max=$1 fi} END {print "Max=", max}'

5,超時的請求

cat dubbo-access-provider.2016-08-25.log |grep getCustoms | awk -F "cost:|ms DONE" '{if($2 > 4999) print $0}' |wc -l