1 # -*- tab-width: 4 -*- ;; Emacs
2 # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM
3 ############################################################ IDENT(1)
5 # $Title: dwatch(8) module for dtrace_proc(4) activity $
6 # $Copyright: 2014-2018 Devin Teske. All rights reserved. $
9 ############################################################ DESCRIPTION
11 # Display process activity
13 ############################################################ PROBE
20 proc:::exec-failure, \
21 proc:::exec-success, \
23 proc:::signal-clear, \
24 proc:::signal-discard, \
29 proc:::signal-clear, \
30 proc:::signal-discard, \
37 proc:::exec-failure, \
38 proc:::exec-success, \
42 : ${PROBE:=proc:::${PROFILE#proc-}}
45 ############################################################ ACTIONS
51 this string exec_arg0;
53 inline string probealias[string name] =
54 name == "create" ? "FORK" :
55 name == "exec" ? "EXEC" :
56 name == "exec-failure" ? "FAIL" :
57 name == "exec-success" ? "INIT" :
58 name == "exit" ? "EXIT" :
59 name == "signal-clear" ? "CLEAR" :
60 name == "signal-discard" ? "DISCARD" :
61 name == "signal-send" ? "SEND" :
64 $PROBE /* probe ID $ID */
70 proc:::create /* probe ID $(( $ID + 1 )) */
72 printf("<$(( $ID + 1 ))>");
74 $( pproc -P _create "(struct proc *)args[0]" )
76 /* details = "pid <pid of args[0]> -- <proc args of args[0]>" */
77 this->details = strjoin(
78 strjoin("pid ", lltostr(this->pid_create)),
79 strjoin(" -- ", this->args_create));
82 proc:::exec /* probe ID $(( $ID + 2 )) */
84 printf("<$(( $ID + 2 ))");}
85 this->details = this->exec_arg0 = stringof(arg0);
88 proc:::exec-failure /* probe ID $(( $ID + 3 )) */
90 printf("<$(( $ID + 3 ))>");
92 /* details = "<arg0 from proc:::exec>: <strerror of arg0> (<arg0>)" */
93 this->details = strjoin(
94 strjoin(this->exec_arg0, ": "),
95 strjoin(strerror[(int)arg0],
96 strjoin(" (", strjoin(lltostr((int)arg0), ")"))));
99 proc:::exec-success /* probe ID $(( $ID + 4 )) */
101 printf("<$(( $ID + 4 ))>");}
102 this->details = this->args0;
105 proc:::exit /* probe ID $(( $ID + 5 )) */
107 printf("<$(( $ID + 5 ))>");}
108 this->details = child_signal_string[(int)arg0];
111 proc:::signal-clear /* probe ID $(( $ID + 6 )) */
113 printf("<$(( $ID + 6 ))>");}
114 this->pid = (pid_t)((ksiginfo_t *)args[1])->ksi_info.si_pid;
115 this->sig = (int)arg0;
118 proc:::signal-discard, proc:::signal-send /* probe ID $(( $ID + 7 )) */
120 printf("<$(( $ID + 7 ))>");}
121 this->pid = (pid_t)((struct proc *)args[1])->p_pid;
122 this->sig = (int)arg2;
126 proc:::signal-discard,
127 proc:::signal-send /* probe ID $(( $ID + 8 )) */
129 printf("<$(( $ID + 8 ))>");
131 /* details = "<signal>[<num>] pid <pid>" */
132 this->details = strjoin(strjoin(signal_string[this->sig], "["),
133 strjoin(strjoin(lltostr(this->sig), "] pid "),
134 lltostr(this->pid)));
137 proc:::signal-send, proc:::signal-discard /* probe ID $(( $ID + 9 )) */
139 printf("<$(( $ID + 9 ))>");
141 $( pproc -P _signal "(struct proc *)args[1]" )
143 this->details = strjoin(this->details,
144 strjoin(" -- ", this->args_signal));
150 ############################################################ EVENT DETAILS
152 if [ ! "$CUSTOM_DETAILS" ]; then
157 printf("%s %s", probealias[probename], this->details);
159 EVENT_DETAILS=$( cat <&9 )
162 ################################################################################
164 ################################################################################