9
3

probes_mysql.d.base 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* Copyright (c) 2008, 2009 Sun Microsystems, Inc.
  2. Use is subject to license terms.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. /*
  14. The actual probe names in DTrace scripts will replace '__' by '-'. Thus
  15. insert__row__start will be insert-row-start.
  16. Recommendations for adding new probes:
  17. - each probe should have the minimal set of arguments required to
  18. unambiguously identify the context in which the probe fires. Redundant
  19. arguments (i.e. the ones that can be obtained in user scripts from previous
  20. probes' arguments or otherwise) may be added for convenience.
  21. - try to avoid computationally expensive probe arguments. If impossible,
  22. use *_ENABLED() macros to check if the probe is activated before
  23. performing expensive calculations for a probe argument.
  24. - all *-done probes should have a status argument wherever applicable to make
  25. it possible for user scripts to figure out whether the completed operation
  26. was successful or not.
  27. - for all status arguments, a non-zero value should be returned on error or
  28. failure, 0 should be returned on success.
  29. */
  30. provider mysql {
  31. /* The following ones fire when creating or closing a client connection */
  32. probe connection__start(unsigned long conn_id, char *user, char *host);
  33. probe connection__done(int status, unsigned long conn_id);
  34. /*
  35. Fire at the start/end of any client command processing (including SQL
  36. queries).
  37. */
  38. probe command__start(unsigned long conn_id, int command,
  39. char *user, char *host);
  40. probe command__done(int status);
  41. /*
  42. The following probes fire at the start/end of any SQL query processing,
  43. respectively.
  44. query_start() has a lot of parameters that can be used to pick up
  45. parameters for a lot of other probes here. For simplicity reasons we also
  46. add the query string to most other DTrace probes as well. Hostname is
  47. either the hostname or the IP address of the MySQL Client.
  48. */
  49. probe query__start(char *query,
  50. unsigned long conn_id,
  51. char *db_name,
  52. char *user,
  53. char *host);
  54. probe query__done(int status);
  55. /* Fire at the start/end of SQL query parsing */
  56. probe query__parse__start(char *query);
  57. probe query__parse__done(int status);
  58. /* Track whether the query hits the query cache or not */
  59. probe query__cache__hit(char *query, unsigned long rows);
  60. probe query__cache__miss(char *query);
  61. /*
  62. This probe fires when the actual query execution starts, i.e. after
  63. parsing and checking the query cache, but before privilege checks,
  64. optimizing, etc.
  65. Query means also all independent queries of a stored procedure and prepared
  66. statements. Also the stored procedure itself is a query.
  67. exec_type is:
  68. 0: Executed query from sql_parse, top-level query (sql_parse.cc)
  69. 1: Executed prepared statement (sql_prepare.cc)
  70. 2: Executed cursor statement (sql_cursor.cc)
  71. 3: Executed query in stored procedure (sp_head.cc)
  72. */
  73. probe query__exec__start(char *query,
  74. unsigned long connid,
  75. char *db_name,
  76. char *user,
  77. char *host,
  78. int exec_type);
  79. probe query__exec__done(int status);
  80. /* These probes fire when performing row operations towards any handler */
  81. probe insert__row__start(char *db, char *table);
  82. probe insert__row__done(int status);
  83. probe update__row__start(char *db, char *table);
  84. probe update__row__done(int status);
  85. probe delete__row__start(char *db, char *table);
  86. probe delete__row__done(int status);
  87. probe read__row__start(char *db, char *table, int scan_flag);
  88. probe read__row__done(int status);
  89. probe index__read__row__start(char *db, char *table);
  90. probe index__read__row__done(int status);
  91. /*
  92. These probes fire when calling external_lock for any handler
  93. depending on the lock type being acquired or released.
  94. */
  95. probe handler__rdlock__start(char *db, char *table);
  96. probe handler__wrlock__start(char *db, char *table);
  97. probe handler__unlock__start(char *db, char *table);
  98. probe handler__rdlock__done(int status);
  99. probe handler__wrlock__done(int status);
  100. probe handler__unlock__done(int status);
  101. /*
  102. These probes fire when a filesort activity happens in a query.
  103. */
  104. probe filesort__start(char *db, char *table);
  105. probe filesort__done(int status, unsigned long rows);
  106. /*
  107. The query types SELECT, INSERT, INSERT AS SELECT, UPDATE, UPDATE with
  108. multiple tables, DELETE, DELETE with multiple tables are all probed.
  109. The start probe always contains the query text.
  110. */
  111. probe select__start(char *query);
  112. probe select__done(int status, unsigned long rows);
  113. probe insert__start(char *query);
  114. probe insert__done(int status, unsigned long rows);
  115. probe insert__select__start(char *query);
  116. probe insert__select__done(int status, unsigned long rows);
  117. probe update__start(char *query);
  118. probe update__done(int status,
  119. unsigned long rowsmatches, unsigned long rowschanged);
  120. probe multi__update__start(char *query);
  121. probe multi__update__done(int status,
  122. unsigned long rowsmatches,
  123. unsigned long rowschanged);
  124. probe delete__start(char *query);
  125. probe delete__done(int status, unsigned long rows);
  126. probe multi__delete__start(char *query);
  127. probe multi__delete__done(int status, unsigned long rows);
  128. /*
  129. These probes can be used to measure the time waiting for network traffic
  130. or identify network-related problems.
  131. */
  132. probe net__read__start();
  133. probe net__read__done(int status, unsigned long bytes);
  134. probe net__write__start(unsigned long bytes);
  135. probe net__write__done(int status);
  136. /* MyISAM Key cache probes */
  137. probe keycache__read__start(char *filepath, unsigned long bytes,
  138. unsigned long mem_used, unsigned long mem_free);
  139. probe keycache__read__block(unsigned long bytes);
  140. probe keycache__read__hit();
  141. probe keycache__read__miss();
  142. probe keycache__read__done(unsigned long mem_used, unsigned long mem_free);
  143. probe keycache__write__start(char *filepath, unsigned long bytes,
  144. unsigned long mem_used, unsigned long mem_free);
  145. probe keycache__write__block(unsigned long bytes);
  146. probe keycache__write__done(unsigned long mem_used, unsigned long mem_free);
  147. };
  148. #pragma D attributes Evolving/Evolving/Common provider mysql provider
  149. #pragma D attributes Evolving/Evolving/Common provider mysql module
  150. #pragma D attributes Evolving/Evolving/Common provider mysql function
  151. #pragma D attributes Evolving/Evolving/Common provider mysql name
  152. #pragma D attributes Evolving/Evolving/Common provider mysql args