diff options
author | Jakub Zelenka <bukka@php.net> | 2021-03-22 21:32:15 +0000 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2021-03-22 21:32:15 +0000 |
commit | 72a22d92cddd61b0228e57be2860f64b1eed1160 (patch) | |
tree | e74119b3024d97b9933b735835a19248b8492d6d | |
parent | f42f539324f3d48cec2f64ff36756533a4ebd230 (diff) | |
download | php-git-72a22d92cddd61b0228e57be2860f64b1eed1160.tar.gz |
Fix types in FPM status openmetrics format
-rw-r--r-- | sapi/fpm/fpm/fpm_status.c | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index 94e3d256ae..6ba42f43dd 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -140,7 +140,7 @@ int fpm_status_handle_request(void) /* {{{ */ struct fpm_scoreboard_proc_s proc; char *buffer, *time_format, time_buffer[64]; time_t now_epoch; - int full, encode; + int full, encode, is_start_time_str; char *short_syntax, *short_post; char *full_pre, *full_syntax, *full_post, *full_separator; zend_string *_GET_str; @@ -223,6 +223,7 @@ int fpm_status_handle_request(void) /* {{{ */ short_syntax = short_post = NULL; full_separator = full_pre = full_syntax = full_post = NULL; encode = 0; + is_start_time_str = 1; /* HTML */ if (fpm_php_get_string_from_table(_GET_str, "html")) { @@ -399,7 +400,7 @@ int fpm_status_handle_request(void) /* {{{ */ "phpfpm_up 1\n" "# HELP phpfpm_start_time When FPM has started.\n" "# TYPE phpfpm_start_time gauge\n" - "phpfpm_start_time %lu\n" + "phpfpm_start_time %lld\n" "# HELP phpfpm_start_since_total The number of seconds since FPM has started.\n" "# TYPE phpfpm_start_since_total counter\n" "phpfpm_start_since_total %lu\n" @@ -408,7 +409,7 @@ int fpm_status_handle_request(void) /* {{{ */ "phpfpm_accepted_connections_total %lu\n" "# HELP phpfpm_listen_queue The number of requests in the queue of pending connections.\n" "# TYPE phpfpm_listen_queue gauge\n" - "phpfpm_listen_queue %lu\n" + "phpfpm_listen_queue %d\n" "# HELP phpfpm_max_listen_queue_total The maximum number of requests in the queue of pending connections since FPM has started.\n" "# TYPE phpfpm_max_listen_queue_total counter\n" "phpfpm_max_listen_queue_total %d\n" @@ -434,6 +435,7 @@ int fpm_status_handle_request(void) /* {{{ */ "# TYPE phpfpm_slow_requests_total counter\n" "phpfpm_slow_requests_total %lu\n"; + is_start_time_str = 0; if (!full) { short_post = ""; } else { @@ -484,23 +486,41 @@ int fpm_status_handle_request(void) /* {{{ */ } } - strftime(time_buffer, sizeof(time_buffer) - 1, time_format, localtime(&scoreboard.start_epoch)); now_epoch = time(NULL); - spprintf(&buffer, 0, short_syntax, - scoreboard.pool, - PM2STR(scoreboard.pm), - time_buffer, - (unsigned long) (now_epoch - scoreboard.start_epoch), - scoreboard.requests, - scoreboard.lq, - scoreboard.lq_max, - scoreboard.lq_len, - scoreboard.idle, - scoreboard.active, - scoreboard.idle + scoreboard.active, - scoreboard.active_max, - scoreboard.max_children_reached, - scoreboard.slow_rq); + if (is_start_time_str) { + strftime(time_buffer, sizeof(time_buffer) - 1, time_format, localtime(&scoreboard.start_epoch)); + spprintf(&buffer, 0, short_syntax, + scoreboard.pool, + PM2STR(scoreboard.pm), + time_buffer, + (unsigned long) (now_epoch - scoreboard.start_epoch), + scoreboard.requests, + scoreboard.lq, + scoreboard.lq_max, + scoreboard.lq_len, + scoreboard.idle, + scoreboard.active, + scoreboard.idle + scoreboard.active, + scoreboard.active_max, + scoreboard.max_children_reached, + scoreboard.slow_rq); + } else { + spprintf(&buffer, 0, short_syntax, + scoreboard.pool, + PM2STR(scoreboard.pm), + scoreboard.start_epoch, + (unsigned long) (now_epoch - scoreboard.start_epoch), + scoreboard.requests, + scoreboard.lq, + scoreboard.lq_max, + scoreboard.lq_len, + scoreboard.idle, + scoreboard.active, + scoreboard.idle + scoreboard.active, + scoreboard.active_max, + scoreboard.max_children_reached, + scoreboard.slow_rq); + } PUTS(buffer); efree(buffer); |