Changeset 580


Ignore:
Timestamp:
Mar 14, 2011, 9:33:11 PM (10 years ago)
Author:
zerodeux
Message:

phptop 0.5.3 release

Location:
phptop
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • phptop/Makefile

    r558 r580  
    1919
    2020debupload:
    21         rsync -z ../phptop_*.deb builder@deb.bearstech.com:~/src/phptop/
    22         ssh builder@deb.bearstech.com make -C www phptop
     21        rsync -z ../phptop_*.deb builder@deb.bearstech.com:~/www/squeeze
     22        ssh builder@deb.bearstech.com make -C www/squeeze phptop
    2323
    2424deploy:
  • phptop/NEWS

    r552 r580  
     1phptop 0.5.3 - 2011-03-14
     2
     3    * Non-compatible change: -t is now using seconds, because it didn't make
     4      any sense to use minutes there and seconds here.
     5    * Minor bugfix, PHP comments use ; and not # now
     6    * Style fix: 'perlcritic phptop' OK
     7    * Added 2011 in various (c) notices
     8    * man page: finally writen the INTERPRETATION section
     9
    110phptop 0.5.2 - 2010-10-19
    211
  • phptop/README

    r395 r580  
    1 phptop (c) 2009,2010 Bearstech - http://bearstech.com/
     1phptop (c) 2009,2010,2011 Bearstech - http://bearstech.com/
    22
    33phptop prints per query and average metrics comparable to 'time' (wallclock,
     
    2020  (Wait at least a few minutes to collect data...)
    2121
    22   server:~# ./phptop -s mem
     22  server:~# phptop -s mem
    2323  URL                                       Hit     Time     User      Sys >Mem/hit  Mem_max
    2424  http://blog.dummy.com/facebook/myapi/       5      0.8      0.5      0.1      6.2     31.0
     
    3838
    3939 * Marc Dequènes aka Duck
     40
  • phptop/debian/changelog

    r558 r580  
     1phptop (0.5.3-1) stable; urgency=low
     2
     3  * Upstream update, see NEWS file
     4
     5 -- Vincent CARON <vcaron@bearstech.com>  Mon, 14 Mar 2011 21:29:25 +0100
     6
    17phptop (0.5.2+nmu2) stable; urgency=low
    28
  • phptop/phptop

    r552 r580  
    22
    33# phptop - Analyse quickly system ressource usage across many PHP queries
    4 # Copyright (C) 2009,2010 Bearstech - http://bearstech.com/
     4# Copyright (C) 2009,2010,2011 Bearstech - http://bearstech.com/
    55#
    66# This program is free software: you can redistribute it and/or modify
     
    2626
    2727my $package_name    = 'phptop';
    28 my $package_version = '0.5.2';
    29 my $package_owner   = 'Copyright (C) 2009,2010 Bearstech - http://bearstech.com/';
     28my $package_version = '0.5.3';
     29my $package_owner   = 'Copyright (C) 2009,2010,2011 Bearstech - http://bearstech.com/';
    3030my $package_url     = 'http://forge.bearstech.com/trac/wiki/PhpTop';
    3131
     
    3939my @sortkeys;
    4040my $count  = 10;
    41 my $span   = 10;
     41my $span   = 300;
    4242my $output = 'text';
    4343
     
    7171  -p, --path-only      Only print path, skip http://host
    7272  -s, --sort key       Sort key: hit, time, user, sys or mem (default is @sortkeys)
    73   -t, --time N         Parse data from now back to N minutes (default is $span)
     73  -t, --time N         Parse data from now back to N seconds (default is $span)
    7474  -v, --version        Display version number and copyright info
    7575
     
    107107        no warnings;
    108108   
    109         if (open($lh, "tac $logfile |")) {
     109        if (open($lh, '-|', "tac $logfile")) {
    110110            $reverse = 1;
    111111        }
    112         elsif (!open($lh, "<$logfile")) {
     112        elsif (!open($lh, '<', $logfile)) {
    113113            warn "$logfile: $!";
    114114            return 0;
     
    128128        if (/^\[(.*?)\]/) {
    129129            my $stamp = str2time($1);
    130             my $skip = defined $stamp && ($now - $stamp) > $span * 60;
     130            my $skip = defined $stamp && ($now - $stamp) > $span;
    131131
    132132            if ($reverse and $skip) {
     
    142142
    143143        $pairs =~ s/, referer.*//;     # Apache may append a referer in error.log, ignore
    144         $pairs =~ s/(\d),(\d)/$1.$2/g; # Be independent of the PHP locale, normalize on dot decimal separator
     144        $pairs =~ s/(\d),(\d)/$1.$2/g; # Be independent from the PHP locale, normalize on dot decimal separator
    145145        my @kv = split(/ /, $pairs);
    146146        next if @kv < 4;               # Protect against bogus/wrapped phptop records, count pairs
     
    148148        # Fix URLs (depending on options)
    149149        $url =~ s/index\.php\/?//;  # / == /index.php (99.9% of the time)
     150        $url =~ s/\/+$/\//;         # Ignore multiple trailing slashes
    150151        $url =~ s/\?.*// if not defined $full_query;
    151152        $url =~ s/^https?:\/\/[^\/]+// if defined $path_only;
     
    219220
    220221    my @sums = map { defined $sum{$_} ? sprintf($_ =~ m/hit/ ? '%d' : '%.1f', $sum{$_}) : '' } @keys;
    221     unshift(@sums, "Total (from last $span min)");
     222    unshift(@sums, "Total (from last $span sec)");
    222223
    223224    return { headers => \@headers, rows => \@rows, sums => \@sums };
     
    255256   
    256257        # Table header
    257         my $h = $r->{headers};
    258         map { $_ = ">$_" if /^$key(\/hit)?$/i } @$h;
    259         printf("%-${width}s %s\n", shift(@$h), join(' ', map { sprintf("%8s", $_) } @$h));
     258        my @h = map { /^$key(\/hit)?$/i ? ">$_" : $_ } @{$r->{headers}};
     259        printf("%-${width}s %s\n", shift(@h), join(' ', map { sprintf("%8s", $_) } @h));
    260260
    261261        # Rows
  • phptop/phptop.1

    r559 r580  
    11.\" Yes, this file is manually edited.
    22.\"
    3 .TH "PHPTOP" "1" "03/23/2010" "\  0.5.2" "\ "
     3.TH "PHPTOP" "1" "03/14/2011" "\  0.5.3" "\ "
    44.\" disable hyphenation
    55.nh
     
    4242.TP
    4343\-t, \-\-time N
    44 Parse data from now back to N minutes (default is 10).
     44Parse data from now back to N seconds (default is 300, ie. 5 minutes).
    4545.TP
    4646\-v, \-\-version
     
    5151.sp
    5252.nf
    53 phptop -l /path/to/error.log -t 10
     53phptop -l /path/to/error.log -t 600
     54.fi
     55.sp
     56Getting stats from the last 10 minutes, sorted by hits, from well known log files:
     57.sp
     58.sp
     59.nf
     60phptop -p
    5461.fi
    5562Hint: on a given server, define a shell alias which already sets the proper error log paths. This way you don't have to repeat them again. Bash recipe:
     
    5966$ echo "alias phptop='phptop -l /home/*/log/error.log'" >>.bashrc
    6067$ source .bashrc
    61 $ phptop -t1
     68$ phptop -t60
    6269.fi
    6370.SH "INTERPRETATION"
    64 FIXME
     71Wallclock, system and user times are cumulated for similar URLs, and the total per URL is shown. It is an absolute time value which must be related to your observation window (-t option). The wallclock time is not a very interesting measure, since it depends both on your server ressources, on the client and on the client-server bandwidth, minus buffering effects. Interpret it with much caution.
     72.sp
     73The user and system time are CPU ressources. For a one minute observation window (-t 60), on a quad-core system you have 4 minutes (240 seconds) worth of CPU time to be split between user (CPU running application code), system (CPU running kernel code) and idle (CPU waiting I/O or doing nothing). On a busy and healthy server, user and system time add up to the whole available CPU time. If your user and system total time is far from the available CPU time, consult your server loadavg: if it's high (more than your number of CPUs), your server is probably waiting on I/O (more often disk than network); if it's low, your application might be waiting on remote services (think remote HTTP APIs) which are slow or not responding.
     74.sp
     75The memory figures can't be added, it would not make any sense. Instead simple satistics like maximum and average memory per URL are computed. The peak memory usage is very interesting when running phptop over a large time window (one day or more) to figure out your optimal PHP memory_limit figure, which is itself very useful for proper configuration and usage of system ressources (number of PHP processes, SQL server connections, and so on). Over a short time window it also acts as a poor man's profiler, and can spot.
    6576.sp
    6677.SH "DISCUSSION"
     
    7182At analysis time (when launching phptop itself), care has been taken to read and parse only the needed amount of data. Most importantly it will use the tac(1) command to 'reverse tail' the error logs, and default to a slower method if this command is not found.
    7283.sp
    73 The analysis process itself is mostly CPU bound if your error log sits on a reasonably available storage, and runs at approx. 15,000 samples/sec on a 2.4Ghz Intel core. That is why phptop output should be almost instantaneous while analysing the last minutes (eg. -t5), even on a very busy server (100 req/sec or more).
     84The analysis process itself is mostly CPU bound if your error log sits on a reasonably available storage, and runs at approx. 15,000 samples/sec on a 2.4Ghz Intel core. That is why phptop output should be almost instantaneous while analysing the last minutes (eg. -t 300), even on a very busy server (100 req/sec or more).
    7485.sp
    7586.SH "BUGS"
     87Phtop should run '-s user' as a default instead of the useless-but-look-ma-my-hits '-s hit'.
     88.sp
    7689Phptop has been extensively used on production servers, but only on GNU/Linux Debian Etch (4.0), Lenny (5.0) and specifically on the AMD64 architecture with PHP 5.2. Tests and reports with other kernels, distributions and PHP versions are warmly welcome.
    7790.sp
     
    96109.SH "COPYRIGHT"
    97110.sp
    98 Copyright © 2009,2010 Bearstech. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
     111Copyright © 2009,2010,2011 Bearstech. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
    99112This is free software: you are free to change and redistribute it.  There is NO WARRANTY, to the extent permitted by law.
    100113.sp
  • phptop/phptop_hook.php

    r395 r580  
    22/*
    33 * phptop - Analyse quickly system ressource usage across many PHP queries
    4  * Copyright (C) 2009,2010 Bearstech - http://bearstech.com/
     4 * Copyright (C) 2009,2010,2011 Bearstech - http://bearstech.com/
    55 *
    66 * This program is free software: you can redistribute it and/or modify
Note: See TracChangeset for help on using the changeset viewer.