s3-libads: use ldap_init_fd() to initialize a ldap session if possible
[bbaumbach/samba-autobuild/.git] / examples / systemtap / generate-winbindd.stp.sh
1 #!/bin/sh
2
3 outfile="$(dirname $0)/winbindd.stp"
4
5 child_funcs="winbindd_dual_ping
6 winbindd_dual_list_trusted_domains
7 winbindd_dual_init_connection
8 winbindd_dual_pam_auth
9 winbindd_dual_pam_auth_crap
10 winbindd_dual_pam_logoff
11 winbindd_dual_pam_chng_pswd_auth_crap
12 winbindd_dual_pam_chauthtok
13 _wbint_LookupSid
14 _wbint_LookupSids
15 _wbint_LookupName
16 _wbint_Sids2UnixIDs
17 _wbint_UnixIDs2Sids
18 _wbint_AllocateUid
19 _wbint_AllocateGid
20 _wbint_GetNssInfo
21 _wbint_LookupUserAliases
22 _wbint_LookupUserGroups
23 _wbint_QuerySequenceNumber
24 _wbint_LookupGroupMembers
25 _wbint_QueryGroupList
26 _wbint_QueryUserRidList
27 _wbint_DsGetDcName
28 _wbint_LookupRids
29 _wbint_CheckMachineAccount
30 _wbint_ChangeMachineAccount
31 _wbint_PingDc"
32
33 async_funcs="wb_ping
34 winbindd_lookupsid
35 winbindd_lookupsids
36 winbindd_lookupname
37 winbindd_sids_to_xids
38 winbindd_xids_to_sids
39 winbindd_getpwsid
40 winbindd_getpwnam
41 winbindd_getpwuid
42 winbindd_getsidaliases
43 winbindd_getuserdomgroups
44 winbindd_getgroups
45 winbindd_show_sequence
46 winbindd_getgrgid
47 winbindd_getgrnam
48 winbindd_getusersids
49 winbindd_lookuprids
50 winbindd_setpwent
51 winbindd_getpwent
52 winbindd_endpwent
53 winbindd_dsgetdcname
54 winbindd_getdcname
55 winbindd_setgrent
56 winbindd_getgrent
57 winbindd_endgrent
58 winbindd_list_users
59 winbindd_list_groups
60 winbindd_check_machine_acct
61 winbindd_ping_dc
62 winbindd_pam_auth
63 winbindd_pam_logoff
64 winbindd_pam_chauthtok
65 winbindd_pam_chng_pswd_auth_crap
66 winbindd_wins_byip
67 winbindd_wins_byname
68 winbindd_allocate_uid
69 winbindd_allocate_gid
70 winbindd_change_machine_acct
71 winbindd_pam_auth_crap"
72
73 backend_funcs="query_user_list
74 enum_dom_groups
75 enum_local_groups
76 name_to_sid
77 sid_to_name
78 rids_to_names
79 lookup_usergroups
80 lookup_useraliases
81 lookup_groupmem
82 sequence_number
83 lockout_policy
84 password_policy
85 trusted_domains"
86
87 header='#!/usr/bin/stap
88 #
89 # Systemtap script to instrument winbindd
90 #
91 '"# Generated by examples/systemtap/$(basename $0) on $(date), do not edit
92 #"'
93 # Usage:
94 #
95 # Instrument all winbindd processes:
96 # # stap winbindd.stp
97 #
98 # Instrument a specific winbindd process:
99 # # stap -x PID winbindd.stp
100 #
101
102 global dc_running, dc_svctime
103 global backend_running, backend_svctime
104 global send_running, recv_running
105 global start_time, idle_time
106 global async_svctime, async_runtime
107
108 probe begin {
109         printf("Collecting data, press ctrl-C to stop... ")
110 }'
111
112 domchild_req_template='
113 #
114 # winbind domain child function XXX
115 #
116
117 probe process("winbindd").function("XXX") {
118         dc_running[tid(), "XXX"] = gettimeofday_us()
119 }
120
121 probe process("winbindd").function("XXX").return {
122         if (!([tid(), "XXX"] in dc_running))
123                 next
124
125         end = gettimeofday_us()
126         begin = dc_running[tid(), "XXX"]
127         delete dc_running[tid(), "XXX"]
128
129         duration = end - begin
130         dc_svctime["XXX"] <<< duration
131 }'
132
133 backend_req_template='
134 #
135 # winbind domain child backend function XXX
136 #
137
138 probe process("winbindd").function("XXX@../source3/winbindd/winbindd_ads.c") {
139         backend_running[tid(), "XXX"] = gettimeofday_us()
140 }
141
142 probe process("winbindd").function("XXX@../source3/winbindd/winbindd_ads.c").return {
143         if (!([tid(), "XXX"] in backend_running))
144                 next
145
146         end = gettimeofday_us()
147         begin = backend_running[tid(), "XXX"]
148         delete backend_running[tid(), "XXX"]
149
150         duration = end - begin
151         backend_svctime["XXX"] <<< duration
152 }'
153
154 async_req_template='
155 #
156 # winbind async function XXX
157 #
158
159 probe process("winbindd").function("XXX_send") {
160         send_running["XXX_send"] = gettimeofday_us()
161 }
162
163 probe process("winbindd").function("XXX_send").return {
164         if (!(["XXX_send"] in send_running))
165                 next
166
167         end = gettimeofday_us()
168         start = send_running["XXX_send"]
169         delete send_running["XXX_send"]
170
171         start_time["XXX_send", $return] = start
172         idle_time["XXX_send", $return] = end
173 }
174
175 probe process("winbindd").function("XXX_recv") {
176         if (!(["XXX_send", $req] in start_time))
177                 next
178
179         recv_running["XXX_recv"] = gettimeofday_us()
180 }
181
182 probe process("winbindd").function("XXX_recv").return {
183         if (!(["XXX_recv"] in recv_running))
184                 next
185
186         recv_end = gettimeofday_us()
187         recv_start = recv_running["XXX_recv"]
188         delete recv_running["XXX_recv"]
189         recv_runtime = recv_end - recv_start
190
191         req = @entry($req)
192
193         send_begin = start_time["XXX_send", req]
194         delete start_time["XXX_send", req]
195         svctime = recv_end - send_begin
196
197         idle = idle_time["XXX_send", req]
198         delete idle_time["XXX_send", req]
199         runtime = (idle - send_begin) + recv_runtime
200
201         async_svctime["XXX_send"] <<< svctime
202         async_runtime["XXX_send"] <<< runtime
203 }'
204
205 footer='
206 probe end {
207         printf("\n\n")
208
209         printf("Winbind request service time\n")
210         printf("============================\n")
211         foreach ([name] in async_svctime) {
212                 printf("%-40s count: %5d, sum: %6d ms (min: %6d us, avg: %6d us, max: %6d us)\n",
213                        name,
214                        @count(async_svctime[name]),
215                        @sum(async_svctime[name]) / 1000,
216                        @min(async_svctime[name]),
217                        @avg(async_svctime[name]),
218                        @max(async_svctime[name]))
219         }
220         printf("\n")
221
222         printf("Winbind request runtime\n")
223         printf("=======================\n")
224         foreach ([name] in async_runtime) {
225                 printf("%-40s count: %5d, sum: %6d ms (min: %6d us, avg: %6d us, max: %6d us)\n",
226                        name,
227                        @count(async_runtime[name]),
228                        @sum(async_runtime[name]) / 1000,
229                        @min(async_runtime[name]),
230                        @avg(async_runtime[name]),
231                        @max(async_runtime[name]))
232         }
233         printf("\n")
234
235         printf("Winbind domain-child request service time\n")
236         printf("=========================================\n")
237         foreach ([name] in dc_svctime) {
238                 printf("%-40s count: %5d, sum: %6d ms (min: %6d us, avg: %6d us, max: %6d us)\n",
239                        name,
240                        @count(dc_svctime[name]),
241                        @sum(dc_svctime[name]) / 1000,
242                        @min(dc_svctime[name]),
243                        @avg(dc_svctime[name]),
244                        @max(dc_svctime[name]))
245         }
246         printf("\n")
247
248         printf("Winbind domain-child AD-backend service time\n")
249         printf("============================================\n")
250         foreach ([name] in backend_svctime) {
251                 printf("%-40s count: %5d, sum: %6d ms (min: %6d us, avg: %6d us, max: %6d us)\n",
252                        name,
253                        @count(backend_svctime[name]),
254                        @sum(backend_svctime[name]) / 1000,
255                        @min(backend_svctime[name]),
256                        @avg(backend_svctime[name]),
257                        @max(backend_svctime[name]))
258         }
259         printf("\n")
260
261         printf("Winbind request service time distributions (us)\n")
262         printf("===============================================\n")
263         foreach ([name] in async_svctime) {
264                 printf("%s:\n", name);
265                 println(@hist_log(async_svctime[name]))
266         }
267         printf("\n")
268
269         printf("Winbind request runtime distributions (us)\n")
270         printf("==========================================\n")
271         foreach ([name] in async_runtime) {
272                 printf("%s:\n", name);
273                 println(@hist_log(async_runtime[name]))
274         }
275
276         printf("Winbind domain-child request service time distributions (us)\n")
277         printf("============================================================\n")
278         foreach ([name] in dc_svctime) {
279                 printf("%s:\n", name);
280                 println(@hist_log(dc_svctime[name]))
281         }
282
283         printf("Winbind domain-child AD-backend service time distributions (us)\n")
284         printf("===============================================================\n")
285         foreach ([name] in backend_svctime) {
286                 printf("%s:\n", name);
287                 println(@hist_log(backend_svctime[name]))
288         }
289 }'
290
291 cat <<EOF > $outfile
292 $header
293 EOF
294
295 printf "$child_funcs\n" | while read func ; do
296         printf "$domchild_req_template\n" | sed -e s/XXX/$func/g >> $outfile
297 done
298
299 printf "$backend_funcs\n" | while read func ; do
300         printf "$backend_req_template\n" | sed -e "s|XXX|$func|g" >> $outfile
301 done
302
303 printf "$async_funcs\n" | while read func ; do
304         printf "$async_req_template\n" | sed -e s/XXX/$func/g >> $outfile
305 done
306
307 cat <<EOF >>$outfile
308 $footer
309 EOF