418ab122c25c87cdef54473c407b707960f0baa5
3 * Profiler sending messages over UDP.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 * ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
27 * http://git.wikimedia.org/tree/operations%2Fsoftware.git/master/udpprofile)
30 class ProfilerSimpleUDP
extends ProfilerSimple
{
31 public function isPersistent() {
35 public function logData() {
36 global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgUDPProfilerFormatString;
40 if ( isset( $this->mCollated
['-total'] ) && $this->mCollated
['-total']['real'] < $this->mMinimumTime
) {
41 # Less than minimum, ignore
45 if ( !function_exists( 'socket_create' ) ) {
46 # Sockets are not enabled
50 $sock = socket_create( AF_INET
, SOCK_DGRAM
, SOL_UDP
);
53 foreach ( $this->mCollated
as $entry => $pfdata ) {
54 if ( !isset( $pfdata['count'] )
55 ||
!isset( $pfdata['cpu'] )
56 ||
!isset( $pfdata['cpu_sq'] )
57 ||
!isset( $pfdata['real'] )
58 ||
!isset( $pfdata['real_sq'] ) ) {
61 $pfline = sprintf( $wgUDPProfilerFormatString, $this->getProfileID(), $pfdata['count'],
62 $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $entry );
63 $length = strlen( $pfline );
64 /* printf("<!-- $pfline -->"); */
65 if ( $length +
$plength > 1400 ) {
66 socket_sendto( $sock, $packet, $plength, 0, $wgUDPProfilerHost, $wgUDPProfilerPort );
73 socket_sendto( $sock, $packet, $plength, 0x100, $wgUDPProfilerHost, $wgUDPProfilerPort );