メトリクス ファイルの形式がわずかに変更されたため、小さな Python スクリプトを変更する必要があります。私は Python をまったく知らないので、自分で修正するために正直な努力をしようとしました。変更は私には理にかなっていますが、どうやらスクリプトにはまだ 1 つの問題があるようです。それ以外の場合は、他のすべてが機能しています。スクリプトは次のようになります。
import sys
import datetime
##########################################################################
now = datetime.datetime.now();
logFile = now.strftime("%Y%m%d")+'.QE-Metric.log';
underlyingParse = True;
strParse = "UNDERLYING_TICK";
if (len(sys.argv) == 2):
if sys.argv[1] == '2':
strParse = "ORDER_SHOOT";
underlyingParse = False;
elif (len(sys.argv) == 3):
logFile = sys.argv[2];
if sys.argv[1] == '2':
strParse = "ORDER_SHOOT";
underlyingParse = False;
else:
print 'Incorrect number of arguments. Usage: <exec> <mode (1) Underlying (2) OrderShoot> <FileName (optional)>'
sys.exit()
##########################################################################
# Read the deployment file
FIput = open(logFile, 'r');
FOput = open('ParsedMetrics.txt', 'w');
##########################################################################
def ParseMetrics( file_lines ):
ii = 0
tokens = [];
for ii in range(len(file_lines)):
line = file_lines[ii].strip()
if (line.find(strParse) != -1):
tokens = line.split(",");
currentTime = float(tokens[2])
if (underlyingParse == True and ii != 0):
newIndex = ii-1
prevLine = file_lines[newIndex].strip()
while (prevLine.find("ORDER_SHOOT") != -1 and newIndex > -1):
newIndex -= 1;
tokens = prevLine.split(",");
currentTime -= float(tokens[2]);
prevLine = file_lines[newIndex].strip();
if currentTime > 0:
FOput.write(str(currentTime) + '\n')
##########################################################################
file_lines = FIput.readlines()
ParseMetrics( file_lines );
print 'Metrics parsed and written to ParsedMetrics.txt'
最後の UNDERLYING_TICK イベントが発生してから、前の行を逆に繰り返して ORDER_SHOOT の数値を合計するロジックを除いて、すべて正常に動作しています (コード: if (underlyingParse == True and ii != 0):.. .) 次に、現在処理中の UNDERLYING_TICK イベント行からその合計を引きます。解析中のファイルの典型的な行は次のようになります。
08:40:02.039387(+26): UNDERLYING_TICK, 1377, 1499.89
基本的に、マイクロ単位の時間である最後のデータ要素 (1499.89) にのみ関心があります。私はそれが愚かなものでなければならないことを知っています。もう一組の目が必要です。ありがとう!