mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
Merge branch 'kulikov-a-pftop_formats'
This commit is contained in:
commit
2aaffc372d
@ -64,9 +64,9 @@
|
||||
bytes: function(column, row) {
|
||||
if (!isNaN(row[column.id]) && row[column.id] > 0) {
|
||||
let fileSizeTypes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||
let ndx = Math.floor(Math.log(row[column.id]) / Math.log(1000) );
|
||||
let ndx = Math.floor(Math.log(row[column.id]) / Math.log(1024) );
|
||||
if (ndx > 0) {
|
||||
return (row[column.id] / Math.pow(1000, ndx)).toFixed(2) + ' ' + fileSizeTypes[ndx];
|
||||
return (row[column.id] / Math.pow(1024, ndx)).toFixed(2) + ' ' + fileSizeTypes[ndx];
|
||||
} else {
|
||||
return row[column.id].toFixed(2);
|
||||
}
|
||||
|
||||
@ -190,11 +190,26 @@ def query_top(rule_label, filter_str):
|
||||
else:
|
||||
idx = 4
|
||||
|
||||
pows = {
|
||||
'K': 1,
|
||||
'M': 2,
|
||||
'G': 3,
|
||||
}
|
||||
time_marks = {
|
||||
'm': 60,
|
||||
'h': 3600,
|
||||
'd': 86400,
|
||||
}
|
||||
record['state'] = parts[idx]
|
||||
record['age'] = parts[idx+1]
|
||||
record['expire'] = parts[idx+2]
|
||||
record['pkts'] = int(parts[idx+3]) if parts[idx+3].isdigit() else 0
|
||||
record['bytes'] = int(parts[idx+4]) if parts[idx+4].isdigit() else 0
|
||||
if parts[idx+4].isdigit():
|
||||
record['bytes'] = int(parts[idx+4])
|
||||
elif parts[idx+4][:-1].isdigit() and parts[idx+4][-1] in pows:
|
||||
record['bytes'] = int(parts[idx+4][:-1])*pow(1024, pows[parts[idx+4][-1]])
|
||||
else:
|
||||
record['bytes'] = 0
|
||||
record['avg'] = int(parts[idx+5]) if parts[idx+5].isdigit() else 0
|
||||
record['rule'] = parts[idx+6]
|
||||
if record['rule'] in rule_labels:
|
||||
@ -204,8 +219,15 @@ def query_top(rule_label, filter_str):
|
||||
record['label'] = None
|
||||
record['descr'] = None
|
||||
for timefield in ['age', 'expire']:
|
||||
tmp = record[timefield].split(':')
|
||||
record[timefield] = int(tmp[0]) * 3600 + int(tmp[1]) * 60 + int(tmp[2]) if len(tmp) > 2 else 0
|
||||
if ':' in record[timefield]:
|
||||
tmp = record[timefield].split(':')
|
||||
record[timefield] = int(tmp[0]) * 3600 + int(tmp[1]) * 60 + int(tmp[2]) if len(tmp) > 2 else 0
|
||||
elif record[timefield].isdigit():
|
||||
record[timefield] = int(record[timefield])
|
||||
elif record[timefield][-1] in time_marks and record[timefield][:-1].isdigit():
|
||||
record[timefield] = int(record[timefield][:-1])*time_marks[record[timefield][-1]]
|
||||
else:
|
||||
record[timefield] = 0
|
||||
|
||||
search_line = " ".join(str(item) for item in filter(None, record.values()))
|
||||
if rule_label != "" and record['label'].lower().find(rule_label) == -1:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user