rrd_api_web_log.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include "rrd_api_web_log.h"
  3. void web_log_chart_init(struct File_info *p_file_info){
  4. p_file_info->chart_meta->chart_data_web_log = callocz(1, sizeof (struct Chart_data_web_log));
  5. chart_data_web_log_t *chart_data = p_file_info->chart_meta->chart_data_web_log;
  6. chart_data->last_update = now_realtime_sec(); // initial value shouldn't be 0
  7. long chart_prio = p_file_info->chart_meta->base_prio;
  8. lgs_mng_do_num_of_logs_charts_init(p_file_info, chart_prio);
  9. /* Vhost - initialise */
  10. if(p_file_info->parser_config->chart_config & CHART_VHOST){
  11. chart_data->cs_vhosts = lgs_mng_create_chart(
  12. (char *) p_file_info->chartname // type
  13. , "vhost" // id
  14. , "Requests by Vhost" // title
  15. , "requests" // units
  16. , "vhost" // family
  17. , NULL // context
  18. , RRDSET_TYPE_AREA_NAME // chart_type
  19. , ++chart_prio // priority
  20. , p_file_info->update_every // update_every
  21. );
  22. }
  23. /* Port - initialise */
  24. if(p_file_info->parser_config->chart_config & CHART_PORT){
  25. chart_data->cs_ports = lgs_mng_create_chart(
  26. (char *) p_file_info->chartname // type
  27. , "port" // id
  28. , "Requests by Port" // title
  29. , "requests" // units
  30. , "port" // family
  31. , NULL // context
  32. , RRDSET_TYPE_AREA_NAME // chart_type
  33. , ++chart_prio // priority
  34. , p_file_info->update_every // update_every
  35. );
  36. }
  37. /* IP Version - initialise */
  38. if(p_file_info->parser_config->chart_config & CHART_IP_VERSION){
  39. lgs_mng_create_chart(
  40. (char *) p_file_info->chartname // type
  41. , "ip_version" // id
  42. , "Requests by IP version" // title
  43. , "requests" // units
  44. , "ip_version" // family
  45. , NULL // context
  46. , RRDSET_TYPE_AREA_NAME // chart_type
  47. , ++chart_prio // priority
  48. , p_file_info->update_every // update_every
  49. );
  50. lgs_mng_add_dim("ipv4", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  51. lgs_mng_add_dim("ipv6", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  52. lgs_mng_add_dim("invalid", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  53. }
  54. /* Request client current poll - initialise */
  55. if(p_file_info->parser_config->chart_config & CHART_REQ_CLIENT_CURRENT){
  56. lgs_mng_create_chart(
  57. (char *) p_file_info->chartname // type
  58. , "clients" // id
  59. , "Current Poll Unique Client IPs" // title
  60. , "unique ips" // units
  61. , "clients" // family
  62. , NULL // context
  63. , RRDSET_TYPE_AREA_NAME // chart_type
  64. , ++chart_prio // priority
  65. , p_file_info->update_every // update_every
  66. );
  67. lgs_mng_add_dim("ipv4", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  68. lgs_mng_add_dim("ipv6", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  69. }
  70. /* Request client all-time - initialise */
  71. if(p_file_info->parser_config->chart_config & CHART_REQ_CLIENT_ALL_TIME){
  72. lgs_mng_create_chart(
  73. (char *) p_file_info->chartname // type
  74. , "clients_all" // id
  75. , "All Time Unique Client IPs" // title
  76. , "unique ips" // units
  77. , "clients" // family
  78. , NULL // context
  79. , RRDSET_TYPE_AREA_NAME // chart_type
  80. , ++chart_prio // priority
  81. , p_file_info->update_every // update_every
  82. );
  83. lgs_mng_add_dim("ipv4", RRD_ALGORITHM_ABSOLUTE_NAME, 1, 1);
  84. lgs_mng_add_dim("ipv6", RRD_ALGORITHM_ABSOLUTE_NAME, 1, 1);
  85. }
  86. /* Request methods - initialise */
  87. if(p_file_info->parser_config->chart_config & CHART_REQ_METHODS){
  88. lgs_mng_create_chart(
  89. (char *) p_file_info->chartname // type
  90. , "http_methods" // id
  91. , "Requests Per HTTP Method" // title
  92. , "requests" // units
  93. , "http_methods" // family
  94. , NULL // context
  95. , RRDSET_TYPE_AREA_NAME // chart_type
  96. , ++chart_prio // priority
  97. , p_file_info->update_every // update_every
  98. );
  99. for(int j = 0; j < REQ_METHOD_ARR_SIZE; j++)
  100. lgs_mng_add_dim(req_method_str[j], RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  101. }
  102. /* Request protocol - initialise */
  103. if(p_file_info->parser_config->chart_config & CHART_REQ_PROTO){
  104. lgs_mng_create_chart(
  105. (char *) p_file_info->chartname // type
  106. , "http_versions" // id
  107. , "Requests Per HTTP Version" // title
  108. , "requests" // units
  109. , "http_versions" // family
  110. , NULL // context
  111. , RRDSET_TYPE_AREA_NAME // chart_type
  112. , ++chart_prio // priority
  113. , p_file_info->update_every // update_every
  114. );
  115. lgs_mng_add_dim("1.0", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  116. lgs_mng_add_dim("1.1", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  117. lgs_mng_add_dim("2.0", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  118. lgs_mng_add_dim("other", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  119. }
  120. /* Request bandwidth - initialise */
  121. if(p_file_info->parser_config->chart_config & CHART_BANDWIDTH){
  122. lgs_mng_create_chart(
  123. (char *) p_file_info->chartname // type
  124. , "bandwidth" // id
  125. , "Bandwidth" // title
  126. , "kilobits" // units
  127. , "bandwidth" // family
  128. , NULL // context
  129. , RRDSET_TYPE_AREA_NAME // chart_type
  130. , ++chart_prio // priority
  131. , p_file_info->update_every // update_every
  132. );
  133. lgs_mng_add_dim("received", RRD_ALGORITHM_INCREMENTAL_NAME, 8, 1000);
  134. lgs_mng_add_dim("sent", RRD_ALGORITHM_INCREMENTAL_NAME, -8, 1000);
  135. }
  136. /* Request processing time - initialise */
  137. if(p_file_info->parser_config->chart_config & CHART_REQ_PROC_TIME){
  138. lgs_mng_create_chart(
  139. (char *) p_file_info->chartname // type
  140. , "timings" // id
  141. , "Request Processing Time" // title
  142. , "milliseconds" // units
  143. , "timings" // family
  144. , NULL // context
  145. , RRDSET_TYPE_LINE_NAME // chart_type
  146. , ++chart_prio // priority
  147. , p_file_info->update_every // update_every
  148. );
  149. lgs_mng_add_dim("min", RRD_ALGORITHM_ABSOLUTE_NAME, 1, 1000);
  150. lgs_mng_add_dim("max", RRD_ALGORITHM_ABSOLUTE_NAME, 1, 1000);
  151. lgs_mng_add_dim("avg", RRD_ALGORITHM_ABSOLUTE_NAME, 1, 1000);
  152. }
  153. /* Response code family - initialise */
  154. if(p_file_info->parser_config->chart_config & CHART_RESP_CODE_FAMILY){
  155. lgs_mng_create_chart(
  156. (char *) p_file_info->chartname // type
  157. , "responses" // id
  158. , "Response Codes" // title
  159. , "requests" // units
  160. , "responses" // family
  161. , NULL // context
  162. , RRDSET_TYPE_AREA_NAME // chart_type
  163. , ++chart_prio // priority
  164. , p_file_info->update_every // update_every
  165. );
  166. lgs_mng_add_dim("1xx", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  167. lgs_mng_add_dim("2xx", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  168. lgs_mng_add_dim("3xx", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  169. lgs_mng_add_dim("4xx", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  170. lgs_mng_add_dim("5xx", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  171. lgs_mng_add_dim("other", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  172. }
  173. /* Response code - initialise */
  174. if(p_file_info->parser_config->chart_config & CHART_RESP_CODE){
  175. lgs_mng_create_chart(
  176. (char *) p_file_info->chartname // type
  177. , "detailed_responses" // id
  178. , "Detailed Response Codes" // title
  179. , "requests" // units
  180. , "responses" // family
  181. , NULL // context
  182. , RRDSET_TYPE_AREA_NAME // chart_type
  183. , ++chart_prio // priority
  184. , p_file_info->update_every // update_every
  185. );
  186. for(int idx = 0; idx < RESP_CODE_ARR_SIZE - 1; idx++){
  187. char dim_name[4];
  188. snprintfz(dim_name, 4, "%d", idx + 100);
  189. lgs_mng_add_dim(dim_name, RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  190. }
  191. }
  192. /* Response code type - initialise */
  193. if(p_file_info->parser_config->chart_config & CHART_RESP_CODE_TYPE){
  194. lgs_mng_create_chart(
  195. (char *) p_file_info->chartname // type
  196. , "response_types" // id
  197. , "Response Statuses" // title
  198. , "requests" // units
  199. , "responses" // family
  200. , NULL // context
  201. , RRDSET_TYPE_AREA_NAME // chart_type
  202. , ++chart_prio // priority
  203. , p_file_info->update_every // update_every
  204. );
  205. lgs_mng_add_dim("success", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  206. lgs_mng_add_dim("redirect", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  207. lgs_mng_add_dim("bad", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  208. lgs_mng_add_dim("error", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  209. lgs_mng_add_dim("other", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  210. }
  211. /* SSL protocol - initialise */
  212. if(p_file_info->parser_config->chart_config & CHART_SSL_PROTO){
  213. lgs_mng_create_chart(
  214. (char *) p_file_info->chartname // type
  215. , "ssl_protocol" // id
  216. , "Requests Per SSL Protocol" // title
  217. , "requests" // units
  218. , "ssl_protocol" // family
  219. , NULL // context
  220. , RRDSET_TYPE_AREA_NAME // chart_type
  221. , ++chart_prio // priority
  222. , p_file_info->update_every // update_every
  223. );
  224. lgs_mng_add_dim("TLSV1", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  225. lgs_mng_add_dim("TLSV1.1", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  226. lgs_mng_add_dim("TLSV1.2", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  227. lgs_mng_add_dim("TLSV1.3", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  228. lgs_mng_add_dim("SSLV2", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  229. lgs_mng_add_dim("SSLV3", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  230. lgs_mng_add_dim("other", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  231. }
  232. /* SSL cipher suite - initialise */
  233. if(p_file_info->parser_config->chart_config & CHART_SSL_CIPHER){
  234. chart_data->cs_ssl_ciphers = lgs_mng_create_chart(
  235. (char *) p_file_info->chartname // type
  236. , "ssl_cipher_suite" // id
  237. , "Requests by SSL cipher suite" // title
  238. , "requests" // units
  239. , "ssl_cipher_suite" // family
  240. , NULL // context
  241. , RRDSET_TYPE_AREA_NAME // chart_type
  242. , ++chart_prio // priority
  243. , p_file_info->update_every // update_every
  244. );
  245. }
  246. lgs_mng_do_custom_charts_init(p_file_info);
  247. }
  248. void web_log_chart_update(struct File_info *p_file_info){
  249. chart_data_web_log_t *chart_data = p_file_info->chart_meta->chart_data_web_log;
  250. Web_log_metrics_t *wlm = p_file_info->parser_metrics->web_log;
  251. if(chart_data->last_update != p_file_info->parser_metrics->last_update){
  252. time_t lag_in_sec = p_file_info->parser_metrics->last_update - chart_data->last_update - 1;
  253. lgs_mng_do_num_of_logs_charts_update(p_file_info, lag_in_sec, chart_data);
  254. /* Vhost - update */
  255. if(p_file_info->parser_config->chart_config & CHART_VHOST){
  256. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  257. sec < p_file_info->parser_metrics->last_update;
  258. sec++){
  259. lgs_mng_update_chart_begin(p_file_info->chartname, "vhost");
  260. for(int idx = 0; idx < chart_data->vhost_size; idx++)
  261. lgs_mng_update_chart_set(wlm->vhost_arr.vhosts[idx].name, chart_data->num_vhosts[idx]);
  262. lgs_mng_update_chart_end(sec);
  263. }
  264. if(wlm->vhost_arr.size > chart_data->vhost_size){
  265. if(wlm->vhost_arr.size >= chart_data->vhost_size_max){
  266. chart_data->vhost_size_max = wlm->vhost_arr.size * VHOST_BUFFS_SCALE_FACTOR + 1;
  267. chart_data->num_vhosts = reallocz( chart_data->num_vhosts,
  268. chart_data->vhost_size_max * sizeof(collected_number));
  269. }
  270. for(int idx = chart_data->vhost_size; idx < wlm->vhost_arr.size; idx++){
  271. chart_data->num_vhosts[idx] = 0;
  272. lgs_mng_add_dim_post_init( &chart_data->cs_vhosts,
  273. wlm->vhost_arr.vhosts[idx].name,
  274. RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  275. }
  276. chart_data->vhost_size = wlm->vhost_arr.size;
  277. }
  278. lgs_mng_update_chart_begin(p_file_info->chartname, "vhost");
  279. for(int idx = 0; idx < chart_data->vhost_size; idx++){
  280. chart_data->num_vhosts[idx] += wlm->vhost_arr.vhosts[idx].count;
  281. wlm->vhost_arr.vhosts[idx].count = 0;
  282. lgs_mng_update_chart_set(wlm->vhost_arr.vhosts[idx].name, chart_data->num_vhosts[idx]);
  283. }
  284. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  285. }
  286. /* Port - update */
  287. if(p_file_info->parser_config->chart_config & CHART_PORT){
  288. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  289. sec < p_file_info->parser_metrics->last_update;
  290. sec++){
  291. lgs_mng_update_chart_begin(p_file_info->chartname, "port");
  292. for(int idx = 0; idx < chart_data->port_size; idx++)
  293. lgs_mng_update_chart_set(wlm->port_arr.ports[idx].name, chart_data->num_ports[idx]);
  294. lgs_mng_update_chart_end(sec);
  295. }
  296. if(wlm->port_arr.size > chart_data->port_size){
  297. if(wlm->port_arr.size >= chart_data->port_size_max){
  298. chart_data->port_size_max = wlm->port_arr.size * PORT_BUFFS_SCALE_FACTOR + 1;
  299. chart_data->num_ports = reallocz( chart_data->num_ports,
  300. chart_data->port_size_max * sizeof(collected_number));
  301. }
  302. for(int idx = chart_data->port_size; idx < wlm->port_arr.size; idx++){
  303. chart_data->num_ports[idx] = 0;
  304. lgs_mng_add_dim_post_init( &chart_data->cs_ports,
  305. wlm->port_arr.ports[idx].name,
  306. RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  307. }
  308. chart_data->port_size = wlm->port_arr.size;
  309. }
  310. lgs_mng_update_chart_begin(p_file_info->chartname, "port");
  311. for(int idx = 0; idx < chart_data->port_size; idx++){
  312. chart_data->num_ports[idx] += wlm->port_arr.ports[idx].count;
  313. wlm->port_arr.ports[idx].count = 0;
  314. lgs_mng_update_chart_set(wlm->port_arr.ports[idx].name, chart_data->num_ports[idx]);
  315. }
  316. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  317. }
  318. /* IP Version - update */
  319. if(p_file_info->parser_config->chart_config & CHART_IP_VERSION){
  320. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  321. sec < p_file_info->parser_metrics->last_update;
  322. sec++){
  323. lgs_mng_update_chart_begin(p_file_info->chartname, "ip_version");
  324. lgs_mng_update_chart_set("ipv4", chart_data->num_ip_ver_4);
  325. lgs_mng_update_chart_set("ipv6", chart_data->num_ip_ver_6);
  326. lgs_mng_update_chart_set("invalid", chart_data->num_ip_ver_invalid);
  327. lgs_mng_update_chart_end(sec);
  328. }
  329. chart_data->num_ip_ver_4 += wlm->ip_ver.v4;
  330. chart_data->num_ip_ver_6 += wlm->ip_ver.v6;
  331. chart_data->num_ip_ver_invalid += wlm->ip_ver.invalid;
  332. memset(&wlm->ip_ver, 0, sizeof(wlm->ip_ver));
  333. lgs_mng_update_chart_begin(p_file_info->chartname, "ip_version");
  334. lgs_mng_update_chart_set("ipv4", chart_data->num_ip_ver_4);
  335. lgs_mng_update_chart_set("ipv6", chart_data->num_ip_ver_6);
  336. lgs_mng_update_chart_set("invalid", chart_data->num_ip_ver_invalid);
  337. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  338. }
  339. /* Request client current poll - update */
  340. if(p_file_info->parser_config->chart_config & CHART_REQ_CLIENT_CURRENT){
  341. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  342. sec < p_file_info->parser_metrics->last_update;
  343. sec++){
  344. lgs_mng_update_chart_begin(p_file_info->chartname, "clients");
  345. lgs_mng_update_chart_set("ipv4", chart_data->num_req_client_current_ipv4);
  346. lgs_mng_update_chart_set("ipv6", chart_data->num_req_client_current_ipv6);
  347. lgs_mng_update_chart_end(sec);
  348. }
  349. chart_data->num_req_client_current_ipv4 += wlm->req_clients_current_arr.ipv4_size;
  350. wlm->req_clients_current_arr.ipv4_size = 0;
  351. chart_data->num_req_client_current_ipv6 += wlm->req_clients_current_arr.ipv6_size;
  352. wlm->req_clients_current_arr.ipv6_size = 0;
  353. lgs_mng_update_chart_begin(p_file_info->chartname, "clients");
  354. lgs_mng_update_chart_set("ipv4", chart_data->num_req_client_current_ipv4);
  355. lgs_mng_update_chart_set("ipv6", chart_data->num_req_client_current_ipv6);
  356. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  357. }
  358. /* Request client all-time - update */
  359. if(p_file_info->parser_config->chart_config & CHART_REQ_CLIENT_ALL_TIME){
  360. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  361. sec < p_file_info->parser_metrics->last_update;
  362. sec++){
  363. lgs_mng_update_chart_begin(p_file_info->chartname, "clients_all");
  364. lgs_mng_update_chart_set("ipv4", chart_data->num_req_client_all_time_ipv4);
  365. lgs_mng_update_chart_set("ipv6", chart_data->num_req_client_all_time_ipv6);
  366. lgs_mng_update_chart_end(sec);
  367. }
  368. chart_data->num_req_client_all_time_ipv4 = wlm->req_clients_alltime_arr.ipv4_size;
  369. chart_data->num_req_client_all_time_ipv6 = wlm->req_clients_alltime_arr.ipv6_size;
  370. lgs_mng_update_chart_begin(p_file_info->chartname, "clients_all");
  371. lgs_mng_update_chart_set("ipv4", chart_data->num_req_client_all_time_ipv4);
  372. lgs_mng_update_chart_set("ipv6", chart_data->num_req_client_all_time_ipv6);
  373. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  374. }
  375. /* Request methods - update */
  376. if(p_file_info->parser_config->chart_config & CHART_REQ_METHODS){
  377. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  378. sec < p_file_info->parser_metrics->last_update;
  379. sec++){
  380. lgs_mng_update_chart_begin(p_file_info->chartname, "http_methods");
  381. for(int idx = 0; idx < REQ_METHOD_ARR_SIZE; idx++){
  382. if(chart_data->num_req_method[idx])
  383. lgs_mng_update_chart_set(req_method_str[idx], chart_data->num_req_method[idx]);
  384. }
  385. lgs_mng_update_chart_end(sec);
  386. }
  387. lgs_mng_update_chart_begin(p_file_info->chartname, "http_methods");
  388. for(int idx = 0; idx < REQ_METHOD_ARR_SIZE; idx++){
  389. chart_data->num_req_method[idx] += wlm->req_method[idx];
  390. wlm->req_method[idx] = 0;
  391. if(chart_data->num_req_method[idx])
  392. lgs_mng_update_chart_set(req_method_str[idx], chart_data->num_req_method[idx]);
  393. }
  394. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  395. }
  396. /* Request protocol - update */
  397. if(p_file_info->parser_config->chart_config & CHART_REQ_PROTO){
  398. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  399. sec < p_file_info->parser_metrics->last_update;
  400. sec++){
  401. lgs_mng_update_chart_begin(p_file_info->chartname, "http_versions");
  402. lgs_mng_update_chart_set("1.0", chart_data->num_req_proto_http_1);
  403. lgs_mng_update_chart_set("1.1", chart_data->num_req_proto_http_1_1);
  404. lgs_mng_update_chart_set("2.0", chart_data->num_req_proto_http_2);
  405. lgs_mng_update_chart_set("other", chart_data->num_req_proto_other);
  406. lgs_mng_update_chart_end(sec);
  407. }
  408. chart_data->num_req_proto_http_1 += wlm->req_proto.http_1;
  409. chart_data->num_req_proto_http_1_1 += wlm->req_proto.http_1_1;
  410. chart_data->num_req_proto_http_2 += wlm->req_proto.http_2;
  411. chart_data->num_req_proto_other += wlm->req_proto.other;
  412. memset(&wlm->req_proto, 0, sizeof(wlm->req_proto));
  413. lgs_mng_update_chart_begin(p_file_info->chartname, "http_versions");
  414. lgs_mng_update_chart_set("1.0", chart_data->num_req_proto_http_1);
  415. lgs_mng_update_chart_set("1.1", chart_data->num_req_proto_http_1_1);
  416. lgs_mng_update_chart_set("2.0", chart_data->num_req_proto_http_2);
  417. lgs_mng_update_chart_set("other", chart_data->num_req_proto_other);
  418. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  419. }
  420. /* Request bandwidth - update */
  421. if(p_file_info->parser_config->chart_config & CHART_BANDWIDTH){
  422. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  423. sec < p_file_info->parser_metrics->last_update;
  424. sec++){
  425. lgs_mng_update_chart_begin(p_file_info->chartname, "bandwidth");
  426. lgs_mng_update_chart_set("received", chart_data->num_bandwidth_req_size);
  427. lgs_mng_update_chart_set("sent", chart_data->num_bandwidth_resp_size);
  428. lgs_mng_update_chart_end(sec);
  429. }
  430. chart_data->num_bandwidth_req_size += wlm->bandwidth.req_size;
  431. chart_data->num_bandwidth_resp_size += wlm->bandwidth.resp_size;
  432. memset(&wlm->bandwidth, 0, sizeof(wlm->bandwidth));
  433. lgs_mng_update_chart_begin(p_file_info->chartname, "bandwidth");
  434. lgs_mng_update_chart_set("received", chart_data->num_bandwidth_req_size);
  435. lgs_mng_update_chart_set("sent", chart_data->num_bandwidth_resp_size);
  436. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  437. }
  438. /* Request proc time - update */
  439. if(p_file_info->parser_config->chart_config & CHART_REQ_PROC_TIME){
  440. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  441. sec < p_file_info->parser_metrics->last_update;
  442. sec++){
  443. lgs_mng_update_chart_begin(p_file_info->chartname, "timings");
  444. lgs_mng_update_chart_set("min", chart_data->num_req_proc_time_min);
  445. lgs_mng_update_chart_set("max", chart_data->num_req_proc_time_max);
  446. lgs_mng_update_chart_set("avg", chart_data->num_req_proc_time_avg);
  447. lgs_mng_update_chart_end(sec);
  448. }
  449. chart_data->num_req_proc_time_min = wlm->req_proc_time.min;
  450. chart_data->num_req_proc_time_max = wlm->req_proc_time.max;
  451. chart_data->num_req_proc_time_avg = wlm->req_proc_time.count ?
  452. wlm->req_proc_time.sum / wlm->req_proc_time.count : 0;
  453. memset(&wlm->req_proc_time, 0, sizeof(wlm->req_proc_time));
  454. lgs_mng_update_chart_begin(p_file_info->chartname, "timings");
  455. lgs_mng_update_chart_set("min", chart_data->num_req_proc_time_min);
  456. lgs_mng_update_chart_set("max", chart_data->num_req_proc_time_max);
  457. lgs_mng_update_chart_set("avg", chart_data->num_req_proc_time_avg);
  458. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  459. }
  460. /* Response code family - update */
  461. if(p_file_info->parser_config->chart_config & CHART_RESP_CODE_FAMILY){
  462. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  463. sec < p_file_info->parser_metrics->last_update;
  464. sec++){
  465. lgs_mng_update_chart_begin(p_file_info->chartname, "responses");
  466. lgs_mng_update_chart_set("1xx", chart_data->num_resp_code_family_1xx);
  467. lgs_mng_update_chart_set("2xx", chart_data->num_resp_code_family_2xx);
  468. lgs_mng_update_chart_set("3xx", chart_data->num_resp_code_family_3xx);
  469. lgs_mng_update_chart_set("4xx", chart_data->num_resp_code_family_4xx);
  470. lgs_mng_update_chart_set("5xx", chart_data->num_resp_code_family_5xx);
  471. lgs_mng_update_chart_set("other", chart_data->num_resp_code_family_other);
  472. lgs_mng_update_chart_end(sec);
  473. }
  474. chart_data->num_resp_code_family_1xx += wlm->resp_code_family.resp_1xx;
  475. chart_data->num_resp_code_family_2xx += wlm->resp_code_family.resp_2xx;
  476. chart_data->num_resp_code_family_3xx += wlm->resp_code_family.resp_3xx;
  477. chart_data->num_resp_code_family_4xx += wlm->resp_code_family.resp_4xx;
  478. chart_data->num_resp_code_family_5xx += wlm->resp_code_family.resp_5xx;
  479. chart_data->num_resp_code_family_other += wlm->resp_code_family.other;
  480. memset(&wlm->resp_code_family, 0, sizeof(wlm->resp_code_family));
  481. lgs_mng_update_chart_begin(p_file_info->chartname, "responses");
  482. lgs_mng_update_chart_set("1xx", chart_data->num_resp_code_family_1xx);
  483. lgs_mng_update_chart_set("2xx", chart_data->num_resp_code_family_2xx);
  484. lgs_mng_update_chart_set("3xx", chart_data->num_resp_code_family_3xx);
  485. lgs_mng_update_chart_set("4xx", chart_data->num_resp_code_family_4xx);
  486. lgs_mng_update_chart_set("5xx", chart_data->num_resp_code_family_5xx);
  487. lgs_mng_update_chart_set("other", chart_data->num_resp_code_family_other);
  488. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  489. }
  490. /* Response code - update */
  491. if(p_file_info->parser_config->chart_config & CHART_RESP_CODE){
  492. char dim_name[4];
  493. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  494. sec < p_file_info->parser_metrics->last_update;
  495. sec++){
  496. lgs_mng_update_chart_begin(p_file_info->chartname, "detailed_responses");
  497. for(int idx = 0; idx < RESP_CODE_ARR_SIZE - 1; idx++){
  498. if(chart_data->num_resp_code[idx]){
  499. snprintfz(dim_name, 4, "%d", idx + 100);
  500. lgs_mng_update_chart_set(dim_name, chart_data->num_resp_code[idx]);
  501. }
  502. }
  503. if(chart_data->num_resp_code[RESP_CODE_ARR_SIZE - 1])
  504. lgs_mng_update_chart_set("other", chart_data->num_resp_code[RESP_CODE_ARR_SIZE - 1]);
  505. lgs_mng_update_chart_end(sec);
  506. }
  507. lgs_mng_update_chart_begin(p_file_info->chartname, "detailed_responses");
  508. for(int idx = 0; idx < RESP_CODE_ARR_SIZE - 1; idx++){
  509. chart_data->num_resp_code[idx] += wlm->resp_code[idx];
  510. wlm->resp_code[idx] = 0;
  511. if(chart_data->num_resp_code[idx]){
  512. snprintfz(dim_name, 4, "%d", idx + 100);
  513. lgs_mng_update_chart_set(dim_name, chart_data->num_resp_code[idx]);
  514. }
  515. }
  516. chart_data->num_resp_code[RESP_CODE_ARR_SIZE - 1] += wlm->resp_code[RESP_CODE_ARR_SIZE - 1];
  517. wlm->resp_code[RESP_CODE_ARR_SIZE - 1] = 0;
  518. if(chart_data->num_resp_code[RESP_CODE_ARR_SIZE - 1])
  519. lgs_mng_update_chart_set("other", chart_data->num_resp_code[RESP_CODE_ARR_SIZE - 1]);
  520. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  521. }
  522. /* Response code type - update */
  523. if(p_file_info->parser_config->chart_config & CHART_RESP_CODE_TYPE){
  524. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  525. sec < p_file_info->parser_metrics->last_update;
  526. sec++){
  527. lgs_mng_update_chart_begin(p_file_info->chartname, "response_types");
  528. lgs_mng_update_chart_set("success", chart_data->num_resp_code_type_success);
  529. lgs_mng_update_chart_set("redirect", chart_data->num_resp_code_type_redirect);
  530. lgs_mng_update_chart_set("bad", chart_data->num_resp_code_type_bad);
  531. lgs_mng_update_chart_set("error", chart_data->num_resp_code_type_error);
  532. lgs_mng_update_chart_set("other", chart_data->num_resp_code_type_other);
  533. lgs_mng_update_chart_end(sec);
  534. }
  535. chart_data->num_resp_code_type_success += wlm->resp_code_type.resp_success;
  536. chart_data->num_resp_code_type_redirect += wlm->resp_code_type.resp_redirect;
  537. chart_data->num_resp_code_type_bad += wlm->resp_code_type.resp_bad;
  538. chart_data->num_resp_code_type_error += wlm->resp_code_type.resp_error;
  539. chart_data->num_resp_code_type_other += wlm->resp_code_type.other;
  540. memset(&wlm->resp_code_type, 0, sizeof(wlm->resp_code_type));
  541. lgs_mng_update_chart_begin(p_file_info->chartname, "response_types");
  542. lgs_mng_update_chart_set("success", chart_data->num_resp_code_type_success);
  543. lgs_mng_update_chart_set("redirect", chart_data->num_resp_code_type_redirect);
  544. lgs_mng_update_chart_set("bad", chart_data->num_resp_code_type_bad);
  545. lgs_mng_update_chart_set("error", chart_data->num_resp_code_type_error);
  546. lgs_mng_update_chart_set("other", chart_data->num_resp_code_type_other);
  547. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  548. }
  549. /* SSL protocol - update */
  550. if(p_file_info->parser_config->chart_config & CHART_SSL_PROTO){
  551. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  552. sec < p_file_info->parser_metrics->last_update;
  553. sec++){
  554. lgs_mng_update_chart_begin(p_file_info->chartname, "ssl_protocol");
  555. lgs_mng_update_chart_set("TLSV1", chart_data->num_ssl_proto_tlsv1);
  556. lgs_mng_update_chart_set("TLSV1.1", chart_data->num_ssl_proto_tlsv1_1);
  557. lgs_mng_update_chart_set("TLSV1.2", chart_data->num_ssl_proto_tlsv1_2);
  558. lgs_mng_update_chart_set("TLSV1.3", chart_data->num_ssl_proto_tlsv1_3);
  559. lgs_mng_update_chart_set("SSLV2", chart_data->num_ssl_proto_sslv2);
  560. lgs_mng_update_chart_set("SSLV3", chart_data->num_ssl_proto_sslv3);
  561. lgs_mng_update_chart_set("other", chart_data->num_ssl_proto_other);
  562. lgs_mng_update_chart_end(sec);
  563. }
  564. chart_data->num_ssl_proto_tlsv1 += wlm->ssl_proto.tlsv1;
  565. chart_data->num_ssl_proto_tlsv1_1 += wlm->ssl_proto.tlsv1_1;
  566. chart_data->num_ssl_proto_tlsv1_2 += wlm->ssl_proto.tlsv1_2;
  567. chart_data->num_ssl_proto_tlsv1_3 += wlm->ssl_proto.tlsv1_3;
  568. chart_data->num_ssl_proto_sslv2 += wlm->ssl_proto.sslv2;
  569. chart_data->num_ssl_proto_sslv3 += wlm->ssl_proto.sslv3;
  570. chart_data->num_ssl_proto_other += wlm->ssl_proto.other;
  571. memset(&wlm->ssl_proto, 0, sizeof(wlm->ssl_proto));
  572. lgs_mng_update_chart_begin(p_file_info->chartname, "ssl_protocol");
  573. lgs_mng_update_chart_set("TLSV1", chart_data->num_ssl_proto_tlsv1);
  574. lgs_mng_update_chart_set("TLSV1.1", chart_data->num_ssl_proto_tlsv1_1);
  575. lgs_mng_update_chart_set("TLSV1.2", chart_data->num_ssl_proto_tlsv1_2);
  576. lgs_mng_update_chart_set("TLSV1.3", chart_data->num_ssl_proto_tlsv1_3);
  577. lgs_mng_update_chart_set("SSLV2", chart_data->num_ssl_proto_sslv2);
  578. lgs_mng_update_chart_set("SSLV3", chart_data->num_ssl_proto_sslv3);
  579. lgs_mng_update_chart_set("other", chart_data->num_ssl_proto_other);
  580. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  581. }
  582. /* SSL cipher suite - update */
  583. if(p_file_info->parser_config->chart_config & CHART_SSL_CIPHER){
  584. for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec;
  585. sec < p_file_info->parser_metrics->last_update;
  586. sec++){
  587. lgs_mng_update_chart_begin(p_file_info->chartname, "ssl_cipher_suite");
  588. for(int idx = 0; idx < chart_data->ssl_cipher_size; idx++){
  589. lgs_mng_update_chart_set( wlm->ssl_cipher_arr.ssl_ciphers[idx].name,
  590. chart_data->num_ssl_ciphers[idx]);
  591. }
  592. lgs_mng_update_chart_end(sec);
  593. }
  594. if(wlm->ssl_cipher_arr.size > chart_data->ssl_cipher_size){
  595. chart_data->ssl_cipher_size = wlm->ssl_cipher_arr.size;
  596. chart_data->num_ssl_ciphers = reallocz( chart_data->num_ssl_ciphers,
  597. chart_data->ssl_cipher_size * sizeof(collected_number));
  598. for(int idx = chart_data->ssl_cipher_size; idx < wlm->ssl_cipher_arr.size; idx++){
  599. chart_data->num_ssl_ciphers[idx] = 0;
  600. lgs_mng_add_dim_post_init( &chart_data->cs_ssl_ciphers,
  601. wlm->ssl_cipher_arr.ssl_ciphers[idx].name,
  602. RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1);
  603. }
  604. chart_data->ssl_cipher_size = wlm->ssl_cipher_arr.size;
  605. }
  606. lgs_mng_update_chart_begin(p_file_info->chartname, "ssl_cipher_suite");
  607. for(int idx = 0; idx < chart_data->ssl_cipher_size; idx++){
  608. chart_data->num_ssl_ciphers[idx] += wlm->ssl_cipher_arr.ssl_ciphers[idx].count;
  609. wlm->ssl_cipher_arr.ssl_ciphers[idx].count = 0;
  610. lgs_mng_update_chart_set( wlm->ssl_cipher_arr.ssl_ciphers[idx].name,
  611. chart_data->num_ssl_ciphers[idx]);
  612. }
  613. lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update);
  614. }
  615. lgs_mng_do_custom_charts_update(p_file_info, lag_in_sec);
  616. chart_data->last_update = p_file_info->parser_metrics->last_update;
  617. }
  618. }