diff options
Diffstat (limited to 'src/collectors/proc.plugin')
-rw-r--r-- | src/collectors/proc.plugin/integrations/zfs_pools.md | 105 | ||||
-rw-r--r-- | src/collectors/proc.plugin/ipc.c | 31 | ||||
-rw-r--r-- | src/collectors/proc.plugin/metadata.yaml | 92 | ||||
-rw-r--r-- | src/collectors/proc.plugin/plugin_proc.c | 1 | ||||
-rw-r--r-- | src/collectors/proc.plugin/plugin_proc.h | 1 | ||||
-rw-r--r-- | src/collectors/proc.plugin/proc_meminfo.c | 4 | ||||
-rw-r--r-- | src/collectors/proc.plugin/proc_spl_kstat_zfs.c | 227 | ||||
-rw-r--r-- | src/collectors/proc.plugin/proc_stat.c | 27 |
8 files changed, 10 insertions, 478 deletions
diff --git a/src/collectors/proc.plugin/integrations/zfs_pools.md b/src/collectors/proc.plugin/integrations/zfs_pools.md deleted file mode 100644 index f18c82ba..00000000 --- a/src/collectors/proc.plugin/integrations/zfs_pools.md +++ /dev/null @@ -1,105 +0,0 @@ -<!--startmeta -custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/collectors/proc.plugin/integrations/zfs_pools.md" -meta_yaml: "https://github.com/netdata/netdata/edit/master/src/collectors/proc.plugin/metadata.yaml" -sidebar_label: "ZFS Pools" -learn_status: "Published" -learn_rel_path: "Collecting Metrics/Linux Systems/Filesystem/ZFS" -most_popular: False -message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE" -endmeta--> - -# ZFS Pools - - -<img src="https://netdata.cloud/img/filesystem.svg" width="150"/> - - -Plugin: proc.plugin -Module: /proc/spl/kstat/zfs - -<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" /> - -## Overview - -This integration provides metrics about the state of ZFS pools. - - - -This collector is supported on all platforms. - -This collector supports collecting metrics from multiple instances of this integration, including remote instances. - - -### Default Behavior - -#### Auto-Detection - -This integration doesn't support auto-detection. - -#### Limits - -The default configuration for this integration does not impose any limits on data collection. - -#### Performance Impact - -The default configuration for this integration is not expected to impose a significant performance impact on the system. - - -## Metrics - -Metrics grouped by *scope*. - -The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels. - - - -### Per zfs pool - - - -Labels: - -| Label | Description | -|:-----------|:----------------| -| pool | TBD | - -Metrics: - -| Metric | Dimensions | Unit | -|:------|:----------|:----| -| zfspool.state | online, degraded, faulted, offline, removed, unavail, suspended | boolean | - - - -## Alerts - - -The following alerts are available: - -| Alert name | On metric | Description | -|:------------|:----------|:------------| -| [ zfs_pool_state_warn ](https://github.com/netdata/netdata/blob/master/src/health/health.d/zfs.conf) | zfspool.state | ZFS pool ${label:pool} state is degraded | -| [ zfs_pool_state_crit ](https://github.com/netdata/netdata/blob/master/src/health/health.d/zfs.conf) | zfspool.state | ZFS pool ${label:pool} state is faulted or unavail | - - -## Setup - -### Prerequisites - -No action required. - -### Configuration - -#### File - -There is no configuration file. -#### Options - - - -There are no configuration options. - -#### Examples -There are no configuration examples. - - diff --git a/src/collectors/proc.plugin/ipc.c b/src/collectors/proc.plugin/ipc.c index 6d7d920f..5b47116b 100644 --- a/src/collectors/proc.plugin/ipc.c +++ b/src/collectors/proc.plugin/ipc.c @@ -6,6 +6,9 @@ #include <sys/msg.h> #include <sys/shm.h> +#define _COMMON_PLUGIN_NAME PLUGIN_PROC_NAME +#define _COMMON_PLUGIN_MODULE_NAME "ipc" +#include "../common-contexts/common-contexts.h" #ifndef SEMVMX #define SEMVMX 32767 /* <= 32767 semaphore maximum value */ @@ -282,8 +285,8 @@ int do_ipc(int update_every, usec_t dt) { static struct ipc_limits limits; static struct ipc_status status; static const RRDVAR_ACQUIRED *arrays_max = NULL, *semaphores_max = NULL; - static RRDSET *st_semaphores = NULL, *st_arrays = NULL; - static RRDDIM *rd_semaphores = NULL, *rd_arrays = NULL; + static RRDSET *st_arrays = NULL; + static RRDDIM *rd_arrays = NULL; static char *msg_filename = NULL; static struct message_queue *message_queue_root = NULL; static long long dimensions_limit; @@ -314,25 +317,7 @@ int do_ipc(int update_every, usec_t dt) { do_sem = CONFIG_BOOLEAN_NO; } else { - // create the charts - if(unlikely(!st_semaphores)) { - st_semaphores = rrdset_create_localhost( - "system" - , "ipc_semaphores" - , NULL - , "ipc semaphores" - , NULL - , "IPC Semaphores" - , "semaphores" - , PLUGIN_PROC_NAME - , "ipc" - , NETDATA_CHART_PRIO_SYSTEM_IPC_SEMAPHORES - , localhost->rrd_update_every - , RRDSET_TYPE_AREA - ); - rd_semaphores = rrddim_add(st_semaphores, "semaphores", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - } - + // create the chart if(unlikely(!st_arrays)) { st_arrays = rrdset_create_localhost( "system" @@ -379,7 +364,6 @@ int do_ipc(int update_every, usec_t dt) { rrdvar_host_variable_set(localhost, arrays_max, limits.semmni); st_arrays->red = limits.semmni; - st_semaphores->red = limits.semmns; read_limits_next = 60 / update_every; } @@ -392,8 +376,7 @@ int do_ipc(int update_every, usec_t dt) { return 0; } - rrddim_set_by_pointer(st_semaphores, rd_semaphores, status.semaem); - rrdset_done(st_semaphores); + common_semaphore_ipc(status.semaem, limits.semmns, "ipc", localhost->rrd_update_every); rrddim_set_by_pointer(st_arrays, rd_arrays, status.semusz); rrdset_done(st_arrays); diff --git a/src/collectors/proc.plugin/metadata.yaml b/src/collectors/proc.plugin/metadata.yaml index fd834dd3..6d9e00d3 100644 --- a/src/collectors/proc.plugin/metadata.yaml +++ b/src/collectors/proc.plugin/metadata.yaml @@ -4497,98 +4497,6 @@ modules: - name: retransmits - meta: plugin_name: proc.plugin - module_name: /proc/spl/kstat/zfs - monitored_instance: - name: ZFS Pools - link: "" - categories: - - data-collection.linux-systems.filesystem-metrics.zfs - icon_filename: "filesystem.svg" - related_resources: - integrations: - list: [] - info_provided_to_referring_integrations: - description: "" - keywords: - - zfs pools - - pools - - zfs - - filesystem - most_popular: false - overview: - data_collection: - metrics_description: "This integration provides metrics about the state of ZFS pools." - method_description: "" - supported_platforms: - include: [] - exclude: [] - multi_instance: true - additional_permissions: - description: "" - default_behavior: - auto_detection: - description: "" - limits: - description: "" - performance_impact: - description: "" - setup: - prerequisites: - list: [] - configuration: - file: - name: "" - description: "" - options: - description: "" - folding: - title: "" - enabled: true - list: [] - examples: - folding: - enabled: true - title: "" - list: [] - troubleshooting: - problems: - list: [] - alerts: - - name: zfs_pool_state_warn - link: https://github.com/netdata/netdata/blob/master/src/health/health.d/zfs.conf - metric: zfspool.state - info: ZFS pool ${label:pool} state is degraded - - name: zfs_pool_state_crit - link: https://github.com/netdata/netdata/blob/master/src/health/health.d/zfs.conf - metric: zfspool.state - info: ZFS pool ${label:pool} state is faulted or unavail - metrics: - folding: - title: Metrics - enabled: false - description: "" - availability: [] - scopes: - - name: zfs pool - description: "" - labels: - - name: pool - description: TBD - metrics: - - name: zfspool.state - description: ZFS pool state - unit: "boolean" - chart_type: line - dimensions: - - name: online - - name: degraded - - name: faulted - - name: offline - - name: removed - - name: unavail - - name: suspended - - meta: - plugin_name: proc.plugin module_name: /proc/spl/kstat/zfs/arcstats monitored_instance: name: ZFS Adaptive Replacement Cache diff --git a/src/collectors/proc.plugin/plugin_proc.c b/src/collectors/proc.plugin/plugin_proc.c index 095cd738..b4a85646 100644 --- a/src/collectors/proc.plugin/plugin_proc.c +++ b/src/collectors/proc.plugin/plugin_proc.c @@ -62,7 +62,6 @@ static struct proc_module { // ZFS metrics {.name = "/proc/spl/kstat/zfs/arcstats", .dim = "zfs_arcstats", .func = do_proc_spl_kstat_zfs_arcstats}, - {.name = "/proc/spl/kstat/zfs/pool/state",.dim = "zfs_pool_state",.func = do_proc_spl_kstat_zfs_pool_state}, // BTRFS metrics {.name = "/sys/fs/btrfs", .dim = "btrfs", .func = do_sys_fs_btrfs}, diff --git a/src/collectors/proc.plugin/plugin_proc.h b/src/collectors/proc.plugin/plugin_proc.h index a5f7ce6e..bb1ddf48 100644 --- a/src/collectors/proc.plugin/plugin_proc.h +++ b/src/collectors/proc.plugin/plugin_proc.h @@ -37,7 +37,6 @@ int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt); int do_proc_sys_devices_pci_aer(int update_every, usec_t dt); int do_proc_sys_devices_system_node(int update_every, usec_t dt); int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt); -int do_proc_spl_kstat_zfs_pool_state(int update_every, usec_t dt); int do_sys_fs_btrfs(int update_every, usec_t dt); int do_proc_net_sockstat(int update_every, usec_t dt); int do_proc_net_sockstat6(int update_every, usec_t dt); diff --git a/src/collectors/proc.plugin/proc_meminfo.c b/src/collectors/proc.plugin/proc_meminfo.c index c11b4f64..db458b23 100644 --- a/src/collectors/proc.plugin/proc_meminfo.c +++ b/src/collectors/proc.plugin/proc_meminfo.c @@ -29,7 +29,7 @@ int do_proc_meminfo(int update_every, usec_t dt) { static ARL_BASE *arl_base = NULL; static ARL_ENTRY *arl_hwcorrupted = NULL, *arl_memavailable = NULL, *arl_hugepages_total = NULL, - *arl_zswapped = NULL, *arl_high_low = NULL, *arl_cma_total = NULL, + *arl_zswapped = NULL, *arl_high_low = NULL, *arl_directmap4k = NULL, *arl_directmap2m = NULL, *arl_directmap4m = NULL, *arl_directmap1g = NULL; static unsigned long long @@ -189,7 +189,7 @@ int do_proc_meminfo(int update_every, usec_t dt) { arl_expect(arl_base, "FilePmdMapped", &FilePmdMapped); // CONFIG_CMA - arl_cma_total = arl_expect(arl_base, "CmaTotal", &CmaTotal); + arl_expect(arl_base, "CmaTotal", &CmaTotal); arl_expect(arl_base, "CmaFree", &CmaFree); // CONFIG_UNACCEPTED_MEMORY diff --git a/src/collectors/proc.plugin/proc_spl_kstat_zfs.c b/src/collectors/proc.plugin/proc_spl_kstat_zfs.c index 53cc299b..be96f444 100644 --- a/src/collectors/proc.plugin/proc_spl_kstat_zfs.c +++ b/src/collectors/proc.plugin/proc_spl_kstat_zfs.c @@ -200,230 +200,3 @@ int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) { return 0; } - -struct zfs_pool { - RRDSET *st; - - RRDDIM *rd_online; - RRDDIM *rd_degraded; - RRDDIM *rd_faulted; - RRDDIM *rd_offline; - RRDDIM *rd_removed; - RRDDIM *rd_unavail; - RRDDIM *rd_suspended; - - int updated; - int disabled; - - int online; - int degraded; - int faulted; - int offline; - int removed; - int unavail; - int suspended; -}; - -struct deleted_zfs_pool { - char *name; - struct deleted_zfs_pool *next; -} *deleted_zfs_pools = NULL; - -DICTIONARY *zfs_pools = NULL; - -void disable_zfs_pool_state(struct zfs_pool *pool) -{ - if (pool->st) - rrdset_is_obsolete___safe_from_collector_thread(pool->st); - - pool->st = NULL; - - pool->rd_online = NULL; - pool->rd_degraded = NULL; - pool->rd_faulted = NULL; - pool->rd_offline = NULL; - pool->rd_removed = NULL; - pool->rd_unavail = NULL; - pool->rd_suspended = NULL; - - pool->disabled = 1; -} - -int update_zfs_pool_state_chart(const DICTIONARY_ITEM *item, void *pool_p, void *update_every_p) { - const char *name = dictionary_acquired_item_name(item); - struct zfs_pool *pool = (struct zfs_pool *)pool_p; - int update_every = *(int *)update_every_p; - - if (pool->updated) { - pool->updated = 0; - - if (!pool->disabled) { - if (unlikely(!pool->st)) { - char chart_id[MAX_CHART_ID + 1]; - snprintf(chart_id, MAX_CHART_ID, "state_%s", name); - - pool->st = rrdset_create_localhost( - "zfspool", - chart_id, - NULL, - "state", - "zfspool.state", - "ZFS pool state", - "boolean", - PLUGIN_PROC_NAME, - ZFS_PROC_POOLS, - NETDATA_CHART_PRIO_ZFS_POOL_STATE, - update_every, - RRDSET_TYPE_LINE); - - pool->rd_online = rrddim_add(pool->st, "online", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - pool->rd_degraded = rrddim_add(pool->st, "degraded", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - pool->rd_faulted = rrddim_add(pool->st, "faulted", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - pool->rd_offline = rrddim_add(pool->st, "offline", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - pool->rd_removed = rrddim_add(pool->st, "removed", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - pool->rd_unavail = rrddim_add(pool->st, "unavail", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - pool->rd_suspended = rrddim_add(pool->st, "suspended", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - - rrdlabels_add(pool->st->rrdlabels, "pool", name, RRDLABEL_SRC_AUTO); - } - - rrddim_set_by_pointer(pool->st, pool->rd_online, pool->online); - rrddim_set_by_pointer(pool->st, pool->rd_degraded, pool->degraded); - rrddim_set_by_pointer(pool->st, pool->rd_faulted, pool->faulted); - rrddim_set_by_pointer(pool->st, pool->rd_offline, pool->offline); - rrddim_set_by_pointer(pool->st, pool->rd_removed, pool->removed); - rrddim_set_by_pointer(pool->st, pool->rd_unavail, pool->unavail); - rrddim_set_by_pointer(pool->st, pool->rd_suspended, pool->suspended); - rrdset_done(pool->st); - } - } else { - disable_zfs_pool_state(pool); - struct deleted_zfs_pool *new = callocz(1, sizeof(struct deleted_zfs_pool)); - new->name = strdupz(name); - new->next = deleted_zfs_pools; - deleted_zfs_pools = new; - } - - return 0; -} - -int do_proc_spl_kstat_zfs_pool_state(int update_every, usec_t dt) -{ - (void)dt; - - static int do_zfs_pool_state = -1; - static char *dirname = NULL; - - int pool_found = 0, state_file_found = 0; - - if (unlikely(do_zfs_pool_state == -1)) { - char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/spl/kstat/zfs"); - dirname = config_get("plugin:proc:" ZFS_PROC_POOLS, "directory to monitor", filename); - - zfs_pools = dictionary_create_advanced(DICT_OPTION_SINGLE_THREADED, &dictionary_stats_category_collectors, 0); - - do_zfs_pool_state = 1; - } - - if (likely(do_zfs_pool_state)) { - DIR *dir = opendir(dirname); - if (unlikely(!dir)) { - if (errno == ENOENT) - collector_info("Cannot read directory '%s'", dirname); - else - collector_error("Cannot read directory '%s'", dirname); - return 1; - } - - struct dirent *de = NULL; - while (likely(de = readdir(dir))) { - if (likely( - de->d_type == DT_DIR && ((de->d_name[0] == '.' && de->d_name[1] == '\0') || - (de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0')))) - continue; - - if (unlikely(de->d_type == DT_LNK || de->d_type == DT_DIR)) { - pool_found = 1; - - struct zfs_pool *pool = dictionary_get(zfs_pools, de->d_name); - - if (unlikely(!pool)) { - struct zfs_pool new_zfs_pool = {}; - pool = dictionary_set(zfs_pools, de->d_name, &new_zfs_pool, sizeof(struct zfs_pool)); - } - - pool->updated = 1; - - if (pool->disabled) { - state_file_found = 1; - continue; - } - - pool->online = 0; - pool->degraded = 0; - pool->faulted = 0; - pool->offline = 0; - pool->removed = 0; - pool->unavail = 0; - pool->suspended = 0; - - char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s/%s/state", dirname, de->d_name); - - char state[STATE_SIZE + 1]; - int ret = read_txt_file(filename, state, sizeof(state)); - - if (!ret) { - state_file_found = 1; - - // ZFS pool states are described at https://openzfs.github.io/openzfs-docs/man/8/zpoolconcepts.8.html?#Device_Failure_and_Recovery - if (!strcmp(state, "ONLINE\n")) { - pool->online = 1; - } else if (!strcmp(state, "DEGRADED\n")) { - pool->degraded = 1; - } else if (!strcmp(state, "FAULTED\n")) { - pool->faulted = 1; - } else if (!strcmp(state, "OFFLINE\n")) { - pool->offline = 1; - } else if (!strcmp(state, "REMOVED\n")) { - pool->removed = 1; - } else if (!strcmp(state, "UNAVAIL\n")) { - pool->unavail = 1; - } else if (!strcmp(state, "SUSPENDED\n")) { - pool->suspended = 1; - } else { - disable_zfs_pool_state(pool); - - char *c = strchr(state, '\n'); - if (c) - *c = '\0'; - collector_error("ZFS POOLS: Undefined state %s for zpool %s, disabling the chart", state, de->d_name); - } - } - } - } - - closedir(dir); - } - - if (do_zfs_pool_state && pool_found && !state_file_found) { - collector_info("ZFS POOLS: State files not found. Disabling the module."); - do_zfs_pool_state = 0; - } - - if (do_zfs_pool_state) - dictionary_walkthrough_read(zfs_pools, update_zfs_pool_state_chart, &update_every); - - while (deleted_zfs_pools) { - struct deleted_zfs_pool *current_pool = deleted_zfs_pools; - dictionary_del(zfs_pools, current_pool->name); - - deleted_zfs_pools = deleted_zfs_pools->next; - - freez(current_pool->name); - freez(current_pool); - } - - return 0; -} diff --git a/src/collectors/proc.plugin/proc_stat.c b/src/collectors/proc.plugin/proc_stat.c index 838d00b8..c211ceee 100644 --- a/src/collectors/proc.plugin/proc_stat.c +++ b/src/collectors/proc.plugin/proc_stat.c @@ -752,33 +752,8 @@ int do_proc_stat(int update_every, usec_t dt) { } else if(unlikely(hash == hash_intr && strcmp(row_key, "intr") == 0)) { if(likely(do_interrupts)) { - static RRDSET *st_intr = NULL; - static RRDDIM *rd_interrupts = NULL; unsigned long long value = str2ull(procfile_lineword(ff, l, 1), NULL); - - if(unlikely(!st_intr)) { - st_intr = rrdset_create_localhost( - "system" - , "intr" - , NULL - , "interrupts" - , NULL - , "CPU Interrupts" - , "interrupts/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_STAT_NAME - , NETDATA_CHART_PRIO_SYSTEM_INTR - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(st_intr, RRDSET_FLAG_DETAIL); - - rd_interrupts = rrddim_add(st_intr, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - - rrddim_set_by_pointer(st_intr, rd_interrupts, value); - rrdset_done(st_intr); + common_interrupts(value, update_every, NULL); } } else if(unlikely(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0)) { |