forked from haproxy/haproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.c
5191 lines (4675 loc) · 199 KB
/
stats.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Functions dedicated to statistics output and the stats socket
*
* Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
* Copyright 2007-2009 Krzysztof Piotr Oledzki <ole@ans.pl>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include <grp.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <haproxy/api.h>
#include <haproxy/applet-t.h>
#include <haproxy/backend.h>
#include <haproxy/base64.h>
#include <haproxy/cfgparse.h>
#include <haproxy/channel.h>
#include <haproxy/check.h>
#include <haproxy/cli.h>
#include <haproxy/compression.h>
#include <haproxy/debug.h>
#include <haproxy/errors.h>
#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <haproxy/frontend.h>
#include <haproxy/global.h>
#include <haproxy/http.h>
#include <haproxy/http_htx.h>
#include <haproxy/htx.h>
#include <haproxy/list.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/map-t.h>
#include <haproxy/pattern-t.h>
#include <haproxy/pipe.h>
#include <haproxy/pool.h>
#include <haproxy/proxy.h>
#include <haproxy/resolvers.h>
#include <haproxy/server.h>
#include <haproxy/session.h>
#include <haproxy/ssl_sock.h>
#include <haproxy/stats.h>
#include <haproxy/stream.h>
#include <haproxy/stream_interface.h>
#include <haproxy/task.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>
#include <haproxy/tools.h>
#include <haproxy/uri_auth-t.h>
#include <haproxy/version.h>
/* status codes available for the stats admin page (strictly 4 chars length) */
const char *stat_status_codes[STAT_STATUS_SIZE] = {
[STAT_STATUS_DENY] = "DENY",
[STAT_STATUS_DONE] = "DONE",
[STAT_STATUS_ERRP] = "ERRP",
[STAT_STATUS_EXCD] = "EXCD",
[STAT_STATUS_NONE] = "NONE",
[STAT_STATUS_PART] = "PART",
[STAT_STATUS_UNKN] = "UNKN",
[STAT_STATUS_IVAL] = "IVAL",
};
/* These are the field names for each INF_* field position. Please pay attention
* to always use the exact same name except that the strings for new names must
* be lower case or CamelCase while the enum entries must be upper case.
*/
const struct name_desc info_fields[INF_TOTAL_FIELDS] = {
[INF_NAME] = { .name = "Name", .desc = "Product name" },
[INF_VERSION] = { .name = "Version", .desc = "Product version" },
[INF_RELEASE_DATE] = { .name = "Release_date", .desc = "Date of latest source code update" },
[INF_NBTHREAD] = { .name = "Nbthread", .desc = "Number of started threads (global.nbthread)" },
[INF_NBPROC] = { .name = "Nbproc", .desc = "Number of started worker processes (historical, always 1)" },
[INF_PROCESS_NUM] = { .name = "Process_num", .desc = "Relative worker process number (1)" },
[INF_PID] = { .name = "Pid", .desc = "This worker process identifier for the system" },
[INF_UPTIME] = { .name = "Uptime", .desc = "How long ago this worker process was started (days+hours+minutes+seconds)" },
[INF_UPTIME_SEC] = { .name = "Uptime_sec", .desc = "How long ago this worker process was started (seconds)" },
[INF_START_TIME_SEC] = { .name = "Start_time_sec", .desc = "Start time in seconds" },
[INF_MEMMAX_MB] = { .name = "Memmax_MB", .desc = "Worker process's hard limit on memory usage in MB (-m on command line)" },
[INF_MEMMAX_BYTES] = { .name = "Memmax_bytes", .desc = "Worker process's hard limit on memory usage in byes (-m on command line)" },
[INF_POOL_ALLOC_MB] = { .name = "PoolAlloc_MB", .desc = "Amount of memory allocated in pools (in MB)" },
[INF_POOL_ALLOC_BYTES] = { .name = "PoolAlloc_bytes", .desc = "Amount of memory allocated in pools (in bytes)" },
[INF_POOL_USED_MB] = { .name = "PoolUsed_MB", .desc = "Amount of pool memory currently used (in MB)" },
[INF_POOL_USED_BYTES] = { .name = "PoolUsed_bytes", .desc = "Amount of pool memory currently used (in bytes)" },
[INF_POOL_FAILED] = { .name = "PoolFailed", .desc = "Number of failed pool allocations since this worker was started" },
[INF_ULIMIT_N] = { .name = "Ulimit-n", .desc = "Hard limit on the number of per-process file descriptors" },
[INF_MAXSOCK] = { .name = "Maxsock", .desc = "Hard limit on the number of per-process sockets" },
[INF_MAXCONN] = { .name = "Maxconn", .desc = "Hard limit on the number of per-process connections (configured or imposed by Ulimit-n)" },
[INF_HARD_MAXCONN] = { .name = "Hard_maxconn", .desc = "Hard limit on the number of per-process connections (imposed by Memmax_MB or Ulimit-n)" },
[INF_CURR_CONN] = { .name = "CurrConns", .desc = "Current number of connections on this worker process" },
[INF_CUM_CONN] = { .name = "CumConns", .desc = "Total number of connections on this worker process since started" },
[INF_CUM_REQ] = { .name = "CumReq", .desc = "Total number of requests on this worker process since started" },
[INF_MAX_SSL_CONNS] = { .name = "MaxSslConns", .desc = "Hard limit on the number of per-process SSL endpoints (front+back), 0=unlimited" },
[INF_CURR_SSL_CONNS] = { .name = "CurrSslConns", .desc = "Current number of SSL endpoints on this worker process (front+back)" },
[INF_CUM_SSL_CONNS] = { .name = "CumSslConns", .desc = "Total number of SSL endpoints on this worker process since started (front+back)" },
[INF_MAXPIPES] = { .name = "Maxpipes", .desc = "Hard limit on the number of pipes for splicing, 0=unlimited" },
[INF_PIPES_USED] = { .name = "PipesUsed", .desc = "Current number of pipes in use in this worker process" },
[INF_PIPES_FREE] = { .name = "PipesFree", .desc = "Current number of allocated and available pipes in this worker process" },
[INF_CONN_RATE] = { .name = "ConnRate", .desc = "Number of front connections created on this worker process over the last second" },
[INF_CONN_RATE_LIMIT] = { .name = "ConnRateLimit", .desc = "Hard limit for ConnRate (global.maxconnrate)" },
[INF_MAX_CONN_RATE] = { .name = "MaxConnRate", .desc = "Highest ConnRate reached on this worker process since started (in connections per second)" },
[INF_SESS_RATE] = { .name = "SessRate", .desc = "Number of sessions created on this worker process over the last second" },
[INF_SESS_RATE_LIMIT] = { .name = "SessRateLimit", .desc = "Hard limit for SessRate (global.maxsessrate)" },
[INF_MAX_SESS_RATE] = { .name = "MaxSessRate", .desc = "Highest SessRate reached on this worker process since started (in sessions per second)" },
[INF_SSL_RATE] = { .name = "SslRate", .desc = "Number of SSL connections created on this worker process over the last second" },
[INF_SSL_RATE_LIMIT] = { .name = "SslRateLimit", .desc = "Hard limit for SslRate (global.maxsslrate)" },
[INF_MAX_SSL_RATE] = { .name = "MaxSslRate", .desc = "Highest SslRate reached on this worker process since started (in connections per second)" },
[INF_SSL_FRONTEND_KEY_RATE] = { .name = "SslFrontendKeyRate", .desc = "Number of SSL keys created on frontends in this worker process over the last second" },
[INF_SSL_FRONTEND_MAX_KEY_RATE] = { .name = "SslFrontendMaxKeyRate", .desc = "Highest SslFrontendKeyRate reached on this worker process since started (in SSL keys per second)" },
[INF_SSL_FRONTEND_SESSION_REUSE_PCT] = { .name = "SslFrontendSessionReuse_pct", .desc = "Percent of frontend SSL connections which did not require a new key" },
[INF_SSL_BACKEND_KEY_RATE] = { .name = "SslBackendKeyRate", .desc = "Number of SSL keys created on backends in this worker process over the last second" },
[INF_SSL_BACKEND_MAX_KEY_RATE] = { .name = "SslBackendMaxKeyRate", .desc = "Highest SslBackendKeyRate reached on this worker process since started (in SSL keys per second)" },
[INF_SSL_CACHE_LOOKUPS] = { .name = "SslCacheLookups", .desc = "Total number of SSL session ID lookups in the SSL session cache on this worker since started" },
[INF_SSL_CACHE_MISSES] = { .name = "SslCacheMisses", .desc = "Total number of SSL session ID lookups that didn't find a session in the SSL session cache on this worker since started" },
[INF_COMPRESS_BPS_IN] = { .name = "CompressBpsIn", .desc = "Number of bytes submitted to the HTTP compressor in this worker process over the last second" },
[INF_COMPRESS_BPS_OUT] = { .name = "CompressBpsOut", .desc = "Number of bytes emitted by the HTTP compressor in this worker process over the last second" },
[INF_COMPRESS_BPS_RATE_LIM] = { .name = "CompressBpsRateLim", .desc = "Limit of CompressBpsOut beyond which HTTP compression is automatically disabled" },
[INF_ZLIB_MEM_USAGE] = { .name = "ZlibMemUsage", .desc = "Amount of memory currently used by HTTP compression on the current worker process (in bytes)" },
[INF_MAX_ZLIB_MEM_USAGE] = { .name = "MaxZlibMemUsage", .desc = "Limit on the amount of memory used by HTTP compression above which it is automatically disabled (in bytes, see global.maxzlibmem)" },
[INF_TASKS] = { .name = "Tasks", .desc = "Total number of tasks in the current worker process (active + sleeping)" },
[INF_RUN_QUEUE] = { .name = "Run_queue", .desc = "Total number of active tasks+tasklets in the current worker process" },
[INF_IDLE_PCT] = { .name = "Idle_pct", .desc = "Percentage of last second spent waiting in the current worker thread" },
[INF_NODE] = { .name = "node", .desc = "Node name (global.node)" },
[INF_DESCRIPTION] = { .name = "description", .desc = "Node description (global.description)" },
[INF_STOPPING] = { .name = "Stopping", .desc = "1 if the worker process is currently stopping, otherwise zero" },
[INF_JOBS] = { .name = "Jobs", .desc = "Current number of active jobs on the current worker process (frontend connections, master connections, listeners)" },
[INF_UNSTOPPABLE_JOBS] = { .name = "Unstoppable Jobs", .desc = "Current number of unstoppable jobs on the current worker process (master connections)" },
[INF_LISTENERS] = { .name = "Listeners", .desc = "Current number of active listeners on the current worker process" },
[INF_ACTIVE_PEERS] = { .name = "ActivePeers", .desc = "Current number of verified active peers connections on the current worker process" },
[INF_CONNECTED_PEERS] = { .name = "ConnectedPeers", .desc = "Current number of peers having passed the connection step on the current worker process" },
[INF_DROPPED_LOGS] = { .name = "DroppedLogs", .desc = "Total number of dropped logs for current worker process since started" },
[INF_BUSY_POLLING] = { .name = "BusyPolling", .desc = "1 if busy-polling is currently in use on the worker process, otherwise zero (config.busy-polling)" },
[INF_FAILED_RESOLUTIONS] = { .name = "FailedResolutions", .desc = "Total number of failed DNS resolutions in current worker process since started" },
[INF_TOTAL_BYTES_OUT] = { .name = "TotalBytesOut", .desc = "Total number of bytes emitted by current worker process since started" },
[INF_TOTAL_SPLICED_BYTES_OUT] = { .name = "TotalSplicdedBytesOut", .desc = "Total number of bytes emitted by current worker process through a kernel pipe since started" },
[INF_BYTES_OUT_RATE] = { .name = "BytesOutRate", .desc = "Number of bytes emitted by current worker process over the last second" },
[INF_DEBUG_COMMANDS_ISSUED] = { .name = "DebugCommandsIssued", .desc = "Number of debug commands issued on this process (anything > 0 is unsafe)" },
[INF_CUM_LOG_MSGS] = { .name = "CumRecvLogs", .desc = "Total number of log messages received by log-forwarding listeners on this worker process since started" },
[INF_BUILD_INFO] = { .name = "Build info", .desc = "Build info" },
[INF_TAINTED] = { .name = "Tainted", .desc = "Experimental features used" },
};
const struct name_desc stat_fields[ST_F_TOTAL_FIELDS] = {
[ST_F_PXNAME] = { .name = "pxname", .desc = "Proxy name" },
[ST_F_SVNAME] = { .name = "svname", .desc = "Server name" },
[ST_F_QCUR] = { .name = "qcur", .desc = "Number of current queued connections" },
[ST_F_QMAX] = { .name = "qmax", .desc = "Highest value of queued connections encountered since process started" },
[ST_F_SCUR] = { .name = "scur", .desc = "Number of current sessions on the frontend, backend or server" },
[ST_F_SMAX] = { .name = "smax", .desc = "Highest value of current sessions encountered since process started" },
[ST_F_SLIM] = { .name = "slim", .desc = "Frontend/listener/server's maxconn, backend's fullconn" },
[ST_F_STOT] = { .name = "stot", .desc = "Total number of sessions since process started" },
[ST_F_BIN] = { .name = "bin", .desc = "Total number of request bytes since process started" },
[ST_F_BOUT] = { .name = "bout", .desc = "Total number of response bytes since process started" },
[ST_F_DREQ] = { .name = "dreq", .desc = "Total number of denied requests since process started" },
[ST_F_DRESP] = { .name = "dresp", .desc = "Total number of denied responses since process started" },
[ST_F_EREQ] = { .name = "ereq", .desc = "Total number of invalid requests since process started" },
[ST_F_ECON] = { .name = "econ", .desc = "Total number of failed connections to server since the worker process started" },
[ST_F_ERESP] = { .name = "eresp", .desc = "Total number of invalid responses since the worker process started" },
[ST_F_WRETR] = { .name = "wretr", .desc = "Total number of server connection retries since the worker process started" },
[ST_F_WREDIS] = { .name = "wredis", .desc = "Total number of server redispatches due to connection failures since the worker process started" },
[ST_F_STATUS] = { .name = "status", .desc = "Frontend/listen status: OPEN/WAITING/FULL/STOP; backend: UP/DOWN; server: last check status" },
[ST_F_WEIGHT] = { .name = "weight", .desc = "Server's effective weight, or sum of active servers' effective weights for a backend" },
[ST_F_ACT] = { .name = "act", .desc = "Total number of active UP servers with a non-zero weight" },
[ST_F_BCK] = { .name = "bck", .desc = "Total number of backup UP servers with a non-zero weight" },
[ST_F_CHKFAIL] = { .name = "chkfail", .desc = "Total number of failed individual health checks per server/backend, since the worker process started" },
[ST_F_CHKDOWN] = { .name = "chkdown", .desc = "Total number of failed checks causing UP to DOWN server transitions, per server/backend, since the worker process started" },
[ST_F_LASTCHG] = { .name = "lastchg", .desc = "How long ago the last server state changed, in seconds" },
[ST_F_DOWNTIME] = { .name = "downtime", .desc = "Total time spent in DOWN state, for server or backend" },
[ST_F_QLIMIT] = { .name = "qlimit", .desc = "Limit on the number of connections in queue, for servers only (maxqueue argument)" },
[ST_F_PID] = { .name = "pid", .desc = "Relative worker process number (1)" },
[ST_F_IID] = { .name = "iid", .desc = "Frontend or Backend numeric identifier ('id' setting)" },
[ST_F_SID] = { .name = "sid", .desc = "Server numeric identifier ('id' setting)" },
[ST_F_THROTTLE] = { .name = "throttle", .desc = "Throttling ratio applied to a server's maxconn and weight during the slowstart period (0 to 100%)" },
[ST_F_LBTOT] = { .name = "lbtot", .desc = "Total number of requests routed by load balancing since the worker process started (ignores queue pop and stickiness)" },
[ST_F_TRACKED] = { .name = "tracked", .desc = "Name of the other server this server tracks for its state" },
[ST_F_TYPE] = { .name = "type", .desc = "Type of the object (Listener, Frontend, Backend, Server)" },
[ST_F_RATE] = { .name = "rate", .desc = "Total number of sessions processed by this object over the last second (sessions for listeners/frontends, requests for backends/servers)" },
[ST_F_RATE_LIM] = { .name = "rate_lim", .desc = "Limit on the number of sessions accepted in a second (frontend only, 'rate-limit sessions' setting)" },
[ST_F_RATE_MAX] = { .name = "rate_max", .desc = "Highest value of sessions per second observed since the worker process started" },
[ST_F_CHECK_STATUS] = { .name = "check_status", .desc = "Status report of the server's latest health check, prefixed with '*' if a check is currently in progress" },
[ST_F_CHECK_CODE] = { .name = "check_code", .desc = "HTTP/SMTP/LDAP status code reported by the latest server health check" },
[ST_F_CHECK_DURATION] = { .name = "check_duration", .desc = "Total duration of the latest server health check, in milliseconds" },
[ST_F_HRSP_1XX] = { .name = "hrsp_1xx", .desc = "Total number of HTTP responses with status 100-199 returned by this object since the worker process started" },
[ST_F_HRSP_2XX] = { .name = "hrsp_2xx", .desc = "Total number of HTTP responses with status 200-299 returned by this object since the worker process started" },
[ST_F_HRSP_3XX] = { .name = "hrsp_3xx", .desc = "Total number of HTTP responses with status 300-399 returned by this object since the worker process started" },
[ST_F_HRSP_4XX] = { .name = "hrsp_4xx", .desc = "Total number of HTTP responses with status 400-499 returned by this object since the worker process started" },
[ST_F_HRSP_5XX] = { .name = "hrsp_5xx", .desc = "Total number of HTTP responses with status 500-599 returned by this object since the worker process started" },
[ST_F_HRSP_OTHER] = { .name = "hrsp_other", .desc = "Total number of HTTP responses with status <100, >599 returned by this object since the worker process started (error -1 included)" },
[ST_F_HANAFAIL] = { .name = "hanafail", .desc = "Total number of failed checks caused by an 'on-error' directive after an 'observe' condition matched" },
[ST_F_REQ_RATE] = { .name = "req_rate", .desc = "Number of HTTP requests processed over the last second on this object" },
[ST_F_REQ_RATE_MAX] = { .name = "req_rate_max", .desc = "Highest value of http requests observed since the worker process started" },
[ST_F_REQ_TOT] = { .name = "req_tot", .desc = "Total number of HTTP requests processed by this object since the worker process started" },
[ST_F_CLI_ABRT] = { .name = "cli_abrt", .desc = "Total number of requests or connections aborted by the client since the worker process started" },
[ST_F_SRV_ABRT] = { .name = "srv_abrt", .desc = "Total number of requests or connections aborted by the server since the worker process started" },
[ST_F_COMP_IN] = { .name = "comp_in", .desc = "Total number of bytes submitted to the HTTP compressor for this object since the worker process started" },
[ST_F_COMP_OUT] = { .name = "comp_out", .desc = "Total number of bytes emitted by the HTTP compressor for this object since the worker process started" },
[ST_F_COMP_BYP] = { .name = "comp_byp", .desc = "Total number of bytes that bypassed HTTP compression for this object since the worker process started (CPU/memory/bandwidth limitation)" },
[ST_F_COMP_RSP] = { .name = "comp_rsp", .desc = "Total number of HTTP responses that were compressed for this object since the worker process started" },
[ST_F_LASTSESS] = { .name = "lastsess", .desc = "How long ago some traffic was seen on this object on this worker process, in seconds" },
[ST_F_LAST_CHK] = { .name = "last_chk", .desc = "Short description of the latest health check report for this server (see also check_desc)" },
[ST_F_LAST_AGT] = { .name = "last_agt", .desc = "Short description of the latest agent check report for this server (see also agent_desc)" },
[ST_F_QTIME] = { .name = "qtime", .desc = "Time spent in the queue, in milliseconds, averaged over the 1024 last requests (backend/server)" },
[ST_F_CTIME] = { .name = "ctime", .desc = "Time spent waiting for a connection to complete, in milliseconds, averaged over the 1024 last requests (backend/server)" },
[ST_F_RTIME] = { .name = "rtime", .desc = "Time spent waiting for a server response, in milliseconds, averaged over the 1024 last requests (backend/server)" },
[ST_F_TTIME] = { .name = "ttime", .desc = "Total request+response time (request+queue+connect+response+processing), in milliseconds, averaged over the 1024 last requests (backend/server)" },
[ST_F_AGENT_STATUS] = { .name = "agent_status", .desc = "Status report of the server's latest agent check, prefixed with '*' if a check is currently in progress" },
[ST_F_AGENT_CODE] = { .name = "agent_code", .desc = "Status code reported by the latest server agent check" },
[ST_F_AGENT_DURATION] = { .name = "agent_duration", .desc = "Total duration of the latest server agent check, in milliseconds" },
[ST_F_CHECK_DESC] = { .name = "check_desc", .desc = "Textual description of the latest health check report for this server" },
[ST_F_AGENT_DESC] = { .name = "agent_desc", .desc = "Textual description of the latest agent check report for this server" },
[ST_F_CHECK_RISE] = { .name = "check_rise", .desc = "Number of successful health checks before declaring a server UP (server 'rise' setting)" },
[ST_F_CHECK_FALL] = { .name = "check_fall", .desc = "Number of failed health checks before declaring a server DOWN (server 'fall' setting)" },
[ST_F_CHECK_HEALTH] = { .name = "check_health", .desc = "Current server health check level (0..fall-1=DOWN, fall..rise-1=UP)" },
[ST_F_AGENT_RISE] = { .name = "agent_rise", .desc = "Number of successful agent checks before declaring a server UP (server 'rise' setting)" },
[ST_F_AGENT_FALL] = { .name = "agent_fall", .desc = "Number of failed agent checks before declaring a server DOWN (server 'fall' setting)" },
[ST_F_AGENT_HEALTH] = { .name = "agent_health", .desc = "Current server agent check level (0..fall-1=DOWN, fall..rise-1=UP)" },
[ST_F_ADDR] = { .name = "addr", .desc = "Server's address:port, shown only if show-legends is set, or at levels oper/admin for the CLI" },
[ST_F_COOKIE] = { .name = "cookie", .desc = "Backend's cookie name or Server's cookie value, shown only if show-legends is set, or at levels oper/admin for the CLI" },
[ST_F_MODE] = { .name = "mode", .desc = "'mode' setting (tcp/http/health/cli)" },
[ST_F_ALGO] = { .name = "algo", .desc = "Backend's load balancing algorithm, shown only if show-legends is set, or at levels oper/admin for the CLI" },
[ST_F_CONN_RATE] = { .name = "conn_rate", .desc = "Number of new connections accepted over the last second on the frontend for this worker process" },
[ST_F_CONN_RATE_MAX] = { .name = "conn_rate_max", .desc = "Highest value of connections per second observed since the worker process started" },
[ST_F_CONN_TOT] = { .name = "conn_tot", .desc = "Total number of new connections accepted on this frontend since the worker process started" },
[ST_F_INTERCEPTED] = { .name = "intercepted", .desc = "Total number of HTTP requests intercepted on the frontend (redirects/stats/services) since the worker process started" },
[ST_F_DCON] = { .name = "dcon", .desc = "Total number of incoming connections blocked on a listener/frontend by a tcp-request connection rule since the worker process started" },
[ST_F_DSES] = { .name = "dses", .desc = "Total number of incoming sessions blocked on a listener/frontend by a tcp-request connection rule since the worker process started" },
[ST_F_WREW] = { .name = "wrew", .desc = "Total number of failed HTTP header rewrites since the worker process started" },
[ST_F_CONNECT] = { .name = "connect", .desc = "Total number of outgoing connection attempts on this backend/server since the worker process started" },
[ST_F_REUSE] = { .name = "reuse", .desc = "Total number of reused connection on this backend/server since the worker process started" },
[ST_F_CACHE_LOOKUPS] = { .name = "cache_lookups", .desc = "Total number of HTTP requests looked up in the cache on this frontend/backend since the worker process started" },
[ST_F_CACHE_HITS] = { .name = "cache_hits", .desc = "Total number of HTTP requests not found in the cache on this frontend/backend since the worker process started" },
[ST_F_SRV_ICUR] = { .name = "srv_icur", .desc = "Current number of idle connections available for reuse on this server" },
[ST_F_SRV_ILIM] = { .name = "src_ilim", .desc = "Limit on the number of available idle connections on this server (server 'pool_max_conn' directive)" },
[ST_F_QT_MAX] = { .name = "qtime_max", .desc = "Maximum observed time spent in the queue, in milliseconds (backend/server)" },
[ST_F_CT_MAX] = { .name = "ctime_max", .desc = "Maximum observed time spent waiting for a connection to complete, in milliseconds (backend/server)" },
[ST_F_RT_MAX] = { .name = "rtime_max", .desc = "Maximum observed time spent waiting for a server response, in milliseconds (backend/server)" },
[ST_F_TT_MAX] = { .name = "ttime_max", .desc = "Maximum observed total request+response time (request+queue+connect+response+processing), in milliseconds (backend/server)" },
[ST_F_EINT] = { .name = "eint", .desc = "Total number of internal errors since process started"},
[ST_F_IDLE_CONN_CUR] = { .name = "idle_conn_cur", .desc = "Current number of unsafe idle connections"},
[ST_F_SAFE_CONN_CUR] = { .name = "safe_conn_cur", .desc = "Current number of safe idle connections"},
[ST_F_USED_CONN_CUR] = { .name = "used_conn_cur", .desc = "Current number of connections in use"},
[ST_F_NEED_CONN_EST] = { .name = "need_conn_est", .desc = "Estimated needed number of connections"},
[ST_F_UWEIGHT] = { .name = "uweight", .desc = "Server's user weight, or sum of active servers' user weights for a backend" },
};
/* one line of info */
THREAD_LOCAL struct field info[INF_TOTAL_FIELDS];
/* description of statistics (static and dynamic) */
static struct name_desc *stat_f[STATS_DOMAIN_COUNT];
static size_t stat_count[STATS_DOMAIN_COUNT];
/* one line for stats */
THREAD_LOCAL struct field *stat_l[STATS_DOMAIN_COUNT];
/* list of all registered stats module */
static struct list stats_module_list[STATS_DOMAIN_COUNT] = {
LIST_HEAD_INIT(stats_module_list[STATS_DOMAIN_PROXY]),
LIST_HEAD_INIT(stats_module_list[STATS_DOMAIN_DNS]),
};
THREAD_LOCAL void *trash_counters;
static inline uint8_t stats_get_domain(uint32_t domain)
{
return domain >> STATS_DOMAIN & STATS_DOMAIN_MASK;
}
static inline enum stats_domain_px_cap stats_px_get_cap(uint32_t domain)
{
return domain >> STATS_PX_CAP & STATS_PX_CAP_MASK;
}
static void stats_dump_json_schema(struct buffer *out);
int stats_putchk(struct channel *chn, struct htx *htx, struct buffer *chk)
{
if (htx) {
if (chk->data >= channel_htx_recv_max(chn, htx))
return 0;
if (!htx_add_data_atonce(htx, ist2(chk->area, chk->data)))
return 0;
channel_add_input(chn, chk->data);
chk->data = 0;
}
else {
if (ci_putchk(chn, chk) == -1)
return 0;
}
return 1;
}
static const char *stats_scope_ptr(struct appctx *appctx, struct stream_interface *si)
{
struct channel *req = si_oc(si);
struct htx *htx = htxbuf(&req->buf);
struct htx_blk *blk;
struct ist uri;
blk = htx_get_head_blk(htx);
BUG_ON(!blk || htx_get_blk_type(blk) != HTX_BLK_REQ_SL);
ALREADY_CHECKED(blk);
uri = htx_sl_req_uri(htx_get_blk_ptr(htx, blk));
return uri.ptr + appctx->ctx.stats.scope_str;
}
/*
* http_stats_io_handler()
* -> stats_dump_stat_to_buffer() // same as above, but used for CSV or HTML
* -> stats_dump_csv_header() // emits the CSV headers (same as above)
* -> stats_dump_json_header() // emits the JSON headers (same as above)
* -> stats_dump_html_head() // emits the HTML headers
* -> stats_dump_html_info() // emits the equivalent of "show info" at the top
* -> stats_dump_proxy_to_buffer() // same as above, valid for CSV and HTML
* -> stats_dump_html_px_hdr()
* -> stats_dump_fe_stats()
* -> stats_dump_li_stats()
* -> stats_dump_sv_stats()
* -> stats_dump_be_stats()
* -> stats_dump_html_px_end()
* -> stats_dump_html_end() // emits HTML trailer
* -> stats_dump_json_end() // emits JSON trailer
*/
/* Dumps the stats CSV header to the trash buffer which. The caller is responsible
* for clearing it if needed.
* NOTE: Some tools happen to rely on the field position instead of its name,
* so please only append new fields at the end, never in the middle.
*/
static void stats_dump_csv_header(enum stats_domain domain)
{
int field;
chunk_appendf(&trash, "# ");
if (stat_f[domain]) {
for (field = 0; field < stat_count[domain]; ++field) {
chunk_appendf(&trash, "%s,", stat_f[domain][field].name);
/* print special delimiter on proxy stats to mark end of
static fields */
if (domain == STATS_DOMAIN_PROXY && field + 1 == ST_F_TOTAL_FIELDS)
chunk_appendf(&trash, "-,");
}
}
chunk_appendf(&trash, "\n");
}
/* Emits a stats field without any surrounding element and properly encoded to
* resist CSV output. Returns non-zero on success, 0 if the buffer is full.
*/
int stats_emit_raw_data_field(struct buffer *out, const struct field *f)
{
switch (field_format(f, 0)) {
case FF_EMPTY: return 1;
case FF_S32: return chunk_appendf(out, "%d", f->u.s32);
case FF_U32: return chunk_appendf(out, "%u", f->u.u32);
case FF_S64: return chunk_appendf(out, "%lld", (long long)f->u.s64);
case FF_U64: return chunk_appendf(out, "%llu", (unsigned long long)f->u.u64);
case FF_FLT: {
size_t prev_data = out->data;
out->data = flt_trim(out->area, prev_data, chunk_appendf(out, "%f", f->u.flt));
return out->data;
}
case FF_STR: return csv_enc_append(field_str(f, 0), 1, out) != NULL;
default: return chunk_appendf(out, "[INCORRECT_FIELD_TYPE_%08x]", f->type);
}
}
const char *field_to_html_str(const struct field *f)
{
switch (field_format(f, 0)) {
case FF_S32: return U2H(f->u.s32);
case FF_S64: return U2H(f->u.s64);
case FF_U64: return U2H(f->u.u64);
case FF_U32: return U2H(f->u.u32);
case FF_FLT: return F2H(f->u.flt);
case FF_STR: return field_str(f, 0);
case FF_EMPTY:
default:
return "";
}
}
/* Emits a stats field prefixed with its type. No CSV encoding is prepared, the
* output is supposed to be used on its own line. Returns non-zero on success, 0
* if the buffer is full.
*/
int stats_emit_typed_data_field(struct buffer *out, const struct field *f)
{
switch (field_format(f, 0)) {
case FF_EMPTY: return 1;
case FF_S32: return chunk_appendf(out, "s32:%d", f->u.s32);
case FF_U32: return chunk_appendf(out, "u32:%u", f->u.u32);
case FF_S64: return chunk_appendf(out, "s64:%lld", (long long)f->u.s64);
case FF_U64: return chunk_appendf(out, "u64:%llu", (unsigned long long)f->u.u64);
case FF_FLT: {
size_t prev_data = out->data;
out->data = flt_trim(out->area, prev_data, chunk_appendf(out, "flt:%f", f->u.flt));
return out->data;
}
case FF_STR: return chunk_appendf(out, "str:%s", field_str(f, 0));
default: return chunk_appendf(out, "%08x:?", f->type);
}
}
/* Limit JSON integer values to the range [-(2**53)+1, (2**53)-1] as per
* the recommendation for interoperable integers in section 6 of RFC 7159.
*/
#define JSON_INT_MAX ((1ULL << 53) - 1)
#define JSON_INT_MIN (0 - JSON_INT_MAX)
/* Emits a stats field value and its type in JSON.
* Returns non-zero on success, 0 on error.
*/
int stats_emit_json_data_field(struct buffer *out, const struct field *f)
{
int old_len;
char buf[20];
const char *type, *value = buf, *quote = "";
switch (field_format(f, 0)) {
case FF_EMPTY: return 1;
case FF_S32: type = "\"s32\"";
snprintf(buf, sizeof(buf), "%d", f->u.s32);
break;
case FF_U32: type = "\"u32\"";
snprintf(buf, sizeof(buf), "%u", f->u.u32);
break;
case FF_S64: type = "\"s64\"";
if (f->u.s64 < JSON_INT_MIN || f->u.s64 > JSON_INT_MAX)
return 0;
type = "\"s64\"";
snprintf(buf, sizeof(buf), "%lld", (long long)f->u.s64);
break;
case FF_U64: if (f->u.u64 > JSON_INT_MAX)
return 0;
type = "\"u64\"";
snprintf(buf, sizeof(buf), "%llu",
(unsigned long long) f->u.u64);
break;
case FF_FLT: type = "\"flt\"";
flt_trim(buf, 0, snprintf(buf, sizeof(buf), "%f", f->u.flt));
break;
case FF_STR: type = "\"str\"";
value = field_str(f, 0);
quote = "\"";
break;
default: snprintf(buf, sizeof(buf), "%u", f->type);
type = buf;
value = "unknown";
quote = "\"";
break;
}
old_len = out->data;
chunk_appendf(out, ",\"value\":{\"type\":%s,\"value\":%s%s%s}",
type, quote, value, quote);
return !(old_len == out->data);
}
/* Emits an encoding of the field type on 3 characters followed by a delimiter.
* Returns non-zero on success, 0 if the buffer is full.
*/
int stats_emit_field_tags(struct buffer *out, const struct field *f,
char delim)
{
char origin, nature, scope;
switch (field_origin(f, 0)) {
case FO_METRIC: origin = 'M'; break;
case FO_STATUS: origin = 'S'; break;
case FO_KEY: origin = 'K'; break;
case FO_CONFIG: origin = 'C'; break;
case FO_PRODUCT: origin = 'P'; break;
default: origin = '?'; break;
}
switch (field_nature(f, 0)) {
case FN_GAUGE: nature = 'G'; break;
case FN_LIMIT: nature = 'L'; break;
case FN_MIN: nature = 'm'; break;
case FN_MAX: nature = 'M'; break;
case FN_RATE: nature = 'R'; break;
case FN_COUNTER: nature = 'C'; break;
case FN_DURATION: nature = 'D'; break;
case FN_AGE: nature = 'A'; break;
case FN_TIME: nature = 'T'; break;
case FN_NAME: nature = 'N'; break;
case FN_OUTPUT: nature = 'O'; break;
case FN_AVG: nature = 'a'; break;
default: nature = '?'; break;
}
switch (field_scope(f, 0)) {
case FS_PROCESS: scope = 'P'; break;
case FS_SERVICE: scope = 'S'; break;
case FS_SYSTEM: scope = 's'; break;
case FS_CLUSTER: scope = 'C'; break;
default: scope = '?'; break;
}
return chunk_appendf(out, "%c%c%c%c", origin, nature, scope, delim);
}
/* Emits an encoding of the field type as JSON.
* Returns non-zero on success, 0 if the buffer is full.
*/
int stats_emit_json_field_tags(struct buffer *out, const struct field *f)
{
const char *origin, *nature, *scope;
int old_len;
switch (field_origin(f, 0)) {
case FO_METRIC: origin = "Metric"; break;
case FO_STATUS: origin = "Status"; break;
case FO_KEY: origin = "Key"; break;
case FO_CONFIG: origin = "Config"; break;
case FO_PRODUCT: origin = "Product"; break;
default: origin = "Unknown"; break;
}
switch (field_nature(f, 0)) {
case FN_GAUGE: nature = "Gauge"; break;
case FN_LIMIT: nature = "Limit"; break;
case FN_MIN: nature = "Min"; break;
case FN_MAX: nature = "Max"; break;
case FN_RATE: nature = "Rate"; break;
case FN_COUNTER: nature = "Counter"; break;
case FN_DURATION: nature = "Duration"; break;
case FN_AGE: nature = "Age"; break;
case FN_TIME: nature = "Time"; break;
case FN_NAME: nature = "Name"; break;
case FN_OUTPUT: nature = "Output"; break;
case FN_AVG: nature = "Avg"; break;
default: nature = "Unknown"; break;
}
switch (field_scope(f, 0)) {
case FS_PROCESS: scope = "Process"; break;
case FS_SERVICE: scope = "Service"; break;
case FS_SYSTEM: scope = "System"; break;
case FS_CLUSTER: scope = "Cluster"; break;
default: scope = "Unknown"; break;
}
old_len = out->data;
chunk_appendf(out, "\"tags\":{"
"\"origin\":\"%s\","
"\"nature\":\"%s\","
"\"scope\":\"%s\""
"}", origin, nature, scope);
return !(old_len == out->data);
}
/* Dump all fields from <stats> into <out> using CSV format */
static int stats_dump_fields_csv(struct buffer *out,
const struct field *stats, size_t stats_count,
unsigned int flags,
enum stats_domain domain)
{
int field;
for (field = 0; field < stats_count; ++field) {
if (!stats_emit_raw_data_field(out, &stats[field]))
return 0;
if (!chunk_strcat(out, ","))
return 0;
/* print special delimiter on proxy stats to mark end of
static fields */
if (domain == STATS_DOMAIN_PROXY && field + 1 == ST_F_TOTAL_FIELDS) {
if (!chunk_strcat(out, "-,"))
return 0;
}
}
chunk_strcat(out, "\n");
return 1;
}
/* Dump all fields from <stats> into <out> using a typed "field:desc:type:value" format */
static int stats_dump_fields_typed(struct buffer *out,
const struct field *stats,
size_t stats_count,
unsigned int flags,
enum stats_domain domain)
{
int field;
for (field = 0; field < stats_count; ++field) {
if (!stats[field].type)
continue;
switch (domain) {
case STATS_DOMAIN_PROXY:
chunk_appendf(out, "%c.%u.%u.%d.%s.%u:",
stats[ST_F_TYPE].u.u32 == STATS_TYPE_FE ? 'F' :
stats[ST_F_TYPE].u.u32 == STATS_TYPE_BE ? 'B' :
stats[ST_F_TYPE].u.u32 == STATS_TYPE_SO ? 'L' :
stats[ST_F_TYPE].u.u32 == STATS_TYPE_SV ? 'S' :
'?',
stats[ST_F_IID].u.u32, stats[ST_F_SID].u.u32,
field,
stat_f[domain][field].name,
stats[ST_F_PID].u.u32);
break;
case STATS_DOMAIN_DNS:
chunk_appendf(out, "D.%d.%s:", field,
stat_f[domain][field].name);
break;
default:
break;
}
if (!stats_emit_field_tags(out, &stats[field], ':'))
return 0;
if (!stats_emit_typed_data_field(out, &stats[field]))
return 0;
if (flags & STAT_SHOW_FDESC &&
!chunk_appendf(out, ":\"%s\"", stat_f[domain][field].desc)) {
return 0;
}
if (!chunk_strcat(out, "\n"))
return 0;
}
return 1;
}
/* Dump all fields from <stats> into <out> using the "show info json" format */
static int stats_dump_json_info_fields(struct buffer *out,
const struct field *info, unsigned int flags)
{
int field;
int started = 0;
if (!chunk_strcat(out, "["))
return 0;
for (field = 0; field < INF_TOTAL_FIELDS; field++) {
int old_len;
if (!field_format(info, field))
continue;
if (started && !chunk_strcat(out, ","))
goto err;
started = 1;
old_len = out->data;
chunk_appendf(out,
"{\"field\":{\"pos\":%d,\"name\":\"%s\"},"
"\"processNum\":%u,",
field, info_fields[field].name,
info[INF_PROCESS_NUM].u.u32);
if (old_len == out->data)
goto err;
if (!stats_emit_json_field_tags(out, &info[field]))
goto err;
if (!stats_emit_json_data_field(out, &info[field]))
goto err;
if (!chunk_strcat(out, "}"))
goto err;
}
if (!chunk_strcat(out, "]"))
goto err;
return 1;
err:
chunk_reset(out);
chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}");
return 0;
}
static void stats_print_proxy_field_json(struct buffer *out,
const struct field *stat,
const char *name,
int pos,
uint32_t field_type,
uint32_t iid,
uint32_t sid,
uint32_t pid)
{
const char *obj_type;
switch (field_type) {
case STATS_TYPE_FE: obj_type = "Frontend"; break;
case STATS_TYPE_BE: obj_type = "Backend"; break;
case STATS_TYPE_SO: obj_type = "Listener"; break;
case STATS_TYPE_SV: obj_type = "Server"; break;
default: obj_type = "Unknown"; break;
}
chunk_appendf(out,
"{"
"\"objType\":\"%s\","
"\"proxyId\":%u,"
"\"id\":%u,"
"\"field\":{\"pos\":%d,\"name\":\"%s\"},"
"\"processNum\":%u,",
obj_type, iid, sid, pos, name, pid);
}
static void stats_print_dns_field_json(struct buffer *out,
const struct field *stat,
const char *name,
int pos)
{
chunk_appendf(out,
"{"
"\"field\":{\"pos\":%d,\"name\":\"%s\"},",
pos, name);
}
/* Dump all fields from <stats> into <out> using a typed "field:desc:type:value" format */
static int stats_dump_fields_json(struct buffer *out,
const struct field *stats, size_t stats_count,
unsigned int flags,
enum stats_domain domain)
{
int field;
int started = 0;
if ((flags & STAT_STARTED) && !chunk_strcat(out, ","))
return 0;
if (!chunk_strcat(out, "["))
return 0;
for (field = 0; field < stats_count; field++) {
int old_len;
if (!stats[field].type)
continue;
if (started && !chunk_strcat(out, ","))
goto err;
started = 1;
old_len = out->data;
if (domain == STATS_DOMAIN_PROXY) {
stats_print_proxy_field_json(out, &stats[field],
stat_f[domain][field].name,
field,
stats[ST_F_TYPE].u.u32,
stats[ST_F_IID].u.u32,
stats[ST_F_SID].u.u32,
stats[ST_F_PID].u.u32);
} else if (domain == STATS_DOMAIN_DNS) {
stats_print_dns_field_json(out, &stats[field],
stat_f[domain][field].name,
field);
}
if (old_len == out->data)
goto err;
if (!stats_emit_json_field_tags(out, &stats[field]))
goto err;
if (!stats_emit_json_data_field(out, &stats[field]))
goto err;
if (!chunk_strcat(out, "}"))
goto err;
}
if (!chunk_strcat(out, "]"))
goto err;
return 1;
err:
chunk_reset(out);
if (flags & STAT_STARTED)
chunk_strcat(out, ",");
chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}");
return 0;
}
/* Dump all fields from <stats> into <out> using the HTML format. A column is
* reserved for the checkbox is STAT_ADMIN is set in <flags>. Some extra info
* are provided if STAT_SHLGNDS is present in <flags>. The statistics from
* extra modules are displayed at the end of the lines if STAT_SHMODULES is
* present in <flags>.
*/
static int stats_dump_fields_html(struct buffer *out,
const struct field *stats,
unsigned int flags)
{
struct buffer src;
struct stats_module *mod;
int i = 0, j = 0;
if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_FE) {
chunk_appendf(out,
/* name, queue */
"<tr class=\"frontend\">");
if (flags & STAT_ADMIN) {
/* Column sub-heading for Enable or Disable server */
chunk_appendf(out, "<td></td>");
}
chunk_appendf(out,
"<td class=ac>"
"<a name=\"%s/Frontend\"></a>"
"<a class=lfsb href=\"#%s/Frontend\">Frontend</a></td>"
"<td colspan=3></td>"
"",
field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_PXNAME));
chunk_appendf(out,
/* sessions rate : current */
"<td><u>%s<div class=tips><table class=det>"
"<tr><th>Current connection rate:</th><td>%s/s</td></tr>"
"<tr><th>Current session rate:</th><td>%s/s</td></tr>"
"",
U2H(stats[ST_F_RATE].u.u32),
U2H(stats[ST_F_CONN_RATE].u.u32),
U2H(stats[ST_F_RATE].u.u32));
if (strcmp(field_str(stats, ST_F_MODE), "http") == 0)
chunk_appendf(out,
"<tr><th>Current request rate:</th><td>%s/s</td></tr>",
U2H(stats[ST_F_REQ_RATE].u.u32));
chunk_appendf(out,
"</table></div></u></td>"
/* sessions rate : max */
"<td><u>%s<div class=tips><table class=det>"
"<tr><th>Max connection rate:</th><td>%s/s</td></tr>"
"<tr><th>Max session rate:</th><td>%s/s</td></tr>"
"",
U2H(stats[ST_F_RATE_MAX].u.u32),
U2H(stats[ST_F_CONN_RATE_MAX].u.u32),
U2H(stats[ST_F_RATE_MAX].u.u32));
if (strcmp(field_str(stats, ST_F_MODE), "http") == 0)
chunk_appendf(out,
"<tr><th>Max request rate:</th><td>%s/s</td></tr>",
U2H(stats[ST_F_REQ_RATE_MAX].u.u32));
chunk_appendf(out,
"</table></div></u></td>"
/* sessions rate : limit */
"<td>%s</td>",
LIM2A(stats[ST_F_RATE_LIM].u.u32, "-"));
chunk_appendf(out,
/* sessions: current, max, limit, total */
"<td>%s</td><td>%s</td><td>%s</td>"
"<td><u>%s<div class=tips><table class=det>"
"<tr><th>Cum. connections:</th><td>%s</td></tr>"
"<tr><th>Cum. sessions:</th><td>%s</td></tr>"
"",
U2H(stats[ST_F_SCUR].u.u32), U2H(stats[ST_F_SMAX].u.u32), U2H(stats[ST_F_SLIM].u.u32),
U2H(stats[ST_F_STOT].u.u64),
U2H(stats[ST_F_CONN_TOT].u.u64),
U2H(stats[ST_F_STOT].u.u64));
/* http response (via hover): 1xx, 2xx, 3xx, 4xx, 5xx, other */
if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) {
chunk_appendf(out,
"<tr><th>Cum. HTTP requests:</th><td>%s</td></tr>"
"<tr><th>- HTTP 1xx responses:</th><td>%s</td></tr>"
"<tr><th>- HTTP 2xx responses:</th><td>%s</td></tr>"
"<tr><th> Compressed 2xx:</th><td>%s</td><td>(%d%%)</td></tr>"
"<tr><th>- HTTP 3xx responses:</th><td>%s</td></tr>"
"<tr><th>- HTTP 4xx responses:</th><td>%s</td></tr>"
"<tr><th>- HTTP 5xx responses:</th><td>%s</td></tr>"
"<tr><th>- other responses:</th><td>%s</td></tr>"
"<tr><th>Intercepted requests:</th><td>%s</td></tr>"
"<tr><th>Cache lookups:</th><td>%s</td></tr>"
"<tr><th>Cache hits:</th><td>%s</td><td>(%d%%)</td></tr>"
"<tr><th>Failed hdr rewrites:</th><td>%s</td></tr>"
"<tr><th>Internal errors:</th><td>%s</td></tr>"
"",
U2H(stats[ST_F_REQ_TOT].u.u64),
U2H(stats[ST_F_HRSP_1XX].u.u64),
U2H(stats[ST_F_HRSP_2XX].u.u64),
U2H(stats[ST_F_COMP_RSP].u.u64),
stats[ST_F_HRSP_2XX].u.u64 ?
(int)(100 * stats[ST_F_COMP_RSP].u.u64 / stats[ST_F_HRSP_2XX].u.u64) : 0,
U2H(stats[ST_F_HRSP_3XX].u.u64),
U2H(stats[ST_F_HRSP_4XX].u.u64),
U2H(stats[ST_F_HRSP_5XX].u.u64),
U2H(stats[ST_F_HRSP_OTHER].u.u64),
U2H(stats[ST_F_INTERCEPTED].u.u64),
U2H(stats[ST_F_CACHE_LOOKUPS].u.u64),
U2H(stats[ST_F_CACHE_HITS].u.u64),
stats[ST_F_CACHE_LOOKUPS].u.u64 ?
(int)(100 * stats[ST_F_CACHE_HITS].u.u64 / stats[ST_F_CACHE_LOOKUPS].u.u64) : 0,
U2H(stats[ST_F_WREW].u.u64),
U2H(stats[ST_F_EINT].u.u64));
}
chunk_appendf(out,
"</table></div></u></td>"
/* sessions: lbtot, lastsess */
"<td></td><td></td>"
/* bytes : in */
"<td>%s</td>"
"",
U2H(stats[ST_F_BIN].u.u64));
chunk_appendf(out,
/* bytes:out + compression stats (via hover): comp_in, comp_out, comp_byp */
"<td>%s%s<div class=tips><table class=det>"
"<tr><th>Response bytes in:</th><td>%s</td></tr>"
"<tr><th>Compression in:</th><td>%s</td></tr>"
"<tr><th>Compression out:</th><td>%s</td><td>(%d%%)</td></tr>"
"<tr><th>Compression bypass:</th><td>%s</td></tr>"
"<tr><th>Total bytes saved:</th><td>%s</td><td>(%d%%)</td></tr>"
"</table></div>%s</td>",
(stats[ST_F_COMP_IN].u.u64 || stats[ST_F_COMP_BYP].u.u64) ? "<u>":"",
U2H(stats[ST_F_BOUT].u.u64),
U2H(stats[ST_F_BOUT].u.u64),
U2H(stats[ST_F_COMP_IN].u.u64),
U2H(stats[ST_F_COMP_OUT].u.u64),
stats[ST_F_COMP_IN].u.u64 ? (int)(stats[ST_F_COMP_OUT].u.u64 * 100 / stats[ST_F_COMP_IN].u.u64) : 0,
U2H(stats[ST_F_COMP_BYP].u.u64),
U2H(stats[ST_F_COMP_IN].u.u64 - stats[ST_F_COMP_OUT].u.u64),
stats[ST_F_BOUT].u.u64 ? (int)((stats[ST_F_COMP_IN].u.u64 - stats[ST_F_COMP_OUT].u.u64) * 100 / stats[ST_F_BOUT].u.u64) : 0,
(stats[ST_F_COMP_IN].u.u64 || stats[ST_F_COMP_BYP].u.u64) ? "</u>":"");
chunk_appendf(out,
/* denied: req, resp */
"<td>%s</td><td>%s</td>"
/* errors : request, connect, response */
"<td>%s</td><td></td><td></td>"
/* warnings: retries, redispatches */
"<td></td><td></td>"
/* server status : reflect frontend status */
"<td class=ac>%s</td>"
/* rest of server: nothing */
"<td class=ac colspan=8></td>"
"",
U2H(stats[ST_F_DREQ].u.u64), U2H(stats[ST_F_DRESP].u.u64),
U2H(stats[ST_F_EREQ].u.u64),
field_str(stats, ST_F_STATUS));
if (flags & STAT_SHMODULES) {
list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
chunk_appendf(out, "<td>");
if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE) {
chunk_appendf(out,
"<u>%s<div class=tips><table class=det>",
mod->name);
for (j = 0; j < mod->stats_count; ++j) {
chunk_appendf(out,
"<tr><th>%s</th><td>%s</td></tr>",
mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i]));
++i;
}
chunk_appendf(out, "</table></div></u>");
} else {
i += mod->stats_count;
}
chunk_appendf(out, "</td>");
}
}
chunk_appendf(out, "</tr>");
}
else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_SO) {
chunk_appendf(out, "<tr class=socket>");
if (flags & STAT_ADMIN) {
/* Column sub-heading for Enable or Disable server */
chunk_appendf(out, "<td></td>");
}
chunk_appendf(out,
/* frontend name, listener name */