Skip to content

Commit 695d0cc

Browse files
author
Mikhail Galanin
committed
[opcache-start-time]: Add "Start time" and "Last restart time" to phpinfo() for opcache
1 parent e2bdf4d commit 695d0cc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

ext/opcache/zend_accelerator_module.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "zend_virtual_cwd.h"
3232
#include "ext/standard/info.h"
3333
#include "ext/standard/php_filestat.h"
34+
#include "ext/date/php_date.h"
3435
#include "opcache_arginfo.h"
3536

3637
#if HAVE_JIT
@@ -461,6 +462,8 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
461462
php_info_print_table_row(2, "Startup Failed", zps_api_failure_reason);
462463
} else {
463464
char buf[32];
465+
zend_string *start_time, *restart_time, *force_restart_time;
466+
464467
php_info_print_table_row(2, "Startup", "OK");
465468
php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model());
466469
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(hits));
@@ -491,6 +494,26 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
491494
php_info_print_table_row(2, "Hash keys restarts", buf);
492495
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(manual_restarts));
493496
php_info_print_table_row(2, "Manual restarts", buf);
497+
498+
start_time = php_format_date("Y-m-d H:i:s e", sizeof("Y-m-d H:i:s e")-1, ZCSG(start_time), 1);
499+
php_info_print_table_row(2, "Start time", ZSTR_VAL(start_time));
500+
zend_string_release(start_time);
501+
502+
if (ZCSG(last_restart_time)) {
503+
restart_time = php_format_date("Y-m-d H:i:s e", sizeof("Y-m-d H:i:s e")-1, ZCSG(last_restart_time), 1);
504+
php_info_print_table_row(2, "Last restart time", ZSTR_VAL(restart_time));
505+
zend_string_release(restart_time);
506+
} else {
507+
php_info_print_table_row(2, "Last restart time", "none");
508+
}
509+
510+
if (ZCSG(force_restart_time)) {
511+
force_restart_time = php_format_date("Y-m-d H:i:s e", sizeof("Y-m-d H:i:s e")-1, ZCSG(force_restart_time), 1);
512+
php_info_print_table_row(2, "Last force restart time", ZSTR_VAL(force_restart_time));
513+
zend_string_release(force_restart_time);
514+
} else {
515+
php_info_print_table_row(2, "Last force restart time", "none");
516+
}
494517
}
495518
}
496519

0 commit comments

Comments
 (0)