@@ -45,29 +45,29 @@ int we_wmi_paging_file_init(struct flb_we *ctx)
45
45
}
46
46
ctx -> wmi_paging_file -> operational = FLB_FALSE ;
47
47
48
- g = cmt_gauge_create (ctx -> cmt , "windows" , "paging_file" , "allocated_base_size_megabytes " ,
49
- "The value indicates the actual amount of disk space allocated " \
50
- "for use with this page file (AllocatedBaseSize) " ,
51
- 0 , NULL );
48
+ g = cmt_gauge_create (ctx -> cmt , "windows" , "paging_file" , "limit_megabytes " ,
49
+ "Number of bytes that can be stored in the operating system paging files. " \
50
+ "0 (zero) indicates that there are no paging files " ,
51
+ 1 , ( char * []) { "file" } );
52
52
53
53
if (!g ) {
54
54
return -1 ;
55
55
}
56
- ctx -> wmi_paging_file -> allocated_base_size_megabytes = g ;
56
+ ctx -> wmi_paging_file -> limit_megabytes = g ;
57
57
58
- g = cmt_gauge_create (ctx -> cmt , "windows" , "paging_file" , "current_usage_megabytes " ,
59
- "The value indicates how much of the total reserved page file " \
60
- "is currently in use (CurrentUsage) " ,
61
- 0 , NULL );
58
+ g = cmt_gauge_create (ctx -> cmt , "windows" , "paging_file" , "free_megabytes " ,
59
+ "Number of bytes that can be mapped into the operating system paging files " \
60
+ "without causing any other pages to be swapped out " ,
61
+ 1 , ( char * []) { "file" } );
62
62
63
63
if (!g ) {
64
64
return -1 ;
65
65
}
66
- ctx -> wmi_paging_file -> current_usage_megabytes = g ;
66
+ ctx -> wmi_paging_file -> free_megabytes = g ;
67
67
68
68
g = cmt_gauge_create (ctx -> cmt , "windows" , "paging_file" , "peak_usage_megabytes" ,
69
69
"The value indicates the highest use page file (PeakUsage)" ,
70
- 0 , NULL );
70
+ 1 , ( char * []) { "file" } );
71
71
72
72
if (!g ) {
73
73
return -1 ;
@@ -112,6 +112,8 @@ int we_wmi_paging_file_update(struct flb_we *ctx)
112
112
IWbemClassObject * class_obj = NULL ;
113
113
ULONG ret = 0 ;
114
114
double val = 0 ;
115
+ double limit_val = 0 ;
116
+ char * paging_file = NULL ;
115
117
116
118
if (!ctx -> wmi_paging_file -> operational ) {
117
119
flb_plg_error (ctx -> ins , "paging_file collector not yet in operational state" );
@@ -136,16 +138,27 @@ int we_wmi_paging_file_update(struct flb_we *ctx)
136
138
break ;
137
139
}
138
140
139
- val = we_wmi_get_property_value (ctx , "AllocatedBaseSize" , class_obj );
140
- cmt_gauge_set (ctx -> wmi_paging_file -> allocated_base_size_megabytes , timestamp , val , 0 , NULL );
141
+ paging_file = we_wmi_get_property_str_value (ctx , "Name" , class_obj );
142
+ if (!paging_file ) {
143
+ continue ;
144
+ }
145
+
146
+ limit_val = we_wmi_get_property_value (ctx , "AllocatedBaseSize" , class_obj );
147
+ cmt_gauge_set (ctx -> wmi_paging_file -> limit_megabytes ,
148
+ timestamp , limit_val , 1 , (char * []){ paging_file });
141
149
150
+ /* Calculate Free megabytes */
142
151
val = we_wmi_get_property_value (ctx , "CurrentUsage" , class_obj );
143
- cmt_gauge_set (ctx -> wmi_paging_file -> current_usage_megabytes , timestamp , val , 0 , NULL );
152
+ val = limit_val - val ;
153
+ cmt_gauge_set (ctx -> wmi_paging_file -> free_megabytes ,
154
+ timestamp , val , 1 , (char * []){ paging_file });
144
155
145
156
val = we_wmi_get_property_value (ctx , "PeakUsage" , class_obj );
146
- cmt_gauge_set (ctx -> wmi_paging_file -> peak_usage_megabytes , timestamp , val , 0 , NULL );
157
+ cmt_gauge_set (ctx -> wmi_paging_file -> peak_usage_megabytes ,
158
+ timestamp , val , 1 , (char * []){ paging_file });
147
159
148
160
class_obj -> lpVtbl -> Release (class_obj );
161
+ flb_free (paging_file );
149
162
}
150
163
151
164
enumerator -> lpVtbl -> Release (enumerator );
0 commit comments