1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson/* Start Run with:
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson * stap -v dp_request.stp
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson *
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson * Then reproduce slow login or id/getent in another terminal.
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson * Ctrl-C running stap once login completes.
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson *
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson * Probe tapsets are in /usr/share/systemtap/tapset/sssd.stp
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson */
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal num_dp_requests
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal time_in_dp_req
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal elapsed_time
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal dp_req_send_start
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal dp_req_send_end
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson/* Used for tracking slowest request as tz_ctime() only converts seconds, not ms */
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal dp_req_send_sec_start
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal dp_req_send_sec_end
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal slowest_req_name
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal slowest_req_target
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal slowest_req_method
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal slowest_req_time = 0
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal slowest_req_start_time
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonglobal slowest_req_end_time
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonfunction print_report()
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson{
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\nEnding Systemtap Run - Providing Summary\n")
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("Total Number of DP requests: [%d]\n", num_dp_requests)
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("Total time in DP requests: [%s]\n", msecs_to_string(time_in_dp_req))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("Slowest request data:\n")
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\tRequest: [%s]\n", slowest_req_name)
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\tTarget: [%s]\n", dp_target_str(slowest_req_target))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\tMethod: [%s]\n", dp_method_str(slowest_req_method))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\tStart Time: [%s]\n", tz_ctime(slowest_req_start_time))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\tEnd Time: [%s]\n", tz_ctime(slowest_req_end_time))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\tDuration: [%s]\n\n", msecs_to_string(slowest_req_time))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson}
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonprobe dp_req_send
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson{
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson dp_req_send_start = gettimeofday_ms()
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson dp_req_send_sec_start = gettimeofday_s()
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\t--> DP Request [%s] sent for domain [%s]\n", dp_req_name, dp_req_domain)
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\t--> Target: [%s] - Method: [%s]\n", dp_target_str(dp_req_target), dp_method_str(dp_req_method))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson num_dp_requests++
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson}
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonprobe dp_req_done
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson{
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson dp_req_send_end = gettimeofday_ms()
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson dp_req_send_sec_end = gettimeofday_s()
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson elapsed_time = (dp_req_send_end - dp_req_send_start)
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\t\t DP Request [%s] finished with return code [%d]: [%s]\n",
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson dp_req_name, dp_ret, dp_errorstr)
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\t\t Elapsed time [%s]\n\n", msecs_to_string(elapsed_time))
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson /* Track slowest request information */
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson if (elapsed_time > slowest_req_time) {
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson slowest_req_time = elapsed_time
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson slowest_req_name = dp_req_name
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson slowest_req_method = dp_req_method
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson slowest_req_target = slowest_req_target
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson slowest_req_start_time = dp_req_send_sec_start
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson slowest_req_end_time = dp_req_send_sec_end
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson }
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson time_in_dp_req += (dp_req_send_end - dp_req_send_start)
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson}
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonprobe begin
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson{
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson printf("\t*** Beginning run! ***\n")
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson}
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephensonprobe end
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson{
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson print_report()
1182dd93a5a6bb18943284273f7fd59b83468843Justin Stephenson}