多个网站的DIG查询时间平均速度

时间:2018-10-24 21:01:26

标签: linux bash time dig

我正在编写第一个脚本。我想使用dig从.txt文件中获取多个网站的查询时间并打​​印平均值。 Here's the source,我不知道如何只打印没有文本的查询时间。 谢谢!

#!/bin/bash

# Colors
default='\033[0m'    # Default
red='\033[0;31m'     # Red
green='\033[0;32m'   # Green
blue='\033[0;34m'    # Blue
cyan='\033[0;36m'    # Cyan

# Vars / const
options='+nocomments +stats'
sites="$(cat sites.txt)"

# User input
echo -ne "${blue}Please enter DNS server: $default"
read dns

echo -e "${green}Welcome to main menu!"
echo -ne "${green}(0) ${default}- Default list / ${green}(1)${default} Custom / ${green}(3)${default} - Install dependencies ${default}: "
read choose


# Conditions for $choose

if [ "$choose" == "0" ]; then
    echo -e "${cyan}"
    /usr/bin/dig @$dns ${options} ${sites}
    echo -e "${default}"

elif [ "$choose" == "1" ]; then
    echo -ne "${blue}Please write the sites here. ${default}Example: ${blue}( google.com instagram.com ) : ${default}"
    read custom_list
    echo -e "${cyan}"
    /usr/bin/dig @$dns ${options} $custom_list
    echo -e "${default}"

elif [ "$choose" == "3" ]; then
apt-get install -y dnsutils



else
echo -e "${blue}Please choose ${default}(0) ${blue}or ${default}(1)"
fi

1 个答案:

答案 0 :(得分:0)

您可以将for train, test in kfold.split(X, Y): # create model model = Sequential() model.add(Dense(12, input_dim=8, activation='relu')) model.add(Dense(8, activation='relu')) model.add(Dense(1, activation='sigmoid')) # Compile model model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) # Fit the model model.fit(X[train], Y[train], epochs=150, batch_size=10, verbose=0) # evaluate the model scores = model.evaluate(X[test], Y[test], verbose=0) print("%s: %.2f%%" % (model.metrics_names[1], scores[1]*100)) cvscores.append(scores[1] * 100) 输送到dig以计算平均值:

awk

查询时间行如下:

/usr/bin/dig @$dns ${options} $custom_list | 
    awk '/Query time/ { total += $4; count++ } 
         END {print "Average:", total/count, "ms" }'

因此,它与字符串;; Query time: 61 msec 相匹配,将第4个字段添加到Query time变量中,并增加了一个计数器。最后,它将总数除以计数以计算平均值。