So far, Production check seems awesome, but I'm having a few problems at the moment.

When viewing the Prod-check report at admin/reports/prod-check ,
there is a link to APC at admin/reports/status/apc&destination=admin/reports/prod-check.
The data shown on this page is correct but the graphs do not dispay. Also, following the links to the other APC data displays gets me the browsers "not found" message. For example, the button/link to "View Host Stats" (which is actually the default page that comes up) has this address: http://localhost/mydrupalsite/admin/reports/status/apc?SCOPE=A&SORT1=H&S... The result is the same for all buttons/links as well as the graphs: "Not Found. The requested URL was not found on this server."

I am currently developing my website on my Ubuntu 11.10 home computer. APC is installed and running. The APC "Host Stats" page displays just fine here: localhost/mydrupalsite/apc.php?SCOPE=A&SORT1=H&SORT2=D&COUNT=20&OB=1 In order to look at it there I extracted and copied the apc.php file from /usr/share/doc/php-apc to the root folder of my Drupal installation.

Any help or direction with this would be very much appreciated. Thanks in advance for your time!

Drupal skill level = beginner ;-)

Comments

malc0mn’s picture

Assigned: Unassigned » malc0mn

Hmz, will have to check myself as the apc.php file you are referring to is exactly what has been integrated in prod_check... Unless there is a newer version available or something like that...

What APC version are you using? Could you compare your apc.php file to includes/prod_check.apc.inc.
Note: there will be small differences which had to be made to integrate the apc.php file into Drupal.

bharata’s picture

Assigned: malc0mn » Unassigned

I am running APC 3.1.7, but a newer version (3.1.13) is available at http://pecl.php.net/package/APC/3.1.13

How can I best communitate to you the differences in the two files? When looking at them with Kompare if I ignore changes in case, the amount of whitespace or added/removed empty lines I get the following statistics:

Format: Unified
Number of hunks: 31
Number of differences: 20

Please forgive the huge amount of stuff below but perhaps it's helpful.
I also did a diff from the command line with the following command and got the info pasted below:

diff -u -b -B -d -i --ignore-case --ignore-space-change apc.php prod_check.apc.inc

--- apc.php	2013-04-01 23:40:10.000000000 -0400
+++ prod_check.apc.inc	2013-02-26 17:02:14.000000000 -0500
@@ -3,7 +4,7 @@
   +----------------------------------------------------------------------+
   | APC                                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2006-2011 The PHP Group                                |
+  | Copyright (c) 2008 The PHP Group                                     |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -22,7 +23,7 @@
 
  */
 
-$VERSION='$Id: apc.php 307048 2011-01-03 23:53:17Z kalle $';
+$VERSION='$Id$';
 
 ////////// READ OPTIONAL CONFIGURATION FILE ////////////
 if (file_exists("apc.conf.php")) include("apc.conf.php");
@@ -38,8 +39,8 @@
 											// If set to 1:
 											//  You need to change ADMIN_PASSWORD to make
 											//  this work!
-defaults('ADMIN_USERNAME','apc'); 			// Admin Username
-defaults('ADMIN_PASSWORD','password');  	// Admin Password - CHANGE THIS TO ENABLE!!!
+//defaults('ADMIN_USERNAME','apc'); 			// Admin Username
+//defaults('ADMIN_PASSWORD','password');  	// Admin Password - CHANGE THIS TO ENABLE!!!
 
 // (beckerr) I'm using a clear text password here, because I've no good idea how to let 
 //           users generate a md5 or crypt password in a easy way to fill it in above
@@ -49,8 +50,6 @@
 
 defaults('GRAPH_SIZE',200);					// Image size
 
-//defaults('PROXY', 'tcp://127.0.0.1:8080');
-
 ////////// END OF DEFAULT CONFIG AREA /////////////////////////////////////////////////////////////
 
 
@@ -61,13 +60,12 @@
 
 // rewrite $PHP_SELF to block XSS attacks
 //
