Last active
August 24, 2017 11:32
-
-
Save kingluo/f14ef0435f477d58e7c8a583d2a8a5a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stap++ | |
global exec_begin | |
global stats | |
probe @pfunc(ngx_epoll_process_events) | |
{ | |
exec_begin = gettimeofday_us() | |
} | |
probe @pfunc(ngx_epoll_process_events).return | |
{ | |
if (exec_begin) { | |
stats <<< gettimeofday_us() - exec_begin | |
exec_begin = 0 | |
} | |
} | |
probe begin { | |
printf("Start tracing process %d ($^exec_path)...\n", target()) | |
%( "$^arg_time :default()" != "" %? | |
printf("Please wait for $^arg_time seconds...\n") | |
%: | |
printf("Hit Ctrl-C to end.\n") | |
%) | |
} | |
%( "$^arg_time" != "" %? | |
probe timer.s($^arg_time) { | |
exit() | |
} | |
%) | |
probe end { | |
count = @count(stats) | |
if (count == 0) { | |
printf("\nNo samples found so far.\n") | |
} else { | |
printf("\nDistribution of Lua code pure execution time (accumulated in each request, in microseconds) for %d samples:\n", | |
count) | |
printf("(min/avg/max: %d/%d/%d)\n", @min(stats), @avg(stats), | |
@max(stats)) | |
print(@hist_log(stats)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gdb -q -x ngx_lua_check_sock_timeout.gdb -p 36436 | |
set logging file /tmp/gdb.log | |
set logging on | |
set $ret=malloc(sizeof(int)) | |
break ngx_http_lua_socket_handle_read_error if ft_type == 0x0002 | |
commands | |
silent | |
call ioctl(u->peer.connection->fd, 0x541B, (int *) $ret) | |
printf "socket timeout, unread bytes: %d\n", *(int *)($ret) | |
cont | |
end | |
cont |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment