34
34
#include "we_net.h"
35
35
#include "we_logical_disk.h"
36
36
#include "we_cs.h"
37
+ #include "we_cache.h"
37
38
38
39
/* wmi collectors */
39
40
#include "we_wmi_cpu_info.h"
@@ -95,6 +96,16 @@ static int we_timer_cs_metrics_cb(struct flb_input_instance *ins,
95
96
return 0 ;
96
97
}
97
98
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
+
98
109
static int we_timer_wmi_thermalzone_metrics_cb (struct flb_input_instance * ins ,
99
110
struct flb_config * config , void * in_context )
100
111
{
@@ -262,6 +273,13 @@ static void we_cs_update_cb(char *name, void *p1, void *p2)
262
273
we_cs_update (ctx );
263
274
}
264
275
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
+
265
283
static void we_wmi_thermalzone_update_cb (char * name , void * p1 , void * p2 )
266
284
{
267
285
struct flb_we * ctx = p1 ;
@@ -337,6 +355,7 @@ struct flb_we_callback ne_callbacks[] = {
337
355
{ "net" , we_net_update_cb },
338
356
{ "logical_disk" , we_logical_disk_update_cb },
339
357
{ "cs" , we_cs_update_cb },
358
+ { "cache" , we_cache_update_cb },
340
359
{ "thermalzone" , we_wmi_thermalzone_update_cb },
341
360
{ "logon" , we_wmi_logon_update_cb },
342
361
{ "system" , we_wmi_system_update_cb },
@@ -373,6 +392,7 @@ static int in_we_init(struct flb_input_instance *in,
373
392
ctx -> coll_logical_disk_fd = -1 ;
374
393
ctx -> coll_cs_fd = -1 ;
375
394
ctx -> coll_os_fd = -1 ;
395
+ ctx -> coll_cache_fd = -1 ;
376
396
ctx -> coll_wmi_thermalzone_fd = -1 ;
377
397
ctx -> coll_wmi_cpu_info_fd = -1 ;
378
398
ctx -> coll_wmi_logon_fd = -1 ;
@@ -586,10 +606,35 @@ static int in_we_init(struct flb_input_instance *in,
586
606
return -1 ;
587
607
}
588
608
}
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
+ }
589
634
else if (strncmp (entry -> str , "thermalzone" , 11 ) == 0 ) {
590
635
if (ctx -> wmi_thermalzone_scrape_interval == 0 ) {
591
636
flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
592
- metric_idx = 6 ;
637
+ metric_idx = 7 ;
593
638
}
594
639
else {
595
640
/* Create the thermalzone collector */
@@ -614,7 +659,7 @@ static int in_we_init(struct flb_input_instance *in,
614
659
else if (strncmp (entry -> str , "logon" , 5 ) == 0 ) {
615
660
if (ctx -> wmi_logon_scrape_interval == 0 ) {
616
661
flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
617
- metric_idx = 7 ;
662
+ metric_idx = 8 ;
618
663
}
619
664
else {
620
665
/* Create the logon collector */
@@ -639,7 +684,7 @@ static int in_we_init(struct flb_input_instance *in,
639
684
else if (strncmp (entry -> str , "system" , 6 ) == 0 ) {
640
685
if (ctx -> wmi_logon_scrape_interval == 0 ) {
641
686
flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
642
- metric_idx = 8 ;
687
+ metric_idx = 9 ;
643
688
}
644
689
else {
645
690
/* Create the logon collector */
@@ -664,7 +709,7 @@ static int in_we_init(struct flb_input_instance *in,
664
709
else if (strncmp (entry -> str , "service" , 7 ) == 0 ) {
665
710
if (ctx -> wmi_service_scrape_interval == 0 ) {
666
711
flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
667
- metric_idx = 9 ;
712
+ metric_idx = 10 ;
668
713
}
669
714
else {
670
715
/* Create the service collector */
@@ -689,7 +734,7 @@ static int in_we_init(struct flb_input_instance *in,
689
734
else if (strncmp (entry -> str , "memory" , 6 ) == 0 ) {
690
735
if (ctx -> wmi_memory_scrape_interval == 0 ) {
691
736
flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
692
- metric_idx = 10 ;
737
+ metric_idx = 11 ;
693
738
}
694
739
else {
695
740
/* Create the memory collector */
@@ -714,7 +759,7 @@ static int in_we_init(struct flb_input_instance *in,
714
759
else if (strncmp (entry -> str , "paging_file" , 11 ) == 0 ) {
715
760
if (ctx -> wmi_paging_file_scrape_interval == 0 ) {
716
761
flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
717
- metric_idx = 11 ;
762
+ metric_idx = 12 ;
718
763
}
719
764
else {
720
765
/* Create the paging_file collector */
@@ -739,7 +784,7 @@ static int in_we_init(struct flb_input_instance *in,
739
784
else if (strncmp (entry -> str , "process" , 7 ) == 0 ) {
740
785
if (ctx -> wmi_process_scrape_interval == 0 ) {
741
786
flb_plg_debug (ctx -> ins , "enabled metrics %s" , entry -> str );
742
- metric_idx = 12 ;
787
+ metric_idx = 13 ;
743
788
}
744
789
else {
745
790
/* Create the process collector */
@@ -822,6 +867,9 @@ static int in_we_exit(void *data, struct flb_config *config)
822
867
else if (strncmp (entry -> str , "cs" , 2 ) == 0 ) {
823
868
we_cs_exit (ctx );
824
869
}
870
+ else if (strncmp (entry -> str , "cache" , 5 ) == 0 ) {
871
+ we_cache_exit (ctx );
872
+ }
825
873
else if (strncmp (entry -> str , "thermalzone" , 11 ) == 0 ) {
826
874
we_wmi_thermalzone_exit (ctx );
827
875
}
@@ -868,6 +916,9 @@ static int in_we_exit(void *data, struct flb_config *config)
868
916
if (ctx -> coll_os_fd != -1 ) {
869
917
we_os_exit (ctx );
870
918
}
919
+ if (ctx -> coll_cache_fd != -1 ) {
920
+ we_cache_exit (ctx );
921
+ }
871
922
if (ctx -> coll_wmi_thermalzone_fd != -1 ) {
872
923
we_wmi_thermalzone_exit (ctx );
873
924
}
@@ -920,6 +971,9 @@ static void in_we_pause(void *data, struct flb_config *config)
920
971
if (ctx -> coll_os_fd != -1 ) {
921
972
flb_input_collector_pause (ctx -> coll_os_fd , ctx -> ins );
922
973
}
974
+ if (ctx -> coll_cache_fd != -1 ) {
975
+ flb_input_collector_pause (ctx -> coll_cache_fd , ctx -> ins );
976
+ }
923
977
if (ctx -> coll_wmi_thermalzone_fd != -1 ) {
924
978
flb_input_collector_pause (ctx -> coll_wmi_thermalzone_fd , ctx -> ins );
925
979
}
@@ -971,6 +1025,9 @@ static void in_we_resume(void *data, struct flb_config *config)
971
1025
if (ctx -> coll_os_fd != -1 ) {
972
1026
flb_input_collector_resume (ctx -> coll_os_fd , ctx -> ins );
973
1027
}
1028
+ if (ctx -> coll_cache_fd != -1 ) {
1029
+ flb_input_collector_resume (ctx -> coll_cache_fd , ctx -> ins );
1030
+ }
974
1031
if (ctx -> coll_wmi_thermalzone_fd != -1 ) {
975
1032
flb_input_collector_resume (ctx -> coll_wmi_thermalzone_fd , ctx -> ins );
976
1033
}
@@ -1035,6 +1092,12 @@ static struct flb_config_map config_map[] = {
1035
1092
"scrape interval to collect os metrics from the node."
1036
1093
},
1037
1094
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
+
1038
1101
{
1039
1102
FLB_CONFIG_MAP_TIME , "collector.thermalzone.scrape_interval" , "0" ,
1040
1103
0 , FLB_TRUE , offsetof(struct flb_we , wmi_thermalzone_scrape_interval ),
@@ -1082,7 +1145,7 @@ static struct flb_config_map config_map[] = {
1082
1145
1083
1146
{
1084
1147
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" ,
1086
1149
0 , FLB_TRUE , offsetof(struct flb_we , metrics ),
1087
1150
"Comma separated list of keys to enable metrics."
1088
1151
},
0 commit comments