Skip to content

Commit 72a22d9

Browse files
committed
Fix types in FPM status openmetrics format
1 parent f42f539 commit 72a22d9

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

sapi/fpm/fpm/fpm_status.c

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ int fpm_status_handle_request(void) /* {{{ */
140140
struct fpm_scoreboard_proc_s proc;
141141
char *buffer, *time_format, time_buffer[64];
142142
time_t now_epoch;
143-
int full, encode;
143+
int full, encode, is_start_time_str;
144144
char *short_syntax, *short_post;
145145
char *full_pre, *full_syntax, *full_post, *full_separator;
146146
zend_string *_GET_str;
@@ -223,6 +223,7 @@ int fpm_status_handle_request(void) /* {{{ */
223223
short_syntax = short_post = NULL;
224224
full_separator = full_pre = full_syntax = full_post = NULL;
225225
encode = 0;
226+
is_start_time_str = 1;
226227

227228
/* HTML */
228229
if (fpm_php_get_string_from_table(_GET_str, "html")) {
@@ -399,7 +400,7 @@ int fpm_status_handle_request(void) /* {{{ */
399400
"phpfpm_up 1\n"
400401
"# HELP phpfpm_start_time When FPM has started.\n"
401402
"# TYPE phpfpm_start_time gauge\n"
402-
"phpfpm_start_time %lu\n"
403+
"phpfpm_start_time %lld\n"
403404
"# HELP phpfpm_start_since_total The number of seconds since FPM has started.\n"
404405
"# TYPE phpfpm_start_since_total counter\n"
405406
"phpfpm_start_since_total %lu\n"
@@ -408,7 +409,7 @@ int fpm_status_handle_request(void) /* {{{ */
408409
"phpfpm_accepted_connections_total %lu\n"
409410
"# HELP phpfpm_listen_queue The number of requests in the queue of pending connections.\n"
410411
"# TYPE phpfpm_listen_queue gauge\n"
411-
"phpfpm_listen_queue %lu\n"
412+
"phpfpm_listen_queue %d\n"
412413
"# HELP phpfpm_max_listen_queue_total The maximum number of requests in the queue of pending connections since FPM has started.\n"
413414
"# TYPE phpfpm_max_listen_queue_total counter\n"
414415
"phpfpm_max_listen_queue_total %d\n"
@@ -434,6 +435,7 @@ int fpm_status_handle_request(void) /* {{{ */
434435
"# TYPE phpfpm_slow_requests_total counter\n"
435436
"phpfpm_slow_requests_total %lu\n";
436437

438+
is_start_time_str = 0;
437439
if (!full) {
438440
short_post = "";
439441
} else {
@@ -484,23 +486,41 @@ int fpm_status_handle_request(void) /* {{{ */
484486
}
485487
}
486488

487-
strftime(time_buffer, sizeof(time_buffer) - 1, time_format, localtime(&scoreboard.start_epoch));
488489
now_epoch = time(NULL);
489-
spprintf(&buffer, 0, short_syntax,
490-
scoreboard.pool,
491-
PM2STR(scoreboard.pm),
492-
time_buffer,
493-
(unsigned long) (now_epoch - scoreboard.start_epoch),
494-
scoreboard.requests,
495-
scoreboard.lq,
496-
scoreboard.lq_max,
497-
scoreboard.lq_len,
498-
scoreboard.idle,
499-
scoreboard.active,
500-
scoreboard.idle + scoreboard.active,
501-
scoreboard.active_max,
502-
scoreboard.max_children_reached,
503-
scoreboard.slow_rq);
490+
if (is_start_time_str) {
491+
strftime(time_buffer, sizeof(time_buffer) - 1, time_format, localtime(&scoreboard.start_epoch));
492+
spprintf(&buffer, 0, short_syntax,
493+
scoreboard.pool,
494+
PM2STR(scoreboard.pm),
495+
time_buffer,
496+
(unsigned long) (now_epoch - scoreboard.start_epoch),
497+
scoreboard.requests,
498+
scoreboard.lq,
499+
scoreboard.lq_max,
500+
scoreboard.lq_len,
501+
scoreboard.idle,
502+
scoreboard.active,
503+
scoreboard.idle + scoreboard.active,
504+
scoreboard.active_max,
505+
scoreboard.max_children_reached,
506+
scoreboard.slow_rq);
507+
} else {
508+
spprintf(&buffer, 0, short_syntax,
509+
scoreboard.pool,
510+
PM2STR(scoreboard.pm),
511+
scoreboard.start_epoch,
512+
(unsigned long) (now_epoch - scoreboard.start_epoch),
513+
scoreboard.requests,
514+
scoreboard.lq,
515+
scoreboard.lq_max,
516+
scoreboard.lq_len,
517+
scoreboard.idle,
518+
scoreboard.active,
519+
scoreboard.idle + scoreboard.active,
520+
scoreboard.active_max,
521+
scoreboard.max_children_reached,
522+
scoreboard.slow_rq);
523+
}
504524

505525
PUTS(buffer);
506526
efree(buffer);

0 commit comments

Comments
 (0)