Get the most out of your Centmin Mod LEMP stack
Become a Member

PHP Opcode and Memcached statistics pages

Discussion in 'Centmin Mod Insights' started by eva2000, Sep 29, 2014.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    30,546
    6,849
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,262
    Local Time:
    3:18 AM
    Nginx 1.13.x
    MariaDB 5.5

    Statistics Pages



    A PHP opcode cacher is installed by default. PHP opcode cacher caches the PHP code. For Centmin Mod 1.2.3-eva2000.07 stable PHP 5.4.33 is installed with APC Cache 3.1.13. For Centmin Mod .08stable and higher default is now Zend Opcache as APC Cache is outdated and not 100% supported in PHP 5.6+.

    Centmin Mod supports other PHP opcode cachers via running centmin.sh menu options for Xcache and Zend Opcache. All three PHP opcode cachers have their own respective statistics admin pages. Installing one of the 3 PHP opcachers via menu options 8, 9 and 12 will automatically remove all other PHP opcachers. I coded it this way so no need to uninstall PHP opcachers if you are switching between them i.e. switch from Xcache to APC Cache will auto remove Xcache via the menu method.

    Memcached server 1.4.20 is installed by default with both memcache and memcached/libmemcached PHP extension support. The memcache and memcached PHP extensions allow PHP to communicate with Memcached server. It too has it's own statistics admin page.

    Main Hostname Used for Stats Page Access



    For all PHP opcode caches, APC Cache, Xcache, Zend Opcache and Memcached server caching, the admin statistics pages are located and served from the Centmin Mod default hostname web root /usr/local/nginx/html/ at your hostname.yourdomain.com/* (outlined in step 1 of Getting Started guide) as well as a PHP INFO page at XXX_phpi.php. So to access these files you would go to hostname.yourdomain.com/${N}_myapc.php.
    • APC Cache - located at /usr/local/nginx/html/${N}_myapc.php where ${N} is randomised number unique to each Centmin Mod installation. You can change the file name or location if you want after install. You can password protect the file if you want and/or change it's filename and location. So to access this file you would go to hostname.yourdomain.com/${N}_myapc.php.
    • Xcache - located at /usr/local/nginx/html/myxcacheadmin which is username and password protected with a unique login auto generated for each Centmin Mod installation. You can change the directory location and name if you want after install. Username and password are located in your Centmin Mod initial install log at /root/centminlogs/centminmod_1.2.3-eva2000.07_DDMMYY-TIMESTAMP_install.log. So to access this directory you would go to hostname.yourdomain.com/myxcacheadmin.
    • Zend Opcache - located at /usr/local/nginx/html/${N}_opcache.php where ${N} is randomised number unique to each Centmin Mod installation. You can change the file name or location if you want after install. You can password protect the file if you want and/or change it's filename and location. So to access this file you would go to hostname.yourdomain.com/${N}_opcache.php.
    • Memcached - located at /usr/local/nginx/html/memcache_${N}.php where ${N} is randomised number unique to each Centmin Mod installation. So to access this file you would go to hostname.yourdomain.com/memcache_${N}.php. You can change the file name or location if you want after install. Memcached statistics page has an auto generated username and password unique to each Centmin Mod install which is printed out at end of the Centmin Mod initial install output. If you missed that info, you can find the username and password located in your Centmin Mod initial install log at /root/centminlogs/centminmod_1.2.3-eva2000.07_DDMMYY-TIMESTAMP_install.log. You can use grep to easily find the relevant part of the install log containing the user/pass details:
      Code:
      grep -A13 'Setup memcached_' /root/centminlogs/centminmod_1.2.3-eva2000.07_DDMMYY-TIMESTAMP_install.log
    • PHP INFO page - located at XXX_phpi.php where XXX is randomised number unique to each Centmin Mod installation. You can change the file name or location if you want after install. So to access this file you would go to hostname.yourdomain.com/XXX_phpi.php.
    For all 5 locations, in additional to password protection you can also IP address restrict access via this context added to your main hostname's Nginx vhost at /usr/local/nginx/conf/conf.d/virtual.conf (command short to launch nano text editor for it = vhostconf)

    Make sure to change the file name matches in location to your specific filenames.

    Code:
    location ~ ^/(XX_opcache|memcache_XXX|XXX_phpi\.php) {
            include /usr/local/nginx/conf/php.conf;
            allow 127.0.0.1;
            allow YOURIPADDRESS;
            deny all;
    }
    
    location ~ ^/myxcacheadmin {
            include /usr/local/nginx/conf/php.conf;
            allow 127.0.0.1;
            allow YOURIPADDRESS;
            deny all;
    }
    
    To edit the memory allocation or settings for PHP Opcachers, you do this via each of their respective PHP *.ini files which can find via SSH command.


    Code:
    php --ini
    Sample output for APC Cache with Memcached server.

    Code:
    php --ini
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/a_customphp.ini,
    /etc/centminmod/php.d/curlcainfo.ini,
    /etc/centminmod/php.d/geoip.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/mailparse.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini,
    /etc/centminmod/php.d/redis.ini,
    /etc/centminmod/php.d/zendopcache.ini
    
    So to edit memory allocation to APC Cache, edit /etc/centminmod/php.d/apc.ini. For Xcache, edit /etc/centminmod/php.d/xcache.ini and for Zend Opcache edit /etc/centminmod/php.d/zendopcache.ini. You need to restart PHP-FPM service after making *.ini file changes.

    However, for Memcached server memory allocation, settings are located directly within /etc/init.d/memcached startup script. Default memory allocation for Memcached server is set by MEMSIZE and is 8MB. You need to restart Memcached service after making /etc/init.d/memcached changes.

    Code:
    BINNAME=memcached
    BIN=/usr/local/bin/memcached
    USER=nobody
    LOGGING='n'
    LOGFILE="/var/log/memcached.log"
    LOGFILEB="/var/log/memcached2.log"
    CON=1024
    THREADS=4
    MINSP=72
    CHUNKF=1.25
    PORT1=11211
    PORT2=11212
    SOCKET_ENABLE=n
    SOCKETA='-s /var/run/memcached/memcached1.sock -a 0755'
    SOCKETB='-s /var/run/memcached/memcached2.sock -a 0755'
    MEMSIZE=8
    SERVERCOUNT=1
    SERVERIP='127.0.0.1'
    OPTIONS='-o slab_reassign,slab_automove'

     
    Last edited: Apr 25, 2017
    • Like Like x 3
    • Useful Useful x 1
  2. eva2000

    eva2000 Administrator Staff Member

    30,546
    6,849
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,262
    Local Time:
    3:18 AM
    Nginx 1.13.x
    MariaDB 5.5
    Sample APC Cache and Memcached Statistics pages

    APC edit settings at /etc/centminmod/php.d/apc.ini

    apc_cache_00.png
    memcached_stats_00.png

    For Zend Opcache stats edit ini file for settings at /etc/centminmod/php.d/zendopcache.ini

    zendopcache_00.png
     
  3. eva2000

    eva2000 Administrator Staff Member

    30,546
    6,849
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,262
    Local Time:
    3:18 AM
    Nginx 1.13.x
    MariaDB 5.5
    FYI, there's various ways in SSH to get memcached server stats too

    Code:
    echo stats | nc 127.0.0.1 11211
    gives

    Code:
    echo stats | nc 127.0.0.1 11211
    STAT pid 22582
    STAT uptime 24
    STAT time 1424349314
    STAT version 1.4.22
    STAT libevent 2.0.21-stable
    STAT pointer_size 64
    STAT rusage_user 0.006666
    STAT rusage_system 0.033333
    STAT curr_connections 5
    STAT total_connections 18
    STAT connection_structures 6
    STAT reserved_fds 20
    STAT cmd_get 100
    STAT cmd_set 37
    STAT cmd_flush 0
    STAT cmd_touch 0
    STAT get_hits 64
    STAT get_misses 36
    STAT delete_misses 0
    STAT delete_hits 0
    STAT incr_misses 0
    STAT incr_hits 0
    STAT decr_misses 0
    STAT decr_hits 0
    STAT cas_misses 0
    STAT cas_hits 0
    STAT cas_badval 0
    STAT touch_hits 0
    STAT touch_misses 0
    STAT auth_cmds 0
    STAT auth_errors 0
    STAT bytes_read 204124
    STAT bytes_written 511405
    STAT limit_maxbytes 268435456
    STAT accepting_conns 1
    STAT listen_disabled_num 0
    STAT threads 4
    STAT conn_yields 0
    STAT hash_power_level 16
    STAT hash_bytes 524288
    STAT hash_is_expanding 0
    STAT slab_reassign_running 0
    STAT slabs_moved 0
    STAT malloc_fails 0
    STAT bytes 202454
    STAT curr_items 37
    STAT total_items 37
    STAT expired_unfetched 0
    STAT evicted_unfetched 0
    STAT evictions 0
    STAT reclaimed 0
    STAT crawler_reclaimed 0
    STAT lrutail_reflocked 0
    END
    via memcached-tool

    the options available

    Code:
    memcached-tool
    Usage: memcached-tool <host[:port] | /path/to/socket> [mode]
    
           memcached-tool 10.0.0.5:11211 display    # shows slabs
           memcached-tool 10.0.0.5:11211            # same.  (default is display)
           memcached-tool 10.0.0.5:11211 stats      # shows general stats
           memcached-tool 10.0.0.5:11211 settings   # shows settings stats
           memcached-tool 10.0.0.5:11211 sizes      # shows sizes stats
           memcached-tool 10.0.0.5:11211 dump       # dumps keys and values
    
    WARNING! sizes is a development command.
    As of 1.4 it is still the only command which will lock your memcached instance for some time.
    If you have many millions of stored items, it can become unresponsive for several minutes.
    Run this at your own risk. It is roadmapped to either make this feature optional
    or at least speed it up.
    for example stats

    Code:
    memcached-tool 127.0.0.1:11211 stats
    Code:
    memcached-tool 127.0.0.1:11211 stats
    #127.0.0.1:11211   Field       Value
             accepting_conns           1
                   auth_cmds           0
                 auth_errors           0
                       bytes      624900
                  bytes_read      701739
               bytes_written     5200282
                  cas_badval           0
                    cas_hits           0
                  cas_misses           0
                   cmd_flush           0
                     cmd_get         917
                     cmd_set         124
                   cmd_touch           0
                 conn_yields           0
       connection_structures           9
           crawler_reclaimed           0
            curr_connections           8
                  curr_items          98
                   decr_hits           0
                 decr_misses           0
                 delete_hits           0
               delete_misses           0
           evicted_unfetched           0
                   evictions           0
           expired_unfetched           0
                    get_hits         827
                  get_misses          90
                  hash_bytes      524288
           hash_is_expanding           0
            hash_power_level          16
                   incr_hits           0
                 incr_misses           0
                    libevent 2.0.21-stable
              limit_maxbytes   268435456
         listen_disabled_num           0
           lrutail_reflocked           0
                malloc_fails           0
                         pid       22582
                pointer_size          64
                   reclaimed           0
                reserved_fds          20
               rusage_system    0.079999
                 rusage_user    0.039999
       slab_reassign_running           0
                 slabs_moved           0
                     threads           4
                        time  1424349464
           total_connections          53
                 total_items         124
                  touch_hits           0
                touch_misses           0
                      uptime         174
                     version      1.4.22
    settings list

    Code:
    memcached-tool 127.0.0.1:11211 settings
    #127.0.0.1:11211   Field       Value
           auth_enabled_sasl          no
            binding_protocol auto-negotiate
                 cas_enabled         yes
                  chunk_size          72
              detail_enabled          no
               domain_socket        NULL
                   evictions          on
               flush_enabled         yes
               growth_factor        1.25
              hash_algorithm     jenkins
              hashpower_init           0
                       inter   127.0.0.1
               item_size_max     1048576
                 lru_crawler          no
           lru_crawler_sleep         100
         lru_crawler_tocrawl           0
                    maxbytes   268435456
                    maxconns        2048
               maxconns_fast          no
                 num_threads           4
         num_threads_per_udp           4
                      oldest           0
              reqs_per_event         200
               slab_automove           1
               slab_reassign         yes
             stat_key_prefix           :
            tail_repair_time           0
                 tcp_backlog        2048
                     tcpport       11211
                     udpport       11211
                       umask         700
                   verbosity           0
    Explanation for memcached-tool at MySQL :: MySQL 5.5 Reference Manual :: 16.6.4.6 Using memcached-tool and details on stats output MySQL :: MySQL 5.5 Reference Manual :: 16.6.4.1 memcached General Statistics

    Statistic Data type Description Version
    pid 32u Process ID of the memcached instance.
    uptime 32u Uptime (in seconds) for this memcached instance.
    time 32u Current time (as epoch).
    version string Version string of this instance.
    pointer_size string Size of pointers for this host specified in bits (32 or 64).
    rusage_user 32u:32u Total user time for this instance (seconds:microseconds).
    rusage_system 32u:32u Total system time for this instance (seconds:microseconds).
    curr_items 32u Current number of items stored by this instance.
    total_items 32u Total number of items stored during the life of this instance.
    bytes 64u Current number of bytes used by this server to store items.
    curr_connections 32u Current number of open connections.
    total_connections 32u Total number of connections opened since the server started running.
    connection_structures 32u Number of connection structures allocated by the server.
    cmd_get 64u Total number of retrieval requests (get operations).
    cmd_set 64u Total number of storage requests (set operations).
    get_hits 64u Number of keys that have been requested and found present.
    get_misses 64u Number of items that have been requested and not found.
    delete_hits 64u Number of keys that have been deleted and found present. 1.3.x
    delete_misses 64u Number of items that have been delete and not found. 1.3.x
    incr_hits 64u Number of keys that have been incremented and found present. 1.3.x
    incr_misses 64u Number of items that have been incremented and not found. 1.3.x
    decr_hits 64u Number of keys that have been decremented and found present. 1.3.x
    decr_misses 64u Number of items that have been decremented and not found. 1.3.x
    cas_hits 64u Number of keys that have been compared and swapped and found present. 1.3.x
    cas_misses 64u Number of items that have been compared and swapped and not found. 1.3.x
    cas_badvalue 64u Number of keys that have been compared and swapped, but the comparison (original) value did not match the supplied value. 1.3.x
    evictions 64u Number of valid items removed from cache to free memory for new items.
    bytes_read 64u Total number of bytes read by this server from network.
    bytes_written 64u Total number of bytes sent by this server to network.
    limit_maxbytes 32u Number of bytes this server is permitted to use for storage.
    threads 32u Number of worker threads requested.
    conn_yields 64u Number of yields for connections (related to the -R option). 1.4.0
     
    Last edited: Feb 19, 2015
Thread Status:
Not open for further replies.