Installing DTrace on Oracle Linux

Source: Internet
Author: User
Tags stack trace

http://www.ohsdba.cn/index.php?g=Home&m=Article&a=show&id=171 time: 2016-10-09-00:40:04 | Author: ohsdba | 中文版
If not noted, this site is the original article. Welcome reprint, please indicate the source and author information when reproduced. DTrace (dynamic tracing) is the primary performance diagnostic tool on a Sun Solaris system that dynamically tracks kernel and user applications and does not pose any dangerous technology to the system, and is then acquired by Oracle to follow CDDL ( Common Development and Distribution License), later Oracle ported the technology to Oracle Linux (officially released in December 2012). Until now, the DTrace for Oracle Linux was limited to Oracle Unbreakable Enterprise Kernel, which was not compatible with other Linux distributions, and at the time caused a clash (http://lwn.net/ articles/483107/).

Using DTrace on Oracle Linux can help you
Observe the dynamic runtime performance of the entire software architecture, operating system kernel, system libraries, and applications
Identify performance bottlenecks by defining real-time probe points at run time
Script to develop probe execution when triggered by predicate control
Detects and reports memory access errors rather than letting the system crash

How to install DTrace

In general, DTrace packages cannot be obtained from the public Yum and must be registered with the ULN (Unbreakable Linux Network) before they can be downloaded and installed

Yum Install Dtrace-utils

Note: You need to install dtrace-modules before installing dtrace-utils (this can be obtained from the public Yum)

Actually only need a dtrace-utils bag, need this package to do the test, can send the message to me (only test study test use)

[Email protected] ~]# RPM-IVH dtrace-utils-0.5.0-4.el6.x86_64.rpmpreparing ...                ########################################### [100%]   1:dtrace-utils           ##################################### ###### [100%][[email protected] ~]#[[email protected] ~]# ls-l/usr/sbin/dtrace-rwxr-xr-x. 1 root root 36880 Nov  4  

DTrace Help Information
[[email protected] ~]# dtraceusage:dtrace [ -32|-64] [-AACEFGHHLQSVVWZ] [-B bufsz] [-c CMD] [-D name[=def]] [- I path] [-l path] [-o output] [-p PID] [-S script] [-u name] [-X Opt[=val]] [-X a|c|s|t] [-P provider [[Pre] Dicate] action] [-M [Provider:] module [[predicate] action]] [-F [[Provider:] Module:] func [[PR Edicate] action] [-N [[[Provider:] Module:] Func:] name [[[predicate] action]] [-I probe-id [[pred        Icate] action] [args ...]  predicate, '/' d-expression '/' action ' {' d-statements '} ' -32 generate 32-bit D programs and Elf files-64 generate 64-bit D programs and ELF files-a claim anonymous tracing state-a Generat e driver.conf (4) Directives for anonymous tracing-b set trace buffer size-c run specified command and ex It upon it completion-c run CPP (1) Preprocessor on script files-d define symbol when INVOKing Preprocessor-e exit after compiling request but prior to enabling probes-f enable or list probes MA  Tching The specified function name-f coalesce trace output by function-g generate an ELF file containing Embedded DTrace program-h generate a header file with definitions for static probes-h print included fi Les when invoking preprocessor-i enable or list probes matching the specified probe id-i add include dir Ectory to preprocessor search path-l list probes matching specified criteria-l add library directory to Library search path-m enable or list probes matching the specified module name-n enable or list probes M Atching the specified probe name-o set output file-p grab specified Process-id and cache its symbol TABL  Es-p enable or list probes matching the specified provider Name-q set Quiet mode (only output explicitly Traced data)-s Enable or list probes according to the specified D script-s print D compiler intermediate Code-u Undefi NE symbol when invoking preprocessor-v set verbose mode (report stability attributes, arguments)-V Repor        T DTrace API version-w permit destructive actions-x enable or modify compiler and tracing options        -X Specify ISO C conformance settings for PREPROCESSOR-Z permit probe descriptions that match zero probes  [[email protected] ~]#

Detectors and providers

To use DTrace, you specify locations of interest in the kernel (called probes), and DTrace can bind a request to perform a set of operations, such as recording a stack trace, a timestamp, or a function parameter. The detector acts like a programmable remote sensing sensor that is buried deep in the operating system for recording information. When a probe is triggered, DTrace collects the data from it and returns it to you. The Oracle Linux DTrace probe runs in a DTrace kernel module called a provider, and the provider performs the plug-in to support the probe.

How to use the modprobe command to load a module that supports the DTrace probe you need to use. For example, if you want to use a probe published by the proc provider, the Systrace module will be loaded:

# modprobe Systrace

