3.4 Using USDT Probes

This section provides some practice in the nominal use of the USDT probes that were created in Section 3.3, “Adding USDT Probes to an Application”.

Initially, the probes are not visible because the application is not running with the probes, as shown in the following output:

# dtrace -l -P 'prime*'
  ID   PROVIDER            MODULE                          FUNCTION NAME
dtrace: failed to match prime*:::: No probe matches description

Start the application, but do not enter any value until you have listed the probes:

# ./prime 
Enter a positive target integer to test for prime status:
 

From another command line, issue a probe listing:

# dtrace -l -P 'prime*'
   ID      PROVIDER            MODULE                          FUNCTION NAME
 2475 primeget26556             prime                              main query-factorreturnA
 2476 primeget26556             prime                              main query-factorreturnB
 2477 primeget26556             prime                              main query-final
 2478 primeget26556             prime                              main query-maxcheckval
 2479 primeget26556             prime                              main query-userentry
 
Note

The provider name is a combination of the defined provider primeget, from the dprime.d file, and the PID of the running application prime. The output of the following command displays the PID of prime:

# ps aux | grep prime
root 26556 0.0 0.0 7404 1692 pts/0 S+ 21:50 0:00 ./prime

If you want to be able to run USDT scripts for users other than root, the helper device must have the proper permissions. Alternatively, you can run the program with the probes in it as the root user. See Section 3.1.1, “Example: Changing the Mode of the DTrace Helper Device” for more information about changing the mode of the DTrace helper device.

One method for getting these permissions is to run the following command to change the configuration so that users other than the root user can send probe provider information to DTrace:

# setfacl -m u:guest:rw /dev/dtrace/helper

Start the application again, but do not enter any values until the probes are listed:

# ./prime 
Enter a positive target integer to test for prime status: 

From another command line, issue a probe listing:

# dtrace -l -P 'prime*'
   ID     PROVIDER            MODULE                    FUNCTION NAME
 2456 primeget2069             prime                        main query-factorreturnA
 2457 primeget2069             prime                        main query-factorreturnB
 2458 primeget2069             prime                        main query-final
 2459 primeget2069             prime                        main query-maxcheckval
 2460 primeget2069             prime                        main query-userentry