summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/plugins/in_windows_exporter_metrics
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluent-bit/plugins/in_windows_exporter_metrics')
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/CMakeLists.txt28
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we.c1144
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we.h332
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.c154
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.h32
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.c304
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.h30
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.c112
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.c272
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.c368
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.h98
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.c253
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.c268
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.h32
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.c1048
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.h72
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.c167
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.h37
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.c572
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.h59
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.c116
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.c198
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.c557
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.c156
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.c417
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.c493
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.c190
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.h29
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.c171
-rw-r--r--src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.h29
39 files changed, 0 insertions, 7999 deletions
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/CMakeLists.txt b/src/fluent-bit/plugins/in_windows_exporter_metrics/CMakeLists.txt
deleted file mode 100644
index 8cc7fe70a..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-set(src
- we_config.c
- we.c
- we_cpu.c
- we_os.c
- we_net.c
- we_logical_disk.c
- we_cs.c
- we_wmi.c
- we_util.c
- we_metric.c
- we_perflib.c
- we_wmi_thermalzone.c
- we_wmi_cpu_info.c
- we_wmi_logon.c
- we_wmi_system.c
- we_wmi_service.c
- we_wmi_memory.c
- we_wmi_paging_file.c
- we_wmi_process.c
- )
-
-set(libs
- wbemuuid
- netapi32
-)
-
-FLB_PLUGIN(in_windows_exporter_metrics "${src}" "${libs}")
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we.c
deleted file mode 100644
index 0f99fb83f..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we.c
+++ /dev/null
@@ -1,1144 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_config.h"
-
-/* collectors */
-#include "we_cpu.h"
-#include "we_os.h"
-#include "we_net.h"
-#include "we_logical_disk.h"
-#include "we_cs.h"
-
-/* wmi collectors */
-#include "we_wmi_cpu_info.h"
-#include "we_wmi_logon.h"
-#include "we_wmi_system.h"
-#include "we_wmi_thermalzone.h"
-#include "we_wmi_service.h"
-#include "we_wmi_memory.h"
-#include "we_wmi_paging_file.h"
-#include "we_wmi_process.h"
-
-static int we_timer_cpu_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_cpu_update(ctx);
-
- return 0;
-}
-
-static int we_timer_os_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_os_update(ctx);
-
- return 0;
-}
-
-static int we_timer_net_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_net_update(ctx);
-
- return 0;
-}
-
-static int we_timer_logical_disk_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_logical_disk_update(ctx);
-
- return 0;
-}
-
-static int we_timer_cs_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_cs_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_thermalzone_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_thermalzone_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_cpu_info_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_cpu_info_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_logon_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_logon_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_system_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_system_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_service_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_service_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_memory_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_memory_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_paging_file_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_paging_file_update(ctx);
-
- return 0;
-}
-
-static int we_timer_wmi_process_metrics_cb(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- struct flb_ne *ctx = in_context;
-
- we_wmi_process_update(ctx);
-
- return 0;
-}
-
-struct flb_we_callback {
- char *name;
- void (*func)(char *, void *, void *);
-};
-
-static int we_update_cb(struct flb_we *ctx, char *name);
-
-static void update_metrics(struct flb_input_instance *ins, struct flb_we *ctx)
-{
- int ret;
- struct mk_list *head;
- struct flb_slist_entry *entry;
-
- /* Update our metrics */
- if (ctx->metrics) {
- mk_list_foreach(head, ctx->metrics) {
- entry = mk_list_entry(head, struct flb_slist_entry, _head);
- ret = flb_callback_exists(ctx->callback, entry->str);
- if (ret == FLB_TRUE) {
- we_update_cb(ctx, entry->str);
- }
- else {
- flb_plg_debug(ctx->ins, "Callback for metrics '%s' is not registered", entry->str);
- }
- }
- }
-}
-
-/*
- * Update the metrics, this function is invoked every time 'scrape_interval'
- * expires.
- */
-static int cb_we_collect(struct flb_input_instance *ins,
- struct flb_config *config, void *in_context)
-{
- int ret;
- struct flb_we *ctx;
-
- ctx = in_context;
-
- update_metrics(ins, ctx);
-
- /* Append the updated metrics */
- ret = flb_input_metrics_append(ins, NULL, 0, ctx->cmt);
-
- if (ret) {
- flb_plg_error(ins, "could not append metrics");
- }
-
- return 0;
-}
-
-static void we_cpu_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_cpu_update(ctx);
-}
-
-static void we_os_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_os_update(ctx);
-}
-
-static void we_net_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_net_update(ctx);
-}
-
-static void we_logical_disk_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_logical_disk_update(ctx);
-}
-
-static void we_cs_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_cs_update(ctx);
-}
-
-static void we_wmi_thermalzone_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_thermalzone_update(ctx);
-}
-
-static void we_wmi_cpu_info_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_cpu_info_update(ctx);
-}
-
-static void we_wmi_logon_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_logon_update(ctx);
-}
-
-static void we_wmi_system_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_system_update(ctx);
-}
-
-static void we_wmi_service_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_service_update(ctx);
-}
-
-static void we_wmi_memory_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_memory_update(ctx);
-}
-
-static void we_wmi_paging_file_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_paging_file_update(ctx);
-}
-
-static void we_wmi_process_update_cb(char *name, void *p1, void *p2)
-{
- struct flb_we *ctx = p1;
-
- we_wmi_process_update(ctx);
-}
-
-static int we_update_cb(struct flb_we *ctx, char *name)
-{
- int ret;
-
- ret = flb_callback_do(ctx->callback, name, ctx, NULL);
- return ret;
-}
-
-/*
- * Callbacks Table
- */
-struct flb_we_callback ne_callbacks[] = {
- /* metrics */
- { "cpu_info", we_wmi_cpu_info_update_cb },
- { "cpu", we_cpu_update_cb },
- { "os", we_os_update_cb },
- { "net", we_net_update_cb },
- { "logical_disk", we_logical_disk_update_cb },
- { "cs", we_cs_update_cb },
- { "thermalzone", we_wmi_thermalzone_update_cb },
- { "logon", we_wmi_logon_update_cb },
- { "system", we_wmi_system_update_cb },
- { "service", we_wmi_service_update_cb },
- { "memory", we_wmi_memory_update_cb },
- { "paging_file", we_wmi_paging_file_update_cb },
- { "process", we_wmi_process_update_cb },
- { 0 }
-};
-
-static int in_we_init(struct flb_input_instance *in,
- struct flb_config *config, void *data)
-{
- int ret;
- int metric_idx = -1;
- struct flb_we *ctx;
- double windows_version = 0.0;
- struct mk_list *head;
- struct flb_slist_entry *entry;
- struct flb_we_callback *cb;
-
- /* Create plugin context */
- ctx = flb_we_config_create(in, config);
-
- if (ctx == NULL) {
- flb_errno();
-
- return -1;
- }
-
- /* Initialize fds */
- ctx->coll_cpu_fd = -1;
- ctx->coll_net_fd = -1;
- ctx->coll_logical_disk_fd = -1;
- ctx->coll_cs_fd = -1;
- ctx->coll_os_fd = -1;
- ctx->coll_wmi_thermalzone_fd = -1;
- ctx->coll_wmi_cpu_info_fd = -1;
- ctx->coll_wmi_logon_fd = -1;
- ctx->coll_wmi_system_fd = -1;
- ctx->coll_wmi_service_fd = -1;
- ctx->coll_wmi_memory_fd = -1;
- ctx->coll_wmi_paging_file_fd = -1;
- ctx->coll_wmi_process_fd = -1;
-
- ctx->callback = flb_callback_create(in->name);
- if (!ctx->callback) {
- flb_plg_error(ctx->ins, "Create callback failed");
- return -1;
- }
-
- /* Associate context with the instance */
- flb_input_set_context(in, ctx);
-
- ret = we_get_windows_version(&windows_version);
-
- if (ret == FLB_FALSE) {
- flb_plg_error(in, "could not get windows version");
-
- return -1;
- }
- ctx->windows_version = windows_version;
-
- ret = we_perflib_init(ctx);
-
- if (ret) {
- flb_plg_error(in, "could not initialize PERFLIB");
- return -1;
- }
-
- ret = we_wmi_init(ctx);
-
- if (ret) {
- flb_plg_error(in, "could not initialize WMI");
-
- return -1;
- }
-
- /* Create the collector */
- ret = flb_input_set_collector_time(in,
- cb_we_collect,
- ctx->scrape_interval, 0,
- config);
-
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set collector for "
- "Windows Exporter Metrics plugin");
- return -1;
- }
-
- ctx->coll_fd = ret;
-
- /* Check and initialize enabled metrics */
- if (ctx->metrics) {
- mk_list_foreach(head, ctx->metrics) {
- entry = mk_list_entry(head, struct flb_slist_entry, _head);
- ret = flb_callback_exists(ctx->callback, entry->str);
-
- if (ret == FLB_FALSE) {
- if (strncmp(entry->str, "cpu_info", 8) == 0) {
- if (ctx->wmi_cpu_info_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 0;
- }
- else {
- /* Create the cpu_info collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_cpu_info_metrics_cb,
- ctx->wmi_cpu_info_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set cpu_info collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_cpu_info_fd = ret;
- }
-
- /* Initialize cpu info metric collectors */
- ret = we_wmi_cpu_info_init(ctx);
- if (ret == -1) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "cpu", 3) == 0) {
- if (ctx->cpu_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 1;
- }
- else {
- /* Create the cpu collector */
- ret = flb_input_set_collector_time(in,
- we_timer_cpu_metrics_cb,
- ctx->cpu_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set cpu collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_cpu_fd = ret;
- }
-
- /* Initialize cpu metric collectors */
- ret = we_cpu_init(ctx);
- if (ret < 0) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "os", 2) == 0) {
- if (ctx->os_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 2;
- } else {
- /* Create the os collector */
- ret = flb_input_set_collector_time(in,
- we_timer_os_metrics_cb,
- ctx->os_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set os collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_os_fd = ret;
- }
-
- /* Initialize os metric collectors */
- ret = we_os_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "net", 3) == 0) {
- if (ctx->net_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 3;
- }
- else {
- /* Create the net collector */
- ret = flb_input_set_collector_time(in,
- we_timer_net_metrics_cb,
- ctx->net_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set net collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_net_fd = ret;
- }
-
- /* Initialize net metric collectors */
- ret = we_net_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "logical_disk", 12) == 0) {
- if (ctx->logical_disk_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 4;
- }
- else {
- /* Create the logical_disk collector */
- ret = flb_input_set_collector_time(in,
- we_timer_logical_disk_metrics_cb,
- ctx->logical_disk_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set logical_disk collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_logical_disk_fd = ret;
- }
-
- /* Initialize logical_disk metric collectors */
- ret = we_logical_disk_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "cs", 2) == 0) {
- if (ctx->cs_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 5;
- }
- else {
- /* Create the logical_disk collector */
- ret = flb_input_set_collector_time(in,
- we_timer_cs_metrics_cb,
- ctx->cs_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set cs collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_cs_fd = ret;
- }
-
- /* Initialize cs metric collectors */
- ret = we_cs_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "thermalzone", 11) == 0) {
- if (ctx->wmi_thermalzone_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 6;
- }
- else {
- /* Create the thermalzone collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_thermalzone_metrics_cb,
- ctx->wmi_thermalzone_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set thermalzone collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_thermalzone_fd = ret;
- }
-
- /* Initialize thermalzone metric collectors */
- ret = we_wmi_thermalzone_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "logon", 5) == 0) {
- if (ctx->wmi_logon_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 7;
- }
- else {
- /* Create the logon collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_logon_metrics_cb,
- ctx->wmi_logon_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set thermalzone collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_logon_fd = ret;
- }
-
- /* Initialize logon metric collectors */
- ret = we_wmi_logon_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "system", 6) == 0) {
- if (ctx->wmi_logon_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 8;
- }
- else {
- /* Create the logon collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_system_metrics_cb,
- ctx->wmi_system_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set system collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_system_fd = ret;
- }
-
- /* Initialize system metric collectors */
- ret = we_wmi_system_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "service", 7) == 0) {
- if (ctx->wmi_service_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 9;
- }
- else {
- /* Create the service collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_service_metrics_cb,
- ctx->wmi_service_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set service collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_service_fd = ret;
- }
-
- /* Initialize service metric collectors */
- ret = we_wmi_service_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "memory", 6) == 0) {
- if (ctx->wmi_memory_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 10;
- }
- else {
- /* Create the memory collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_memory_metrics_cb,
- ctx->wmi_memory_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set memory collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_memory_fd = ret;
- }
-
- /* Initialize memory metric collectors */
- ret = we_wmi_memory_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "paging_file", 11) == 0) {
- if (ctx->wmi_paging_file_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 11;
- }
- else {
- /* Create the paging_file collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_paging_file_metrics_cb,
- ctx->wmi_paging_file_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set paging_file collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_paging_file_fd = ret;
- }
-
- /* Initialize paging_file metric collectors */
- ret = we_wmi_paging_file_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else if (strncmp(entry->str, "process", 7) == 0) {
- if (ctx->wmi_process_scrape_interval == 0) {
- flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
- metric_idx = 12;
- }
- else {
- /* Create the process collector */
- ret = flb_input_set_collector_time(in,
- we_timer_wmi_process_metrics_cb,
- ctx->wmi_process_scrape_interval, 0,
- config);
- if (ret == -1) {
- flb_plg_error(ctx->ins,
- "could not set process collector for Windows Exporter Metrics plugin");
- return -1;
- }
- ctx->coll_wmi_process_fd = ret;
- }
-
- /* Initialize paging_file metric collectors */
- ret = we_wmi_process_init(ctx);
- if (ret) {
- return -1;
- }
- }
- else {
- flb_plg_warn(ctx->ins, "Unknown metrics: %s", entry->str);
- metric_idx = -1;
- }
-
- if (metric_idx >= 0) {
- cb = &ne_callbacks[metric_idx];
- ret = flb_callback_set(ctx->callback, cb->name, cb->func);
- if (ret == -1) {
- flb_plg_error(ctx->ins, "error setting up default "
- "callback '%s'", cb->name);
- }
- }
- }
- }
- }
- else {
- flb_plg_error(ctx->ins, "No metrics is specified");
-
- return -1;
- }
-
- return 0;
-}
-
-static int in_we_exit(void *data, struct flb_config *config)
-{
- int ret;
- struct flb_we* ctx = data;
- struct mk_list *head;
- struct flb_slist_entry *entry;
-
- if (data == NULL) {
- return 0;
- }
-
- /* Teardown for callback tied up resources */
- if (ctx->metrics) {
- mk_list_foreach(head, ctx->metrics) {
- entry = mk_list_entry(head, struct flb_slist_entry, _head);
- ret = flb_callback_exists(ctx->callback, entry->str);
-
- if (ret == FLB_TRUE) {
- if (strncmp(entry->str, "cpu_info", 8) == 0) {
- we_wmi_cpu_info_exit(ctx);
- }
- else if (strncmp(entry->str, "cpu", 3) == 0) {
- /* nop */
- }
- else if (strncmp(entry->str, "os", 2) == 0) {
- we_os_exit(ctx);
- }
- else if (strncmp(entry->str, "net", 3) == 0) {
- we_net_exit(ctx);
- }
- else if (strncmp(entry->str, "logical_disk", 12) == 0) {
- we_logical_disk_exit(ctx);
- }
- else if (strncmp(entry->str, "cs", 2) == 0) {
- we_cs_exit(ctx);
- }
- else if (strncmp(entry->str, "thermalzone", 11) == 0) {
- we_wmi_thermalzone_exit(ctx);
- }
- else if (strncmp(entry->str, "logon", 5) == 0) {
- we_wmi_logon_exit(ctx);
- }
- else if (strncmp(entry->str, "system", 6) == 0) {
- we_wmi_system_exit(ctx);
- }
- else if (strncmp(entry->str, "service", 7) == 0) {
- we_wmi_service_exit(ctx);
- }
- else if (strncmp(entry->str, "memory", 6) == 0) {
- we_wmi_memory_exit(ctx);
- }
- else if (strncmp(entry->str, "paging_file", 11) == 0) {
- we_wmi_paging_file_exit(ctx);
- }
- else if (strncmp(entry->str, "process", 7) == 0) {
- we_wmi_process_exit(ctx);
- }
- else {
- flb_plg_warn(ctx->ins, "Unknown metrics: %s", entry->str);
- }
- }
- }
- }
-
- /* destroy callback context */
- if (ctx->callback) {
- flb_callback_destroy(ctx->callback);
- }
-
- /* Teardown for timer tied up resources */
- if (ctx->coll_net_fd != -1) {
- we_net_exit(ctx);
- }
- if (ctx->coll_logical_disk_fd != -1) {
- we_logical_disk_exit(ctx);
- }
- if (ctx->coll_cs_fd != -1) {
- we_cs_exit(ctx);
- }
- if (ctx->coll_os_fd != -1) {
- we_os_exit(ctx);
- }
- if (ctx->coll_wmi_thermalzone_fd != -1) {
- we_wmi_thermalzone_exit(ctx);
- }
- if (ctx->coll_wmi_cpu_info_fd != -1) {
- we_wmi_cpu_info_exit(ctx);
- }
- if (ctx->coll_wmi_logon_fd != -1) {
- we_wmi_logon_exit(ctx);
- }
- if (ctx->coll_wmi_system_fd != -1) {
- we_wmi_system_exit(ctx);
- }
- if (ctx->coll_wmi_service_fd != -1) {
- we_wmi_service_exit(ctx);
- }
- if (ctx->coll_wmi_memory_fd != -1) {
- we_wmi_memory_exit(ctx);
- }
- if (ctx->coll_wmi_paging_file_fd != -1) {
- we_wmi_paging_file_exit(ctx);
- }
- if (ctx->coll_wmi_process_fd != -1) {
- we_wmi_process_exit(ctx);
- }
-
- flb_we_config_destroy(ctx);
-
- return 0;
-}
-
-static void in_we_pause(void *data, struct flb_config *config)
-{
- struct flb_we *ctx;
-
- ctx = (struct flb_we *) data;
-
- flb_input_collector_pause(ctx->coll_fd, ctx->ins);
- if (ctx->coll_cpu_fd != -1) {
- flb_input_collector_pause(ctx->coll_cpu_fd, ctx->ins);
- }
- if (ctx->coll_net_fd != -1) {
- flb_input_collector_pause(ctx->coll_net_fd, ctx->ins);
- }
- if (ctx->coll_logical_disk_fd != -1) {
- flb_input_collector_pause(ctx->coll_logical_disk_fd, ctx->ins);
- }
- if (ctx->coll_cs_fd != -1) {
- flb_input_collector_pause(ctx->coll_cs_fd, ctx->ins);
- }
- if (ctx->coll_os_fd != -1) {
- flb_input_collector_pause(ctx->coll_os_fd, ctx->ins);
- }
- if (ctx->coll_wmi_thermalzone_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_thermalzone_fd, ctx->ins);
- }
- if (ctx->coll_wmi_cpu_info_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_cpu_info_fd, ctx->ins);
- }
- if (ctx->coll_wmi_logon_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_logon_fd, ctx->ins);
- }
- if (ctx->coll_wmi_system_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_system_fd, ctx->ins);
- }
- if (ctx->coll_wmi_service_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_service_fd, ctx->ins);
- }
- if (ctx->coll_wmi_memory_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_memory_fd, ctx->ins);
- }
- if (ctx->coll_wmi_paging_file_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_paging_file_fd, ctx->ins);
- }
- if (ctx->coll_wmi_process_fd != -1) {
- flb_input_collector_pause(ctx->coll_wmi_process_fd, ctx->ins);
- }
-}
-
-static void in_we_resume(void *data, struct flb_config *config)
-{
- struct flb_we *ctx;
-
- ctx = (struct flb_we *) data;
-
- flb_input_collector_resume(ctx->coll_fd, ctx->ins);
- if (ctx->coll_cpu_fd != -1) {
- flb_input_collector_resume(ctx->coll_cpu_fd, ctx->ins);
- }
- if (ctx->coll_net_fd != -1) {
- flb_input_collector_resume(ctx->coll_net_fd, ctx->ins);
- }
- if (ctx->coll_logical_disk_fd != -1) {
- flb_input_collector_resume(ctx->coll_logical_disk_fd, ctx->ins);
- }
- if (ctx->coll_wmi_process_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_process_fd, ctx->ins);
- }
- if (ctx->coll_cs_fd != -1) {
- flb_input_collector_resume(ctx->coll_cs_fd, ctx->ins);
- }
- if (ctx->coll_os_fd != -1) {
- flb_input_collector_resume(ctx->coll_os_fd, ctx->ins);
- }
- if (ctx->coll_wmi_thermalzone_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_thermalzone_fd, ctx->ins);
- }
- if (ctx->coll_wmi_cpu_info_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_cpu_info_fd, ctx->ins);
- }
- if (ctx->coll_wmi_logon_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_logon_fd, ctx->ins);
- }
- if (ctx->coll_wmi_system_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_system_fd, ctx->ins);
- }
- if (ctx->coll_wmi_service_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_service_fd, ctx->ins);
- }
- if (ctx->coll_wmi_memory_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_memory_fd, ctx->ins);
- }
- if (ctx->coll_wmi_paging_file_fd != -1) {
- flb_input_collector_resume(ctx->coll_wmi_paging_file_fd, ctx->ins);
- }
-}
-
-/* Configuration properties map */
-static struct flb_config_map config_map[] = {
- {
- FLB_CONFIG_MAP_TIME, "scrape_interval", "1",
- 0, FLB_TRUE, offsetof(struct flb_we, scrape_interval),
- "scrape interval to collect metrics from the node."
- },
- {
- FLB_CONFIG_MAP_STR, "enable_collector", NULL,
- FLB_CONFIG_MAP_MULT, FLB_TRUE, offsetof(struct flb_we, collectors),
- "Collector to enable."
- },
- {
- FLB_CONFIG_MAP_TIME, "collector.cpu.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, cpu_scrape_interval),
- "scrape interval to collect cpu metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.net.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, net_scrape_interval),
- "scrape interval to collect net metrics from the node."
- },
- {
- FLB_CONFIG_MAP_TIME, "collector.logical_disk.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, logical_disk_scrape_interval),
- "scrape interval to collect logical_disk metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.cs.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, cs_scrape_interval),
- "scrape interval to collect cs metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.os.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, os_scrape_interval),
- "scrape interval to collect os metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.thermalzone.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_thermalzone_scrape_interval),
- "scrape interval to collect thermalzone metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.cpu_info.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_cpu_info_scrape_interval),
- "scrape interval to collect cpu_info metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.logon.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_logon_scrape_interval),
- "scrape interval to collect logon metrics from the node."
- },
- {
- FLB_CONFIG_MAP_TIME, "collector.system.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_system_scrape_interval),
- "scrape interval to collect system metrics from the node."
- },
- {
- FLB_CONFIG_MAP_TIME, "collector.service.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_service_scrape_interval),
- "scrape interval to collect service metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.memory.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_memory_scrape_interval),
- "scrape interval to collect memory metrics from the node."
- },
- {
- FLB_CONFIG_MAP_TIME, "collector.paging_file.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_paging_file_scrape_interval),
- "scrape interval to collect paging_file metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_TIME, "collector.process.scrape_interval", "0",
- 0, FLB_TRUE, offsetof(struct flb_we, wmi_process_scrape_interval),
- "scrape interval to collect process metrics from the node."
- },
-
- {
- FLB_CONFIG_MAP_CLIST, "metrics",
- "cpu,cpu_info,os,net,logical_disk,cs,thermalzone,logon,system,service",
- 0, FLB_TRUE, offsetof(struct flb_we, metrics),
- "Comma separated list of keys to enable metrics."
- },
- {
- FLB_CONFIG_MAP_STR, "we.logical_disk.allow_disk_regex", "/.+/",
- 0, FLB_TRUE, offsetof(struct flb_we, raw_allowing_disk),
- "Specify to be scribable regex for logical disk metrics."
- },
- {
- FLB_CONFIG_MAP_STR, "we.logical_disk.deny_disk_regex", NULL,
- 0, FLB_TRUE, offsetof(struct flb_we, raw_denying_disk),
- "Specify to be denied regex for logical disk metrics."
- },
- {
- FLB_CONFIG_MAP_STR, "we.net.allow_nic_regex", "/.+/",
- 0, FLB_TRUE, offsetof(struct flb_we, raw_allowing_nic),
- "Specify to be scribable regex for net metrics by name of NIC."
- },
- {
- FLB_CONFIG_MAP_STR, "we.service.where", NULL,
- 0, FLB_TRUE, offsetof(struct flb_we, raw_where_clause),
- "Specify the where clause for retrieving service metrics."
- },
- {
- FLB_CONFIG_MAP_STR, "we.service.include", NULL,
- 0, FLB_TRUE, offsetof(struct flb_we, raw_service_include),
- "Specify the key value condition pairs for includeing condition to construct where clause of service metrics."
- },
- {
- FLB_CONFIG_MAP_STR, "we.service.exclude", NULL,
- 0, FLB_TRUE, offsetof(struct flb_we, raw_service_exclude),
- "Specify the key value condition pairs for excludeing condition to construct where clause of service metrics."
- },
- {
- FLB_CONFIG_MAP_STR, "we.process.allow_process_regex", "/.+/",
- 0, FLB_TRUE, offsetof(struct flb_we, raw_allowing_process),
- "Specify the regex covering the process metrics to collect."
- },
- {
- FLB_CONFIG_MAP_STR, "we.process.deny_process_regex", NULL,
- 0, FLB_TRUE, offsetof(struct flb_we, raw_denying_process),
- "Specify the regex for process metrics to prevent collection of/ignore."
- },
- /* EOF */
- {0}
-};
-
-struct flb_input_plugin in_windows_exporter_metrics_plugin = {
- .name = "windows_exporter_metrics",
- .description = "Windows Exporter Metrics (Prometheus Compatible)",
- .cb_init = in_we_init,
- .cb_pre_run = NULL,
- .cb_collect = cb_we_collect,
- .cb_flush_buf = NULL,
- .config_map = config_map,
- .cb_pause = in_we_pause,
- .cb_resume = in_we_resume,
- .cb_exit = in_we_exit,
-};
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we.h
deleted file mode 100644
index 1ec848893..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we.h
+++ /dev/null
@@ -1,332 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WINDOWS_EXPORTER_H
-#define FLB_WINDOWS_EXPORTER_H
-
-#include <fluent-bit/flb_info.h>
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_hash_table.h>
-#include <fluent-bit/flb_metrics.h>
-
-#include <monkey/mk_core/mk_list.h>
-#include <fluent-bit/flb_sds.h>
-
-#include <windows.h>
-#include <wbemidl.h>
-
-#include "we_metric.h"
-
-#define PERFLIB_COUNTER_TYPE_COUNTER 0x400
-#define PERFLIB_COUNTER_FLAG_BASE_VALUE 0x00030000
-#define PERFLIB_COUNTER_FLAG_BASE_NANOSECONDS 0x00100000
-
-struct we_perflib_counter_definition {
- char *name_index_str;
- uint32_t name_index;
- char *name;
- uint32_t help_index;
- char *help;
-
- uint32_t type;
- uint32_t size;
- uint32_t offset;
- uint32_t detail_level;
-
- struct mk_list _head;
-};
-
-union we_perflib_value {
- uint64_t as_qword;
- double as_double;
- uint32_t as_dword;
- float as_float;
-};
-
-struct we_perflib_counter {
- struct we_perflib_instance *parent;
- struct we_perflib_counter_definition *definition;
- union we_perflib_value primary_value;
- union we_perflib_value secondary_value;
- struct mk_list _head;
-};
-
-struct we_perflib_instance {
- char *name;
- struct we_perflib_object *parent;
- struct flb_hash_table *counters;
- struct mk_list _head;
-};
-
-struct we_perflib_object {
- char *name;
- int64_t time;
- int64_t frequency;
- int64_t hundred_ns_time;
- size_t counter_count;
- size_t instance_count;
- struct flb_hash_table *instances;
- struct mk_list counter_definitions;
-};
-
-
-struct we_perflib_context {
- struct flb_hash_table *counter_indexes;
-};
-
-struct we_cpu_counters {
- struct we_perflib_metric_source *metric_sources;
- struct we_perflib_metric_spec *metric_specs;
- int operational;
- struct flb_hash_table *metrics;
- char *query;
-};
-
-struct we_net_counters {
- struct we_perflib_metric_source *metric_sources;
- struct we_perflib_metric_spec *metric_specs;
- int operational;
- struct flb_hash_table *metrics;
- char *query;
-};
-
-struct we_logical_disk_counters {
- struct we_perflib_metric_source *metric_sources;
- struct we_perflib_metric_spec *metric_specs;
- int operational;
- struct flb_hash_table *metrics;
- char *query;
-};
-
-struct wmi_query_spec;
-
-struct we_wmi_thermal_counters {
- struct wmi_query_spec *temperature_celsius;
- struct wmi_query_spec *percent_passive_limit;
- struct wmi_query_spec *throttle_reasons;
- int operational;
-};
-
-struct we_wmi_cpu_info_counters {
- struct wmi_query_spec *info;
- int operational;
-};
-
-struct we_wmi_logon_counters {
- struct wmi_query_spec *info;
- int operational;
-};
-
-struct we_wmi_system_counters {
- struct wmi_query_spec *info;
- struct cmt_gauge *context_switches;
- struct cmt_gauge *exception_dispatches;
- struct cmt_gauge *processor_queue;
- struct cmt_gauge *system_calls;
- struct cmt_gauge *system_up_time;
- struct cmt_gauge *threads;
- int operational;
-};
-
-struct we_wmi_service_counters {
- struct wmi_query_spec *info;
- struct cmt_gauge *information;
- struct cmt_gauge *state;
- struct cmt_gauge *start_mode;
- struct cmt_gauge *status;
- int operational;
-};
-
-struct we_wmi_memory_counters {
- struct wmi_query_spec *info;
- struct cmt_gauge *available_bytes;
- struct cmt_gauge *cache_bytes;
- struct cmt_gauge *cache_bytes_peak;
- struct cmt_gauge *cache_faults_total;
- struct cmt_gauge *commit_limit;
- struct cmt_gauge *committed_bytes;
- struct cmt_gauge *demand_zero_faults_total;
- struct cmt_gauge *free_and_zero_page_list_bytes;
- struct cmt_gauge *free_system_page_table_entries;
- struct cmt_gauge *modified_page_list_bytes;
- struct cmt_gauge *page_faults_total;
- struct cmt_gauge *swap_page_reads_total;
- struct cmt_gauge *swap_pages_read_total;
- struct cmt_gauge *swap_pages_written_total;
- struct cmt_gauge *swap_page_operations_total;
- struct cmt_gauge *swap_page_writes_total;
- struct cmt_gauge *pool_nonpaged_allocs_total;
- struct cmt_gauge *pool_nonpaged_bytes;
- struct cmt_gauge *pool_paged_allocs_total;
- struct cmt_gauge *pool_paged_bytes;
- struct cmt_gauge *pool_paged_resident_bytes;
- struct cmt_gauge *standby_cache_core_bytes;
- struct cmt_gauge *standby_cache_normal_priority_bytes;
- struct cmt_gauge *standby_cache_reserve_bytes;
- struct cmt_gauge *system_cache_resident_bytes;
- struct cmt_gauge *system_code_resident_bytes;
- struct cmt_gauge *system_code_total_bytes;
- struct cmt_gauge *system_driver_resident_bytes;
- struct cmt_gauge *system_driver_total_bytes;
- struct cmt_gauge *transition_faults_total;
- struct cmt_gauge *transition_pages_repurposed_total;
- struct cmt_gauge *write_copies_total;
- int operational;
-};
-
-struct we_wmi_paging_file_counters {
- struct wmi_query_spec *info;
- struct cmt_gauge *allocated_base_size_megabytes;
- struct cmt_gauge *current_usage_megabytes;
- struct cmt_gauge *peak_usage_megabytes;
- int operational;
-};
-
-struct we_wmi_process_counters {
- struct wmi_query_spec *info;
- struct cmt_gauge *start_time;
- struct cmt_gauge *handles;
- struct cmt_gauge *cpu_time_total;
- struct cmt_gauge *io_bytes_total;
- struct cmt_gauge *io_operations_total;
- struct cmt_gauge *page_faults_total;
- struct cmt_gauge *page_file_bytes;
- struct cmt_gauge *pool_bytes;
- struct cmt_gauge *priority_base;
- struct cmt_gauge *thread_count;
- struct cmt_gauge *private_bytes;
- struct cmt_gauge *virtual_bytes;
- struct cmt_gauge *working_set_private_bytes;
- struct cmt_gauge *working_set_peak_bytes;
- struct cmt_gauge *working_set_bytes;
- int operational;
-};
-
-struct we_os_counters {
- struct cmt_gauge *info;
- struct cmt_gauge *users;
- struct cmt_gauge *physical_memory_free_bytes;
- struct cmt_gauge *time;
- struct cmt_gauge *tz;
- struct cmt_gauge *virtual_memory_free_bytes;
- struct cmt_gauge *processes_limit;
- struct cmt_gauge *process_memory_limit_bytes;
- struct cmt_gauge *processes;
- struct cmt_gauge *virtual_memory_bytes;
- struct cmt_gauge *visible_memory_bytes;
- int operational;
-};
-
-struct we_cs_counters {
- struct cmt_gauge *logical_processors;
- struct cmt_gauge *physical_memory_bytes;
- struct cmt_gauge *hostname;
- int operational;
-};
-
-struct flb_we {
- /* configuration */
- int scrape_interval;
-
- int coll_fd; /* collector fd */
- struct cmt *cmt; /* cmetrics context */
- struct flb_input_instance *ins; /* input instance */
- struct mk_list *collectors;
- char *raw_allowing_disk;
- char *raw_denying_disk;
- char *raw_allowing_nic;
- char *raw_where_clause;
- char *raw_service_include;
- char *raw_service_exclude;
- char *raw_allowing_process;
- char *raw_denying_process;
- char *service_include_buffer;
- int service_include_buffer_size;
- char *service_exclude_buffer;
- int service_exclude_buffer_size;
-
- struct flb_regex *allowing_disk_regex;
- struct flb_regex *denying_disk_regex;
- struct flb_regex *allowing_nic_regex;
- struct flb_regex *allowing_process_regex;
- struct flb_regex *denying_process_regex;
-
- struct we_perflib_context perflib_context;
- /* WMI locator and service contexts */
- IWbemLocator *locator;
- IWbemServices *service;
-
- float windows_version;
-
- struct flb_callback *callback; /* metric callback */
- struct mk_list *metrics; /* enabled metrics */
-
- /* Individual intervals for metrics */
- int cpu_scrape_interval;
- int net_scrape_interval;
- int logical_disk_scrape_interval;
- int cs_scrape_interval;
- int os_scrape_interval;
- int wmi_thermalzone_scrape_interval;
- int wmi_cpu_info_scrape_interval;
- int wmi_logon_scrape_interval;
- int wmi_system_scrape_interval;
- int wmi_service_scrape_interval;
- int wmi_memory_scrape_interval;
- int wmi_paging_file_scrape_interval;
- int wmi_process_scrape_interval;
-
- int coll_cpu_fd; /* collector fd (cpu) */
- int coll_net_fd; /* collector fd (net) */
- int coll_logical_disk_fd; /* collector fd (logical_disk) */
- int coll_cs_fd; /* collector fd (cs) */
- int coll_os_fd; /* collector fd (os) */
- int coll_wmi_thermalzone_fd; /* collector fd (wmi_thermalzone) */
- int coll_wmi_cpu_info_fd; /* collector fd (wmi_cpu_info) */
- int coll_wmi_logon_fd; /* collector fd (wmi_logon) */
- int coll_wmi_system_fd; /* collector fd (wmi_system) */
- int coll_wmi_service_fd; /* collector fd (wmi_service) */
- int coll_wmi_memory_fd; /* collector fd (wmi_memory) */
- int coll_wmi_paging_file_fd; /* collector fd (wmi_paging_file) */
- int coll_wmi_process_fd; /* collector fd (wmi_process) */
-
- /*
- * Metrics Contexts
- * ----------------
- */
-
- struct we_cpu_counters cpu;
- struct we_net_counters net;
- struct we_logical_disk_counters logical_disk;
- struct we_cs_counters cs;
- struct we_os_counters *os;
- struct we_wmi_thermal_counters *wmi_thermals;
- struct we_wmi_cpu_info_counters *wmi_cpu_info;
- struct we_wmi_logon_counters *wmi_logon;
- struct we_wmi_system_counters *wmi_system;
- struct we_wmi_service_counters *wmi_service;
- struct we_wmi_memory_counters *wmi_memory;
- struct we_wmi_paging_file_counters *wmi_paging_file;
- struct we_wmi_process_counters *wmi_process;
-};
-
-typedef int (*collector_cb)(struct flb_we *);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.c
deleted file mode 100644
index 14913b433..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_pack.h>
-#include "we.h"
-
-struct flb_we *flb_we_config_create(struct flb_input_instance *ins,
- struct flb_config *config)
-{
- int ret;
- struct flb_we *ctx;
- int root_type;
-
- ctx = flb_calloc(1, sizeof(struct flb_we));
- if (!ctx) {
- flb_errno();
- return NULL;
- }
- ctx->ins = ins;
- ctx->allowing_disk_regex = NULL;
- ctx->denying_disk_regex = NULL;
- ctx->allowing_nic_regex = NULL;
- ctx->service_include_buffer = NULL;
- ctx->service_include_buffer_size = 0;
- ctx->service_exclude_buffer = NULL;
- ctx->service_exclude_buffer_size = 0;
- ctx->allowing_process_regex = NULL;
- ctx->denying_process_regex = NULL;
-
- /* Load the config map */
- ret = flb_input_config_map_set(ins, (void *) ctx);
- if (ret == -1) {
- flb_free(ctx);
- return NULL;
- }
-
- /* Process allow/deny regex rules */
- if (ctx->raw_allowing_disk != NULL) {
- ctx->allowing_disk_regex = flb_regex_create(ctx->raw_allowing_disk);
- }
-
- if (ctx->raw_denying_disk != NULL) {
- ctx->denying_disk_regex = flb_regex_create(ctx->raw_denying_disk);
- }
-
- if (ctx->raw_allowing_nic != NULL) {
- ctx->allowing_nic_regex = flb_regex_create(ctx->raw_allowing_nic);
- }
-
- if (ctx->raw_service_include != NULL) {
- ret = flb_pack_json(ctx->raw_service_include,
- strlen(ctx->raw_service_include),
- &ctx->service_include_buffer,
- &ctx->service_include_buffer_size,
- &root_type,
- NULL);
- if (ret != 0) {
- flb_plg_warn(ctx->ins, "we.service.include is incomplete. Ignored.");
- ctx->service_include_buffer = NULL;
- ctx->service_include_buffer_size = 0;
- }
- }
-
- if (ctx->raw_service_exclude != NULL) {
- ret = flb_pack_json(ctx->raw_service_exclude,
- strlen(ctx->raw_service_exclude),
- &ctx->service_exclude_buffer,
- &ctx->service_exclude_buffer_size,
- &root_type,
- NULL);
- if (ret != 0) {
- flb_plg_warn(ctx->ins, "we.service.exclude is incomplete. Ignored.");
- ctx->service_exclude_buffer = NULL;
- ctx->service_exclude_buffer_size = 0;
- }
- }
-
- /* Process allow/deny regex rules for process metrics */
- if (ctx->raw_allowing_process != NULL) {
- ctx->allowing_process_regex = flb_regex_create(ctx->raw_allowing_process);
- }
-
- if (ctx->raw_denying_process != NULL) {
- ctx->denying_process_regex = flb_regex_create(ctx->raw_denying_process);
- }
-
- ctx->cmt = cmt_create();
- if (!ctx->cmt) {
- flb_plg_error(ins, "could not initialize CMetrics");
- flb_free(ctx);
- return NULL;
- }
-
- return ctx;
-}
-
-void flb_we_config_destroy(struct flb_we *ctx)
-{
- if (!ctx) {
- return;
- }
-
- if (ctx->allowing_disk_regex != NULL) {
- flb_regex_destroy(ctx->allowing_disk_regex);
- }
-
- if (ctx->denying_disk_regex != NULL) {
- flb_regex_destroy(ctx->denying_disk_regex);
- }
-
- if (ctx->allowing_nic_regex != NULL) {
- flb_regex_destroy(ctx->allowing_nic_regex);
- }
-
- if (ctx->service_include_buffer != NULL) {
- flb_free(ctx->service_include_buffer);
- }
-
- if (ctx->service_exclude_buffer != NULL) {
- flb_free(ctx->service_exclude_buffer);
- }
-
- if (ctx->allowing_process_regex != NULL) {
- flb_regex_destroy(ctx->allowing_process_regex);
- }
-
- if (ctx->denying_disk_regex != NULL) {
- flb_regex_destroy(ctx->denying_disk_regex);
- }
-
- if (ctx->cmt) {
- cmt_destroy(ctx->cmt);
- }
-
- flb_free(ctx);
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.h
deleted file mode 100644
index 00eea3ebe..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_config.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_CONFIG_H
-#define FLB_WE_CONFIG_H
-
-#include <fluent-bit/flb_input_plugin.h>
-#include "we.h"
-
-struct flb_we *flb_we_config_create(struct flb_input_instance *ins,
- struct flb_config *config);
-
-void flb_we_config_destroy(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.c
deleted file mode 100644
index d6013d797..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include <float.h>
-
-#include "we.h"
-#include "we_cpu.h"
-#include "we_util.h"
-#include "we_metric.h"
-#include "we_perflib.h"
-
-
-struct we_perflib_metric_source basic_metric_sources[] = {
- WE_PERFLIB_METRIC_SOURCE("cstate_seconds_total",
- "% C1 Time",
- "c1"),
-
- WE_PERFLIB_METRIC_SOURCE("cstate_seconds_total",
- "% C2 Time",
- "c2"),
-
- WE_PERFLIB_METRIC_SOURCE("cstate_seconds_total",
- "% C3 Time",
- "c3"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% Idle Time",
- "idle"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% Interrupt Time",
- "interrupt"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% DPC Time",
- "dpc"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% Privileged Time",
- "privileged"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% User Time",
- "user"),
-
- WE_PERFLIB_METRIC_SOURCE("interrupts_total",
- "Interrupts/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("dpcs_total",
- "DPCs Queued/sec",
- NULL),
-
- WE_PERFLIB_TERMINATOR_SOURCE()
- };
-
-
-struct we_perflib_metric_source full_metric_sources[] = {
- WE_PERFLIB_METRIC_SOURCE("cstate_seconds_total",
- "% C1 Time",
- "c1"),
-
- WE_PERFLIB_METRIC_SOURCE("cstate_seconds_total",
- "% C2 Time",
- "c2"),
-
- WE_PERFLIB_METRIC_SOURCE("cstate_seconds_total",
- "% C3 Time",
- "c3"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% Idle Time",
- "idle"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% Interrupt Time",
- "interrupt"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% DPC Time",
- "dpc"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% Privileged Time",
- "privileged"),
-
- WE_PERFLIB_METRIC_SOURCE("time_total",
- "% User Time",
- "user"),
-
- WE_PERFLIB_METRIC_SOURCE("interrupts_total",
- "Interrupts/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("dpcs_total",
- "DPCs Queued/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("clock_interrupts_total",
- "Clock Interrupts/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("idle_break_events_total",
- "Idle Break Events/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("parkings_status",
- "Parking Status",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("core_frequency_mhz",
- "Processor Frequency",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("processor_performance",
- "% Processor Performance",
- NULL),
-
- WE_PERFLIB_TERMINATOR_SOURCE()
- };
-
-struct we_perflib_metric_spec full_metric_specs[] =
- {
- WE_PERFLIB_COUNTER_SPEC("cstate_seconds_total",
- "Time spent in low-power idle state.",
- "core,state"),
-
- WE_PERFLIB_COUNTER_SPEC("time_total",
- "Time that processor spent in different " \
- "modes (idle, user, system, ...)",
- "core,mode"),
-
- WE_PERFLIB_COUNTER_SPEC("interrupts_total",
- "Total number of received and serviced " \
- "hardware interrupts",
- "core"),
-
- WE_PERFLIB_COUNTER_SPEC("dpcs_total",
- "Total number of received and serviced " \
- "deferred procedure calls (DPCs)",
- "core"),
-
- WE_PERFLIB_COUNTER_SPEC("clock_interrupts_total",
- "Total number of received and serviced " \
- "clock tick interrupts",
- "core"),
-
- WE_PERFLIB_COUNTER_SPEC("idle_break_events_total",
- "Total number of time processor was woken " \
- "from idle",
- "core"),
-
- WE_PERFLIB_GAUGE_SPEC("parkings_status",
- "Parking Status represents whether a " \
- "processor is parked or not",
- "core"),
-
- WE_PERFLIB_GAUGE_SPEC("core_frequency_mhz",
- "Core frequency in megahertz",
- "core"),
-
- WE_PERFLIB_GAUGE_SPEC("processor_performance",
- "Processor Performance is the average " \
- "performance of the processor while it is " \
- "executing instructions, as a percentage of" \
- " the nominal performance of the processor." \
- " On some processors, Processor Performance" \
- " may exceed 100%",
- "core"),
-
- WE_PERFLIB_TERMINATOR_SPEC()
- };
-
-
-int we_cpu_init(struct flb_we *ctx)
-{
- struct we_perflib_metric_source *metric_sources;
- int result;
-
- ctx->cpu.operational = FLB_FALSE;
-
- ctx->cpu.metrics = flb_hash_table_create(FLB_HASH_TABLE_EVICT_NONE, 64, 128);
-
- if (ctx->cpu.metrics == NULL) {
- flb_plg_error(ctx->ins, "could not create metrics hash table");
-
- return -1;
- }
-
- result = we_initialize_perflib_metric_specs(ctx->cmt,
- ctx->cpu.metrics,
- "windows",
- "cpu",
- &ctx->cpu.metric_specs,
- full_metric_specs);
-
- if (result != 0) {
- flb_plg_error(ctx->ins, "could not initialize metric specs");
-
- return -2;
- }
-
- if (fabsf(ctx->windows_version - 6.05) > FLT_EPSILON) {
- metric_sources = full_metric_sources;
- ctx->cpu.query = (char *) "Processor Information";
- }
- else {
- metric_sources = basic_metric_sources;
- ctx->cpu.query = (char *) "Processor";
- }
-
- result = we_initialize_perflib_metric_sources(ctx->cpu.metrics,
- &ctx->cpu.metric_sources,
- metric_sources);
-
- if (result != 0) {
- flb_plg_error(ctx->ins, "could not initialize metric sources");
-
- we_deinitialize_perflib_metric_specs(ctx->cpu.metric_specs);
- flb_free(ctx->cpu.metric_specs);
-
- return -3;
- }
-
- ctx->cpu.operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_cpu_exit(struct flb_we *ctx)
-{
- we_deinitialize_perflib_metric_sources(ctx->cpu.metric_sources);
- we_deinitialize_perflib_metric_specs(ctx->cpu.metric_specs);
-
- flb_free(ctx->cpu.metric_sources);
- flb_free(ctx->cpu.metric_specs);
-
- ctx->cpu.operational = FLB_FALSE;
-
- return 0;
-}
-
-int we_cpu_instance_hook(char *instance_name, struct flb_we *ctx)
-{
- return (strcasestr(instance_name, "Total") != NULL);
-}
-
-int we_cpu_label_prepend_hook(char **label_list,
- size_t label_list_size,
- size_t *label_count,
- struct we_perflib_metric_source *metric_source,
- char *instance_name,
- struct we_perflib_counter *counter)
-{
- if (label_count == NULL) {
- return -1;
- }
-
- if (*label_count >= label_list_size) {
- return -2;
- }
-
- label_list[(*label_count)++] = instance_name;
-
- return 0;
-}
-
-int we_cpu_update(struct flb_we *ctx)
-{
- if (!ctx->cpu.operational) {
- flb_plg_error(ctx->ins, "cpu collector not yet in operational state");
-
- return -1;
- }
-
- return we_perflib_update_counters(ctx,
- ctx->cpu.query,
- ctx->cpu.metric_sources,
- we_cpu_instance_hook,
- we_cpu_label_prepend_hook);
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.h
deleted file mode 100644
index f2b040977..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cpu.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_CPU_H
-#define FLB_WE_CPU_H
-
-#include "we.h"
-
-int we_cpu_init(struct flb_we *ctx);
-int we_cpu_exit(struct flb_we *ctx);
-int we_cpu_update(struct flb_we *ctx);
-
-#endif \ No newline at end of file
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.c
deleted file mode 100644
index 9ed4a1ca1..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_cs.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-int we_cs_init(struct flb_we *ctx)
-{
- ctx->cs.operational = FLB_FALSE;
-
- struct cmt_gauge *g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "cs", "logical_processors",
- "Number of logical processors",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->cs.logical_processors = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "cs", "physical_memory_bytes",
- "Amount of bytes of physical memory",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->cs.physical_memory_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "cs", "hostname",
- "Value of Local Time",
- 3, (char *[]) {"hostname", "domain", "fqdn"});
- if (!g) {
- return -1;
- }
- ctx->cs.hostname = g;
-
- ctx->cs.operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_cs_exit(struct flb_we *ctx)
-{
- return 0;
-}
-
-int we_cs_update(struct flb_we *ctx)
-{
- SYSTEM_INFO system_info;
- MEMORYSTATUSEX statex;
- char hostname[256] = "", domain[256] = "", fqdn[256] = "";
- DWORD size = 0;
- uint64_t timestamp = 0;
-
- if (!ctx->cs.operational) {
- flb_plg_error(ctx->ins, "cs collector not yet in operational state");
-
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- statex.dwLength = sizeof (statex);
- GlobalMemoryStatusEx(&statex);
-
- GetSystemInfo(&system_info);
-
- size = _countof(hostname);
- if (!GetComputerNameExA(ComputerNameDnsHostname, hostname, &size)) {
- flb_plg_warn(ctx->ins, "Failed to retrieve hostname info");
- }
- size = _countof(domain);
- if (!GetComputerNameExA(ComputerNameDnsDomain, domain, &size)) {
- flb_plg_warn(ctx->ins, "Failed to retrieve domain info");
- }
- size = _countof(fqdn);
- if (!GetComputerNameExA(ComputerNameDnsFullyQualified, fqdn, &size)) {
- flb_plg_warn(ctx->ins, "Failed to retrieve fqdn info");
- }
-
- cmt_gauge_set(ctx->cs.logical_processors, timestamp, (double)system_info.dwNumberOfProcessors, 0, NULL);
- cmt_gauge_set(ctx->cs.physical_memory_bytes, timestamp, (double)statex.ullTotalPhys, 0, NULL);
- cmt_gauge_set(ctx->cs.hostname, timestamp, 1.0, 3, (char *[]) { hostname, domain, fqdn });
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.h
deleted file mode 100644
index 111672891..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_cs.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_CS_H
-#define FLB_WE_CS_H
-
-#include "we.h"
-
-int we_cs_init(struct flb_we *ctx);
-int we_cs_exit(struct flb_we *ctx);
-int we_cs_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.c
deleted file mode 100644
index df2e09c41..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_logical_disk.h"
-#include "we_util.h"
-#include "we_metric.h"
-#include "we_perflib.h"
-
-
-struct we_perflib_metric_source logical_disk_metric_sources[] = {
- WE_PERFLIB_METRIC_SOURCE("requests_queued",
- "Current Disk Queue Length",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("read_bytes_total",
- "Disk Read Bytes/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("read_total",
- "Disk Reads/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("write_bytes_total",
- "Disk Write Bytes/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("write_total",
- "Disk Writes/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("read_seconds_total",
- "% Disk Read Time",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("write_seconds_total",
- "% Disk Write Time",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("free_megabytes",
- "Free Megabytes",
- NULL),
-
- /* FIXME: Prometheus windows exporter uses '% Free Space_Base' as
- * query for size_(mega)bytes metrics, but it does not work. */
- /* WE_PERFLIB_METRIC_SOURCE("size_megabytes", */
- /* "% Free Space_Base", */
- /* NULL), */
-
- WE_PERFLIB_METRIC_SOURCE("idle_seconds_total",
- "% Idle Time",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("split_ios_total",
- "Split IO/Sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("read_latency_seconds_total",
- "Avg. Disk sec/Read",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("write_latency_seconds_total",
- "Avg. Disk sec/Write",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("read_write_latency_seconds_total",
- "Avg. Disk sec/Transfer",
- NULL),
-
- WE_PERFLIB_TERMINATOR_SOURCE()
- };
-
-struct we_perflib_metric_spec logical_disk_metric_specs[] = {
- WE_PERFLIB_GAUGE_SPEC("requests_queued",
- "Number of queued requests on the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("read_bytes_total",
- "Number of read bytes from the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("read_total",
- "Number of read from the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("write_bytes_total",
- "Number of write bytes to the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("write_total",
- "Number of write from to disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("read_seconds_total",
- "Total amount of reading time from the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("write_seconds_total",
- "Total amount of writeing time to the disk",
- "volume"),
-
- WE_PERFLIB_GAUGE_SPEC("free_megabytes",
- "Free megabytes on the disk",
- "volume"),
-
- /* WE_PERFLIB_COUNTER_SPEC("size_megabytes", */
- /* "Total amount of free megabytes on the disk", */
- /* "volume"), */
-
- WE_PERFLIB_COUNTER_SPEC("idle_seconds_total",
- "Total amount of idling time on the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("split_ios_total",
- "Total amount of split I/O operations on the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("read_latency_seconds_total",
- "Average latency, in seconds, to read from the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("write_latency_seconds_total",
- "Average latency, in seconds, to write into the disk",
- "volume"),
-
- WE_PERFLIB_COUNTER_SPEC("read_write_latency_seconds_total",
- "Average latency, in seconds, to transfer operations on the disk",
- "volume"),
-
- WE_PERFLIB_TERMINATOR_SPEC()
- };
-
-
-int we_logical_disk_init(struct flb_we *ctx)
-{
- struct we_perflib_metric_source *metric_sources;
- int result;
-
- ctx->logical_disk.operational = FLB_FALSE;
-
- ctx->logical_disk.metrics = flb_hash_table_create(FLB_HASH_TABLE_EVICT_NONE, 32, 128);
-
- if (ctx->logical_disk.metrics == NULL) {
- flb_plg_error(ctx->ins, "could not create metrics hash table for logical_disk metrics");
-
- return -1;
- }
-
- result = we_initialize_perflib_metric_specs(ctx->cmt,
- ctx->logical_disk.metrics,
- "windows",
- "logical_disk",
- &ctx->logical_disk.metric_specs,
- logical_disk_metric_specs);
-
- if (result != 0) {
- flb_plg_error(ctx->ins, "could not initialize logical_disk metric specs");
-
- return -2;
- }
-
- ctx->logical_disk.query = (char *) "LogicalDisk";
-
- result = we_initialize_perflib_metric_sources(ctx->logical_disk.metrics,
- &ctx->logical_disk.metric_sources,
- logical_disk_metric_sources);
-
- if (result != 0) {
- flb_plg_error(ctx->ins, "could not initialize logical_disk metric sources");
-
- we_deinitialize_perflib_metric_specs(ctx->logical_disk.metric_specs);
- flb_free(ctx->logical_disk.metric_specs);
-
- return -3;
- }
-
- ctx->logical_disk.operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_logical_disk_exit(struct flb_we *ctx)
-{
- we_deinitialize_perflib_metric_sources(ctx->logical_disk.metric_sources);
- we_deinitialize_perflib_metric_specs(ctx->logical_disk.metric_specs);
-
- flb_free(ctx->logical_disk.metric_sources);
- flb_free(ctx->logical_disk.metric_specs);
-
- ctx->logical_disk.operational = FLB_FALSE;
-
- return 0;
-}
-
-static int logical_disk_regex_match(struct flb_regex *regex, char *instance_name)
-{
- if (regex == NULL) {
- return 0;
- }
- return flb_regex_match(regex, instance_name, strlen(instance_name));
-}
-
-
-int we_logical_disk_instance_hook(char *instance_name, struct flb_we *ctx)
-{
- if (strcasestr(instance_name, "Total") != NULL) {
- return 1;
- }
- if (logical_disk_regex_match(ctx->denying_disk_regex, instance_name) ||
- !logical_disk_regex_match(ctx->allowing_disk_regex, instance_name)) {
- return 1;
- }
-
- return 0;
-}
-
-int we_logical_disk_label_prepend_hook(char **label_list,
- size_t label_list_size,
- size_t *label_count,
- struct we_perflib_metric_source *metric_source,
- char *instance_name,
- struct we_perflib_counter *counter)
-{
- if (label_count == NULL) {
- return -1;
- }
-
- if (*label_count >= label_list_size) {
- return -2;
- }
-
- label_list[(*label_count)++] = instance_name;
-
- return 0;
-}
-
-int we_logical_disk_update(struct flb_we *ctx)
-{
- if (!ctx->logical_disk.operational) {
- flb_plg_error(ctx->ins, "logical_disk collector not yet in operational state");
-
- return -1;
- }
-
- return we_perflib_update_counters(ctx,
- ctx->logical_disk.query,
- ctx->logical_disk.metric_sources,
- we_logical_disk_instance_hook,
- we_logical_disk_label_prepend_hook);
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.h
deleted file mode 100644
index d63678bae..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_logical_disk.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_LOGICAL_DISK_H
-#define FLB_WE_LOGICAL_DISK_H
-
-#include "we.h"
-
-int we_logical_disk_init(struct flb_we *ctx);
-int we_logical_disk_exit(struct flb_we *ctx);
-int we_logical_disk_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.c
deleted file mode 100644
index 3475cdad3..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_cpu.h"
-#include "we_util.h"
-#include "we_perflib.h"
-
-static int we_expand_perflib_label_set(char *input_raw_label_set,
- char ***output_label_set,
- size_t *output_label_set_size)
-{
- flb_sds_t raw_label_set;
- size_t label_index;
- size_t label_count;
- char *label_name;
- char **label_set;
- int result;
-
- raw_label_set = flb_sds_create(input_raw_label_set);
-
- if (raw_label_set == NULL) {
- return -1;
- }
-
- label_count = 0;
- label_name = (char *) raw_label_set;
-
- while (label_name != NULL) {
- result = mk_string_char_search(label_name, ',', -1);
-
- if (result != -1) {
- label_name[result] = '\0';
- label_name = &label_name[result + 1];
- }
- else {
- label_name = NULL;
- }
-
- label_count++;
- }
-
- label_set = (char **) flb_calloc(label_count, sizeof(char *));
-
- if (label_set == NULL) {
- flb_sds_destroy(raw_label_set);
-
- return -2;
- }
-
- label_name = (char *) raw_label_set;
-
- for (label_index = 0 ; label_index < label_count ; label_index++) {
- label_set[label_index] = label_name;
- label_name = &label_name[strlen(label_name) + 1];
- }
-
- *output_label_set = label_set;
- *output_label_set_size = label_count;
-
- return 0;
-}
-
-static int we_expand_perflib_metric_source_labels(
- struct we_perflib_metric_source *source)
-{
- source->label_set_size = 0;
- source->label_set = NULL;
-
- if (source->raw_label_set == NULL) {
- return 0;
- }
-
- return we_expand_perflib_label_set(source->raw_label_set,
- &source->label_set,
- &source->label_set_size);
-}
-
-static int we_expand_perflib_metric_spec_labels(
- struct we_perflib_metric_spec *spec)
-{
- spec->label_set_size = 0;
- spec->label_set = NULL;
-
- if (spec->raw_label_set == NULL) {
- return 0;
- }
-
- return we_expand_perflib_label_set(spec->raw_label_set,
- &spec->label_set,
- &spec->label_set_size);
-}
-
-static int we_match_perflib_metric_source_to_parent(
- struct flb_hash_table *lookup_table,
- struct we_perflib_metric_source *source)
-{
- struct we_perflib_metric_spec *spec;
-
- spec = flb_hash_table_get_ptr(lookup_table,
- source->parent_name,
- strlen(source->parent_name));
-
- if (spec == NULL) {
- return -1;
- }
-
- source->parent = spec;
-
- return 0;
-}
-
-static int we_create_perflib_metric_instance(
- struct cmt *context,
- struct flb_hash_table *lookup_table,
- char *namespace,
- char *subsystem,
- struct we_perflib_metric_spec *spec)
-{
- void *metric_instance;
- int result;
-
- if (spec->type == CMT_COUNTER) {
- metric_instance = (void *) cmt_counter_create(context,
- namespace,
- subsystem,
- spec->name,
- spec->description,
- spec->label_set_size,
- spec->label_set);
- if (metric_instance == NULL) {
- return -1;
- }
- }
- else if (spec->type == CMT_GAUGE) {
- metric_instance = (void *) cmt_gauge_create(context,
- namespace,
- subsystem,
- spec->name,
- spec->description,
- spec->label_set_size,
- spec->label_set);
-
- if (metric_instance == NULL) {
- return -2;
- }
- }
- else {
- return -3;
- }
-
- result = flb_hash_table_add(lookup_table,
- spec->name,
- strlen(spec->name),
- spec,
- 0);
-
- if (result < 0) {
- if (spec->type == CMT_COUNTER) {
- cmt_counter_destroy(metric_instance);
- }
- else {
- cmt_gauge_destroy(metric_instance);
- }
-
- return -4;
- }
-
- spec->metric_instance = metric_instance;
-
- return 0;
-}
-
-void we_deinitialize_perflib_metric_sources(struct we_perflib_metric_source *sources)
-{
- size_t source_index;
-
- for (source_index = 0 ;
- sources[source_index].name != NULL;
- source_index++) {
- if (sources[source_index].label_set_size) {
- flb_sds_destroy(sources[source_index].label_set[0]);
- flb_free(sources[source_index].label_set);
- }
- }
-}
-
-int we_initialize_perflib_metric_sources(
- struct flb_hash_table *lookup_table,
- struct we_perflib_metric_source **out_sources,
- struct we_perflib_metric_source *in_sources)
-{
- size_t source_array_size;
- struct we_perflib_metric_source *source_array_copy;
- struct we_perflib_metric_spec *source_entry;
- size_t source_index;
- size_t source_count;
- int result;
-
- if (out_sources == NULL) {
- return -1;
- }
-
- if (in_sources == NULL) {
- return -2;
- }
-
- source_count = 0;
-
- while (in_sources[source_count].name != NULL) {
- source_count++;
- }
-
- if (source_count == 0) {
- return -3;
- }
-
- source_array_size = sizeof(struct we_perflib_metric_source);
- source_array_size *= (source_count + 1);
-
- source_array_copy = (struct we_perflib_metric_spec *) flb_calloc(1, source_array_size);
-
- if (source_array_copy == NULL) {
- return -4;
- }
-
- memcpy(source_array_copy, in_sources, source_array_size);
-
- for (source_index = 0 ; source_index < source_count; source_index++) {
- source_entry = &source_array_copy[source_index];
-
- result = we_expand_perflib_metric_source_labels(source_entry);
-
- if (result != 0) {
- we_deinitialize_perflib_metric_sources(source_array_copy);
- flb_free(source_array_copy);
-
- return -5;
- }
-
- result = we_match_perflib_metric_source_to_parent(lookup_table,
- source_entry);
-
- if (result != 0) {
- we_deinitialize_perflib_metric_sources(source_array_copy);
- flb_free(source_array_copy);
-
- return -6;
- }
- }
-
- *out_sources = source_array_copy;
-
- return 0;
-}
-
-void we_deinitialize_perflib_metric_specs(struct we_perflib_metric_spec *specs)
-{
- size_t spec_index;
-
- for (spec_index = 0 ;
- specs[spec_index].name != NULL;
- spec_index++) {
- if (specs[spec_index].label_set_size) {
- flb_sds_destroy(specs[spec_index].label_set[0]);
- flb_free(specs[spec_index].label_set);
- }
- }
-}
-
-int we_initialize_perflib_metric_specs(
- struct cmt *context,
- struct flb_hash_table *lookup_table,
- char *namespace,
- char *subsystem,
- struct we_perflib_metric_spec **out_specs,
- struct we_perflib_metric_spec *in_specs)
-{
- size_t spec_array_size;
- struct we_perflib_metric_spec *spec_array_copy;
- struct we_perflib_metric_spec *spec_entry;
- size_t spec_index;
- size_t spec_count;
- int result;
-
- if (out_specs == NULL) {
- return -1;
- }
-
- if (in_specs == NULL) {
- return -2;
- }
-
- spec_count = 0;
-
- while (in_specs[spec_count].name != NULL) {
- spec_count++;
- }
-
- if (spec_count == 0) {
- return -3;
- }
-
- spec_array_size = sizeof(struct we_perflib_metric_spec);
- spec_array_size *= spec_count + 1;
-
- spec_array_copy = (struct we_perflib_metric_spec *) flb_calloc(1, spec_array_size);
-
- if (spec_array_copy == NULL) {
- return -4;
- }
-
- memcpy(spec_array_copy, in_specs, spec_array_size);
-
- for (spec_index = 0 ; spec_index < spec_count; spec_index++) {
- spec_entry = &spec_array_copy[spec_index];
-
- result = we_expand_perflib_metric_spec_labels(spec_entry);
-
- if (result) {
- we_deinitialize_perflib_metric_specs(spec_array_copy);
- flb_free(spec_array_copy);
-
- return -5;
- }
-
- result = we_create_perflib_metric_instance(context,
- lookup_table,
- namespace,
- subsystem,
- spec_entry);
-
- if (result) {
- we_deinitialize_perflib_metric_specs(spec_array_copy);
- flb_free(spec_array_copy);
-
- return -6;
- }
- }
-
- *out_specs = spec_array_copy;
-
- return 0;
-}
-
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.h
deleted file mode 100644
index 7c9611a69..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_metric.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_METRIC_H
-#define FLB_METRIC_H
-
-#include <fluent-bit/flb_info.h>
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_hash_table.h>
-#include <fluent-bit/flb_metrics.h>
-
-struct we_perflib_metric_spec {
- int type;
- char *name;
- char *description;
- char *raw_label_set;
- char **label_set;
- size_t label_set_size;
- void *metric_instance;
-};
-
-struct we_perflib_metric_source {
- struct we_perflib_metric_spec *parent;
- char *parent_name;
- char *name;
- char *raw_label_set;
- char **label_set;
- size_t label_set_size;
-};
-
-#define WE_PERFLIB_SPEC(type_, name_, description_, raw_label_set_) \
- { \
- .type = type_, \
- .name = name_, \
- .description = description_, \
- .raw_label_set = raw_label_set_, \
- .label_set = NULL, \
- .label_set_size = 0, \
- .metric_instance = NULL \
- }
-
-#define WE_PERFLIB_COUNTER_SPEC(name_, description_, raw_label_set_) \
- WE_PERFLIB_SPEC(CMT_COUNTER, name_, description_, raw_label_set_)
-
-#define WE_PERFLIB_GAUGE_SPEC(name_, description_, raw_label_set_) \
- WE_PERFLIB_SPEC(CMT_GAUGE, name_, description_, raw_label_set_)
-
-#define WE_PERFLIB_TERMINATOR_SPEC() \
- WE_PERFLIB_SPEC(0, NULL, NULL, NULL)
-
-#define WE_PERFLIB_METRIC_SOURCE(parent_name_, name_, raw_label_set_) \
- { \
- .parent = NULL, \
- .parent_name = parent_name_, \
- .name = name_, \
- .raw_label_set = raw_label_set_, \
- .label_set = NULL, \
- .label_set_size = 0 \
- }
-
-#define WE_PERFLIB_TERMINATOR_SOURCE() \
- WE_PERFLIB_METRIC_SOURCE(NULL, NULL, NULL)
-
-
-void we_deinitialize_perflib_metric_sources(struct we_perflib_metric_source *sources);
-int we_initialize_perflib_metric_sources(
- struct flb_hash *lookup_table,
- struct we_perflib_metric_source **out_sources,
- struct we_perflib_metric_source *in_sources);
-
-
-void we_deinitialize_perflib_metric_specs(struct we_perflib_metric_spec *specs);
-int we_initialize_perflib_metric_specs(
- struct cmt *context,
- struct flb_hash *lookup_table,
- char *namespace,
- char *subsystem,
- struct we_perflib_metric_spec **out_specs,
- struct we_perflib_metric_spec *in_specs);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.c
deleted file mode 100644
index 673d665e8..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_net.h"
-#include "we_util.h"
-#include "we_metric.h"
-#include "we_perflib.h"
-
-
-struct we_perflib_metric_source net_metric_sources[] = {
- WE_PERFLIB_METRIC_SOURCE("bytes_received_total",
- "Bytes Received/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("bytes_sent_total",
- "Bytes Sent/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("bytes_total",
- "Bytes Total/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_outbound_discarded_total",
- "Packets Outbound Discarded",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_outbound_errors_total",
- "Packets Outbound Errors",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_received_discarded_total",
- "Packets Received Discarded",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_received_errors_total",
- "Packets Received Errors",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_received_total",
- "Packets Received/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_received_unknown_total",
- "Packets Received Unknown",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_total",
- "Packets/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("packets_sent_total",
- "Packets Sent/sec",
- NULL),
-
- WE_PERFLIB_METRIC_SOURCE("current_bandwidth_bits",
- "Current Bandwidth",
- NULL),
-
- WE_PERFLIB_TERMINATOR_SOURCE()
- };
-
-struct we_perflib_metric_spec net_metric_specs[] = {
- WE_PERFLIB_COUNTER_SPEC("bytes_received_total",
- "Total amount of received bytes",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("bytes_sent_total",
- "Total amount of sent bytes",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("bytes_total",
- "Total amount of bytes",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_outbound_discarded_total",
- "Total amount of outbound discarded bytes",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_outbound_errors_total",
- "Total number of outbound errors",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_received_discarded_total",
- "Total amount of received discarded bytes",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_received_errors_total",
- "Total number of received packets' errors",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_received_total",
- "Total number of received packets",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_received_unknown_total",
- "Total number of received unknown",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_total",
- "Total amount of packets",
- "nic"),
-
- WE_PERFLIB_COUNTER_SPEC("packets_sent_total",
- "Total amount of sent packets",
- "nic"),
-
- WE_PERFLIB_GAUGE_SPEC("current_bandwidth_bits",
- "Current Bandwidth /bits",
- "nic"),
-
- WE_PERFLIB_TERMINATOR_SPEC()
- };
-
-
-int we_net_init(struct flb_we *ctx)
-{
- struct we_perflib_metric_source *metric_sources;
- int result;
-
- ctx->net.operational = FLB_FALSE;
-
- ctx->net.metrics = flb_hash_table_create(FLB_HASH_TABLE_EVICT_NONE, 32, 128);
-
- if (ctx->net.metrics == NULL) {
- flb_plg_error(ctx->ins, "could not create metrics hash table");
-
- return -1;
- }
-
- result = we_initialize_perflib_metric_specs(ctx->cmt,
- ctx->net.metrics,
- "windows",
- "net",
- &ctx->net.metric_specs,
- net_metric_specs);
-
- if (result != 0) {
- flb_plg_error(ctx->ins, "could not initialize net metric specs");
-
- return -2;
- }
-
- ctx->net.query = (char *) "Network Interface";
-
- result = we_initialize_perflib_metric_sources(ctx->net.metrics,
- &ctx->net.metric_sources,
- net_metric_sources);
-
- if (result != 0) {
- flb_plg_error(ctx->ins, "could not initialize net metric sources");
-
- we_deinitialize_perflib_metric_specs(ctx->net.metric_specs);
- flb_free(ctx->net.metric_specs);
-
- return -3;
- }
-
- ctx->net.operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_net_exit(struct flb_we *ctx)
-{
- we_deinitialize_perflib_metric_sources(ctx->net.metric_sources);
- we_deinitialize_perflib_metric_specs(ctx->net.metric_specs);
-
- flb_free(ctx->net.metric_sources);
- flb_free(ctx->net.metric_specs);
-
- ctx->net.operational = FLB_FALSE;
-
- return 0;
-}
-
-static int net_regex_match(struct flb_regex *regex, char *instance_name)
-{
- if (regex == NULL) {
- return 0;
- }
- return flb_regex_match(regex, instance_name, strlen(instance_name));
-}
-
-int we_net_instance_hook(char *instance_name, struct flb_we *ctx)
-{
- if (strcasestr(instance_name, "Total") != NULL) {
- return 1;
- }
-
- if (!net_regex_match(ctx->allowing_nic_regex, instance_name)) {
- return 1;
- }
-
- return 0;
-}
-
-int we_net_label_prepend_hook(char **label_list,
- size_t label_list_size,
- size_t *label_count,
- struct we_perflib_metric_source *metric_source,
- char *instance_name,
- struct we_perflib_counter *counter)
-{
- if (label_count == NULL) {
- return -1;
- }
-
- if (*label_count >= label_list_size) {
- return -2;
- }
-
- label_list[(*label_count)++] = instance_name;
-
- return 0;
-}
-
-int we_net_update(struct flb_we *ctx)
-{
- if (!ctx->net.operational) {
- flb_plg_error(ctx->ins, "net collector not yet in operational state");
-
- return -1;
- }
-
- return we_perflib_update_counters(ctx,
- ctx->net.query,
- ctx->net.metric_sources,
- we_net_instance_hook,
- we_net_label_prepend_hook);
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.h
deleted file mode 100644
index 52340ccfb..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_net.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_NET_H
-#define FLB_WE_NET_H
-
-#include "we.h"
-
-int we_net_init(struct flb_we *ctx);
-int we_net_exit(struct flb_we *ctx);
-int we_net_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.c
deleted file mode 100644
index 299514d8c..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#ifndef UNICODE
-#define UNICODE
-#endif
-#include <lm.h>
-#include <psapi.h>
-#include <timezoneapi.h>
-
-#include "we.h"
-#include "we_os.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-int we_os_init(struct flb_we *ctx)
-{
- ctx->os = flb_calloc(1, sizeof(struct we_os_counters));
- if (!ctx->os) {
- flb_errno();
- return -1;
- }
- ctx->os->operational = FLB_FALSE;
-
- struct cmt_gauge *g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "info",
- "Version information of OperatingSystem",
- 5, (char *[]) {"product", "version", "major_version", "minor_version", "build_number"});
-
- if (!g) {
- return -1;
- }
- ctx->os->info = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "physical_memory_free_bytes",
- "Amount of free bytes of physical memory",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->physical_memory_free_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "time",
- "Value of Local Time",
- 0, NULL);
- if (!g) {
- return -1;
- }
- ctx->os->time = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "timezone",
- "Name of Local Timezone",
- 1, (char *[]) {"timezone"});
- if (!g) {
- return -1;
- }
- ctx->os->tz = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "virtual_memory_bytes",
- "Total amount of bytes of virtual memory",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->virtual_memory_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "processes_limit",
- "Number of processes limit",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->processes_limit = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "process_memory_limit_bytes",
- "Limit of processes memory",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->process_memory_limit_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "processes",
- "Number of processes",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->processes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "users",
- "Number of users",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->users = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "visible_memory_bytes",
- "Total amount of bytes of visibile memory",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->visible_memory_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "os", "virtual_memory_free_bytes",
- "Amount of free bytes of virtual memory",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->os->virtual_memory_free_bytes = g;
-
- ctx->os->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_os_exit(struct flb_we *ctx)
-{
- flb_free(ctx->os);
- return 0;
-}
-
-int we_os_update(struct flb_we *ctx)
-{
- DWORD level = 102;
- LPWKSTA_INFO_102 wksta = NULL;
- NET_API_STATUS status;
- MEMORYSTATUSEX statex;
- PERFORMANCE_INFORMATION perf;
- DWORD size = 0;
- char version[65] = {0}, major[32] = {0}, minor[32] = {0};
- int users = 0;
- LONG ret;
- HKEY hkey;
- char caption[80], build_number[32];
- DWORD caption_len = sizeof(caption), build_len = sizeof(build_number);
- uint64_t timestamp = 0;
- char label_caption[90];
- TIME_ZONE_INFORMATION tzi;
- DWORD tztype = 0;
- char *displaytz;
-
- if (!ctx->os->operational) {
- flb_plg_error(ctx->ins, "os collector not yet in operational state");
-
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WE_OS_CURRENT_VERSION_PATH, 0, KEY_QUERY_VALUE, &hkey);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
- ret = RegQueryValueExA(hkey, "ProductName", NULL, NULL, (LPBYTE)caption, &caption_len);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
- ret = RegQueryValueExA(hkey, "CurrentBuildNumber", NULL, NULL, (LPBYTE)build_number, &build_len);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
- RegCloseKey(hkey);
-
- status = NetWkstaGetInfo(NULL,
- level,
- (LPBYTE *)&wksta);
-
- if (status == NERR_Success) {
- snprintf(version, 65, "%d.%d", wksta->wki102_ver_major,
- wksta->wki102_ver_minor);
- snprintf(major, 32, "%d", wksta->wki102_ver_major);
- snprintf(minor, 32, "%d", wksta->wki102_ver_minor);
- snprintf(label_caption, 90, "Microsoft %s", caption);
-
- users = wksta->wki102_logged_on_users;
-
- cmt_gauge_set(ctx->os->info, timestamp, 1.0, 5,
- (char *[]) { label_caption, version, major, minor, build_number});
- cmt_gauge_set(ctx->os->users, timestamp, (double)users, 0, NULL);
- }
- else {
- if (wksta != NULL) {
- NetApiBufferFree(wksta);
- }
- flb_plg_error(ctx->ins, "A system error has occurred: %d\n", status);
- return -1;
- }
-
- cmt_gauge_set(ctx->os->time, timestamp, (double)timestamp/1000000000L, 0, NULL);
-
- tztype = GetTimeZoneInformation(&tzi);
- switch (tztype) {
- case TIME_ZONE_ID_STANDARD:
- displaytz = we_convert_wstr(tzi.StandardName, CP_UTF8);
- cmt_gauge_set(ctx->os->tz, timestamp, 1.0, 1, (char *[]) {displaytz});
- flb_free(displaytz);
- break;
- case TIME_ZONE_ID_DAYLIGHT:
- displaytz = we_convert_wstr(tzi.DaylightName, CP_UTF8);
- cmt_gauge_set(ctx->os->tz, timestamp, 1.0, 1, (char *[]) {displaytz});
- flb_free(displaytz);
- break;
- case TIME_ZONE_ID_UNKNOWN:
- /* The current timezone does not use daylight saving time. */
- displaytz = we_convert_wstr(tzi.StandardName, CP_UTF8);
- cmt_gauge_set(ctx->os->tz, timestamp, 1.0, 1, (char *[]) {displaytz});
- flb_free(displaytz);
- break;
- default:
- flb_plg_error(ctx->ins, "Error to retrieve timezone information with status: %d", GetLastError());
- }
-
- statex.dwLength = sizeof (statex);
- GlobalMemoryStatusEx(&statex);
-
- size = sizeof(perf);
- GetPerformanceInfo(&perf, size);
-
- cmt_gauge_set(ctx->os->physical_memory_free_bytes, timestamp, (double)statex.ullAvailPhys, 0, NULL);
- cmt_gauge_set(ctx->os->virtual_memory_free_bytes, timestamp, (double)statex.ullAvailPageFile, 0, NULL);
- /* The result is from $(Get-WMIObject Win32_OperatingSystem).MaxNumberOfProcesses. */
- cmt_gauge_set(ctx->os->processes_limit, timestamp, (double)4294967295, 0, NULL);
- cmt_gauge_set(ctx->os->process_memory_limit_bytes, timestamp, (double)statex.ullTotalVirtual, 0, NULL);
- cmt_gauge_set(ctx->os->processes, timestamp, (double)perf.ProcessCount, 0, NULL);
- cmt_gauge_set(ctx->os->virtual_memory_bytes, timestamp, (double)statex.ullTotalPageFile, 0, NULL);
- cmt_gauge_set(ctx->os->visible_memory_bytes, timestamp, (double)statex.ullTotalPhys, 0, NULL);
-
- if (wksta != NULL) {
- NetApiBufferFree(wksta);
- }
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.h
deleted file mode 100644
index 6a62e6064..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_os.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_OS_H
-#define FLB_WE_OS_H
-
-#include "we.h"
-
-#define WE_OS_CURRENT_VERSION_PATH \
- "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
-
-int we_os_init(struct flb_we *ctx);
-int we_os_exit(struct flb_we *ctx);
-int we_os_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.c
deleted file mode 100644
index 0c140661d..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.c
+++ /dev/null
@@ -1,1048 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <fluent-bit/flb_sds.h>
-
-#include "we.h"
-#include "we_util.h"
-#include "we_metric.h"
-#include "we_perflib.h"
-
-double we_perflib_get_adjusted_counter_value(struct we_perflib_counter *counter)
-{
- double result;
-
- result = (double) counter->primary_value.as_qword;
-
- switch(counter->definition->type) {
- case PERF_ELAPSED_TIME:
- result -= counter->parent->parent->time;
- result /= counter->parent->parent->frequency;
- break;
-
- case PERF_100NSEC_TIMER:
- case PERF_PRECISION_100NS_TIMER:
- result /= counter->parent->parent->frequency;
- break;
- }
-
- return result;
-}
-
-char *we_perflib_get_counter_type_as_text(uint32_t counter_Type)
-{
- switch (counter_Type) {
- case PERF_100NSEC_TIMER:
- return "PERF_100NSEC_TIMER";
- case PERF_100NSEC_TIMER_INV:
- return "PERF_100NSEC_TIMER_INV";
- case PERF_100NSEC_MULTI_TIMER:
- return "PERF_100NSEC_MULTI_TIMER";
- case PERF_100NSEC_MULTI_TIMER_INV:
- return "PERF_100NSEC_MULTI_TIMER_INV";
- case PERF_AVERAGE_BASE:
- return "PERF_AVERAGE_BASE";
- case PERF_AVERAGE_BULK:
- return "PERF_AVERAGE_BULK";
- case PERF_AVERAGE_TIMER:
- return "PERF_AVERAGE_TIMER";
- case PERF_COUNTER_100NS_QUEUELEN_TYPE:
- return "PERF_COUNTER_100NS_QUEUELEN_TYPE";
- case PERF_COUNTER_BULK_COUNT:
- return "PERF_COUNTER_BULK_COUNT";
- case PERF_COUNTER_COUNTER:
- return "PERF_COUNTER_COUNTER";
- case PERF_COUNTER_DELTA:
- return "PERF_COUNTER_DELTA";
- case PERF_COUNTER_HISTOGRAM_TYPE:
- return "PERF_COUNTER_HISTOGRAM_TYPE";
- case PERF_COUNTER_LARGE_DELTA:
- return "PERF_COUNTER_LARGE_DELTA";
- case PERF_COUNTER_LARGE_QUEUELEN_TYPE:
- return "PERF_COUNTER_LARGE_QUEUELEN_TYPE";
- case PERF_COUNTER_LARGE_RAWCOUNT:
- return "PERF_COUNTER_LARGE_RAWCOUNT";
- case PERF_COUNTER_LARGE_RAWCOUNT_HEX:
- return "PERF_COUNTER_LARGE_RAWCOUNT_HEX";
- case PERF_COUNTER_MULTI_BASE:
- return "PERF_COUNTER_MULTI_BASE";
- case PERF_COUNTER_MULTI_TIMER:
- return "PERF_COUNTER_MULTI_TIMER";
- case PERF_COUNTER_MULTI_TIMER_INV:
- return "PERF_COUNTER_MULTI_TIMER_INV";
- case PERF_COUNTER_NODATA:
- return "PERF_COUNTER_NODATA";
- case PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE:
- return "PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE";
- case PERF_COUNTER_QUEUELEN_TYPE:
- return "PERF_COUNTER_QUEUELEN_TYPE";
- case PERF_COUNTER_RAWCOUNT:
- return "PERF_COUNTER_RAWCOUNT";
- case PERF_COUNTER_RAWCOUNT_HEX:
- return "PERF_COUNTER_RAWCOUNT_HEX";
- case PERF_COUNTER_TEXT:
- return "PERF_COUNTER_TEXT";
- case PERF_COUNTER_TIMER:
- return "PERF_COUNTER_TIMER";
- case PERF_COUNTER_TIMER_INV:
- return "PERF_COUNTER_TIMER_INV";
- case PERF_ELAPSED_TIME:
- return "PERF_ELAPSED_TIME";
- case PERF_LARGE_RAW_BASE:
- return "PERF_LARGE_RAW_BASE";
- case PERF_LARGE_RAW_FRACTION:
- return "PERF_LARGE_RAW_FRACTION";
- case PERF_OBJ_TIME_TIMER:
- return "PERF_OBJ_TIME_TIMER";
- case PERF_PRECISION_100NS_TIMER:
- return "PERF_PRECISION_100NS_TIMER";
- case PERF_PRECISION_OBJECT_TIMER:
- return "PERF_PRECISION_OBJECT_TIMER";
- case PERF_PRECISION_SYSTEM_TIMER:
- return "PERF_PRECISION_SYSTEM_TIMER";
- case PERF_RAW_BASE:
- return "PERF_RAW_BASE";
- case PERF_RAW_FRACTION:
- return "PERF_RAW_FRACTION";
- case PERF_SAMPLE_BASE:
- return "PERF_SAMPLE_BASE";
- case PERF_SAMPLE_COUNTER:
- return "PERF_SAMPLE_COUNTER";
- case PERF_SAMPLE_FRACTION:
- return "PERF_SAMPLE_FRACTION";
- };
-
- return "UNRECOGNIZED_COUNTER_TYPE";
-}
-
-void we_perflib_destroy_counter(struct we_perflib_counter *counter)
-{
- flb_free(counter);
-}
-
-void we_perflib_destroy_instance(struct we_perflib_instance *instance)
-{
- struct flb_hash_table_entry *counter_hash_entry;
- struct mk_list *counter_iterator;
- struct we_perflib_counter *counter;
- struct mk_list *tmp;
-
- mk_list_foreach_safe(counter_iterator,
- tmp,
- &instance->counters->entries) {
- counter_hash_entry = mk_list_entry(counter_iterator,
- struct flb_hash_table_entry,
- _head_parent);
-
- counter = (struct we_perflib_counter *) counter_hash_entry->val;
-
- we_perflib_destroy_counter(counter);
- }
-
- if (instance->name != NULL) {
- flb_free(instance->name);
- }
-
- flb_hash_table_destroy(instance->counters);
-
- flb_free(instance);
-}
-
-void we_perflib_destroy_counter_definition(
- struct we_perflib_counter_definition *definition)
-{
- flb_sds_destroy(definition->name_index_str);
-
- mk_list_del(&definition->_head);
-
- flb_free(definition);
-}
-
-void we_perflib_destroy_object(struct we_perflib_object *object)
-{
- struct mk_list *definition_iterator;
- struct flb_hash_table_entry *instance_hash_entry;
- struct mk_list *instance_iterator;
- struct we_perflib_counter_definition *definition;
- struct we_perflib_instance *instance;
- struct mk_list *tmp;
-
- mk_list_foreach_safe(definition_iterator, tmp, &object->counter_definitions) {
- definition = mk_list_entry(definition_iterator,
- struct we_perflib_counter_definition,
- _head);
-
- we_perflib_destroy_counter_definition(definition);
- }
-
- mk_list_foreach_safe(instance_iterator, tmp, &object->instances->entries) {
- instance_hash_entry = mk_list_entry(instance_iterator,
- struct flb_hash_table_entry,
- _head_parent);
-
- instance = (struct we_perflib_instance *) instance_hash_entry->val;
-
- we_perflib_destroy_instance(instance);
- }
-
- flb_hash_table_destroy(object->instances);
-
- flb_free(object);
-}
-
-static int get_string_list(char *source, flb_sds_t *out_result_buffer)
-{
- DWORD result_buffer_size;
- flb_sds_t result_buffer;
- LSTATUS result;
-
- result_buffer = NULL;
- result_buffer_size = 0;
-
- if (out_result_buffer == NULL) {
- return -1;
- }
-
- result = RegQueryValueExA(HKEY_PERFORMANCE_TEXT,
- source,
- NULL,
- NULL,
- NULL,
- &result_buffer_size);
-
- if (result != ERROR_SUCCESS) {
- return -2;
- }
-
- result_buffer = flb_sds_create_size(result_buffer_size);
-
- if (result_buffer == NULL) {
- return -3;
- }
-
- result = RegQueryValueExA(HKEY_PERFORMANCE_TEXT,
- source,
- NULL,
- NULL,
- (LPBYTE) result_buffer,
- &result_buffer_size);
-
- if (result != ERROR_SUCCESS)
- {
- flb_sds_destroy(result_buffer);
-
- return -4;
- }
-
- *out_result_buffer = result_buffer;
-
- return 0;
-}
-
-static int get_number_of_string_entries(uint32_t *result_count)
-{
- DWORD argument_size;
- DWORD entry_count;
- HKEY key_handle;
- LSTATUS result;
-
- entry_count = 0;
- argument_size = sizeof(DWORD);
-
- result = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
- WE_PERFLIB_REGISTRY_PATH,
- 0,
- KEY_READ,
- &key_handle);
-
- if (result != ERROR_SUCCESS) {
- return -1;
- }
-
- result = RegQueryValueExA(key_handle,
- WE_PERFLIB_STRING_COUNT_KEY,
- NULL,
- 0,
- (LPBYTE) &entry_count,
- &argument_size);
-
- RegCloseKey(key_handle);
-
- if (result != ERROR_SUCCESS) {
- return -2;
- }
-
- *result_count = (uint32_t) entry_count;
-
- return 0;
-}
-
-static int get_text_mapping_table(struct flb_hash_table **out_mapping_table)
-{
- char *current_counter_string;
- flb_sds_t counter_strings;
- char *counter_index;
- char *counter_name;
- uint32_t string_count;
- int result;
-
- if (out_mapping_table == NULL) {
- return -1;
- }
-
- result = get_number_of_string_entries(&string_count);
-
- if (result) {
- return -2;
- }
-
- result = get_string_list(WE_PERFLIB_COUNTER_KEY_NAME, &counter_strings);
-
- if (result) {
- return -3;
- }
-
- *out_mapping_table = flb_hash_table_create(FLB_HASH_TABLE_EVICT_NONE,
- 512, string_count * 2);
- if (*out_mapping_table == NULL) {
- flb_sds_destroy(counter_strings);
-
- return -4;
- }
-
- current_counter_string = (char *) counter_strings;
-
- while (1) {
- counter_index = current_counter_string;
- current_counter_string = &current_counter_string[strlen(current_counter_string) + 1];
-
- if (!current_counter_string[0]) {
- break;
- }
-
- counter_name = current_counter_string;
- current_counter_string = &current_counter_string[strlen(current_counter_string) + 1];
-
- if (!current_counter_string[0]) {
- break;
- }
-
- result = flb_hash_table_add(*out_mapping_table,
- counter_name, strlen(counter_name),
- counter_index, strlen(counter_index));
-
- if (result < 0) {
- flb_sds_destroy(counter_strings);
- flb_hash_table_destroy(*out_mapping_table);
-
- *out_mapping_table = NULL;
-
- return -5;
- }
-
- result = flb_hash_table_add(*out_mapping_table,
- counter_index, strlen(counter_index),
- counter_name, strlen(counter_name));
-
- if (result < 0) {
- flb_sds_destroy(counter_strings);
- flb_hash_table_destroy(*out_mapping_table);
-
- *out_mapping_table = NULL;
-
- return -5;
- }
- }
-
- flb_sds_destroy(counter_strings);
-
- return 0;
-}
-
-int we_perflib_query_raw_data(struct flb_we *ctx, char *source,
- char **out_buffer, size_t *out_buffer_size)
-{
- char *reallocated_buffer;
- DWORD buffer_size;
- DWORD data_size;
- char *buffer;
- LSTATUS result;
-
- buffer_size = WE_PERFLIB_QUERY_BUFFER_INITIAL_SIZE;
-
- result = ERROR_MORE_DATA;
-
- buffer = (char *) flb_malloc(buffer_size);
-
- if (buffer == NULL) {
- return -1;
- }
-
- while (result == ERROR_MORE_DATA) {
- data_size = buffer_size;
-
- result = RegQueryValueExA(HKEY_PERFORMANCE_DATA,
- source,
- NULL,
- NULL,
- buffer,
- &data_size);
-
- RegCloseKey(HKEY_PERFORMANCE_DATA);
-
- buffer_size += WE_PERFLIB_QUERY_BUFFER_INCREMENT_SIZE;
-
- reallocated_buffer = (char *) flb_realloc(buffer, buffer_size);
-
- if (reallocated_buffer == NULL) {
- flb_free(buffer);
-
- return -2;
- }
-
- buffer = reallocated_buffer;
- }
-
- *out_buffer = buffer;
- *out_buffer_size = data_size;
-
- return 0;
-}
-
-static char *we_perflib_lookup_counter_index(struct flb_hash_table *mapping_table,
- char *name)
-{
- return flb_hash_table_get_ptr(mapping_table,
- name,
- strlen(name));
-}
-
-static char *we_perflib_lookup_counter_name(struct flb_hash_table *mapping_table,
- uint32_t index)
-{
- char hash_table_index[11];
-
- sprintf(hash_table_index, "%" PRIu32, index);
-
- return flb_hash_table_get_ptr(mapping_table,
- hash_table_index,
- strlen(hash_table_index));
-}
-
-static int we_perflib_process_object_type(
- struct we_perflib_context *context,
- char *input_data_block,
- struct we_perflib_object **out_perflib_object)
-{
- char *input_object_block;
- struct we_perflib_object *perflib_object;
- PERF_OBJECT_TYPE *perf_object;
- PERF_DATA_BLOCK *perf_data;
- int result;
-
- perf_data = (PERF_DATA_BLOCK *) input_data_block;
-
- result = wcsncmp(perf_data->Signature, L"PERF", 4);
-
- if (result) {
- return -1;
- }
-
- input_object_block = &input_data_block[perf_data->HeaderLength];
-
- perf_object = (PERF_OBJECT_TYPE *) input_object_block;
-
- perflib_object = (struct we_perflib_object *) \
- flb_calloc(1, sizeof(struct we_perflib_object));
-
- if (perflib_object == NULL) {
- return -2;
- }
-
- perflib_object->name = we_perflib_lookup_counter_name(
- context->counter_indexes,
- perf_object->ObjectNameTitleIndex);
-
- if (perflib_object->name == NULL) {
- flb_free(perflib_object);
-
- return -3;
- }
-
- perflib_object->time = perf_data->PerfTime.QuadPart;
- perflib_object->frequency = perf_data->PerfFreq.QuadPart;
- perflib_object->hundred_ns_time = perf_data->PerfTime100nSec.QuadPart;
-
- perflib_object->counter_count = perf_object->NumCounters;
- perflib_object->instance_count = perf_object->NumInstances;
-
-
- perflib_object->instances = flb_hash_table_create(
- FLB_HASH_TABLE_EVICT_NONE,
- 64,
- perflib_object->instance_count + 1);
-
- if (perflib_object->instances == NULL) {
- flb_free(perflib_object);
-
- return -4;
- }
-
- mk_list_init(&perflib_object->counter_definitions);
-
- *out_perflib_object = perflib_object;
-
- return perf_data->HeaderLength + perf_object->HeaderLength;
-}
-
-static int we_perflib_process_counter_definition(
- struct we_perflib_context *context,
- char *input_data_block,
- struct we_perflib_counter_definition **out_counter_definition)
-{
- PERF_COUNTER_DEFINITION *perf_counter_definition;
- struct we_perflib_counter_definition *counter_definition;
- char name_index_str[12];
-
- perf_counter_definition = (PERF_COUNTER_DEFINITION *) input_data_block;
-
- counter_definition = (struct we_perflib_counter_definition *) \
- flb_calloc(1, sizeof(struct we_perflib_counter_definition));
-
- if (counter_definition == NULL) {
- return -1;
- }
-
- counter_definition->name_index = perf_counter_definition->CounterNameTitleIndex;
-
- counter_definition->name = we_perflib_lookup_counter_name(
- context->counter_indexes,
- counter_definition->name_index);
-
- snprintf(name_index_str,
- sizeof(name_index_str),
- "%" PRIu32,
- counter_definition->name_index);
-
- counter_definition->name_index_str = flb_sds_create(name_index_str);
-
- if (counter_definition->name_index_str == NULL) {
- flb_free(counter_definition);
-
- return -2;
- }
-
- if (counter_definition->name == NULL) {
- counter_definition->name = "";
- }
-
- if (counter_definition->name_index_str == NULL) {
- counter_definition->name_index_str = flb_sds_create("");
- }
-
- counter_definition->help_index = perf_counter_definition->CounterHelpTitleIndex;
-
- counter_definition->type = perf_counter_definition->CounterType;
- counter_definition->size = perf_counter_definition->CounterSize;
- counter_definition->offset = perf_counter_definition->CounterOffset;
- counter_definition->detail_level = perf_counter_definition->DetailLevel;
-
- *out_counter_definition = counter_definition;
-
- return perf_counter_definition->ByteLength;
-}
-
-static int we_perflib_process_counter_definitions(
- struct we_perflib_context *context,
- struct we_perflib_object *perflib_object,
- char *input_data_block)
-{
- size_t counter_definition_index;
- struct we_perflib_counter_definition *counter_definition;
- size_t offset;
- int result;
-
- offset = 0;
-
- for (counter_definition_index = 0 ;
- counter_definition_index < perflib_object->counter_count ;
- counter_definition_index++) {
- result = we_perflib_process_counter_definition(context,
- &input_data_block[offset],
- &counter_definition);
-
- if (result <= 0) {
- return -1;
- }
-
- offset += result;
-
- mk_list_add(&counter_definition->_head, &perflib_object->counter_definitions);
- }
-
- return offset;
-}
-
-static struct we_perflib_counter * we_perflib_create_counter(
- struct we_perflib_counter_definition *counter_definition)
-{
- struct we_perflib_counter *counter;
-
- counter = (struct we_perflib_counter *) \
- flb_calloc(1, sizeof(struct we_perflib_counter));
-
- if (counter == NULL) {
- return NULL;
- }
-
- counter->definition = counter_definition;
-
- return counter;
-}
-
-static int we_perflib_process_counter(
- struct we_perflib_context *context,
- struct we_perflib_counter_definition *counter_definition,
- char *input_data_block,
- struct we_perflib_counter **out_counter)
-{
- struct we_perflib_counter *perflib_instance_counter;
-
- perflib_instance_counter = we_perflib_create_counter(counter_definition);
-
- if (perflib_instance_counter == NULL) {
- return -1;
- }
-
- memcpy(&perflib_instance_counter->primary_value,
- &input_data_block[counter_definition->offset],
- counter_definition->size);
-
- if (counter_definition->size > sizeof(union we_perflib_value)) {
- we_perflib_destroy_counter(perflib_instance_counter);
-
- return -2;
- }
-
- *out_counter = perflib_instance_counter;
-
- return 0;
-}
-
-static int we_perflib_process_counters(struct we_perflib_context *context,
- struct we_perflib_object *perflib_object,
- struct we_perflib_instance *instance,
- char *input_data_block)
-{
- struct mk_list *counter_definition_iterator;
- struct we_perflib_counter *perflib_instance_counter;
- PERF_COUNTER_BLOCK *perf_counter_block;
- struct we_perflib_counter_definition *counter_definition;
- int result;
- int offset;
-
- perf_counter_block = (PERF_COUNTER_BLOCK *) input_data_block;
-
- mk_list_foreach(counter_definition_iterator,
- &perflib_object->counter_definitions) {
- counter_definition = mk_list_entry(counter_definition_iterator,
- struct we_perflib_counter_definition,
- _head);
-
- if (!counter_definition->name_index) {
- continue;
- }
-
- result = we_perflib_process_counter(context,
- counter_definition,
- input_data_block,
- &perflib_instance_counter);
-
- if (result < 0) {
- return -1;
- }
-
- perflib_instance_counter->parent = instance;
-
- result = -1;
-
- if (counter_definition->name[0]) {
- result = flb_hash_table_add(instance->counters,
- counter_definition->name,
- strlen(counter_definition->name),
- perflib_instance_counter,
- 0);
- }
- else
- {
- result = flb_hash_table_add(instance->counters,
- counter_definition->name_index_str,
- strlen(counter_definition->name_index_str),
- perflib_instance_counter,
- 0);
- }
-
- if (result < 0) {
- we_perflib_destroy_counter(perflib_instance_counter);
-
- return -2;
- }
- }
-
- return perf_counter_block->ByteLength;
-}
-
-static struct we_perflib_instance *we_perflib_create_instance(size_t counter_count)
-{
- struct we_perflib_instance *instance;
-
- instance = (struct we_perflib_instance *) \
- flb_calloc(1, sizeof(struct we_perflib_instance));
-
- if (instance == NULL) {
- return NULL;
- }
-
- instance->counters = flb_hash_table_create(FLB_HASH_TABLE_EVICT_NONE,
- 64,
- counter_count + 1);
-
- if (instance->counters == NULL) {
- flb_free(instance);
-
- return NULL;
- }
-
- return instance;
-}
-
-static int we_perflib_process_instance(struct we_perflib_context *context,
- struct we_perflib_object *perflib_object,
- char *input_data_block,
- struct we_perflib_instance **out_instance)
-{
- PERF_INSTANCE_DEFINITION *perf_instance_definition;
- struct we_perflib_instance *perflib_instance;
- int offset;
- int result;
-
- perflib_instance = we_perflib_create_instance(perflib_object->counter_count);
-
- if (perflib_instance == NULL) {
- return -1;
- }
-
- offset = 0;
-
- if (perflib_object->instance_count >= 1) {
- perf_instance_definition = (PERF_INSTANCE_DEFINITION *) input_data_block;
-
- if (perf_instance_definition->NameLength > 0) {
- perflib_instance->name = \
- we_convert_wstr(&input_data_block[perf_instance_definition->NameOffset], CP_UTF8);
- if (perflib_instance->name == NULL) {
- we_perflib_destroy_instance(perflib_instance);
-
- return -2;
- }
- }
- else {
- perflib_instance->name = flb_strdup("DEFAULT");
- }
-
- offset = perf_instance_definition->ByteLength;
- }
-
- perflib_instance->parent = perflib_object;
-
- result = we_perflib_process_counters(context,
- perflib_object,
- perflib_instance,
- &input_data_block[offset]);
-
- if (result < 0) {
- we_perflib_destroy_instance(perflib_instance);
-
- return -3;
- }
-
- offset += result;
-
- *out_instance = perflib_instance;
-
- return offset;
-}
-
-static int we_perflib_process_instances(struct we_perflib_context *context,
- struct we_perflib_object *perflib_object,
- char *input_data_block)
-{
- struct we_perflib_instance *perflib_instance;
- size_t instance_index;
- int result;
- int offset;
-
- offset = 0;
-
- for (instance_index = 0 ;
- instance_index < perflib_object->instance_count ;
- instance_index++) {
-
- result = we_perflib_process_instance(context,
- perflib_object,
- &input_data_block[offset],
- &perflib_instance);
-
- if (result <= 0) {
- return -1;
- }
-
- offset += result;
-
- result = flb_hash_table_add(perflib_object->instances,
- perflib_instance->name,
- strlen(perflib_instance->name),
- perflib_instance,
- 0);
-
- if (result < 0) {
- we_perflib_destroy_instance(perflib_instance);
-
- return -2;
- }
- }
-
- return offset;
-}
-
-int we_perflib_query(struct flb_we *ctx,
- char *counter_name,
- struct we_perflib_object **out_object)
-{
- char *counter_name_index;
- char *raw_data_buffer;
- size_t raw_data_offset;
- struct we_perflib_object *perflib_object;
- size_t raw_data_size;
- int result;
-
-
- counter_name_index = we_perflib_lookup_counter_index(
- ctx->perflib_context.counter_indexes, counter_name);
-
- if (counter_name_index == NULL) {
- return -1;
- }
-
- result = we_perflib_query_raw_data(ctx,
- counter_name_index,
- &raw_data_buffer,
- &raw_data_size);
-
- if (result) {
- return -2;
- }
-
- raw_data_offset = 0;
-
- result = we_perflib_process_object_type(&ctx->perflib_context,
- &raw_data_buffer[raw_data_offset],
- &perflib_object);
-
- if (result < 0) {
- flb_free(raw_data_buffer);
-
- return -3;
- }
-
- raw_data_offset += result;
-
- result = we_perflib_process_counter_definitions(&ctx->perflib_context,
- perflib_object,
- &raw_data_buffer[raw_data_offset]);
-
- if (result < 0) {
- we_perflib_destroy_object(perflib_object);
- flb_free(raw_data_buffer);
-
- return -4;
- }
-
- raw_data_offset += result;
-
- result = we_perflib_process_instances(&ctx->perflib_context,
- perflib_object,
- &raw_data_buffer[raw_data_offset]);
-
- if (result < 0) {
- we_perflib_destroy_object(perflib_object);
- flb_free(raw_data_buffer);
-
- return -5;
- }
-
- flb_free(raw_data_buffer);
-
- *out_object = perflib_object;
-
- return 0;
-}
-
-int we_perflib_update_counters(struct flb_we *ctx,
- char *query,
- struct we_perflib_metric_source *metric_sources,
- we_perflib_instance_filter filter_hook,
- we_perflib_label_prepend_hook label_prepend_hook)
-{
- char *metric_label_list[WE_PERFLIB_METRIC_LABEL_LIST_SIZE];
- struct flb_hash_table_entry *instance_hash_entry;
- size_t metric_label_count;
- struct mk_list *instance_iterator;
- struct we_perflib_metric_source *metric_source;
- size_t metric_index;
- void *metric_entry;
- size_t label_index;
- struct we_perflib_object *measurement;
- uint64_t timestamp;
- struct we_perflib_counter *counter;
- int result;
-
-
- timestamp = cfl_time_now();
-
- result = we_perflib_query(ctx, query, &measurement);
-
- if (result) {
- return -1;
- }
-
- mk_list_foreach_r (instance_iterator, &measurement->instances->entries) {
- instance_hash_entry = mk_list_entry(instance_iterator,
- struct flb_hash_table_entry,
- _head_parent);
-
- if (filter_hook(instance_hash_entry->key, ctx) == 0) {
- for (metric_index = 0 ;
- metric_sources[metric_index].name != NULL ;
- metric_index++) {
-
- metric_source = &metric_sources[metric_index];
-
- counter = we_perflib_get_counter(measurement,
- instance_hash_entry->key,
- metric_source->name);
-
- if (counter == NULL) {
- return -2;
- }
-
- metric_label_count = 0;
-
- result = label_prepend_hook(metric_label_list,
- WE_PERFLIB_METRIC_LABEL_LIST_SIZE,
- &metric_label_count,
- metric_source,
- instance_hash_entry->key,
- counter);
-
- if (result != 0) {
- return -3;
- }
-
- for (label_index = 0 ;
- label_index < metric_source->label_set_size;
- label_index++) {
- metric_label_list[metric_label_count++] = \
- metric_source->label_set[label_index];
- }
-
- metric_entry = metric_source->parent->metric_instance;
-
- if (metric_source->parent->type == CMT_COUNTER) {
- cmt_counter_set(metric_entry, timestamp,
- we_perflib_get_adjusted_counter_value(counter),
- metric_label_count, metric_label_list);
- }
- else if (metric_source->parent->type == CMT_GAUGE) {
- cmt_gauge_set(metric_entry, timestamp,
- we_perflib_get_adjusted_counter_value(counter),
- metric_label_count, metric_label_list);
- }
- }
- }
- }
-
- we_perflib_destroy_object(measurement);
-
- return 0;
-}
-
-struct we_perflib_counter *we_perflib_get_counter(struct we_perflib_object *object,
- char *instance_name,
- char *counter_name)
-{
- struct we_perflib_instance *instance;
- struct we_perflib_counter *counter;
-
- if (instance_name == NULL) {
- instance_name = "DEFAULT";
- }
-
- instance = flb_hash_table_get_ptr(object->instances,
- instance_name,
- strlen(instance_name));
-
- if (instance == NULL) {
- return NULL;
- }
-
- counter = flb_hash_table_get_ptr(instance->counters,
- counter_name,
- strlen(counter_name));
-
- return counter;
-}
-
-int we_perflib_init(struct flb_we *ctx)
-{
- int result;
-
- result = get_text_mapping_table(&ctx->perflib_context.counter_indexes);
-
- if (result) {
- return -1;
- }
-
- return 0;
-}
-
-int we_perflib_exit(struct flb_we *ctx)
-{
- if (ctx->perflib_context.counter_indexes != NULL) {
- flb_hash_table_destroy(ctx->perflib_context.counter_indexes);
- ctx->perflib_context.counter_indexes = NULL;
- }
-
- return 0;
-}
-
-/*
-https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc785636(v=ws.10)
-*/
-
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.h
deleted file mode 100644
index 46059bb8d..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_perflib.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_PERFLIB_H
-#define FLB_WE_PERFLIB_H
-
-#include "we.h"
-#include "we_metric.h"
-
-#define WE_PERFLIB_REGISTRY_PATH \
- "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"
-
-#define WE_PERFLIB_STRING_COUNT_KEY "Last Help"
-#define WE_PERFLIB_COUNTER_KEY_NAME "Counter 009"
-
-#define WE_PERFLIB_METRIC_LABEL_LIST_SIZE 64
-
-#define WE_PERFLIB_QUERY_BUFFER_INITIAL_SIZE (32 * 1024)
-#define WE_PERFLIB_QUERY_BUFFER_INCREMENT_SIZE (16 * 1024)
-
-#define WE_PERFLIB_WINDOWS_EPOCH ((double) 1 / 1e7)
-#define WE_PERFLIB_TICKS_TO_SECONDS_SCALE_FACTOR ((double) 116444736000000000)
-
-typedef int (*we_perflib_instance_filter)(char *, struct flb_we *);
-typedef int (*we_perflib_label_prepend_hook)(char **,
- size_t,
- size_t *,
- struct we_perflib_metric_source *,
- char *,
- struct we_perflib_counter *);
-
-int we_perflib_init(struct flb_we *ctx);
-int we_perflib_exit(struct flb_we *ctx);
-
-int we_perflib_query(struct flb_we *ctx,
- char *counter_name,
- struct we_perflib_object **out_object);
-
-struct we_perflib_counter *we_perflib_get_counter(struct we_perflib_object *object,
- char *instance_name,
- char *counter_name);
-
-void we_perflib_destroy_object(struct we_perflib_object *object);
-
-char *we_perflib_get_counter_type_as_text(uint32_t counter_Type);
-
-int we_perflib_update_counters(struct flb_we *ctx,
- char *query,
- struct we_perflib_metric_source *metric_sources,
- we_perflib_instance_filter filter_hook,
- we_perflib_label_prepend_hook label_prepend_hook);
-
-double we_perflib_get_adjusted_counter_value(struct we_perflib_counter *counter);
-
-#endif \ No newline at end of file
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.c
deleted file mode 100644
index 625872709..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_sds.h>
-
-#include "we.h"
-#include "we_util.h"
-
-int we_get_windows_version(double *version_number)
-{
- LSTATUS result;
- DWORD data_size;
- HKEY key_handle;
- char version_text[8];
-
- data_size = sizeof(version_text);
-
- result = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
- WE_VERSION_REGISTRY_PATH,
- 0,
- KEY_READ,
- &key_handle);
-
- if (result != ERROR_SUCCESS) {
- return FLB_FALSE;
- }
-
- result = RegQueryValueExA(key_handle,
- WE_VERSION_KEY_NAME,
- NULL,
- 0,
- version_text,
- &data_size);
-
- RegCloseKey(key_handle);
-
- if (result != ERROR_SUCCESS)
- {
- return FLB_FALSE;
- }
-
- *version_number = strtod(version_text, NULL);
-
- return FLB_TRUE;
-}
-
-void we_hexdump(uint8_t *buffer, size_t buffer_length, size_t line_length) {
- char *printable_line;
- size_t buffer_index;
- size_t filler_index;
-
- if (40 < line_length)
- {
- line_length = 40;
- }
-
- printable_line = malloc(line_length + 1);
-
- if (NULL == printable_line)
- {
- printf("Alloca returned NULL\n");
-
- return;
- }
-
- memset(printable_line, '\0', line_length + 1);
-
- for (buffer_index = 0 ; buffer_index < buffer_length ; buffer_index++) {
- if (0 != buffer_index &&
- 0 == (buffer_index % line_length)) {
-
- printf("%s\n", printable_line);
-
- memset(printable_line, '\0', line_length + 1);
- }
-
- if (0 != isprint(buffer[buffer_index])) {
- printable_line[(buffer_index % line_length)] = buffer[buffer_index];
- }
- else {
- printable_line[(buffer_index % line_length)] = '.';
- }
-
- printf("%02X ", buffer[buffer_index]);
- }
-
- if (0 != buffer_index &&
- 0 != (buffer_index % line_length)) {
-
- for (filler_index = 0 ;
- filler_index < (line_length - (buffer_index % line_length)) ;
- filler_index++) {
- printf(" ");
- }
-
- printf("%s\n", printable_line);
-
- memset(printable_line, '.', line_length);
- }
-
- free(printable_line);
-}
-
-char* we_convert_wstr(wchar_t *wstr, UINT codePage)
-{
- int size = 0;
- char *buf = NULL;
-
- size = WideCharToMultiByte(codePage, 0, wstr, -1, NULL, 0, NULL, NULL);
- if (size == 0) {
- return NULL;
- }
-
- buf = flb_calloc(1, size);
- if (buf == NULL) {
- flb_errno();
- return NULL;
- }
- size = WideCharToMultiByte(codePage, 0, wstr, -1, buf, size, NULL, NULL);
- if (size == 0) {
- flb_free(buf);
- return NULL;
- }
-
- return buf;
-}
-
-wchar_t* we_convert_str(char *str)
-{
- int size = 0;
- wchar_t *buf = NULL;
-
- size = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
- if (size == 0) {
- return NULL;
- }
-
- buf = flb_calloc(1, sizeof(PWSTR) * size);
- if (buf == NULL) {
- flb_errno();
- return NULL;
- }
- size = MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, size);
- if (size == 0) {
- flb_free(buf);
- return NULL;
- }
-
- return buf;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.h
deleted file mode 100644
index 1f556d2cb..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_util.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_UTIL_H
-#define FLB_WE_UTIL_H
-
-#include "we.h"
-
-#define WE_VERSION_REGISTRY_PATH \
- "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
-
-#define WE_VERSION_KEY_NAME "CurrentVersion"
-
-int we_get_windows_version(double *version_number);
-void we_hexdump(uint8_t *buffer, size_t buffer_length, size_t line_length);
-/* Utilites for char/wchar_t conversion */
-wchar_t* we_convert_str(char *str);
-char* we_convert_wstr(wchar_t *wstr, UINT codePage);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.c
deleted file mode 100644
index 03505c4bc..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.c
+++ /dev/null
@@ -1,572 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_util.h"
-#include "we_wmi.h"
-
-static int wmi_coinitialize(struct flb_we *ctx, char* wmi_namespace)
-{
- IWbemLocator *locator = 0;
- IWbemServices *service = 0;
- HRESULT hr;
- wchar_t *wnamespace;
-
- flb_plg_debug(ctx->ins, "initializing WMI instance....");
-
- /* Initialize COM library */
- hr = CoInitializeEx(0, COINIT_MULTITHREADED);
- if (FAILED(hr)) {
- flb_plg_error(ctx->ins, "Failed to initialize COM library. Error code = %x", hr);
- return -1;
- }
-
- /* Initialize COM security */
- hr = CoInitializeSecurity(NULL,
- -1,
- NULL,
- NULL,
- RPC_C_AUTHN_LEVEL_DEFAULT,
- RPC_C_IMP_LEVEL_IMPERSONATE,
- NULL,
- EOAC_NONE,
- NULL);
-
- if (FAILED(hr)) {
- return hr;
- }
-
- /* Create WMI instance */
- hr = CoCreateInstance(&CLSID_WbemLocator, 0,
- CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (LPVOID *) &locator);
- if (FAILED(hr)) {
- flb_plg_error(ctx->ins, "Failed to create IWbemLocator object. Error code = %x", hr);
- CoUninitialize();
- return hr;
- }
- ctx->locator = locator;
-
- if (wmi_namespace == NULL) {
- wnamespace = we_convert_str("ROOT\\CIMV2");
- }
- else {
- wnamespace = we_convert_str(wmi_namespace);
- }
- /* Connect WMI server */
- hr = locator->lpVtbl->ConnectServer(locator,
- wnamespace,
- NULL,
- NULL,
- 0,
- 0,
- 0,
- NULL,
- &service);
- flb_free(wnamespace);
-
- if (FAILED(hr)) {
- flb_plg_error(ctx->ins, "Could not connect. Error code = %x", hr);
- locator->lpVtbl->Release(locator);
- CoUninitialize();
- return hr;
- }
- ctx->service = service;
-
- /* Set up ProxyBlanket */
- hr = CoSetProxyBlanket(service,
- RPC_C_AUTHN_WINNT,
- RPC_C_AUTHZ_NONE,
- NULL,
- RPC_C_AUTHN_LEVEL_CALL,
- RPC_C_IMP_LEVEL_IMPERSONATE,
- NULL,
- EOAC_NONE
- );
- if (FAILED(hr)) {
- flb_plg_error(ctx->ins, "Could not set proxy blanket. Error code = %x", hr);
- service->lpVtbl->Release(service);
- locator->lpVtbl->Release(locator);
- CoUninitialize();
- return hr;
- }
-
- return 0;
-}
-
-
-
-int wmi_utils_str_to_double(char *str, double *out_val)
-{
- double val;
- char *end;
-
- errno = 0;
- val = strtod(str, &end);
- if (errno != 0 || *end != '\0') {
- return -1;
- }
- *out_val = val;
- return 0;
-}
-
-static int wmi_update_counters(struct wmi_query_spec *spec, uint64_t timestamp, double val, int metric_label_count, char **metric_label_set)
-{
- val = spec->value_adjuster(val);
-
- if (spec->type == CMT_GAUGE) {
- cmt_gauge_set((struct cmt_gauge *)spec->metric_instance, timestamp,
- val,
- metric_label_count, metric_label_set);
- }
- else if (spec->type == CMT_COUNTER) {
- cmt_counter_set((struct cmt_counter *)spec->metric_instance, timestamp,
- val,
- metric_label_count, metric_label_set);
- }
-
- return 0;
-}
-
-static char *convert_prop_to_str(VARIANT *prop, int handle_null)
-{
- char *strlabel = NULL;
- char *newstr = NULL;
-
- if (handle_null == FLB_TRUE && prop->vt == VT_NULL) {
- newstr = strdup("");
- if (newstr == NULL) {
- return NULL;
- }
- }
- else {
- if (VariantChangeType(prop, prop, 0, VT_BSTR) != S_OK) {
- return NULL;
- }
- strlabel = we_convert_wstr(prop->bstrVal, CP_UTF8);
- if (strlabel == NULL) {
- return NULL;
- }
- newstr = strdup(strlabel);
- if (newstr == NULL) {
- free(strlabel);
- return NULL;
- }
- free(strlabel);
- }
- return newstr;
-}
-
-static double wmi_get_value(struct flb_we *ctx, struct wmi_query_spec *spec, IWbemClassObject *class_obj)
-{
- VARIANT prop;
- char *strprop;
- double val = 1.0;
- HRESULT hr;
- wchar_t *wproperty;
-
- VariantInit(&prop);
- wproperty = we_convert_str(spec->wmi_property);
- hr = class_obj->lpVtbl->Get(class_obj, wproperty, 0, &prop, 0, 0);
- if (FAILED(hr)) {
- flb_plg_warn(ctx->ins, "Retrive prop '%s' failed. Error code = %x", spec->wmi_property, hr);
- }
- strprop = convert_prop_to_str(&prop, FLB_FALSE);
- if (strprop == NULL) {
- return 0;
- }
- wmi_utils_str_to_double(strprop, &val);
- flb_free(strprop);
- VariantClear(&prop);
- flb_free(wproperty);
-
- return val;
-}
-
-static double wmi_get_property_value(struct flb_we *ctx, char *raw_property_key, IWbemClassObject *class_obj)
-{
- VARIANT prop;
- char *strprop;
- double val = 1.0;
- HRESULT hr;
- wchar_t *wproperty;
-
- VariantInit(&prop);
- wproperty = we_convert_str(raw_property_key);
- hr = class_obj->lpVtbl->Get(class_obj, wproperty, 0, &prop, 0, 0);
- if (FAILED(hr)) {
- flb_plg_warn(ctx->ins, "Retrive prop '%s' failed. Error code = %x", raw_property_key, hr);
- }
- strprop = convert_prop_to_str(&prop, FLB_FALSE);
- if (strprop == NULL) {
- return 0;
- }
- wmi_utils_str_to_double(strprop, &val);
- flb_free(strprop);
- VariantClear(&prop);
- flb_free(wproperty);
-
- return val;
-}
-
-static char *wmi_get_property_str_value(struct flb_we *ctx, char *raw_property_key,
- IWbemClassObject *class_obj)
-{
- VARIANT prop;
- char *strprop;
- char *str_val = NULL;
- HRESULT hr;
- wchar_t *wproperty;
-
-
- VariantInit(&prop);
- wproperty = we_convert_str(raw_property_key);
- hr = class_obj->lpVtbl->Get(class_obj, wproperty, 0, &prop, 0, 0);
- if (FAILED(hr)) {
- flb_plg_warn(ctx->ins, "Retrive prop '%s' failed. Error code = %x", raw_property_key, hr);
- }
- str_val = convert_prop_to_str(&prop, FLB_TRUE);
- VariantClear(&prop);
- flb_free(wproperty);
-
- return str_val;
-}
-
-static inline int wmi_update_metrics(struct flb_we *ctx, struct wmi_query_spec *spec,
- double val, IWbemClassObject *class_obj, uint64_t timestamp)
-{
-
- VARIANT prop;
- int label_index = 0;
- HRESULT hr;
- char *metric_label_set[WE_WMI_METRIC_LABEL_LIST_SIZE];
- int metric_label_count = 0;
- char buf[16] = {0};
- wchar_t *wlabel;
- char *newstr = NULL;
-
- VariantInit(&prop);
- metric_label_count = 0;
- for (label_index = 0; label_index < spec->label_property_count; label_index++) {
- wlabel = we_convert_str(spec->label_property_keys[label_index]);
- hr = class_obj->lpVtbl->Get(class_obj, wlabel, 0, &prop, 0, 0);
- if (FAILED(hr)) {
- flb_plg_warn(ctx->ins, "Retrive prop failed. Error code = %x", hr);
- }
- newstr = convert_prop_to_str(&prop, FLB_TRUE);
- if (newstr == NULL) {
- continue;
- }
- metric_label_set[label_index] = newstr;
- metric_label_count++;
- VariantClear(&prop);
- flb_free(wlabel);
- }
-
- wmi_update_counters(spec, timestamp, val, metric_label_count, metric_label_set);
-
- VariantClear(&prop);
-
- return 0;
-}
-
-static inline int wmi_execute_query(struct flb_we *ctx, struct wmi_query_spec *spec, IEnumWbemClassObject **out_enumerator)
-{
- HRESULT hr;
- wchar_t *wquery;
- char *query = NULL;
- IEnumWbemClassObject* enumerator = NULL;
- size_t size;
-
- size = 14 + strlen(spec->wmi_counter);
- if (spec->where_clause != NULL) {
- size += 7 + strlen(spec->where_clause);
- }
- query = flb_calloc(size, sizeof(char *));
- if (!query) {
- flb_errno();
- return -1;
- }
- if (spec->where_clause != NULL) {
- snprintf(query, size, "SELECT * FROM %s WHERE %s", spec->wmi_counter, spec->where_clause);
- }
- else {
- snprintf(query, size, "SELECT * FROM %s", spec->wmi_counter);
- }
- flb_trace("[wmi] query = %s", query);
- wquery = we_convert_str(query);
- flb_free(query);
-
- hr = ctx->service->lpVtbl->ExecQuery(
- ctx->service,
- L"WQL",
- wquery,
- WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
- NULL,
- &enumerator);
-
- flb_free(wquery);
-
- if (FAILED(hr)) {
- flb_plg_error(ctx->ins, "Query for %s %s failed. Error code = %x",
- spec->wmi_counter, spec->wmi_counter, hr);
- ctx->service->lpVtbl->Release(ctx->service);
- ctx->locator->lpVtbl->Release(ctx->locator);
- CoUninitialize();
- return -1;
- }
-
- *out_enumerator = enumerator;
-
- return 0;
-}
-
-static int wmi_exec_query_fixed_val(struct flb_we *ctx, struct wmi_query_spec *spec)
-{
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- uint64_t timestamp = 0;
-
- timestamp = cfl_time_now();
-
- if (FAILED(wmi_execute_query(ctx, spec, &enumerator))) {
- return -1;
- }
-
- while (enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1,
- &class_obj, &ret);
-
- if(0 == ret) {
- break;
- }
-
- wmi_update_metrics(ctx, spec, 1.0, class_obj, timestamp);
-
- class_obj->lpVtbl->Release(class_obj);
- }
-
- enumerator->lpVtbl->Release(enumerator);
-
- return 0;
-}
-
-static int wmi_exec_query(struct flb_we *ctx, struct wmi_query_spec *spec)
-{
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- double val = 0;
- uint64_t timestamp = 0;
-
- timestamp = cfl_time_now();
-
- if (FAILED(wmi_execute_query(ctx, spec, &enumerator))) {
- return -1;
- }
-
- while (enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1,
- &class_obj, &ret);
-
- if(0 == ret) {
- break;
- }
-
- val = wmi_get_value(ctx, spec, class_obj);
-
- wmi_update_metrics(ctx, spec, val, class_obj, timestamp);
-
- class_obj->lpVtbl->Release(class_obj);
- }
-
- enumerator->lpVtbl->Release(enumerator);
-
- return 0;
-}
-
-static int wmi_cleanup(struct flb_we *ctx)
-{
- flb_plg_debug(ctx->ins, "deinitializing WMI instance....");
-
- /* Clean up */
- if (ctx->service != NULL) {
- ctx->service->lpVtbl->Release(ctx->service);
- ctx->service = NULL;
- }
- if (ctx->locator != NULL) {
- ctx->locator->lpVtbl->Release(ctx->locator);
- ctx->locator = NULL;
- }
- CoUninitialize();
-
- return 0;
-}
-
-static int wmi_query(struct flb_we *ctx, struct wmi_query_spec *spec)
-{
- if (FAILED(wmi_coinitialize(ctx, NULL))) {
- return -1;
- }
- if (FAILED(wmi_exec_query(ctx, spec))) {
- return -1;
- }
-
- wmi_cleanup(ctx);
-
- return 0;
-}
-
-static int wmi_query_namespace(struct flb_we *ctx, struct wmi_query_spec *spec, char *namespace)
-{
- if (FAILED(wmi_coinitialize(ctx, namespace))) {
- return -1;
- }
- if (FAILED(wmi_exec_query(ctx, spec))) {
- return -1;
- }
-
- wmi_cleanup(ctx);
-
- return 0;
-}
-
-static int wmi_query_fixed_val(struct flb_we *ctx, struct wmi_query_spec *spec)
-{
- if (FAILED(wmi_coinitialize(ctx, NULL))) {
- return -1;
- }
- if (FAILED(wmi_exec_query_fixed_val(ctx, spec))) {
- return -1;
- }
-
- wmi_cleanup(ctx);
-
- return 0;
-}
-
-int we_wmi_init(struct flb_we *ctx)
-{
- ctx->locator = NULL;
- ctx->service = NULL;
-
- return 0;
-}
-
-int we_wmi_cleanup(struct flb_we *ctx)
-{
- wmi_cleanup(ctx);
-
- return 0;
-}
-
-int we_wmi_exit(struct flb_we *ctx)
-{
- return 0;
-}
-
-/* Abstract APIs */
-int we_wmi_query_fixed_val(struct flb_we *ctx, struct wmi_query_specs *spec)
-{
- if (FAILED(wmi_query_fixed_val(ctx, spec))) {
- return -1;
- }
- return 0;
-}
-
-int we_wmi_query(struct flb_we *ctx, struct wmi_query_specs *spec)
-{
- if (FAILED(wmi_query(ctx, spec))) {
- return -1;
- }
- return 0;
-}
-
-int we_wmi_query_namespace(struct flb_we *ctx, struct wmi_query_specs *spec, char *namespace)
-{
- if (FAILED(wmi_query_namespace(ctx, spec, namespace))) {
- return -1;
- }
- return 0;
-}
-
-/* Concreate APIs */
-int we_wmi_coinitialize(struct flb_we *ctx)
-{
- if (FAILED(wmi_coinitialize(ctx, NULL))) {
- return -1;
- }
-
- return 0;
-}
-
-int we_wmi_execute_query(struct flb_we *ctx, struct wmi_query_spec *spec, IEnumWbemClassObject **out_enumerator)
-{
- IEnumWbemClassObject* enumerator = NULL;
-
- if (FAILED(wmi_execute_query(ctx, spec, &enumerator))) {
- return -1;
- }
-
- *out_enumerator = enumerator;
-
- return 0;
-}
-
-double we_wmi_get_value(struct flb_we *ctx, struct wmi_query_spec *spec, IWbemClassObject *class_obj)
-{
- return wmi_get_value(ctx, spec, class_obj);
-}
-
-double we_wmi_get_property_value(struct flb_we *ctx, char *raw_property_key, IWbemClassObject *class_obj)
-{
- return wmi_get_property_value(ctx, raw_property_key, class_obj);
-}
-
-char *we_wmi_get_property_str_value(struct flb_we *ctx, char *raw_property_key,
- IWbemClassObject *class_obj)
-{
- return wmi_get_property_str_value(ctx, raw_property_key, class_obj);
-}
-
-int we_wmi_update_counters(struct flb_we *ctx, struct wmi_query_spec *spec, uint64_t timestamp, double val, int metric_label_count, char **metric_label_set)
-{
- wmi_update_counters(spec, timestamp, val, metric_label_count, metric_label_set);
-
- return 0;
-}
-
-/*
-https://stackoverflow.com/questions/33033111/create-com-object-using-plain-c
-https://stackoverflow.com/questions/1431103/how-to-obtain-data-from-wmi-using-a-c-application
-https://stackoverflow.com/questions/626674/wmi-queries-in-c
-https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WmiSdk/example--getting-wmi-data-from-the-local-computer.md
-https://docs.microsoft.com/en-us/windows/win32/wmisdk/creating-wmi-clients
-*/
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.h
deleted file mode 100644
index 2999f5764..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2021 The Fluent Bit Authors
- * Copyright (C) 2015-2018 Treasure Data Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_H
-#define FLB_WE_WMI_H
-
-#include "we.h"
-
-#define WE_WMI_METRIC_LABEL_LIST_SIZE 64
-
-typedef double (*we_wmi_value_adjuster) (double);
-struct wmi_query_spec {
- void *metric_instance;
- int type;
- we_wmi_value_adjuster value_adjuster;
- char *wmi_counter;
- char *wmi_property;
- int label_property_count;
- char **label_property_keys;
- char *where_clause;
-};
-
-int we_wmi_init(struct flb_we *ctx);
-int we_wmi_cleanup(struct flb_we *ctx);
-int we_wmi_exit(struct flb_we *ctx);
-
-/* Abstract APIs */
-int we_wmi_query(struct flb_we *ctx, struct wmi_query_specs *spec);
-int we_wmi_query_fixed_val(struct flb_we *ctx, struct wmi_query_specs *spec);
-int we_wmi_query_namespace(struct flb_we *ctx, struct wmi_query_specs *spec, char *namepsace);
-
-/* Concrete APIs */
-int we_wmi_coinitialize(struct flb_we *ctx);
-int we_wmi_execute_query(struct flb_we *ctx, struct wmi_query_spec *spec, IEnumWbemClassObject **out_enumerator);
-double we_wmi_get_value(struct flb_we *ctx, struct wmi_query_spec *spec, IWbemClassObject *class_obj);
-double we_wmi_get_property_value(struct flb_we *ctx, char *raw_property_key, IWbemClassObject *class_obj);
-char *we_wmi_get_property_str_value(struct flb_we *ctx, char *raw_property_key,
- IWbemClassObject *class_obj);
-int we_wmi_update_counters(struct flb_we *ctx, struct wmi_query_spec *spec,
- uint64_t timestamp, double val, int metric_label_count, char **metric_label_set);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.c
deleted file mode 100644
index 9e8e96e1a..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_cpu_info.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-int we_wmi_cpu_info_init(struct flb_we *ctx)
-{
- ctx->wmi_cpu_info = flb_calloc(1, sizeof(struct we_wmi_cpu_info_counters));
- if (!ctx->wmi_cpu_info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_cpu_info->operational = FLB_FALSE;
-
- struct cmt_gauge *g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "", "cpu_info",
- "Labeled CPU information provided by WMI Win32_Processor",
- 7, (char *[]) {"architecture",
- "device_id",
- "description",
- "family",
- "l2_cache_size",
- "l3_cache_size",
- "name"});
- if (!g) {
- return -1;
- }
-
- ctx->wmi_cpu_info->info = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_cpu_info->info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_cpu_info->info->label_property_keys = (char **) flb_calloc(7, sizeof(char *));
- if (!ctx->wmi_cpu_info->info->label_property_keys) {
- flb_errno();
- return -1;
- }
-
- ctx->wmi_cpu_info->info->metric_instance = (void *)g;
- ctx->wmi_cpu_info->info->type = CMT_GAUGE;
- ctx->wmi_cpu_info->info->value_adjuster = nop_adjust;
- ctx->wmi_cpu_info->info->wmi_counter = "Win32_Processor";
- /* This metrics does not retrieve metrics values. Filled out as
- * 1.0. */
- ctx->wmi_cpu_info->info->wmi_property = "";
- ctx->wmi_cpu_info->info->label_property_count = 7;
- ctx->wmi_cpu_info->info->label_property_keys[0] = "architecture" ;
- ctx->wmi_cpu_info->info->label_property_keys[1] = "deviceid" ;
- ctx->wmi_cpu_info->info->label_property_keys[2] = "description" ;
- ctx->wmi_cpu_info->info->label_property_keys[3] = "family" ;
- ctx->wmi_cpu_info->info->label_property_keys[4] = "l2cachesize" ;
- ctx->wmi_cpu_info->info->label_property_keys[5] = "l3cachesize" ;
- ctx->wmi_cpu_info->info->label_property_keys[6] = "name" ;
- ctx->wmi_cpu_info->info->where_clause = NULL;
-
- ctx->wmi_cpu_info->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_cpu_info_exit(struct flb_we *ctx)
-{
- flb_free(ctx->wmi_cpu_info->info->label_property_keys);
- flb_free(ctx->wmi_cpu_info->info);
- flb_free(ctx->wmi_cpu_info);
-
- return 0;
-}
-
-int we_wmi_cpu_info_update(struct flb_we *ctx)
-{
- if (!ctx->wmi_cpu_info->operational) {
- flb_plg_error(ctx->ins, "cpu_info collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_query_fixed_val(ctx, ctx->wmi_cpu_info->info))) {
- return -1;
- }
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.h
deleted file mode 100644
index 8120b4983..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_cpu_info.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_CPU_INFO_H
-#define FLB_WE_WMI_CPU_INFO_H
-
-#include "we.h"
-
-int we_wmi_cpu_info_init(struct flb_we *ctx);
-int we_wmi_cpu_info_exit(struct flb_we *ctx);
-int we_wmi_cpu_info_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.c
deleted file mode 100644
index 761d4ac7a..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_cpu_info.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-int we_wmi_logon_init(struct flb_we *ctx)
-{
- ctx->wmi_logon = flb_calloc(1, sizeof(struct we_wmi_logon_counters));
- if (!ctx->wmi_logon) {
- flb_errno();
- return -1;
- }
- ctx->wmi_logon->operational = FLB_FALSE;
-
- struct cmt_gauge *g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "logon", "logon_type",
- "Number of active logon sessions (LogonSession.LogonType) by WMI Win32_LogonSession",
- 1, (char *[]) {"status"});
- if (!g) {
- return -1;
- }
-
- ctx->wmi_logon->info = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_logon->info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_logon->info->label_property_keys = (char **) flb_calloc(1, sizeof(char *));
- if (!ctx->wmi_logon->info->label_property_keys) {
- flb_errno();
- return -1;
- }
-
- ctx->wmi_logon->info->metric_instance = (void *)g;
- ctx->wmi_logon->info->type = CMT_GAUGE;
- ctx->wmi_logon->info->value_adjuster = nop_adjust;
- ctx->wmi_logon->info->wmi_counter = "Win32_LogonSession";
- ctx->wmi_logon->info->wmi_property = "LogonType";
- ctx->wmi_logon->info->label_property_count = 1;
- ctx->wmi_logon->info->label_property_keys[0] = "status" ;
- ctx->wmi_logon->info->where_clause = NULL;
-
- ctx->wmi_logon->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_logon_exit(struct flb_we *ctx)
-{
- flb_free(ctx->wmi_logon->info->label_property_keys);
- flb_free(ctx->wmi_logon->info);
- flb_free(ctx->wmi_logon);
-
- return 0;
-}
-
-int we_wmi_logon_update(struct flb_we *ctx)
-{
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- double val = 0;
- int type = 0;
- uint64_t timestamp = 0;
- /* Init counters for logon */
- uint64_t system = 0, interactive = 0, network = 0, batch = 0, service = 0,
- proxy = 0, unlock = 0, networkcleartext = 0, newcredentials = 0, remoteinteractive = 0,
- cachedinteractive = 0, cachedremoteinteractive = 0, cachedunlock = 0;
- struct wmi_query_spec *spec;
-
- if (!ctx->wmi_logon->operational) {
- flb_plg_error(ctx->ins, "logon collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_coinitialize(ctx))) {
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- if (FAILED(we_wmi_execute_query(ctx, ctx->wmi_logon->info, &enumerator))) {
- return -1;
- }
-
- while(enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1,
- &class_obj, &ret);
-
- if(0 == ret) {
- break;
- }
-
- val = we_wmi_get_value(ctx, ctx->wmi_logon->info, class_obj);
- type = (int)val;
-
- switch(type) {
- case 0:
- system++;
- break;
- case 2:
- interactive++;
- break;
- case 3:
- network++;
- break;
- case 4:
- batch++;
- break;
- case 5:
- service++;
- break;
- case 6:
- proxy++;
- break;
- case 7:
- unlock++;
- break;
- case 8:
- networkcleartext++;
- break;
- case 9:
- newcredentials++;
- break;
- case 10:
- remoteinteractive++;
- break;
- case 11:
- cachedinteractive++;
- break;
- case 12:
- cachedremoteinteractive++;
- break;
- case 13:
- cachedunlock++;
- break;
- }
-
- class_obj->lpVtbl->Release(class_obj);
- }
-
- enumerator->lpVtbl->Release(enumerator);
-
- spec = ctx->wmi_logon->info;
-
- we_wmi_update_counters(ctx, spec, timestamp, (double)system, 1, (char *[]) {"system"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)interactive, 1, (char *[]) {"interactive"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)network, 1, (char *[]) {"network"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)batch, 1, (char *[]) {"batch"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)service, 1, (char *[]) {"service"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)proxy, 1, (char *[]) {"proxy"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)unlock, 1, (char *[]) {"unlock"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)networkcleartext, 1, (char *[]) {"network_clear_text"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)newcredentials, 1, (char *[]) {"new_credentials"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)remoteinteractive, 1, (char *[]) {"remote_interactive"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)cachedinteractive, 1, (char *[]) {"cached_interactive"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)cachedremoteinteractive, 1, (char *[]) {"cached_remote_interactive"} );
- we_wmi_update_counters(ctx, spec, timestamp, (double)cachedunlock, 1, (char *[]) {"cached_unlock"} );
-
- we_wmi_cleanup(ctx);
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.h
deleted file mode 100644
index 9fc8c5318..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_logon.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_LOGON_H
-#define FLB_WE_WMI_LOGON_H
-
-#include "we.h"
-
-int we_wmi_logon_init(struct flb_we *ctx);
-int we_wmi_logon_exit(struct flb_we *ctx);
-int we_wmi_logon_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.c
deleted file mode 100644
index ec1a13e96..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.c
+++ /dev/null
@@ -1,557 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_memory.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-int we_wmi_memory_init(struct flb_we *ctx)
-{
- struct cmt_gauge *g;
-
- ctx->wmi_memory = flb_calloc(1, sizeof(struct we_wmi_memory_counters));
- if (!ctx->wmi_memory) {
- flb_errno();
- return -1;
- }
- ctx->wmi_memory->operational = FLB_FALSE;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "available_bytes",
- "The amount of physical memory, in bytes, immediately available " \
- "for allocation to a process or for system use. (AvailableBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->available_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "cache_bytes",
- "The size, in bytes, of the portion of the system file cache " \
- "which is currently resident and active in physical memory "\
- "(CacheBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->cache_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "cache_bytes_peak",
- "the maximum number of bytes used by the system file cache " \
- "since the system was last restarted (CacheBytesPeak)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->cache_bytes_peak = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "cache_faults_total",
- "The rate at which faults occur when a page sought in " \
- "the file system cache is not found and must be retrieved " \
- "from elsewhere in memory (a soft fault) or from disk (a hard fault)" \
- "(CacheFaultsPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->cache_faults_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "commit_limit",
- "The amount of virtual memory that can be committed " \
- "without having to extend the paging file(s) " \
- "(CommitLimit)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->commit_limit = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "committed_bytes",
- "The amount of committed virtual memory, in bytes " \
- "(CommittedBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->committed_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "demand_zero_faults_total",
- "The rate at which a zeroed page is required to satisfy the fault " \
- "(DemandZeroFaultsPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->demand_zero_faults_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "free_and_zero_page_list_bytes",
- "the amount of physical memory, in bytes, that is assigned to " \
- "the free and zero page lists " \
- "(FreeAndZeroPageListBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->free_and_zero_page_list_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "free_system_page_table_entries",
- "The number of page table entries not currently in used by the system " \
- "(FreeSystemPageTableEntries)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->free_system_page_table_entries = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "modified_page_list_bytes",
- "The amount of physical memory, in bytes, that is assigned to " \
- "the modified page list " \
- "(ModifiedPageListBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->modified_page_list_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "page_faults_total",
- "The average number of pages faulted per second. " \
- "It is measured in number of pages faulted per second " \
- "because only one page is faulted in each fault operation, " \
- "hence this is also equal to the number of page fault operations " \
- "(PageFaultsPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->page_faults_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "swap_page_reads_total",
- "The rate at which the disk was read to resolve hard page faults " \
- "(PageReadsPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->swap_page_reads_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "swap_pages_read_total",
- "The rate at which pages are read from disk to resolve hard page faults " \
- "(PagesInputPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->swap_pages_read_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "swap_pages_written_total",
- "the rate at which pages are written to disk to free up space "\
- "in physical memory (PagesOutputPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->swap_pages_written_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "swap_page_operations_total",
- "the rate at which pages are read from or written " \
- "to disk to resolve hard page faults (PagesPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->swap_page_operations_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "swap_page_writes_total",
- "the rate at which pages are written to disk to free up space " \
- "in physical memory (PageWritesPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->swap_page_writes_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "pool_nonpaged_allocs_total",
- "Number of calls to allocate space in the nonpaged pool (PoolNonpagedAllocs)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->pool_nonpaged_allocs_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "pool_nonpaged_bytes",
- "the size, in bytes, of the nonpaged pool, an area of " \
- "the system virtual memory that is used for objects " \
- "that cannot be written to disk, but must remain " \
- "in physical memory as long as they are allocated " \
- "(PoolNonpagedBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->pool_nonpaged_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "pool_nonpaged_allocs_total",
- "Number of bytes of allocated space in paged pool (PoolPagedAllocs)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->pool_paged_allocs_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "pool_paged_bytes",
- "the size, in bytes, of the paged pool, an area of the system " \
- "virtual memory that is used for objects that can be written " \
- "to disk when they are not being used (PoolPagedBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->pool_paged_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "pool_paged_resident_bytes",
- "the size, in bytes, of the portion of the paged pool " \
- "that is currently resident and active in physical memory " \
- "(PoolPagedResidentBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->pool_paged_resident_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "standby_cache_core_bytes",
- "The amount of physical memory, in bytes, that is assigned " \
- "to the core standby cache page lists (StandbyCacheCoreBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->standby_cache_core_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "standby_cache_normal_priority_bytes",
- " the amount of physical memory, in bytes, that is assigned " \
- "to the normal priority standby cache page lists " \
- "(StandbyCacheNormalPriorityBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->standby_cache_normal_priority_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "standby_cache_reserve_bytes",
- "Number of physical memory size(bytes) which is assigned to " \
- "the reserve standby cache page lists (StandbyCacheReserveBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->standby_cache_reserve_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "system_cache_resident_bytes",
- "Number of physical memory size(bytes) of the portion of " \
- "the system file cache which is currently resident and active " \
- "(SystemCacheResidentBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->system_cache_resident_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "system_code_resident_bytes",
- "Number of physical memory size(bytes) of the pageable operating system code "\
- "which is currently resident and active (SystemCodeResidentBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->system_code_resident_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "system_code_total_bytes",
- "Number of virtual memory size(bytes) of the pageable operating system code " \
- "which is mapped into virtual address (SystemCodeTotalBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->system_code_total_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "system_driver_resident_bytes",
- "Number of pagable physical memory size(bytes) by used device drivers "\
- "(SystemDriverResidentBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->system_driver_resident_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "system_driver_total_bytes",
- "Number of virtual memory size(bytes) by used device drivers " \
- "(SystemDriverTotalBytes)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->system_driver_total_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "transition_faults_total",
- "Number of the rate at which page faults are resolved by recovering pages " \
- "that were being used by another process sharing the page, " \
- "or were on the modified page list or the standby list, " \
- "or were being written to disk at the time of the page fault " \
- "(TransitionFaultsPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->transition_faults_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "transition_pages_repurposed_total",
- "Number of the rate at which the number of transition cache " \
- "pages were reused for a different purpose " \
- "(TransitionPagesRePurposedPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->transition_pages_repurposed_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "memory", "write_copies_total",
- "Number of the rate at which page faults are caused by "\
- "attempts to write that have been satisfied by coping " \
- "of the page from elsewhere in physical memory " \
- "(WriteCopiesPersec)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_memory->write_copies_total = g;
-
- ctx->wmi_memory->info = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_memory->info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_memory->info->metric_instance = (void *)g;
- ctx->wmi_memory->info->type = CMT_GAUGE;
- ctx->wmi_memory->info->value_adjuster = nop_adjust;
- ctx->wmi_memory->info->wmi_counter = "Win32_PerfRawData_PerfOS_Memory";
- ctx->wmi_memory->info->wmi_property = "";
- ctx->wmi_memory->info->label_property_count = 0;
- ctx->wmi_memory->info->label_property_keys = NULL;
- ctx->wmi_memory->info->where_clause = NULL;
-
- ctx->wmi_memory->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_memory_exit(struct flb_we *ctx)
-{
- ctx->wmi_memory->operational = FLB_FALSE;
-
- flb_free(ctx->wmi_memory->info);
- flb_free(ctx->wmi_memory);
-
- return 0;
-}
-
-int we_wmi_memory_update(struct flb_we *ctx)
-{
- uint64_t timestamp = 0;
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- double val = 0;
-
- if (!ctx->wmi_memory->operational) {
- flb_plg_error(ctx->ins, "memory collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_coinitialize(ctx))) {
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- if (FAILED(we_wmi_execute_query(ctx, ctx->wmi_memory->info, &enumerator))) {
- return -1;
- }
-
- while(enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1, &class_obj, &ret);
-
- if(ret == 0) {
- break;
- }
-
- val = we_wmi_get_property_value(ctx, "AvailableBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->available_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "CacheBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->cache_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "CacheBytesPeak", class_obj);
- cmt_gauge_set(ctx->wmi_memory->cache_bytes_peak, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "CacheFaultsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->cache_faults_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "CommitLimit", class_obj);
- cmt_gauge_set(ctx->wmi_memory->commit_limit, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "CommittedBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->committed_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "DemandZeroFaultsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->demand_zero_faults_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "FreeAndZeroPageListBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->free_and_zero_page_list_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "FreeSystemPageTableEntries", class_obj);
- cmt_gauge_set(ctx->wmi_memory->free_system_page_table_entries, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "ModifiedPageListBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->modified_page_list_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PageFaultsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->page_faults_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PageReadsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->swap_page_reads_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PagesInputPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->swap_pages_read_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PagesOutputPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->swap_pages_written_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PagesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->swap_page_operations_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PageWritesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->swap_page_writes_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PoolNonpagedAllocs", class_obj);
- cmt_gauge_set(ctx->wmi_memory->pool_nonpaged_allocs_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PoolNonpagedBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->pool_nonpaged_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PoolPagedAllocs", class_obj);
- cmt_gauge_set(ctx->wmi_memory->pool_paged_allocs_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PoolPagedBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->pool_paged_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PoolPagedResidentBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->pool_paged_resident_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "StandbyCacheCoreBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->standby_cache_core_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "StandbyCacheNormalPriorityBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->standby_cache_normal_priority_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "StandbyCacheReserveBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->standby_cache_reserve_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemCacheResidentBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->system_cache_resident_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemCacheResidentBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->system_cache_resident_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemCodeResidentBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->system_code_resident_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemCodeTotalBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->system_code_total_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemDriverResidentBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->system_driver_resident_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemDriverTotalBytes", class_obj);
- cmt_gauge_set(ctx->wmi_memory->system_driver_total_bytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "TransitionFaultsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->transition_faults_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "TransitionPagesRePurposedPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->transition_pages_repurposed_total, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "WriteCopiesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_memory->write_copies_total, timestamp, val, 0, NULL);
-
- class_obj->lpVtbl->Release(class_obj);
- }
-
- enumerator->lpVtbl->Release(enumerator);
-
- we_wmi_cleanup(ctx);
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.h
deleted file mode 100644
index fd6f08d54..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_memory.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2023 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_MEMORY_H
-#define FLB_WE_WMI_MEMORY_H
-
-#include "we.h"
-
-int we_wmi_memory_init(struct flb_we *ctx);
-int we_wmi_memory_exit(struct flb_we *ctx);
-int we_wmi_memory_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.c
deleted file mode 100644
index ed5853811..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_paging_file.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-int we_wmi_paging_file_init(struct flb_we *ctx)
-{
- struct cmt_gauge *g;
-
- ctx->wmi_paging_file = flb_calloc(1, sizeof(struct we_wmi_paging_file_counters));
- if (!ctx->wmi_paging_file) {
- flb_errno();
- return -1;
- }
- ctx->wmi_paging_file->operational = FLB_FALSE;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "paging_file", "allocated_base_size_megabytes",
- "The value indicates the actual amount of disk space allocated "\
- "for use with this page file (AllocatedBaseSize)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_paging_file->allocated_base_size_megabytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "paging_file", "current_usage_megabytes",
- "The value indicates how much of the total reserved page file " \
- "is currently in use (CurrentUsage)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_paging_file->current_usage_megabytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "paging_file", "peak_usage_megabytes",
- "The value indicates the highest use page file (PeakUsage)",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_paging_file->peak_usage_megabytes = g;
-
- ctx->wmi_paging_file->info = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_paging_file->info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_paging_file->info->metric_instance = (void *)g;
- ctx->wmi_paging_file->info->type = CMT_GAUGE;
- ctx->wmi_paging_file->info->value_adjuster = nop_adjust;
- ctx->wmi_paging_file->info->wmi_counter = "Win32_PageFileUsage";
- ctx->wmi_paging_file->info->wmi_property = "";
- ctx->wmi_paging_file->info->label_property_count = 0;
- ctx->wmi_paging_file->info->label_property_keys = NULL;
- ctx->wmi_paging_file->info->where_clause = NULL;
-
- ctx->wmi_paging_file->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_paging_file_exit(struct flb_we *ctx)
-{
- ctx->wmi_paging_file->operational = FLB_FALSE;
-
- flb_free(ctx->wmi_paging_file->info);
- flb_free(ctx->wmi_paging_file);
-
- return 0;
-}
-
-int we_wmi_paging_file_update(struct flb_we *ctx)
-{
- uint64_t timestamp = 0;
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- double val = 0;
-
- if (!ctx->wmi_paging_file->operational) {
- flb_plg_error(ctx->ins, "paging_file collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_coinitialize(ctx))) {
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- if (FAILED(we_wmi_execute_query(ctx, ctx->wmi_paging_file->info, &enumerator))) {
- return -1;
- }
-
- while(enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1, &class_obj, &ret);
-
- if(ret == 0) {
- break;
- }
-
- val = we_wmi_get_property_value(ctx, "AllocatedBaseSize", class_obj);
- cmt_gauge_set(ctx->wmi_paging_file->allocated_base_size_megabytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "CurrentUsage", class_obj);
- cmt_gauge_set(ctx->wmi_paging_file->current_usage_megabytes, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "PeakUsage", class_obj);
- cmt_gauge_set(ctx->wmi_paging_file->peak_usage_megabytes, timestamp, val, 0, NULL);
-
- class_obj->lpVtbl->Release(class_obj);
- }
-
- enumerator->lpVtbl->Release(enumerator);
-
- we_wmi_cleanup(ctx);
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.h
deleted file mode 100644
index 5ed74d292..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_paging_file.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2023 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_PAGING_FILE_H
-#define FLB_WE_WMI_PAGING_FILE_H
-
-#include "we.h"
-
-int we_wmi_paging_file_init(struct flb_we *ctx);
-int we_wmi_paging_file_exit(struct flb_we *ctx);
-int we_wmi_paging_file_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.c
deleted file mode 100644
index 97226c274..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2023 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_process.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-int we_wmi_process_init(struct flb_we *ctx)
-{
- struct cmt_gauge *g;
-
- ctx->wmi_process = flb_calloc(1, sizeof(struct we_wmi_process_counters));
- if (!ctx->wmi_process) {
- flb_errno();
- return -1;
- }
- ctx->wmi_process->operational = FLB_FALSE;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "start_time",
- "Time of process start",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->start_time = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "handles",
- "Total number of handles the process has open. " \
- "This number is the sum of the handles currently " \
- "open by each thread in the process.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->handles = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "cpu_time_total",
- "Returns elapsed time that all of the threads of this process " \
- "used the processor to execute instructions by mode " \
- "(privileged, user). An instruction is the basic unit " \
- "of execution in a computer, a thread is the object " \
- "that executes instructions, and a process is " \
- "the object created when a program is run. " \
- "Code executed to handle some hardware interrupts " \
- "and trap conditions is included in this count.",
- 4, (char *[]) {"process", "process_id", "creating_process_id", "mode"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->cpu_time_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "io_bytes_total",
- "Bytes issued to I/O operations in different modes "\
- "(read, write, other).",
- 4, (char *[]) {"process", "process_id", "creating_process_id", "mode"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->io_bytes_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "io_operations_total",
- "I/O operations issued in different modes (read, write, other).",
- 4, (char *[]) {"process", "process_id", "creating_process_id", "mode"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->io_operations_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "page_faults_total",
- "Page faults by the threads executing in this process.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->page_faults_total = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "page_file_bytes",
- "Current number of bytes this process has used " \
- "in the paging file(s).",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->page_file_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "pool_bytes",
- "Pool Bytes is the last observed number of bytes " \
- "in the paged or nonpaged pool.",
- 4, (char *[]) {"process", "process_id", "creating_process_id", "pool"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->pool_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "priority_base",
- "Current base priority of this process. " \
- "Threads within a process can raise and " \
- "lower their own base priority relative to " \
- "the process base priority of the process.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->priority_base = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "private_bytes",
- "Current number of bytes this process has allocated " \
- "that cannot be shared with other processes.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->private_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "thread_count",
- "Number of threads currently active in this process.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->thread_count = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "virtual_bytes",
- "Current size, in bytes, of the virtual address space " \
- "that the process is using.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->virtual_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "working_set_private_bytes",
- "Size of the working set, in bytes, that is " \
- "use for this process only and not shared nor " \
- "shareable by other processes.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->working_set_private_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "working_set_peak_bytes",
- "Maximum size, in bytes, of the Working Set of " \
- "this process at any point in time. " \
- "The Working Set is the set of memory pages touched recently " \
- "by the threads in the process.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->working_set_peak_bytes = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "process", "working_set_bytes",
- "Maximum number of bytes in the working set of " \
- "this process at any point in time. " \
- "The working set is the set of memory pages touched recently " \
- "by the threads in the process.",
- 3, (char *[]) {"process", "process_id", "creating_process_id"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_process->working_set_bytes = g;
-
- ctx->wmi_process->info = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_process->info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_process->info->metric_instance = (void *)g;
- ctx->wmi_process->info->type = CMT_GAUGE;
- ctx->wmi_process->info->value_adjuster = nop_adjust;
- ctx->wmi_process->info->wmi_counter = "Win32_PerfRawData_PerfProc_Process";
- ctx->wmi_process->info->wmi_property = "";
- ctx->wmi_process->info->label_property_count = 0;
- ctx->wmi_process->info->label_property_keys = NULL;
- ctx->wmi_process->info->where_clause = NULL;
-
- ctx->wmi_process->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_process_exit(struct flb_we *ctx)
-{
- ctx->wmi_process->operational = FLB_FALSE;
-
- flb_free(ctx->wmi_process->info);
- flb_free(ctx->wmi_process);
-
- return 0;
-}
-
-static int wmi_process_regex_match(struct flb_regex *regex, char *name)
-{
- if (regex == NULL) {
- return 0;
- }
-
- if (name == NULL) {
- return 0;
- }
-
- return flb_regex_match(regex, name, strlen(name));
-}
-
-int we_wmi_process_filter(char *name, struct flb_we *ctx)
-{
- if (strcasestr(name, "_Total") != NULL) {
- return 1;
- }
-
- if (wmi_process_regex_match(ctx->denying_process_regex, name) ||
- !wmi_process_regex_match(ctx->allowing_process_regex, name)) {
- return 1;
- }
-
- return 0;
-}
-
-int we_wmi_process_update(struct flb_we *ctx)
-{
- uint64_t timestamp = 0;
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- double val = 0;
- char *name = NULL;
- char *process_name = NULL;
- char *process_id = NULL;
- char *creating_process_id = NULL;
- double freq = 0;
- double ticks_to_seconds = 1 / 1e7;
- char *state;
-
- if (!ctx->wmi_process->operational) {
- flb_plg_error(ctx->ins, "process collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_coinitialize(ctx))) {
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- if (FAILED(we_wmi_execute_query(ctx, ctx->wmi_process->info, &enumerator))) {
- return -1;
- }
-
- while(enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1, &class_obj, &ret);
-
- if(ret == 0) {
- break;
- }
-
- name = we_wmi_get_property_str_value(ctx, "Name", class_obj);
- if (!name) {
- continue;
- }
- /* Remove # from the duplicated process names */
- process_name = strtok_s(name, "#", &state);
- if (we_wmi_process_filter(process_name, ctx) == 1) {
- flb_free(name);
-
- continue;
- }
-
- process_id = we_wmi_get_property_str_value(ctx, "IDProcess", class_obj);
- creating_process_id = we_wmi_get_property_str_value(ctx, "CreatingProcessID", class_obj);
- freq = we_wmi_get_property_value(ctx, "Frequency_Object", class_obj);
-
- val = we_wmi_get_property_value(ctx, "ElapsedTime", class_obj);
- cmt_gauge_set(ctx->wmi_process->start_time, timestamp,
- (double)((val-116444736000000000)/freq),
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "HandleCount", class_obj);
- cmt_gauge_set(ctx->wmi_process->handles, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "PercentUserTime", class_obj);
- cmt_gauge_set(ctx->wmi_process->cpu_time_total, timestamp, val * ticks_to_seconds,
- 4, (char *[]) {process_name, process_id, creating_process_id, "user"});
-
- val = we_wmi_get_property_value(ctx, "PercentPrivilegedTime", class_obj);
- cmt_gauge_set(ctx->wmi_process->cpu_time_total, timestamp, val * ticks_to_seconds,
- 4, (char *[]) {process_name, process_id, creating_process_id, "privileged"});
-
- val = we_wmi_get_property_value(ctx, "IOOtherBytesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_process->io_bytes_total, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "other"});
-
- val = we_wmi_get_property_value(ctx, "IOOtherOperationsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_process->io_operations_total, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "other"});
-
- val = we_wmi_get_property_value(ctx, "IOReadBytesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_process->io_bytes_total, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "read"});
-
- val = we_wmi_get_property_value(ctx, "IOReadOperationsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_process->io_operations_total, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "read"});
-
- val = we_wmi_get_property_value(ctx, "IOWriteBytesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_process->io_bytes_total, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "write"});
-
- val = we_wmi_get_property_value(ctx, "IOWriteOperationsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_process->io_operations_total, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "write"});
-
- val = we_wmi_get_property_value(ctx, "PageFaultsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_process->page_faults_total, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "PageFileBytes", class_obj);
- cmt_gauge_set(ctx->wmi_process->page_file_bytes, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "PoolNonpagedBytes", class_obj);
- cmt_gauge_set(ctx->wmi_process->pool_bytes, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "nonpaged"});
-
- val = we_wmi_get_property_value(ctx, "PoolPagedBytes", class_obj);
- cmt_gauge_set(ctx->wmi_process->pool_bytes, timestamp, val,
- 4, (char *[]) {process_name, process_id, creating_process_id, "paged"});
-
- val = we_wmi_get_property_value(ctx, "PriorityBase", class_obj);
- cmt_gauge_set(ctx->wmi_process->priority_base, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "ThreadCount", class_obj);
- cmt_gauge_set(ctx->wmi_process->thread_count, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "PrivateBytes", class_obj);
- cmt_gauge_set(ctx->wmi_process->private_bytes, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "VirtualBytes", class_obj);
- cmt_gauge_set(ctx->wmi_process->virtual_bytes, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "WorkingSetPrivate", class_obj);
- cmt_gauge_set(ctx->wmi_process->working_set_private_bytes, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "WorkingSetPeak", class_obj);
- cmt_gauge_set(ctx->wmi_process->working_set_peak_bytes, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- val = we_wmi_get_property_value(ctx, "WorkingSet", class_obj);
- cmt_gauge_set(ctx->wmi_process->working_set_bytes, timestamp, val,
- 3, (char *[]) {process_name, process_id, creating_process_id});
-
- class_obj->lpVtbl->Release(class_obj);
-
- flb_free(name);
- flb_free(process_id);
- flb_free(creating_process_id);
- }
-
- enumerator->lpVtbl->Release(enumerator);
-
- we_wmi_cleanup(ctx);
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.h
deleted file mode 100644
index 0ad921ea6..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_process.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2023 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_PROCESS_INFO_H
-#define FLB_WE_WMI_PROCESS_INFO_H
-
-#include "we.h"
-
-int we_wmi_process_info_init(struct flb_we *ctx);
-int we_wmi_process_info_exit(struct flb_we *ctx);
-int we_wmi_process_info_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.c
deleted file mode 100644
index e31a4943b..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.c
+++ /dev/null
@@ -1,493 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2023 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_service.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-static int construct_include_clause(struct flb_we *ctx, flb_sds_t *clause)
-{
- int ret = -1;
- size_t off = 0;
- msgpack_unpacked result;
- msgpack_object key;
- msgpack_object val;
- msgpack_object map;
- int map_size;
- int i;
- int idx = 0;
- int use_like = FLB_FALSE;
- char *key_str = NULL;
- size_t key_str_size = 0;
- char *val_str = NULL;
- size_t val_str_size = 0;
- flb_sds_t val_buf;
-
- msgpack_unpacked_init(&result);
- while (msgpack_unpack_next(&result,
- ctx->service_include_buffer,
- ctx->service_include_buffer_size,
- &off) == MSGPACK_UNPACK_SUCCESS) {
- if (result.data.type != MSGPACK_OBJECT_MAP) {
- flb_plg_error(ctx->ins, "Invalid include buffer");
- ret = -2;
-
- goto cleanup;
- }
-
- map = result.data;
- map_size = map.via.map.size;
-
- for (i = 0; i < map_size; i++) {
- use_like = FLB_FALSE;
- if (idx == 0) {
- flb_sds_cat_safe(clause, "(", 1);
- }
- else {
- flb_sds_cat_safe(clause, " OR ", 4);
- }
-
- key = map.via.map.ptr[i].key;
- val = map.via.map.ptr[i].val;
- if (key.type == MSGPACK_OBJECT_BIN) {
- key_str = (char *) key.via.bin.ptr;
- key_str_size = key.via.bin.size;
- }
- else if (key.type == MSGPACK_OBJECT_STR) {
- key_str = (char *) key.via.str.ptr;
- key_str_size = key.via.str.size;
- }
- if (val.type == MSGPACK_OBJECT_BIN) {
- val_str = (char *) val.via.bin.ptr;
- val_str_size = val.via.bin.size;
- val_buf = flb_sds_create_len(val_str, val_str_size);
- if (val_buf == NULL) {
- flb_plg_error(ctx->ins, "val_buf creation is failed");
- ret = -3;
-
- goto cleanup;
- }
- }
- else if (val.type == MSGPACK_OBJECT_STR) {
- val_str = (char *) val.via.str.ptr;
- val_str_size = val.via.str.size;
- val_buf = flb_sds_create_len(val_str, val_str_size);
- if (val_buf == NULL) {
- flb_plg_error(ctx->ins, "val_buf creation is failed");
- ret = -3;
-
- goto cleanup;
- }
- }
-
- if (val_str != NULL && strstr(val_buf, "%") != NULL) {
- use_like = FLB_TRUE;
- flb_sds_destroy(val_buf);
- }
- flb_sds_cat_safe(clause, key_str, key_str_size);
- if (use_like == FLB_TRUE) {
- flb_sds_cat_safe(clause, " LIKE ", 6);
- }
- else {
- flb_sds_cat_safe(clause, "=", 1);
- }
- flb_sds_cat_safe(clause, "'", 1);
- flb_sds_cat_safe(clause, val_str, val_str_size);
- flb_sds_cat_safe(clause, "'", 1);
- idx++;
- }
- flb_sds_cat_safe(clause, ")", 1);
- }
- msgpack_unpacked_destroy(&result);
-
- return 0;
-
-cleanup:
- msgpack_unpacked_destroy(&result);
-
- return ret;
-}
-
-static int construct_exclude_clause(struct flb_we *ctx, flb_sds_t *clause)
-{
- int ret = -1;
- size_t off = 0;
- msgpack_unpacked result;
- msgpack_object key;
- msgpack_object val;
- msgpack_object map;
- int map_size;
- int i;
- int idx = 0;
- int use_like = FLB_FALSE;
- char *key_str = NULL;
- size_t key_str_size = 0;
- char *val_str = NULL;
- size_t val_str_size = 0;
- flb_sds_t val_buf;
-
- msgpack_unpacked_init(&result);
- while (msgpack_unpack_next(&result,
- ctx->service_exclude_buffer,
- ctx->service_exclude_buffer_size,
- &off) == MSGPACK_UNPACK_SUCCESS) {
- if (result.data.type != MSGPACK_OBJECT_MAP) {
- flb_plg_error(ctx->ins, "Invalid exclude buffer");
- ret = -2;
-
- goto cleanup;
- }
-
- map = result.data;
- map_size = map.via.map.size;
-
- for (i = 0; i < map_size; i++) {
- use_like = FLB_FALSE;
- if (idx == 0) {
- flb_sds_cat_safe(clause, "(", 1);
- }
- else {
- flb_sds_cat_safe(clause, " AND ", 5);
- }
-
- key = map.via.map.ptr[i].key;
- val = map.via.map.ptr[i].val;
- if (key.type == MSGPACK_OBJECT_BIN) {
- key_str = (char *) key.via.bin.ptr;
- key_str_size = key.via.bin.size;
- }
- else if (key.type == MSGPACK_OBJECT_STR) {
- key_str = (char *) key.via.str.ptr;
- key_str_size = key.via.str.size;
- }
- if (val.type == MSGPACK_OBJECT_BIN) {
- val_str = (char *) val.via.bin.ptr;
- val_str_size = val.via.bin.size;
- val_buf = flb_sds_create_len(val_str, val_str_size);
- if (val_buf == NULL) {
- flb_plg_error(ctx->ins, "val_buf creation is failed");
- ret = -3;
-
- goto cleanup;
- }
- }
- else if (val.type == MSGPACK_OBJECT_STR) {
- val_str = (char *) val.via.str.ptr;
- val_str_size = val.via.str.size;
- val_buf = flb_sds_create_len(val_str, val_str_size);
- if (val_buf == NULL) {
- flb_plg_error(ctx->ins, "val_buf creation is failed");
- ret = -3;
-
- goto cleanup;
- }
- }
-
- if (val_str != NULL && strstr(val_buf, "%") != NULL) {
- use_like = FLB_TRUE;
- flb_sds_destroy(val_buf);
- }
- if (use_like == FLB_TRUE) {
- flb_sds_cat_safe(clause, "NOT ", 4);
- }
- flb_sds_cat_safe(clause, key_str, key_str_size);
- if (use_like == FLB_TRUE) {
- flb_sds_cat_safe(clause, " LIKE ", 6);
- }
- else {
- flb_sds_cat_safe(clause, "!=", 2);
- }
- flb_sds_cat_safe(clause, "'", 1);
- flb_sds_cat_safe(clause, val_str, val_str_size);
- flb_sds_cat_safe(clause, "'", 1);
- idx++;
- }
- flb_sds_cat_safe(clause, ")", 1);
- }
- msgpack_unpacked_destroy(&result);
-
- return 0;
-
-cleanup:
- msgpack_unpacked_destroy(&result);
-
- return ret;
-}
-
-static int construct_where_clause(struct flb_we *ctx)
-{
- int ret;
- flb_sds_t clause;
-
- clause = flb_sds_create_size(256);
- if (!clause) {
- return -1;
- }
-
- if (ctx->service_include_buffer != NULL && ctx->service_include_buffer_size > 0) {
- ret = construct_include_clause(ctx, &clause);
- if (ret != 0) {
- goto cleanup;
- }
- }
-
- if (ctx->service_exclude_buffer != NULL && ctx->service_exclude_buffer_size > 0) {
- if (flb_sds_len(clause) > 0) {
- flb_sds_cat_safe(&clause, " AND ", 5);
- }
- ret = construct_exclude_clause(ctx, &clause);
- if (ret != 0) {
- goto cleanup;
- }
- }
-
- if (ctx->raw_where_clause != NULL){
- if (flb_sds_len(clause) > 0) {
- flb_sds_cat_safe(&clause, " AND (", 6);
- flb_sds_cat_safe(&clause, ctx->raw_where_clause, strlen(ctx->raw_where_clause));
- flb_sds_cat_safe(&clause, ")", 1);
- }
- else {
- flb_sds_cat_safe(&clause, ctx->raw_where_clause, strlen(ctx->raw_where_clause));
- }
- }
-
- if (flb_sds_len(clause) > 0) {
- ctx->wmi_service->info->where_clause = clause;
- }
-
- return 0;
-
-cleanup:
- flb_sds_destroy(clause);
-
- return ret;
-}
-
-int we_wmi_service_init(struct flb_we *ctx)
-{
- int ret;
- struct cmt_gauge *g;
-
- ctx->wmi_service = flb_calloc(1, sizeof(struct we_wmi_service_counters));
- if (!ctx->wmi_service) {
- flb_errno();
- return -1;
- }
- ctx->wmi_service->operational = FLB_FALSE;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "service", "info",
- "A metric for Windows Service information",
- 4, (char *[]) {"name", "display_name", "process_id", "run_as"});
-
- if (!g) {
- return -1;
- }
- ctx->wmi_service->information = g;
-
-
- g = cmt_gauge_create(ctx->cmt, "windows", "service", "state",
- "A state of the service",
- 2, (char *[]){"name", "state"});
- if (!g) {
- return -1;
- }
- ctx->wmi_service->state = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "service", "start_mode",
- "A start mode of the service",
- 2, (char *[]){"name", "start_mode"});
- if (!g) {
- return -1;
- }
- ctx->wmi_service->start_mode = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "service", "status",
- "A status of the service",
- 2, (char *[]){"name", "status"});
- if (!g) {
- return -1;
- }
- ctx->wmi_service->status = g;
-
- ctx->wmi_service->info = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_service->info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_service->info->metric_instance = (void *)g;
- ctx->wmi_service->info->type = CMT_GAUGE;
- ctx->wmi_service->info->value_adjuster = nop_adjust;
- ctx->wmi_service->info->wmi_counter = "Win32_Service";
- ctx->wmi_service->info->wmi_property = "";
- ctx->wmi_service->info->label_property_count = 0;
- ctx->wmi_service->info->label_property_keys = NULL;
- ctx->wmi_service->info->where_clause = NULL;
- ret = construct_where_clause(ctx);
- if (ret != 0) {
- return ret;
- }
-
- ctx->wmi_service->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_service_exit(struct flb_we *ctx)
-{
- ctx->wmi_service->operational = FLB_FALSE;
-
- if (ctx->wmi_service->info->where_clause != NULL) {
- flb_sds_destroy(ctx->wmi_service->info->where_clause);
- }
- flb_free(ctx->wmi_service->info);
- flb_free(ctx->wmi_service);
-
- return 0;
-}
-
-int we_wmi_service_update(struct flb_we *ctx)
-{
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- int i = 0;
- uint64_t timestamp = 0;
- char *service_name = NULL;
- char *display_name = NULL;
- char *pid = NULL;
- char *run_as = NULL;
- char *str_prop = NULL;
- char *state = NULL;
- char *start_mode = NULL;
- char *status = NULL;
- char **states = (char *[]){
- "stopped", "start pending", "stop pending", "running",
- "continue pending", "pause pending", "paused", "unknown", NULL
- };
- char **statuses = (char *[]){
- "ok", "error", "degraded", "unknown",
- "pred fail", "starting", "stopping", "service",
- "stressed", "nonrecover", "no contact", "lost comm", NULL
- };
- char **start_modes = (char *[]) {
- "boot", "system", "auto", "manual", "disabled", NULL
- };
-
- if (!ctx->wmi_service->operational) {
- flb_plg_error(ctx->ins, "windows_service collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_coinitialize(ctx))) {
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- if (FAILED(we_wmi_execute_query(ctx, ctx->wmi_service->info, &enumerator))) {
- return -1;
- }
-
- while (enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1,
- &class_obj, &ret);
-
- if (0 == ret) {
- break;
- }
-
- service_name = we_wmi_get_property_str_value(ctx, "Name", class_obj);
- display_name = we_wmi_get_property_str_value(ctx, "DisplayName", class_obj);
- pid = we_wmi_get_property_str_value(ctx, "ProcessID", class_obj);
- run_as = we_wmi_get_property_str_value(ctx, "StartName", class_obj);
- state = we_wmi_get_property_str_value(ctx, "State", class_obj);
- start_mode = we_wmi_get_property_str_value(ctx, "StartMode", class_obj);
- status = we_wmi_get_property_str_value(ctx, "Status", class_obj);
-
- /* Information */
- cmt_gauge_set(ctx->wmi_service->information, timestamp, 1.0,
- 4, (char *[]){ service_name, display_name, pid, run_as});
-
- /* State */
- for (i = 0; states[i] != NULL; i++) {
- if (strcasecmp(state, states[i]) == 0) {
- cmt_gauge_set(ctx->wmi_service->state, timestamp, 1.0,
- 2, (char *[]){ service_name, states[i]});
- }
- else {
- cmt_gauge_set(ctx->wmi_service->state, timestamp, 0.0,
- 2, (char *[]){ service_name, states[i]});
- }
- }
- /* Start Mode */
- for (i = 0; start_modes[i] != NULL; i++) {
- if (strcasecmp(start_mode, start_modes[i]) == 0) {
- cmt_gauge_set(ctx->wmi_service->start_mode, timestamp, 1.0,
- 2, (char *[]){ service_name, start_modes[i]});
- }
- else {
- cmt_gauge_set(ctx->wmi_service->start_mode, timestamp, 0.0,
- 2, (char *[]){ service_name, start_modes[i]});
- }
- }
-
- /* Status */
- for (i = 0; statuses[i] != NULL; i++) {
- if (strcasecmp(status, statuses[i]) == 0) {
- cmt_gauge_set(ctx->wmi_service->status, timestamp, 1.0,
- 2, (char *[]){ service_name, statuses[i]});
- } else {
- cmt_gauge_set(ctx->wmi_service->status, timestamp, 0.0,
- 2, (char *[]){ service_name, statuses[i]});
- }
- }
-
- class_obj->lpVtbl->Release(class_obj);
-
- flb_free(service_name);
- flb_free(display_name);
- flb_free(pid);
- flb_free(run_as);
- flb_free(state);
- flb_free(start_mode);
- flb_free(status);
- }
-
- enumerator->lpVtbl->Release(enumerator);
- we_wmi_cleanup(ctx);
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.h
deleted file mode 100644
index d9b3efea9..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_service.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2023 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_SERVICE_H
-#define FLB_WE_WMI_SERVICE_H
-
-#include "we.h"
-
-int we_wmi_service_init(struct flb_we *ctx);
-int we_wmi_service_exit(struct flb_we *ctx);
-int we_wmi_service_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.c
deleted file mode 100644
index 0eb7fffaf..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_system.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-int we_wmi_system_init(struct flb_we *ctx)
-{
- ctx->wmi_system = flb_calloc(1, sizeof(struct we_wmi_system_counters));
- if (!ctx->wmi_system) {
- flb_errno();
- return -1;
- }
- ctx->wmi_system->operational = FLB_FALSE;
-
- struct cmt_gauge *g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "system", "context_switches_total",
- "Total number of context switches",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_system->context_switches = g;
-
- g = cmt_counter_create(ctx->cmt, "windows", "system", "exception_dispatches_total",
- "Total number of exception_dispatches",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_system->exception_dispatches = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "system", "processor_queue",
- "Length of processor queues",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_system->processor_queue = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "system", "system_calls_total",
- "Total number of system calls",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_system->system_calls = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "system", "system_up_time",
- "System boot time",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_system->system_up_time = g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "system", "threads",
- "Current number of threads",
- 0, NULL);
-
- if (!g) {
- return -1;
- }
- ctx->wmi_system->threads = g;
-
- ctx->wmi_system->info = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_system->info) {
- flb_errno();
- return -1;
- }
- ctx->wmi_system->info->metric_instance = (void *)g;
- ctx->wmi_system->info->type = CMT_GAUGE;
- ctx->wmi_system->info->value_adjuster = nop_adjust;
- ctx->wmi_system->info->wmi_counter = "Win32_PerfFormattedData_PerfOS_System";
- ctx->wmi_system->info->wmi_property = "";
- ctx->wmi_system->info->label_property_count = 0;
- ctx->wmi_system->info->label_property_keys = NULL;
- ctx->wmi_system->info->where_clause = NULL;
-
- ctx->wmi_system->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_system_exit(struct flb_we *ctx)
-{
- ctx->wmi_system->operational = FLB_FALSE;
-
- flb_free(ctx->wmi_system->info);
- flb_free(ctx->wmi_system);
-
- return 0;
-}
-
-int we_wmi_system_update(struct flb_we *ctx)
-{
- uint64_t timestamp = 0;
- IEnumWbemClassObject* enumerator = NULL;
- HRESULT hr;
-
- IWbemClassObject *class_obj = NULL;
- ULONG ret = 0;
- double val = 0;
-
- if (!ctx->wmi_system->operational) {
- flb_plg_error(ctx->ins, "system collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_coinitialize(ctx))) {
- return -1;
- }
-
- timestamp = cfl_time_now();
-
- if (FAILED(we_wmi_execute_query(ctx, ctx->wmi_system->info, &enumerator))) {
- return -1;
- }
-
- while(enumerator) {
- hr = enumerator->lpVtbl->Next(enumerator, WBEM_INFINITE, 1, &class_obj, &ret);
-
- if(0 == ret) {
- break;
- }
-
- val = we_wmi_get_property_value(ctx, "ContextSwitchesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_system->context_switches, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "ExceptionDispatchesPersec", class_obj);
- cmt_gauge_set(ctx->wmi_system->exception_dispatches, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "ProcessorQueueLength", class_obj);
- cmt_gauge_set(ctx->wmi_system->processor_queue, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemCallsPersec", class_obj);
- cmt_gauge_set(ctx->wmi_system->system_calls, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "SystemUpTime", class_obj);
- cmt_gauge_set(ctx->wmi_system->system_up_time, timestamp, val, 0, NULL);
-
- val = we_wmi_get_property_value(ctx, "Threads", class_obj);
- cmt_gauge_set(ctx->wmi_system->threads, timestamp, val, 0, NULL);
-
- class_obj->lpVtbl->Release(class_obj);
- }
-
- enumerator->lpVtbl->Release(enumerator);
-
- we_wmi_cleanup(ctx);
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.h
deleted file mode 100644
index abc8ea6f5..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_system.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_SYSTEM_H
-#define FLB_WE_WMI_SYSTEM_H
-
-#include "we.h"
-
-int we_wmi_system_init(struct flb_we *ctx);
-int we_wmi_system_exit(struct flb_we *ctx);
-int we_wmi_system_update(struct flb_we *ctx);
-
-#endif
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.c b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.c
deleted file mode 100644
index 1766c5907..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2019-2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fluent-bit/flb_input_plugin.h>
-#include <fluent-bit/flb_config.h>
-#include <fluent-bit/flb_config_map.h>
-#include <fluent-bit/flb_error.h>
-#include <fluent-bit/flb_pack.h>
-
-#include "we.h"
-#include "we_wmi.h"
-#include "we_wmi_thermalzone.h"
-#include "we_util.h"
-#include "we_metric.h"
-
-static double adjust_celsius(double value)
-{
- return (value/10.0) - 273.15;
-}
-
-static double nop_adjust(double value)
-{
- return value;
-}
-
-int we_wmi_thermalzone_init(struct flb_we *ctx)
-{
- ctx->wmi_thermals = flb_calloc(1, sizeof(struct we_wmi_thermal_counters));
- if (!ctx->wmi_thermals) {
- flb_errno();
- return -1;
- }
- ctx->wmi_thermals->operational = FLB_FALSE;
-
- struct cmt_gauge *g;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "thermalzone", "temperature_celsius",
- "Temperature of the sensor device.",
- 1, (char *[]) {"name"});
- if (!g) {
- return -1;
- }
-
- ctx->wmi_thermals->temperature_celsius = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_thermals->temperature_celsius) {
- return -1;
- }
- ctx->wmi_thermals->temperature_celsius->label_property_keys = (char **) flb_calloc(1, sizeof(char *));
- if (!ctx->wmi_thermals->temperature_celsius->label_property_keys) {
- return -1;
- }
-
- ctx->wmi_thermals->temperature_celsius->metric_instance = (void *)g;
- ctx->wmi_thermals->temperature_celsius->type = CMT_GAUGE;
- ctx->wmi_thermals->temperature_celsius->value_adjuster = adjust_celsius;
- ctx->wmi_thermals->temperature_celsius->wmi_counter = "Win32_PerfRawData_Counters_ThermalZoneInformation";
- ctx->wmi_thermals->temperature_celsius->wmi_property = "HighPrecisionTemperature";
- ctx->wmi_thermals->temperature_celsius->label_property_count = 1;
- ctx->wmi_thermals->temperature_celsius->label_property_keys[0] = "name" ;
- ctx->wmi_thermals->temperature_celsius->where_clause = NULL;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "thermalzone", "percent_passive_limit",
- "The limit of passive limit (percent).",
- 1, (char *[]) {"name"});
- if (!g) {
- return -1;
- }
-
- ctx->wmi_thermals->percent_passive_limit = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_thermals->percent_passive_limit) {
- flb_errno();
- return -1;
- }
-
- ctx->wmi_thermals->percent_passive_limit->label_property_keys = (char **) flb_calloc(1, sizeof(char *));
- if (!ctx->wmi_thermals->percent_passive_limit->label_property_keys) {
- flb_errno();
- return -1;
- }
-
- ctx->wmi_thermals->percent_passive_limit->metric_instance = (void *)g;
- ctx->wmi_thermals->percent_passive_limit->type = CMT_GAUGE;
- ctx->wmi_thermals->percent_passive_limit->value_adjuster = nop_adjust;
- ctx->wmi_thermals->percent_passive_limit->wmi_counter = "Win32_PerfRawData_Counters_ThermalZoneInformation";
- ctx->wmi_thermals->percent_passive_limit->wmi_property = "PercentPassiveLimit";
- ctx->wmi_thermals->percent_passive_limit->label_property_count = 1;
- ctx->wmi_thermals->percent_passive_limit->label_property_keys[0] = "name";
- ctx->wmi_thermals->percent_passive_limit->where_clause = NULL;
-
- g = cmt_gauge_create(ctx->cmt, "windows", "thermalzone", "throttle_reasons",
- "The reason of throttle.",
- 1, (char *[]) {"name"});
- if (!g) {
- return -1;
- }
- ctx->wmi_thermals->throttle_reasons = flb_calloc(1, sizeof(struct wmi_query_spec));
- if (!ctx->wmi_thermals->throttle_reasons) {
- flb_errno();
- return -1;
- }
- ctx->wmi_thermals->throttle_reasons->label_property_keys = (char **) flb_calloc(1, sizeof(char *));
- if (!ctx->wmi_thermals->throttle_reasons->label_property_keys) {
- flb_errno();
- return -1;
- }
-
- ctx->wmi_thermals->throttle_reasons->metric_instance = (void *)g;
- ctx->wmi_thermals->throttle_reasons->type = CMT_GAUGE;
- ctx->wmi_thermals->throttle_reasons->value_adjuster = nop_adjust;
- ctx->wmi_thermals->throttle_reasons->wmi_counter = "Win32_PerfRawData_Counters_ThermalZoneInformation";
- ctx->wmi_thermals->throttle_reasons->wmi_property = "ThrottleReasons";
- ctx->wmi_thermals->throttle_reasons->label_property_count = 1;
- ctx->wmi_thermals->throttle_reasons->label_property_keys[0] = "name";
- ctx->wmi_thermals->throttle_reasons->where_clause = NULL;
-
- ctx->wmi_thermals->operational = FLB_TRUE;
-
- return 0;
-}
-
-int we_wmi_thermalzone_exit(struct flb_we *ctx)
-{
- flb_free(ctx->wmi_thermals->temperature_celsius->label_property_keys);
- flb_free(ctx->wmi_thermals->temperature_celsius);
- flb_free(ctx->wmi_thermals->percent_passive_limit->label_property_keys);
- flb_free(ctx->wmi_thermals->percent_passive_limit);
- flb_free(ctx->wmi_thermals->throttle_reasons->label_property_keys);
- flb_free(ctx->wmi_thermals->throttle_reasons);
- flb_free(ctx->wmi_thermals);
-
- return 0;
-}
-
-int we_wmi_thermalzone_update(struct flb_we *ctx)
-{
- if (!ctx->wmi_thermals->operational) {
- flb_plg_error(ctx->ins, "thermalzone collector not yet in operational state");
-
- return -1;
- }
-
- if (FAILED(we_wmi_query(ctx, ctx->wmi_thermals->temperature_celsius))) {
- return -1;
- }
-
- if (FAILED(we_wmi_query(ctx, ctx->wmi_thermals->percent_passive_limit))) {
- return -1;
- }
-
- if (FAILED(we_wmi_query(ctx, ctx->wmi_thermals->throttle_reasons))) {
- return -1;
- }
-
- return 0;
-}
diff --git a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.h b/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.h
deleted file mode 100644
index a94d6dc36..000000000
--- a/src/fluent-bit/plugins/in_windows_exporter_metrics/we_wmi_thermalzone.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Fluent Bit
- * ==========
- * Copyright (C) 2022 The Fluent Bit Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FLB_WE_WMI_THERMAL_ZONE_H
-#define FLB_WE_WMI_THERMAL_ZONE_H
-
-#include "we.h"
-
-int we_wmi_thermalzone_init(struct flb_we *ctx);
-int we_wmi_thermalzone_exit(struct flb_we *ctx);
-int we_wmi_thermalzone_update(struct flb_we *ctx);
-
-#endif