List of kernel modules
Kernel module description
DTrace DTrace Provides a probe for DTrace itself: Begin, END, ERROR, which optionally initializes dtrace before the trace starts, performs post-trace processing, and handles unexpected errors in other probes during execution.
Io Io Provides monitoring probes related to data input and output.
Proc Proc Provides probes for monitoring process creation and termination, new program image execution, and sending and processing signals.
Profile Profile Provides a probe associated with a timed interrupt. You can use these probes to sample the system state at regular intervals.
Sched Sdt Provides probes related to CPU scheduling.
Sdt Sdt Provides a statically defined trace probe that is located in several important locations of interest in the kernel.
Syscall Systrace The probe is provided at the entry point and the return point of each system call. These probes are particularly useful for understanding the interaction between an application and the underlying system.

The DTrace probe comes from a set of kernel modules called providers, each of which performs a specific type of plug-in to create a probe. When you use DTrace, each provider has the opportunity to publish the probes it can provide for the DTrace framework. You can then enable and bind trace operations on any probes that have been published. To list all available probes on the system, you can use Dtrace-l. Depending on the Oracle Linux platform, the installed software, and the loaded provider module, the number of probes varies.
[[email protected] ~]# Dtrace-l|wc-l622[[email protected] ~]#[[email protected] ~]# dtrace-l|more   ID   provider< C2/>module                          FUNCTION NAME    1     dtrace                                                     BEGIN    2     dtrace                                                     END    3     dtrace                                                     ERROR
Each probe displays an integer ID and an easy-to-understand name, consisting of four parts, displayed as a separate four column in the DTrace output.
    Provider  -Name of the DTrace provider that publishes this probe. The provider name typically corresponds to the name of the DTrace kernel module that performs the plug-in to enable the probe    -If this probe corresponds to a specific program location, the name of the kernel module where the probe is located    function  - If this probe corresponds to a specific program location, the name of the program function in which the probe is located      -the last part of the probe name-Indicates the name of the probe semantics
When referring to specific detectors, these parts are shown together, separated by colons, such as:
Provider:module:function:name

dtrace Command Sample
# New processes with Argumentsdtrace-n ' proc:::exec-success {trace (Curpsinfo->pr_psargs);} ' # Files opened by Processdtrace-n ' Syscall::open*:entry {printf ("%s%s", Execname,copyinstr (arg0));} ' # Syscall count by Programdtrace-n ' syscall:::entry {@num [execname] = count ();} ' # Syscall count by Syscalldtrace-n ' syscall:::entry {@num [Probefunc] = count ();} ' # Syscall count by Processdtrace-n ' syscall:::entry {@num [pid,execname] = count ();} ' # Disk size by processdtrace-n ' Io:::start {printf ("%d%s%d", pid,execname,args[0]->b_bcount);} ' # Pages paged in by Processdtrace-n ' Vminfo:::p gpgin {@pg [execname] = SUM (arg0);} '

Call the D language script SYSCALLS.D to show the system calls that process 3961 is using and its frequency
[[email protected] ~]# cat Syscalls.d#!/usr/sbin/dtrace-qssyscall:::entry/pid = = $1/{@num [Probefunc] = count ();} [[email protected] ~]#./SYSCALLS.D 3961^c Rt_sigreturn 1 shut                                                            Down 1 Accept                                                           2 Clone 3 Connect                                                   3 Gettid 3 Set_robust_list                                                              3 Socket 3 Exit                                                        4 getsockopt                                                           4 GetSockName 5 Madvise 5 CLOSE 6 dup2                                                              6 Sched_getaffinity 6 Mmap                                                   7 Epoll_ctl Rt_sigprocmask                                                            SetSockOpt Fcntl                                                            Write                                                       -Read epoll_wait                                                          Mprotect Wuyi Newstat                                 The IOCTL poll                           SendTo 265 recvfrom 284 Futex 1714[[email   protected] ~]#


Reference
Https://en.wikipedia.org/wiki/DTrace
Http://docs.oracle.com/cd/E37670_01/E50705/html/ol_intro_dtrace.html
Http://docs.oracle.com/cd/E37670_01/E38608/html/dt_gs_about.html
Http://www.oracle.com/technetwork/cn/articles/servers-storage-admin/dtrace-on-linux-1956556-zhs.html
http://dtrace.org/blogs/
Http://dtrace.org/guide/preface.html
Https://blogs.oracle.com/linux/entry/announcement_dtrace_for_oracle_linux
Http://www.ibm.com/developerworks/cn/aix/library/au-dtraceprobes.html
Http://www.oracle.com/technetwork/server-storage/solaris10/solaris-dtrace-wp-167895.pdf

Https://github.com/dtrace4linux/linux

Installing DTrace on Oracle Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.