MediaWiki
REL1_22
|
00001 <?php 00029 class ProfilerSimpleUDP extends ProfilerSimple { 00030 public function isPersistent() { 00031 return true; 00032 } 00033 00034 public function logData() { 00035 global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgUDPProfilerFormatString; 00036 00037 $this->close(); 00038 00039 if ( isset( $this->mCollated['-total'] ) && $this->mCollated['-total']['real'] < $this->mMinimumTime ) { 00040 # Less than minimum, ignore 00041 return; 00042 } 00043 00044 if ( !function_exists( 'socket_create' ) ) { 00045 # Sockets are not enabled 00046 return; 00047 } 00048 00049 $sock = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); 00050 $plength = 0; 00051 $packet = ""; 00052 foreach ( $this->mCollated as $entry => $pfdata ) { 00053 if ( !isset( $pfdata['count'] ) 00054 || !isset( $pfdata['cpu'] ) 00055 || !isset( $pfdata['cpu_sq'] ) 00056 || !isset( $pfdata['real'] ) 00057 || !isset( $pfdata['real_sq'] ) ) { 00058 continue; 00059 } 00060 $pfline = sprintf( $wgUDPProfilerFormatString, $this->getProfileID(), $pfdata['count'], 00061 $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $entry ); 00062 $length = strlen( $pfline ); 00063 /* printf("<!-- $pfline -->"); */ 00064 if ( $length + $plength > 1400 ) { 00065 socket_sendto( $sock, $packet, $plength, 0, $wgUDPProfilerHost, $wgUDPProfilerPort ); 00066 $packet = ""; 00067 $plength = 0; 00068 } 00069 $packet .= $pfline; 00070 $plength += $length; 00071 } 00072 socket_sendto( $sock, $packet, $plength, 0x100, $wgUDPProfilerHost, $wgUDPProfilerPort ); 00073 } 00074 }