3434#include "we_net.h"
3535#include "we_logical_disk.h"
3636#include "we_cs.h"
37+ #include "we_cache.h"
3738
3839/* wmi collectors */
3940#include "we_wmi_cpu_info.h"
@@ -95,6 +96,16 @@ static int we_timer_cs_metrics_cb(struct flb_input_instance *ins,
9596 return 0 ;
9697}
9798
99+ static int we_timer_cache_metrics_cb (struct flb_input_instance * ins ,
100+ struct flb_config * config , void * in_context )
101+ {
102+ struct flb_ne * ctx = in_context ;
103+
104+ we_cache_update (ctx );
105+
106+ return 0 ;
107+ }
108+
98109static int we_timer_wmi_thermalzone_metrics_cb (struct flb_input_instance * ins ,
99110 struct flb_config * config , void * in_context )
100111{
@@ -262,6 +273,13 @@ static void we_cs_update_cb(char *name, void *p1, void *p2)
262273 we_cs_update (ctx );
263274}
264275
276+ static void we_cache_update_cb (char * name , void * p1 , void * p2 )
277+ {
278+ struct flb_we * ctx = p1 ;
279+
280+ we_cache_update (ctx );
281+ }
282+
265283static void we_wmi_thermalzone_update_cb (char * name , void * p1 , void * p2 )
266284{
267285 struct flb_we * ctx = p1 ;
@@ -337,6 +355,7 @@ struct flb_we_callback ne_callbacks[] = {
337355 { "net" , we_net_update_cb },
338356 { "logical_disk" , we_logical_disk_update_cb },
339357 { "cs" , we_cs_update_cb },
358+ { "cache" , we_cache_update_cb },
340359 { "thermalzone" , we_wmi_thermalzone_update_cb },
341360 { "logon" , we_wmi_logon_update_cb },
342361 { "system" , we_wmi_system_update_cb },
@@ -373,6 +392,7 @@ static int in_we_init(struct flb_input_instance *in,
373392 ctx -> coll_logical_disk_fd = -1 ;
374393 ctx -> coll_cs_fd = -1 ;
375394 ctx -> coll_os_fd = -1 ;
395+ ctx -> coll_cache_fd = -1 ;
376396 ctx -> coll_wmi_thermalzone_fd = -1 ;
377397 ctx -> coll_wmi_cpu_info_fd = -1 ;
378398 ctx -> coll_wmi_logon_fd = -1 ;
@@ -586,10 +606,35 @@ static int in_we_init(struct flb_input_instance *in,
586606 return -1 ;
587607 }
588608 }
609+ else if (strncmp (entry -> str , "cache" , 5 ) == 0 ) {
610+ if (ctx -> cache_scrape_interval == 0 ) {
611+ flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
612+ metric_idx = 6 ;
613+ }
614+ else {
615+ /* Create the cache collector */
616+ ret = flb_input_set_collector_time (in ,
617+ we_timer_cache_metrics_cb ,
618+ ctx -> cache_scrape_interval , 0 ,
619+ config );
620+ if (ret == -1 ) {
621+ flb_plg_error (ctx -> ins ,
622+ "could not set cache collector for Windows Exporter Metrics plugin" );
623+ return -1 ;
624+ }
625+ ctx -> coll_cache_fd = ret ;
626+ }
627+
628+ /* Initialize cache metric collectors */
629+ ret = we_cache_init (ctx );
630+ if (ret ) {
631+ return -1 ;
632+ }
633+ }
589634 else if (strncmp (entry -> str , "thermalzone" , 11 ) == 0 ) {
590635 if (ctx -> wmi_thermalzone_scrape_interval == 0 ) {
591636 flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
592- metric_idx = 6 ;
637+ metric_idx = 7 ;
593638 }
594639 else {
595640 /* Create the thermalzone collector */
@@ -614,7 +659,7 @@ static int in_we_init(struct flb_input_instance *in,
614659 else if (strncmp (entry -> str , "logon" , 5 ) == 0 ) {
615660 if (ctx -> wmi_logon_scrape_interval == 0 ) {
616661 flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
617- metric_idx = 7 ;
662+ metric_idx = 8 ;
618663 }
619664 else {
620665 /* Create the logon collector */
@@ -639,7 +684,7 @@ static int in_we_init(struct flb_input_instance *in,
639684 else if (strncmp (entry -> str , "system" , 6 ) == 0 ) {
640685 if (ctx -> wmi_logon_scrape_interval == 0 ) {
641686 flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
642- metric_idx = 8 ;
687+ metric_idx = 9 ;
643688 }
644689 else {
645690 /* Create the logon collector */
@@ -664,7 +709,7 @@ static int in_we_init(struct flb_input_instance *in,
664709 else if (strncmp (entry -> str , "service" , 7 ) == 0 ) {
665710 if (ctx -> wmi_service_scrape_interval == 0 ) {
666711 flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
667- metric_idx = 9 ;
712+ metric_idx = 10 ;
668713 }
669714 else {
670715 /* Create the service collector */
@@ -689,7 +734,7 @@ static int in_we_init(struct flb_input_instance *in,
689734 else if (strncmp (entry -> str , "memory" , 6 ) == 0 ) {
690735 if (ctx -> wmi_memory_scrape_interval == 0 ) {
691736 flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
692- metric_idx = 10 ;
737+ metric_idx = 11 ;
693738 }
694739 else {
695740 /* Create the memory collector */
@@ -714,7 +759,7 @@ static int in_we_init(struct flb_input_instance *in,
714759 else if (strncmp (entry -> str , "paging_file" , 11 ) == 0 ) {
715760 if (ctx -> wmi_paging_file_scrape_interval == 0 ) {
716761 flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
717- metric_idx = 11 ;
762+ metric_idx = 12 ;
718763 }
719764 else {
720765 /* Create the paging_file collector */
@@ -739,7 +784,7 @@ static int in_we_init(struct flb_input_instance *in,
739784 else if (strncmp (entry -> str , "process" , 7 ) == 0 ) {
740785 if (ctx -> wmi_process_scrape_interval == 0 ) {
741786 flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
742- metric_idx = 12 ;
787+ metric_idx = 13 ;
743788 }
744789 else {
745790 /* Create the process collector */
@@ -822,6 +867,9 @@ static int in_we_exit(void *data, struct flb_config *config)
822867 else if (strncmp (entry -> str , "cs" , 2 ) == 0 ) {
823868 we_cs_exit (ctx );
824869 }
870+ else if (strncmp (entry -> str , "cache" , 5 ) == 0 ) {
871+ we_cache_exit (ctx );
872+ }
825873 else if (strncmp (entry -> str , "thermalzone" , 11 ) == 0 ) {
826874 we_wmi_thermalzone_exit (ctx );
827875 }
@@ -868,6 +916,9 @@ static int in_we_exit(void *data, struct flb_config *config)
868916 if (ctx -> coll_os_fd != -1 ) {
869917 we_os_exit (ctx );
870918 }
919+ if (ctx -> coll_cache_fd != -1 ) {
920+ we_cache_exit (ctx );
921+ }
871922 if (ctx -> coll_wmi_thermalzone_fd != -1 ) {
872923 we_wmi_thermalzone_exit (ctx );
873924 }
@@ -920,6 +971,9 @@ static void in_we_pause(void *data, struct flb_config *config)
920971 if (ctx -> coll_os_fd != -1 ) {
921972 flb_input_collector_pause (ctx -> coll_os_fd , ctx -> ins );
922973 }
974+ if (ctx -> coll_cache_fd != -1 ) {
975+ flb_input_collector_pause (ctx -> coll_cache_fd , ctx -> ins );
976+ }
923977 if (ctx -> coll_wmi_thermalzone_fd != -1 ) {
924978 flb_input_collector_pause (ctx -> coll_wmi_thermalzone_fd , ctx -> ins );
925979 }
@@ -971,6 +1025,9 @@ static void in_we_resume(void *data, struct flb_config *config)
9711025 if (ctx -> coll_os_fd != -1 ) {
9721026 flb_input_collector_resume (ctx -> coll_os_fd , ctx -> ins );
9731027 }
1028+ if (ctx -> coll_cache_fd != -1 ) {
1029+ flb_input_collector_resume (ctx -> coll_cache_fd , ctx -> ins );
1030+ }
9741031 if (ctx -> coll_wmi_thermalzone_fd != -1 ) {
9751032 flb_input_collector_resume (ctx -> coll_wmi_thermalzone_fd , ctx -> ins );
9761033 }
@@ -1035,6 +1092,12 @@ static struct flb_config_map config_map[] = {
10351092 "scrape interval to collect os metrics from the node."
10361093 },
10371094
1095+ {
1096+ FLB_CONFIG_MAP_TIME , "collector.cache.scrape_interval" , "0" ,
1097+ 0 , FLB_TRUE , offsetof(struct flb_we , cache_scrape_interval ),
1098+ "scrape interval to collect cache metrics from the node."
1099+ },
1100+
10381101 {
10391102 FLB_CONFIG_MAP_TIME , "collector.thermalzone.scrape_interval" , "0" ,
10401103 0 , FLB_TRUE , offsetof(struct flb_we , wmi_thermalzone_scrape_interval ),
@@ -1082,7 +1145,7 @@ static struct flb_config_map config_map[] = {
10821145
10831146 {
10841147 FLB_CONFIG_MAP_CLIST , "metrics" ,
1085- "cpu,cpu_info,os,net,logical_disk,cs,thermalzone,logon,system,service" ,
1148+ "cpu,cpu_info,os,net,logical_disk,cs,cache, thermalzone,logon,system,service" ,
10861149 0 , FLB_TRUE , offsetof(struct flb_we , metrics ),
10871150 "Comma separated list of keys to enable metrics."
10881151 },
0 commit comments