-$PHP_SELF= isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'],''), ENT_QUOTES, 'UTF-8') : '';
-$time = time();
-$host = php_uname('n');
+//$PHP_SELF= isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'],''), ENT_QUOTES) : '';
+//Line above modified to make this work for the Drupal 'Prod check' module
+$PHP_SELF= isset($_GET['q']) ? base_path() . htmlentities(strip_tags($_GET['q'],''), ENT_QUOTES) : '';
+$time = REQUEST_TIME;
+$host = getenv('HOSTNAME');
 if($host) { $host = '('.$host.')'; }
-if (isset($_SERVER['SERVER_ADDR'])) {
-  $host .= ' ('.$_SERVER['SERVER_ADDR'].')';
-}
 
 // operation constants
 define('OB_HOST_STATS',1);
@@ -134,13 +132,18 @@
 if (empty($MYREQUEST['OB']))	$MYREQUEST['OB']=OB_HOST_STATS;
 if (!isset($MYREQUEST['COUNT'])) $MYREQUEST['COUNT']=20;
 if (!isset($scope_list[$MYREQUEST['SCOPE']])) $MYREQUEST['SCOPE']='A';
-
+// added for prod_check support
+global $MY_SELF;
+// end prod_check
 $MY_SELF=
 	"$PHP_SELF".
 	"?SCOPE=".$MYREQUEST['SCOPE'].
 	"&SORT1=".$MYREQUEST['SORT1'].
 	"&SORT2=".$MYREQUEST['SORT2'].
 	"&COUNT=".$MYREQUEST['COUNT'];
+// added for prod_check support
+global $MY_SELF_WO_SORT;
+// end prod_check
 $MY_SELF_WO_SORT=
 	"$PHP_SELF".
 	"?SCOPE=".$MYREQUEST['SCOPE'].
@@ -345,7 +348,6 @@
 		for($i=0; $i<$mem['num_seg']; $i++) {	
 			$ptr = 0;
 			$free = $mem['block_lists'][$i];
-			uasort($free, 'block_sort');
 			foreach($free as $block) {
 				if($block['offset']!=$ptr) {       // Used block
 					$angle_to = $angle_from+($block['offset']-$ptr)/$s;
@@ -403,7 +405,6 @@
 		for($i=0; $i<$mem['num_seg']; $i++) {	
 			$ptr = 0;
 			$free = $mem['block_lists'][$i];
-			uasort($free, 'block_sort');
 			foreach($free as $block) {
 				if($block['offset']!=$ptr) {       // Used block
 					$h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s;
@@ -501,15 +502,6 @@
 	}
 }
 
-function block_sort($array1, $array2)
-{
-	if ($array1['offset'] > $array2['offset']) {
-		return 1;
-	} else {
-		return -1;
-	}
-}
-
 
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -743,7 +735,7 @@
 	
 if ($AUTHENTICATED) {
 	echo <<<EOB
-		<li><a class="aright" href="$MY_SELF&CC=1&OB={$MYREQUEST['OB']}" onClick="javascript:return confirm('Are you sure?');">Clear $cache_mode Cache</a></li>
+		<li><a class="aright" href="$MY_SELF&CC=1&OB={$MYREQUEST['OB']}" onClick="javascipt:return confirm('Are you sure?');">Clear $cache_mode Cache</a></li>
 EOB;
 }
 echo <<<EOB
@@ -991,14 +983,14 @@
 					echo
 						"<tr class=tr-$m>",
 						"<td class=td-0>",ucwords(preg_replace("/_/"," ",$k)),"</td>",
-						"<td class=td-last>",(preg_match("/time/",$k) && $value!='None') ? date(DATE_FORMAT,$value) : htmlspecialchars($value, ENT_QUOTES, 'UTF-8'),"</td>",
+						"<td class=td-last>",(preg_match("/time/",$k) && $value!='None') ? date(DATE_FORMAT,$value) : $value,"</td>",
 						"</tr>";
 					$m=1-$m;
 				}
 				if($fieldkey=='info') {
 					echo "<tr class=tr-$m><td class=td-0>Stored Value</td><td class=td-last><pre>";
 					$output = var_export(apc_fetch($entry[$fieldkey]),true);
-					echo htmlspecialchars($output, ENT_QUOTES, 'UTF-8');
+					echo htmlspecialchars($output);
 					echo "</pre></td></tr>\n";
 				}
 				break;
@@ -1094,7 +1086,7 @@
 		}
 		if (!$AUTHENTICATED) {
 			// hide all path entries if not logged in
-			$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry);
+			$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','<i>&lt;hidden&gt;</i>/',$entry);
 		} else {
 			$list[$k.$entry[$fieldname]]=$entry;
 		}
@@ -1113,10 +1105,9 @@
 		$i=0;
 		foreach($list as $k => $entry) {
       if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) {  
-        $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8');
         echo
           '<tr class=tr-',$i%2,'>',
-          "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",md5($entry[$fieldkey]),"\">",$field_value,'</a></td>',
+          "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",md5($entry[$fieldkey]),"\">",$entry[$fieldname],'</a></td>',
           '<td class="td-n center">',$entry['num_hits'],'</td>',
           '<td class="td-n right">',$entry['mem_size'],'</td>',
           '<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>',
@@ -1301,12 +1292,8 @@
 		<th></th>
 		</tr>
 EOB;
-  if (defined('PROXY')) {
-    $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
-    $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apc.rss", False, $ctxt);
-  } else {
+
     $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apc.rss");
-  }
 	if (!$rss) {
 		echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>';
 	} else {
@@ -1337,8 +1324,8 @@
 			} else if (!$i--) {
 				break;
 			}
-			echo "<b><a href=\"http://pecl.php.net/package/APC/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>";
-			echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>";
+			echo "<b><a href=\"http://pecl.php.net/package/APC/$ver\">".htmlspecialchars($v)."</a></b><br><blockquote>";
+			echo nl2br(htmlspecialchars(current($match[2])))."</blockquote>";
 			next($match[2]);
 		}
 		echo '</td></tr>';
malc0mn’s picture

Gimme some time on this, I'll probably be able to test it on some systems tomorrow.

Edit: managed to test one system already, running FreeBSD, Apache, PHP 5.2.17 (using php5-fpm) and the latest version of APC (3.1.13). No problems at all.

A quick scan of the code shows the images are generated using the GD library:

// create graphics
//
function graphics_avail() {
	return extension_loaded('gd');
}

Have you installed the php5-gd package?

$ sudo apt-get install php5-gd

Edit 2: hmz, you said the latest apc.php file runs just fine, so the GD library must be up and running then. What version of PHP are you using?

bharata’s picture

Thank you so much for you help with this malc0mn.

admin/reports/status/php says: PHP Version 5.3.10-1ubuntu3.6

malc0mn’s picture

Still no luck in reproducing... How are you running PHP? Using fast-cgi and php-fpm or just plain old mod_php?

bharata’s picture

Priority: Normal » Minor
Status: Active » Postponed

Thanks for getting back to me. To be honest I have know idea and would need to do some research to even figure out where to look up such information. It seems like I will be needing to take a different direction for the time being. I had been trying to get everything working on my home based localhost before going live. I'm not officially live yet, still writing content for the site and putting some final touches on the structure, but I have been practicing uploading the site and database and making everything work online. Things are working really well so far but APC is not installed on the server. My current web hosting is shared so installing APC could be a pain. I think there is a funky way of installing it in one of my site's sub-folders but I'm not sure if it's worth the effort because the site is quite responsive at things currently are. I think for the moment I will just simply enjoy all of the other wonderful features this module provides and I will come back to the APC thing later if needed.

Thanks again for all your help!! It really is a great module, especially for a first timer.

malc0mn’s picture

Allright, glad you like the module anyway ;-)

About APC: I really doubt that you can install it yourself on a shared hosting environment as it's a pecl PHP extension and needs it's own config files that need to be loaded when the server is started up.

malc0mn’s picture

Do you know if the server you had/have this problem on is perhaps nginx? I'm seeing this issue on an ngnix server right now running php-cgi:

APC Version	3.1.3p1
PHP Version	5.3.2-1ubuntu4.18

GD Support	enabled
GD Version	bundled (2.0.34 compatible)
malc0mn’s picture

latest version of the official apc.php page integrated in the X.x-1.x-dev releases. Feel free to test if it makes a difference on your system (have not been able to test it on the ngnix environment I encountered the problem on due to deploy / update policies there)

anybody’s picture

Issue summary: View changes
Status: Postponed » Closed (outdated)

APC isn't that relevant anymore since OPC.