#!/usr/sbin/dtrace -s /* * * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma D option switchrate=10 #pragma D option aggrate=10 #pragma D option bufsize=512k #pragma D option aggsize=512k #pragma D option dynvarsize=64m BEGIN { } php*:::execute-entry { self->execute_file = copyinstr(arg0); self->lineno = arg1; self->execute_start_time = timestamp; } php*:::execute-return /self->lineno == arg1 && self->execute_file == copyinstr(arg0)/ { self->execute_elapsed = ((timestamp - self->execute_start_time) / 1000000); @execute_time[self->execute_file, self->lineno] = quantize(self->execute_elapsed); /* printf("Fired 'execute-return' in process -> %d within file -> %s at line no -> %d time taken -> %d",pid, self->execute_file,self->lineno, self->execute_elapsed); */ self->execute_file = 0; self->lineno = 0; self->execute_start_time = 0; } php*:::function-entry { self->funcname = (arg0 != NULL) ? copyinstr(arg0) : ""; self->function_file = copyinstr(arg1); self->lineno = arg2; self->function_start_time = timestamp; } php*:::function-return /self->lineno == arg2 && self->function_file == copyinstr(arg1)/ { self->function_elapsed = ((timestamp - self->function_start_time)/ 1000000); @function_time[self->function_file, self->funcname] = quantize(self->function_elapsed); /* printf("Fired 'function-return' in process -> %d within function -> %s in file -> %s time taken -> %d", pid, self->funcname, self->function_file, self->function_elapsed); */ self->funcname = 0; self->function_file = 0; self->lineno = 0; self->function_start_time = 0; } php*:::compile-file-entry /arg0 != NULL/ { self->compile_file = (arg1 != NULL) ? copyinstr(arg0) : ""; self->compile_file_translated = (arg1 != NULL) ? copyinstr(arg1) : ""; self->compile_start_time = timestamp; } php*:::compile-file-return /arg0 != NULL && self->compile_file == copyinstr(arg0)/ { self->compile_elapsed = ((timestamp - self->compile_start_time) / 1000000); @compile_time[self->compile_file] = quantize(self->compile_elapsed); /* printf("Fired 'compile-file-return in process -> %d within file -> %s time taken -> %d",pid, self->compile_file, self->compile_elapsed); */ self->compile_file = 0; self->compile_file_translated = 0; self->compile_start_time = 0; } php*:::request-startup { self->request_file = copyinstr(arg0); self->request_uri = copyinstr(arg1); self->request_method = copyinstr(arg2); self->request_start_time = timestamp; } php*:::request-shutdown /self->request_file == copyinstr(arg0)/ { self->request_elapsed = ((timestamp - self->request_start_time) / 1000000); @request_time[self->request_file] = quantize(self->request_elapsed); /* printf("Completed Processing Request in process => %d for File => %s time taken = %d", pid, self->request_file, self->request_elapsed); */ self->request_file = 0; self->request_uri = 0; self->request_method = 0; self->request_start_time = 0; } php*:::error { self->error_msg = (arg0 != NULL) ? copyinstr(arg0) : ""; self->execute_file = copyinstr(arg1); self->lineno = arg2; /* printf("Error thrown in pid -> %d within file -> %s at line no -> %d with message -> %s" , pid, self->execute_file, self->lineno, self->error_msg); */ } php*:::exception-thrown { self->classname = copyinstr(arg0); printf("Error thrown with classname : %s\n", self->classname); } php*:::exception-catched /arg0 != NULL && self->classname == copyinstr(arg0)/ { printf("Exception caught for classname: %s\n", self->classname); self->classname = 0; } tick-60s { printf("\nElapsed times after 60 seconds\n"); printf("\nInclusive Script execute time,\n"); printa(" %s, %d, %@d\n", @execute_time); printf("\nExclusive Function execute times,\n"); printa(" %s, %s, %@d\n", @function_time); printf("\nExclusive compile elapsed times,\n"); printa(" %s, %@d\n", @compile_time); printf("\nExclusive request elapsed times,\n"); printa(" %s, %@d\n", @request_time); }