Skip to content

Instantly share code, notes, and snippets.

@NanXiao
Created February 7, 2020 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NanXiao/bf10e4adb52a4bd10e1769c0beb2f7b7 to your computer and use it in GitHub Desktop.
Save NanXiao/bf10e4adb52a4bd10e1769c0beb2f7b7 to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
function max_value(new_value, old_value)
{
if (new_value > old_value)
{
return new_value;
}
else
{
return old_value;
}
}
BEGIN {
FS = ",";
client_session_id_max_len = 0;
server_session_id_max_len = 0;
client_session_ticket_max_len = 0;
server_session_ticket_max_len = 0;
max_record_len = 0;
total_record_len = 0;
records_have_session_id = 0;
records_session_id_len_greater_than_32 = 0;
records_have_session_ticket = 0;
records_session_ticket_reach_max_num = 0;
}
{
client_session_id_max_len = max_value(length($1), client_session_id_max_len);
server_session_id_max_len = max_value(length($2), server_session_id_max_len);
client_session_ticket_max_len = max_value(length($3), client_session_ticket_max_len);
server_session_ticket_max_len = max_value(length($4), server_session_ticket_max_len);
record_len = length($1) + length($2) + length($3) + length($4);
max_record_len = max_value(record_len, max_record_len);
total_record_len += record_len;
if (length($1) != 0 || length($2) != 0)
{
records_have_session_id++;
}
if (length($1) > 64 || length($2) > 64)
{
records_session_id_len_greater_than_32++;
}
if (length($3) != 0 || length($4) != 0)
{
records_have_session_ticket++;
}
if (length($3) == 1024 || length($4) == 1024)
{
records_session_ticket_reach_max_num++;
}
}
END {
printf "total_record_num=%d\n", NR;
printf "\n";
printf "client_session_id_max_len=%d\n", client_session_id_max_len;
printf "server_session_id_max_len=%d\n", server_session_id_max_len;
printf "client_session_ticket_max_len=%d\n", client_session_ticket_max_len;
printf "server_session_ticket_max_len=%d\n", server_session_ticket_max_len;
printf "\n";
printf "max_record_len=%d\n", max_record_len;
printf "total_record_len=%d\n", total_record_len;
printf "average_record_len=%d\n", total_record_len / NR;
printf "\n";
printf "records_have_session_id=%d\n", records_have_session_id;
printf "records_session_id_len_greater_than_32=%d\n", records_session_id_len_greater_than_32;
printf "records_session_id_len_greater_than_32 ratio=%f\n", records_session_id_len_greater_than_32 / records_have_session_id;
printf "\n";
printf "records_have_session_ticket=%d\n", records_have_session_ticket;
printf "records_session_ticket_reach_max_num=%d\n", records_session_ticket_reach_max_num;
printf "records_session_ticket_reach_max_num ratio=%f\n", records_session_ticket_reach_max_num / records_have_session_ticket;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment