Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14294 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27484 invoked by uid 1010); 6 Jan 2005 20:50:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27140 invoked from network); 6 Jan 2005 20:50:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jan 2005 20:50:39 -0000 X-Host-Fingerprint: 193.45.238.241 novell.stoldgods.nu Linux 2.5 (sometimes 2.4) (4) Received: from ([193.45.238.241:34324] helo=novell.stoldgods.nu) by pb1.pair.com (ecelerity HEAD (r4049:4050)) with SMTP id FB/F0-30894-A94ADD14 for ; Thu, 06 Jan 2005 15:50:35 -0500 Received: from localhost (localhost [127.0.0.1]) by novell.stoldgods.nu (Postfix) with ESMTP id A6AE84DE7 for ; Thu, 6 Jan 2005 21:50:30 +0100 (CET) Received: from novell.stoldgods.nu ([127.0.0.1]) by localhost (netsrv2 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20256-17 for ; Thu, 6 Jan 2005 21:50:13 +0100 (CET) Received: from novell.stoldgods.nu (unknown [10.0.1.254]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by novell.stoldgods.nu (Postfix) with ESMTP id 5D5D54A5A for ; Thu, 6 Jan 2005 21:50:04 +0100 (CET) To: internals@lists.php.net Date: Thu, 6 Jan 2005 21:49:49 +0100 User-Agent: KMail/1.7.1 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_tRa3B+/3D7vnG1T" Message-ID: <200501062149.49937.magnus@php.net> Subject: [PATCH] Add apache uptime to phpinfo() FR #31391 From: magnus@php.net (Magnus =?iso-8859-1?q?M=E4=E4tt=E4?=) --Boundary-00=_tRa3B+/3D7vnG1T Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, This patch adds apache uptime to phpinfo() page for apache, apache2filter and apache2handler SAPIs. Should I commit, throw it away, change something ? /Magnus -- Debian is like Suse with yast turned off, just better. :) -- Goswin Brederlow --Boundary-00=_tRa3B+/3D7vnG1T Content-Type: text/x-diff; charset="us-ascii"; name="sapi_apache_uptime.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sapi_apache_uptime.patch" Index: sapi/apache/php_apache.c =================================================================== RCS file: /repository/php-src/sapi/apache/php_apache.c,v retrieving revision 1.88 diff -u -r1.88 php_apache.c --- sapi/apache/php_apache.c 4 Dec 2004 13:47:13 -0000 1.88 +++ sapi/apache/php_apache.c 6 Jan 2005 19:40:41 -0000 @@ -178,9 +178,11 @@ extern char *user_name; extern gid_t group_id; extern int max_requests_per_child; + time_t uptime; serv = ((request_rec *) SG(server_context))->server; + uptime = time(NULL) - ap_restart_time; php_info_print_table_start(); @@ -217,6 +219,9 @@ #endif sprintf(output_buf, "Connection: %d - Keep-Alive: %d", serv->timeout, serv->keep_alive_timeout); php_info_print_table_row(2, "Timeouts", output_buf); + sprintf(output_buf, "%ld day(s) %ld hour(s) %ld minute(s) %ld second(s)", + uptime / 60 / 60 / 24, uptime / 60 / 60 % 24, uptime / 60 % 60, uptime % 60); + php_info_print_table_row(2, "Uptime", output_buf); #if !defined(WIN32) && !defined(WINNT) /* This block seems to be working on NetWare; But it seems to be showing Index: sapi/apache2filter/php_functions.c =================================================================== RCS file: /repository/php-src/sapi/apache2filter/php_functions.c,v retrieving revision 1.43 diff -u -r1.43 php_functions.c --- sapi/apache2filter/php_functions.c 23 Oct 2004 13:48:04 -0000 1.43 +++ sapi/apache2filter/php_functions.c 6 Jan 2005 19:40:42 -0000 @@ -40,6 +40,7 @@ #include "http_main.h" #include "util_script.h" #include "http_core.h" +#include "scoreboard.h" #include "php_apache.h" @@ -330,8 +331,12 @@ { char *apv = php_apache_get_version(); smart_str tmp1 = {0}; + char tmp[1024]; int n; char *p; + apr_interval_time_t uptime; + + uptime = (apr_uint32_t) apr_time_sec(apr_time_now() - ap_scoreboard_image->global->restart_time); for (n = 0; ap_loaded_modules[n]; ++n) { char *s = (char *) ap_loaded_modules[n]->name; @@ -350,6 +355,12 @@ if (apv && *apv) { php_info_print_table_row(2, "Apache Version", apv); } + apr_snprintf(tmp, sizeof tmp, + "%" APR_TIME_T_FMT " day(s) %" APR_TIME_T_FMT " hour(s) %" APR_TIME_T_FMT + " minute(s) %" APR_TIME_T_FMT " second(s)", + uptime / 60 / 60 / 24, uptime / 60 / 60 % 24, uptime / 60 % 60, uptime % 60); + php_info_print_table_row(2, "Uptime", tmp); + php_info_print_table_row(2, "Loaded Modules", tmp1.c); smart_str_free(&tmp1); php_info_print_table_end(); Index: sapi/apache2handler/php_functions.c =================================================================== RCS file: /repository/php-src/sapi/apache2handler/php_functions.c,v retrieving revision 1.15 diff -u -r1.15 php_functions.c --- sapi/apache2handler/php_functions.c 23 Oct 2004 13:48:05 -0000 1.15 +++ sapi/apache2handler/php_functions.c 6 Jan 2005 19:40:43 -0000 @@ -42,6 +42,7 @@ #include "util_script.h" #include "http_core.h" #include "ap_mpm.h" +#include "scoreboard.h" #if !defined(WIN32) && !defined(WINNT) #include "unixd.h" #endif @@ -364,6 +365,9 @@ #if !defined(WIN32) && !defined(WINNT) AP_DECLARE_DATA extern unixd_config_rec unixd_config; #endif + + apr_interval_time_t uptime; + uptime = (apr_uint32_t) apr_time_sec(apr_time_now() - ap_scoreboard_image->global->restart_time); for (n = 0; ap_loaded_modules[n]; ++n) { char *s = (char *) ap_loaded_modules[n]->name; @@ -405,6 +409,12 @@ "Connection: %" APR_TIME_T_FMT " - Keep-Alive: %" APR_TIME_T_FMT, apr_time_sec(serv->timeout), apr_time_sec(serv->keep_alive_timeout)); php_info_print_table_row(2, "Timeouts", tmp); + + apr_snprintf(tmp, sizeof tmp, + "%" APR_TIME_T_FMT " day(s) %" APR_TIME_T_FMT " hour(s) %" APR_TIME_T_FMT + " minute(s) %" APR_TIME_T_FMT " second(s)", + uptime / 60 / 60 / 24, uptime / 60 / 60 % 24, uptime / 60 % 60, uptime % 60); + php_info_print_table_row(2, "Uptime", tmp); php_info_print_table_row(2, "Virtual Server", (serv->is_virtual ? "Yes" : "No")); php_info_print_table_row(2, "Server Root", ap_server_root); --Boundary-00=_tRa3B+/3D7vnG1T--