diff options
Diffstat (limited to 'collectors/proc.plugin')
41 files changed, 3332 insertions, 3734 deletions
diff --git a/collectors/proc.plugin/ipc.c b/collectors/proc.plugin/ipc.c index b5c9ae5e1..9185894eb 100644 --- a/collectors/proc.plugin/ipc.c +++ b/collectors/proc.plugin/ipc.c @@ -281,7 +281,7 @@ int do_ipc(int update_every, usec_t dt) { static int read_limits_next = -1; static struct ipc_limits limits; static struct ipc_status status; - static RRDVAR *arrays_max = NULL, *semaphores_max = NULL; + 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 char *msg_filename = NULL; @@ -352,8 +352,8 @@ int do_ipc(int update_every, usec_t dt) { } // variables - semaphores_max = rrdvar_custom_host_variable_create(localhost, "ipc_semaphores_max"); - arrays_max = rrdvar_custom_host_variable_create(localhost, "ipc_semaphores_arrays_max"); + semaphores_max = rrdvar_custom_host_variable_add_and_acquire(localhost, "ipc_semaphores_max"); + arrays_max = rrdvar_custom_host_variable_add_and_acquire(localhost, "ipc_semaphores_arrays_max"); } struct stat stbuf; @@ -390,17 +390,13 @@ int do_ipc(int update_every, usec_t dt) { return 0; } - if(st_semaphores->counter_done) rrdset_next(st_semaphores); rrddim_set_by_pointer(st_semaphores, rd_semaphores, status.semaem); rrdset_done(st_semaphores); - if(st_arrays->counter_done) rrdset_next(st_arrays); rrddim_set_by_pointer(st_arrays, rd_arrays, status.semusz); rrdset_done(st_arrays); } - // -------------------------------------------------------------------- - if(likely(do_msg != CONFIG_BOOLEAN_NO)) { static RRDSET *st_msq_messages = NULL, *st_msq_bytes = NULL; @@ -422,8 +418,6 @@ int do_ipc(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_STACKED ); - else - rrdset_next(st_msq_messages); if(unlikely(!st_msq_bytes)) st_msq_bytes = rrdset_create_localhost( @@ -440,8 +434,6 @@ int do_ipc(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_STACKED ); - else - rrdset_next(st_msq_bytes); struct message_queue *msq = message_queue_root, *msq_prev = NULL; while(likely(msq)){ @@ -483,11 +475,7 @@ int do_ipc(int update_every, usec_t dt) { rrdset_done(st_msq_messages); rrdset_done(st_msq_bytes); - long long dimensions_num = 0; - RRDDIM *rd; - rrdset_rdlock(st_msq_messages); - rrddim_foreach_read(rd, st_msq_messages) dimensions_num++; - rrdset_unlock(st_msq_messages); + long long dimensions_num = rrdset_number_of_dimensions(st_msq_messages); if(unlikely(dimensions_num > dimensions_limit)) { info("Message queue statistics has been disabled"); @@ -499,19 +487,17 @@ int do_ipc(int update_every, usec_t dt) { do_msg = CONFIG_BOOLEAN_NO; } else if(unlikely(!message_queue_root)) { - info("Making chart %s (%s) obsolete since it does not have any dimensions", st_msq_messages->name, st_msq_messages->id); + info("Making chart %s (%s) obsolete since it does not have any dimensions", rrdset_name(st_msq_messages), rrdset_id(st_msq_messages)); rrdset_is_obsolete(st_msq_messages); st_msq_messages = NULL; - info("Making chart %s (%s) obsolete since it does not have any dimensions", st_msq_bytes->name, st_msq_bytes->id); + info("Making chart %s (%s) obsolete since it does not have any dimensions", rrdset_name(st_msq_bytes), rrdset_id(st_msq_bytes)); rrdset_is_obsolete(st_msq_bytes); st_msq_bytes = NULL; } } } - // -------------------------------------------------------------------- - if(likely(do_shm != CONFIG_BOOLEAN_NO)) { static RRDSET *st_shm_segments = NULL, *st_shm_bytes = NULL; static RRDDIM *rd_shm_segments = NULL, *rd_shm_bytes = NULL; @@ -536,15 +522,10 @@ int do_ipc(int update_every, usec_t dt) { rd_shm_segments = rrddim_add(st_shm_segments, "segments", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_shm_segments); rrddim_set_by_pointer(st_shm_segments, rd_shm_segments, shm.segments); - rrdset_done(st_shm_segments); - // -------------------------------------------------------------------- - if(unlikely(!st_shm_bytes)) { st_shm_bytes = rrdset_create_localhost( "system" @@ -563,11 +544,8 @@ int do_ipc(int update_every, usec_t dt) { rd_shm_bytes = rrddim_add(st_shm_bytes, "bytes", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_shm_bytes); rrddim_set_by_pointer(st_shm_bytes, rd_shm_bytes, shm.bytes); - rrdset_done(st_shm_bytes); } } diff --git a/collectors/proc.plugin/plugin_proc.c b/collectors/proc.plugin/plugin_proc.c index 5033aa5e2..1b24df45f 100644 --- a/collectors/proc.plugin/plugin_proc.c +++ b/collectors/proc.plugin/plugin_proc.c @@ -40,11 +40,7 @@ static struct proc_module { {.name = "/proc/net/wireless", .dim = "netwireless", .func = do_proc_net_wireless}, {.name = "/proc/net/sockstat", .dim = "sockstat", .func = do_proc_net_sockstat}, {.name = "/proc/net/sockstat6", .dim = "sockstat6", .func = do_proc_net_sockstat6}, - {.name = "/proc/net/netstat", - .dim = "netstat", - .func = do_proc_net_netstat}, // this has to be before /proc/net/snmp, because there is a shared metric - {.name = "/proc/net/snmp", .dim = "snmp", .func = do_proc_net_snmp}, - {.name = "/proc/net/snmp6", .dim = "snmp6", .func = do_proc_net_snmp6}, + {.name = "/proc/net/netstat", .dim = "netstat", .func = do_proc_net_netstat}, {.name = "/proc/net/sctp/snmp", .dim = "sctp", .func = do_proc_net_sctp_snmp}, {.name = "/proc/net/softnet_stat", .dim = "softnet", .func = do_proc_net_softnet_stat}, {.name = "/proc/net/ip_vs/stats", .dim = "ipvs", .func = do_proc_net_ip_vs_stats}, diff --git a/collectors/proc.plugin/plugin_proc.h b/collectors/proc.plugin/plugin_proc.h index 8cb5431e5..d67ccd6e5 100644 --- a/collectors/proc.plugin/plugin_proc.h +++ b/collectors/proc.plugin/plugin_proc.h @@ -9,58 +9,55 @@ #define PLUGIN_PROC_NAME PLUGIN_PROC_CONFIG_NAME ".plugin" #define THREAD_NETDEV_NAME "PLUGIN[proc netdev]" -extern void *netdev_main(void *ptr); +void *netdev_main(void *ptr); -extern int do_proc_net_wireless(int update_every, usec_t dt); -extern int do_proc_diskstats(int update_every, usec_t dt); -extern int do_proc_mdstat(int update_every, usec_t dt); -extern int do_proc_net_snmp(int update_every, usec_t dt); -extern int do_proc_net_snmp6(int update_every, usec_t dt); -extern int do_proc_net_netstat(int update_every, usec_t dt); -extern int do_proc_net_stat_conntrack(int update_every, usec_t dt); -extern int do_proc_net_ip_vs_stats(int update_every, usec_t dt); -extern int do_proc_stat(int update_every, usec_t dt); -extern int do_proc_meminfo(int update_every, usec_t dt); -extern int do_proc_vmstat(int update_every, usec_t dt); -extern int do_proc_net_rpc_nfs(int update_every, usec_t dt); -extern int do_proc_net_rpc_nfsd(int update_every, usec_t dt); -extern int do_proc_sys_kernel_random_entropy_avail(int update_every, usec_t dt); -extern int do_proc_interrupts(int update_every, usec_t dt); -extern int do_proc_softirqs(int update_every, usec_t dt); -extern int do_proc_pressure(int update_every, usec_t dt); -extern int do_sys_kernel_mm_ksm(int update_every, usec_t dt); -extern int do_sys_block_zram(int update_every, usec_t dt); -extern int do_proc_loadavg(int update_every, usec_t dt); -extern int do_proc_net_stat_synproxy(int update_every, usec_t dt); -extern int do_proc_net_softnet_stat(int update_every, usec_t dt); -extern int do_proc_uptime(int update_every, usec_t dt); -extern int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt); -extern int do_proc_sys_devices_system_node(int update_every, usec_t dt); -extern int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt); -extern int do_proc_spl_kstat_zfs_pool_state(int update_every, usec_t dt); -extern int do_sys_fs_btrfs(int update_every, usec_t dt); -extern int do_proc_net_sockstat(int update_every, usec_t dt); -extern int do_proc_net_sockstat6(int update_every, usec_t dt); -extern int do_proc_net_sctp_snmp(int update_every, usec_t dt); -extern int do_ipc(int update_every, usec_t dt); -extern int do_sys_class_power_supply(int update_every, usec_t dt); -extern int do_proc_pagetypeinfo(int update_every, usec_t dt); -extern int do_sys_class_infiniband(int update_every, usec_t dt); -extern int get_numa_node_count(void); +int do_proc_net_wireless(int update_every, usec_t dt); +int do_proc_diskstats(int update_every, usec_t dt); +int do_proc_mdstat(int update_every, usec_t dt); +int do_proc_net_netstat(int update_every, usec_t dt); +int do_proc_net_stat_conntrack(int update_every, usec_t dt); +int do_proc_net_ip_vs_stats(int update_every, usec_t dt); +int do_proc_stat(int update_every, usec_t dt); +int do_proc_meminfo(int update_every, usec_t dt); +int do_proc_vmstat(int update_every, usec_t dt); +int do_proc_net_rpc_nfs(int update_every, usec_t dt); +int do_proc_net_rpc_nfsd(int update_every, usec_t dt); +int do_proc_sys_kernel_random_entropy_avail(int update_every, usec_t dt); +int do_proc_interrupts(int update_every, usec_t dt); +int do_proc_softirqs(int update_every, usec_t dt); +int do_proc_pressure(int update_every, usec_t dt); +int do_sys_kernel_mm_ksm(int update_every, usec_t dt); +int do_sys_block_zram(int update_every, usec_t dt); +int do_proc_loadavg(int update_every, usec_t dt); +int do_proc_net_stat_synproxy(int update_every, usec_t dt); +int do_proc_net_softnet_stat(int update_every, usec_t dt); +int do_proc_uptime(int update_every, usec_t dt); +int do_proc_sys_devices_system_edac_mc(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); +int do_proc_net_sctp_snmp(int update_every, usec_t dt); +int do_ipc(int update_every, usec_t dt); +int do_sys_class_power_supply(int update_every, usec_t dt); +int do_proc_pagetypeinfo(int update_every, usec_t dt); +int do_sys_class_infiniband(int update_every, usec_t dt); +int get_numa_node_count(void); // metrics that need to be shared among data collectors -extern unsigned long long tcpext_TCPSynRetrans; extern unsigned long long zfs_arcstats_shrinkable_cache_size_bytes; // netdev renames -extern void netdev_rename_device_add( +void netdev_rename_device_add( const char *host_device, const char *container_device, const char *container_name, DICTIONARY *labels, const char *ctx_prefix); -extern void netdev_rename_device_del(const char *host_device); +void netdev_rename_device_del(const char *host_device); #include "proc_self_mountinfo.h" #include "proc_pressure.h" diff --git a/collectors/proc.plugin/proc_diskstats.c b/collectors/proc.plugin/proc_diskstats.c index be4a481cd..28d0e7584 100644 --- a/collectors/proc.plugin/proc_diskstats.c +++ b/collectors/proc.plugin/proc_diskstats.c @@ -25,6 +25,8 @@ static struct disk { char *mount_point; + char *chart_id; + // disk options caching int do_io; int do_ops; @@ -283,7 +285,7 @@ void bcache_read_priority_stats(struct disk *d, const char *family, int update_e if(unlikely(!d->st_bcache_cache_allocations)) { d->st_bcache_cache_allocations = rrdset_create_localhost( "disk_bcache_cache_alloc" - , d->device + , d->chart_id , d->disk , family , "disk.bcache_cache_alloc" @@ -304,7 +306,6 @@ void bcache_read_priority_stats(struct disk *d, const char *family, int update_e d->bcache_priority_stats_update_every_usec = update_every * USEC_PER_SEC; } - else rrdset_next(d->st_bcache_cache_allocations); rrddim_set_by_pointer(d->st_bcache_cache_allocations, d->rd_bcache_cache_allocations_unused, unused); rrddim_set_by_pointer(d->st_bcache_cache_allocations, d->rd_bcache_cache_allocations_dirty, dirty); @@ -609,6 +610,26 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis last->next = d; } + d->chart_id = strdupz(d->device); + + // read device uuid if it is an LVM volume + if (!strncmp(d->device, "dm-", 3)) { + char uuid_filename[FILENAME_MAX + 1]; + snprintfz(uuid_filename, FILENAME_MAX, path_to_sys_devices_virtual_block_device, disk); + strncat(uuid_filename, "/dm/uuid", FILENAME_MAX); + + char device_uuid[RRD_ID_LENGTH_MAX + 1]; + if (!read_file(uuid_filename, device_uuid, RRD_ID_LENGTH_MAX) && !strncmp(device_uuid, "LVM-", 4)) { + trim(device_uuid); + + char chart_id[RRD_ID_LENGTH_MAX + 1]; + snprintf(chart_id, RRD_ID_LENGTH_MAX, "%s-%s", d->device, device_uuid + 4); + + freez(d->chart_id); + d->chart_id = strdupz(chart_id); + } + } + char buffer[FILENAME_MAX + 1]; // find if it is a physical disk @@ -831,25 +852,25 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis } static void add_labels_to_disk(struct disk *d, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", d->disk, RRDLABEL_SRC_AUTO); - rrdlabels_add(st->state->chart_labels, "mount_point", d->mount_point, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", d->disk, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "mount_point", d->mount_point, RRDLABEL_SRC_AUTO); switch (d->type) { default: case DISK_TYPE_UNKNOWN: - rrdlabels_add(st->state->chart_labels, "device_type", "unknown", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "unknown", RRDLABEL_SRC_AUTO); break; case DISK_TYPE_PHYSICAL: - rrdlabels_add(st->state->chart_labels, "device_type", "physical", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "physical", RRDLABEL_SRC_AUTO); break; case DISK_TYPE_PARTITION: - rrdlabels_add(st->state->chart_labels, "device_type", "partition", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "partition", RRDLABEL_SRC_AUTO); break; case DISK_TYPE_VIRTUAL: - rrdlabels_add(st->state->chart_labels, "device_type", "virtual", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "virtual", RRDLABEL_SRC_AUTO); break; } } @@ -1076,7 +1097,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_io)) { d->st_io = rrdset_create_localhost( RRD_TYPE_DISK - , d->device + , d->chart_id , d->disk , family , "disk.io" @@ -1094,20 +1115,17 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_io); } - else rrdset_next(d->st_io); last_readsectors = rrddim_set_by_pointer(d->st_io, d->rd_io_reads, readsectors); last_writesectors = rrddim_set_by_pointer(d->st_io, d->rd_io_writes, writesectors); rrdset_done(d->st_io); } - // -------------------------------------------------------------------- - if (do_dc_stats && d->do_io == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { if (unlikely(!d->st_ext_io)) { d->st_ext_io = rrdset_create_localhost( "disk_ext" - , d->device + , d->chart_id , d->disk , family , "disk_ext.io" @@ -1123,15 +1141,12 @@ int do_proc_diskstats(int update_every, usec_t dt) { d->rd_io_discards = rrddim_add(d->st_ext_io, "discards", NULL, d->sector_size, 1024, RRD_ALGORITHM_INCREMENTAL); add_labels_to_disk(d, d->st_ext_io); - } else - rrdset_next(d->st_ext_io); + } last_discardsectors = rrddim_set_by_pointer(d->st_ext_io, d->rd_io_discards, discardsectors); rrdset_done(d->st_ext_io); } - // -------------------------------------------------------------------- - if(d->do_ops == CONFIG_BOOLEAN_YES || (d->do_ops == CONFIG_BOOLEAN_AUTO && (reads || writes || discards || flushes || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { @@ -1140,7 +1155,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_ops)) { d->st_ops = rrdset_create_localhost( "disk_ops" - , d->device + , d->chart_id , d->disk , family , "disk.ops" @@ -1160,20 +1175,17 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_ops); } - else rrdset_next(d->st_ops); last_reads = rrddim_set_by_pointer(d->st_ops, d->rd_ops_reads, reads); last_writes = rrddim_set_by_pointer(d->st_ops, d->rd_ops_writes, writes); rrdset_done(d->st_ops); } - // -------------------------------------------------------------------- - if (do_dc_stats && d->do_ops == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { if (unlikely(!d->st_ext_ops)) { d->st_ext_ops = rrdset_create_localhost( "disk_ext_ops" - , d->device + , d->chart_id , d->disk , family , "disk_ext.ops" @@ -1194,8 +1206,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_ext_ops); } - else - rrdset_next(d->st_ext_ops); last_discards = rrddim_set_by_pointer(d->st_ext_ops, d->rd_ops_discards, discards); if (do_fl_stats) @@ -1203,8 +1213,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { rrdset_done(d->st_ext_ops); } - // -------------------------------------------------------------------- - if(d->do_qops == CONFIG_BOOLEAN_YES || (d->do_qops == CONFIG_BOOLEAN_AUTO && (queued_ios || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { d->do_qops = CONFIG_BOOLEAN_YES; @@ -1212,7 +1220,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_qops)) { d->st_qops = rrdset_create_localhost( "disk_qops" - , d->device + , d->chart_id , d->disk , family , "disk.qops" @@ -1231,14 +1239,11 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_qops); } - else rrdset_next(d->st_qops); rrddim_set_by_pointer(d->st_qops, d->rd_qops_operations, queued_ios); rrdset_done(d->st_qops); } - // -------------------------------------------------------------------- - if(d->do_backlog == CONFIG_BOOLEAN_YES || (d->do_backlog == CONFIG_BOOLEAN_AUTO && (backlog_ms || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { d->do_backlog = CONFIG_BOOLEAN_YES; @@ -1246,7 +1251,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_backlog)) { d->st_backlog = rrdset_create_localhost( "disk_backlog" - , d->device + , d->chart_id , d->disk , family , "disk.backlog" @@ -1265,14 +1270,11 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_backlog); } - else rrdset_next(d->st_backlog); rrddim_set_by_pointer(d->st_backlog, d->rd_backlog_backlog, backlog_ms); rrdset_done(d->st_backlog); } - // -------------------------------------------------------------------- - if(d->do_util == CONFIG_BOOLEAN_YES || (d->do_util == CONFIG_BOOLEAN_AUTO && (busy_ms || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { d->do_util = CONFIG_BOOLEAN_YES; @@ -1280,7 +1282,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_busy)) { d->st_busy = rrdset_create_localhost( "disk_busy" - , d->device + , d->chart_id , d->disk , family , "disk.busy" @@ -1299,17 +1301,14 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_busy); } - else rrdset_next(d->st_busy); last_busy_ms = rrddim_set_by_pointer(d->st_busy, d->rd_busy_busy, busy_ms); rrdset_done(d->st_busy); - // -------------------------------------------------------------------- - if(unlikely(!d->st_util)) { d->st_util = rrdset_create_localhost( "disk_util" - , d->device + , d->chart_id , d->disk , family , "disk.util" @@ -1328,7 +1327,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_util); } - else rrdset_next(d->st_util); collected_number disk_utilization = (busy_ms - last_busy_ms) / (10 * update_every); if (disk_utilization > 100) @@ -1338,8 +1336,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { rrdset_done(d->st_util); } - // -------------------------------------------------------------------- - if(d->do_mops == CONFIG_BOOLEAN_YES || (d->do_mops == CONFIG_BOOLEAN_AUTO && (mreads || mwrites || mdiscards || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { @@ -1348,7 +1344,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_mops)) { d->st_mops = rrdset_create_localhost( "disk_mops" - , d->device + , d->chart_id , d->disk , family , "disk.mops" @@ -1368,22 +1364,19 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_mops); } - else rrdset_next(d->st_mops); rrddim_set_by_pointer(d->st_mops, d->rd_mops_reads, mreads); rrddim_set_by_pointer(d->st_mops, d->rd_mops_writes, mwrites); rrdset_done(d->st_mops); } - // -------------------------------------------------------------------- - if(do_dc_stats && d->do_mops == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { d->do_mops = CONFIG_BOOLEAN_YES; if(unlikely(!d->st_ext_mops)) { d->st_ext_mops = rrdset_create_localhost( "disk_ext_mops" - , d->device + , d->chart_id , d->disk , family , "disk_ext.mops" @@ -1402,15 +1395,11 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_ext_mops); } - else - rrdset_next(d->st_ext_mops); rrddim_set_by_pointer(d->st_ext_mops, d->rd_mops_discards, mdiscards); rrdset_done(d->st_ext_mops); } - // -------------------------------------------------------------------- - if(d->do_iotime == CONFIG_BOOLEAN_YES || (d->do_iotime == CONFIG_BOOLEAN_AUTO && (readms || writems || discardms || flushms || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { d->do_iotime = CONFIG_BOOLEAN_YES; @@ -1418,7 +1407,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_iotime)) { d->st_iotime = rrdset_create_localhost( "disk_iotime" - , d->device + , d->chart_id , d->disk , family , "disk.iotime" @@ -1438,20 +1427,17 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_iotime); } - else rrdset_next(d->st_iotime); last_readms = rrddim_set_by_pointer(d->st_iotime, d->rd_iotime_reads, readms); last_writems = rrddim_set_by_pointer(d->st_iotime, d->rd_iotime_writes, writems); rrdset_done(d->st_iotime); } - // -------------------------------------------------------------------- - if(do_dc_stats && d->do_iotime == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { if(unlikely(!d->st_ext_iotime)) { d->st_ext_iotime = rrdset_create_localhost( "disk_ext_iotime" - , d->device + , d->chart_id , d->disk , family , "disk_ext.iotime" @@ -1472,8 +1458,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_ext_iotime); } - else - rrdset_next(d->st_ext_iotime); last_discardms = rrddim_set_by_pointer(d->st_ext_iotime, d->rd_iotime_discards, discardms); if (do_fl_stats) @@ -1481,7 +1465,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { rrdset_done(d->st_ext_iotime); } - // -------------------------------------------------------------------- // calculate differential charts // only if this is not the first time we run @@ -1496,7 +1479,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_await)) { d->st_await = rrdset_create_localhost( "disk_await" - , d->device + , d->chart_id , d->disk , family , "disk.await" @@ -1516,7 +1499,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_await); } - else rrdset_next(d->st_await); rrddim_set_by_pointer(d->st_await, d->rd_await_reads, (reads - last_reads) ? (readms - last_readms) / (reads - last_reads) : 0); rrddim_set_by_pointer(d->st_await, d->rd_await_writes, (writes - last_writes) ? (writems - last_writems) / (writes - last_writes) : 0); @@ -1527,7 +1509,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_ext_await)) { d->st_ext_await = rrdset_create_localhost( "disk_ext_await" - , d->device + , d->chart_id , d->disk , family , "disk_ext.await" @@ -1548,8 +1530,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_ext_await); } - else - rrdset_next(d->st_ext_await); rrddim_set_by_pointer( d->st_ext_await, d->rd_await_discards, @@ -1571,7 +1551,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_avgsz)) { d->st_avgsz = rrdset_create_localhost( "disk_avgsz" - , d->device + , d->chart_id , d->disk , family , "disk.avgsz" @@ -1591,7 +1571,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_avgsz); } - else rrdset_next(d->st_avgsz); rrddim_set_by_pointer(d->st_avgsz, d->rd_avgsz_reads, (reads - last_reads) ? (readsectors - last_readsectors) / (reads - last_reads) : 0); rrddim_set_by_pointer(d->st_avgsz, d->rd_avgsz_writes, (writes - last_writes) ? (writesectors - last_writesectors) / (writes - last_writes) : 0); @@ -1602,7 +1581,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_ext_avgsz)) { d->st_ext_avgsz = rrdset_create_localhost( "disk_ext_avgsz" - , d->device + , d->chart_id , d->disk , family , "disk_ext.avgsz" @@ -1621,8 +1600,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_ext_avgsz); } - else - rrdset_next(d->st_ext_avgsz); rrddim_set_by_pointer( d->st_ext_avgsz, d->rd_avgsz_discards, @@ -1641,7 +1618,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_svctm)) { d->st_svctm = rrdset_create_localhost( "disk_svctm" - , d->device + , d->chart_id , d->disk , family , "disk.svctm" @@ -1660,15 +1637,12 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_svctm); } - else - rrdset_next(d->st_svctm); rrddim_set_by_pointer(d->st_svctm, d->rd_svctm_svctm, ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0); rrdset_done(d->st_svctm); } } - // -------------------------------------------------------------------------- // read bcache metrics and generate the bcache charts if(d->device_is_bcache && d->do_bcache != CONFIG_BOOLEAN_NO) { @@ -1749,7 +1723,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_bcache_hit_ratio)) { d->st_bcache_hit_ratio = rrdset_create_localhost( "disk_bcache_hit_ratio" - , d->device + , d->chart_id , d->disk , family , "disk.bcache_hit_ratio" @@ -1769,8 +1743,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_bcache_hit_ratio); } - else - rrdset_next(d->st_bcache_hit_ratio); rrddim_set_by_pointer(d->st_bcache_hit_ratio, d->rd_bcache_hit_ratio_5min, stats_five_minute_cache_hit_ratio); rrddim_set_by_pointer(d->st_bcache_hit_ratio, d->rd_bcache_hit_ratio_1hour, stats_hour_cache_hit_ratio); @@ -1784,7 +1756,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_bcache_rates)) { d->st_bcache_rates = rrdset_create_localhost( "disk_bcache_rates" - , d->device + , d->chart_id , d->disk , family , "disk.bcache_rates" @@ -1802,8 +1774,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_bcache_rates); } - else - rrdset_next(d->st_bcache_rates); rrddim_set_by_pointer(d->st_bcache_rates, d->rd_bcache_rate_writeback, writeback_rate); rrddim_set_by_pointer(d->st_bcache_rates, d->rd_bcache_rate_congested, cache_congested); @@ -1814,7 +1784,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_bcache_size)) { d->st_bcache_size = rrdset_create_localhost( "disk_bcache_size" - , d->device + , d->chart_id , d->disk , family , "disk.bcache_size" @@ -1831,8 +1801,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_bcache_size); } - else - rrdset_next(d->st_bcache_size); rrddim_set_by_pointer(d->st_bcache_size, d->rd_bcache_dirty_size, dirty_data); rrdset_done(d->st_bcache_size); @@ -1842,7 +1810,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_bcache_usage)) { d->st_bcache_usage = rrdset_create_localhost( "disk_bcache_usage" - , d->device + , d->chart_id , d->disk , family , "disk.bcache_usage" @@ -1859,8 +1827,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_bcache_usage); } - else - rrdset_next(d->st_bcache_usage); rrddim_set_by_pointer(d->st_bcache_usage, d->rd_bcache_available_percent, cache_available_percent); rrdset_done(d->st_bcache_usage); @@ -1871,7 +1837,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_bcache_cache_read_races)) { d->st_bcache_cache_read_races = rrdset_create_localhost( "disk_bcache_cache_read_races" - , d->device + , d->chart_id , d->disk , family , "disk.bcache_cache_read_races" @@ -1889,8 +1855,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_bcache_cache_read_races); } - else - rrdset_next(d->st_bcache_cache_read_races); rrddim_set_by_pointer(d->st_bcache_cache_read_races, d->rd_bcache_cache_read_races, cache_read_races); rrddim_set_by_pointer(d->st_bcache_cache_read_races, d->rd_bcache_cache_io_errors, cache_io_errors); @@ -1906,7 +1870,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_bcache)) { d->st_bcache = rrdset_create_localhost( "disk_bcache" - , d->device + , d->chart_id , d->disk , family , "disk.bcache" @@ -1928,8 +1892,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_bcache); } - else - rrdset_next(d->st_bcache); rrddim_set_by_pointer(d->st_bcache, d->rd_bcache_hits, stats_total_cache_hits); rrddim_set_by_pointer(d->st_bcache, d->rd_bcache_misses, stats_total_cache_misses); @@ -1946,7 +1908,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(unlikely(!d->st_bcache_bypass)) { d->st_bcache_bypass = rrdset_create_localhost( "disk_bcache_bypass" - , d->device + , d->chart_id , d->disk , family , "disk.bcache_bypass" @@ -1966,7 +1928,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { add_labels_to_disk(d, d->st_bcache_bypass); } - else rrdset_next(d->st_bcache_bypass); rrddim_set_by_pointer(d->st_bcache_bypass, d->rd_bcache_bypass_hits, stats_total_cache_bypass_hits); rrddim_set_by_pointer(d->st_bcache_bypass, d->rd_bcache_bypass_misses, stats_total_cache_bypass_misses); @@ -1975,8 +1936,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { } } - - // ------------------------------------------------------------------------ // update the system total I/O if(global_do_io == CONFIG_BOOLEAN_YES || (global_do_io == CONFIG_BOOLEAN_AUTO && @@ -2004,15 +1963,12 @@ int do_proc_diskstats(int update_every, usec_t dt) { rd_in = rrddim_add(st_io, "in", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_io, "out", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_io); rrddim_set_by_pointer(st_io, rd_in, system_read_kb); rrddim_set_by_pointer(st_io, rd_out, system_write_kb); rrdset_done(st_io); } - - // ------------------------------------------------------------------------ // cleanup removed disks struct disk *d = disk_root, *last = NULL; @@ -2021,12 +1977,19 @@ int do_proc_diskstats(int update_every, usec_t dt) { struct disk *t = d; rrdset_obsolete_and_pointer_null(d->st_avgsz); + rrdset_obsolete_and_pointer_null(d->st_ext_avgsz); rrdset_obsolete_and_pointer_null(d->st_await); + rrdset_obsolete_and_pointer_null(d->st_ext_await); rrdset_obsolete_and_pointer_null(d->st_backlog); + rrdset_obsolete_and_pointer_null(d->st_busy); rrdset_obsolete_and_pointer_null(d->st_io); + rrdset_obsolete_and_pointer_null(d->st_ext_io); rrdset_obsolete_and_pointer_null(d->st_iotime); + rrdset_obsolete_and_pointer_null(d->st_ext_iotime); rrdset_obsolete_and_pointer_null(d->st_mops); + rrdset_obsolete_and_pointer_null(d->st_ext_mops); rrdset_obsolete_and_pointer_null(d->st_ops); + rrdset_obsolete_and_pointer_null(d->st_ext_ops); rrdset_obsolete_and_pointer_null(d->st_qops); rrdset_obsolete_and_pointer_null(d->st_svctm); rrdset_obsolete_and_pointer_null(d->st_util); @@ -2036,6 +1999,8 @@ int do_proc_diskstats(int update_every, usec_t dt) { rrdset_obsolete_and_pointer_null(d->st_bcache_size); rrdset_obsolete_and_pointer_null(d->st_bcache_usage); rrdset_obsolete_and_pointer_null(d->st_bcache_hit_ratio); + rrdset_obsolete_and_pointer_null(d->st_bcache_cache_allocations); + rrdset_obsolete_and_pointer_null(d->st_bcache_cache_read_races); if(d == disk_root) { disk_root = d = d->next; @@ -2066,6 +2031,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { freez(t->disk); freez(t->device); freez(t->mount_point); + freez(t->chart_id); freez(t); } else { diff --git a/collectors/proc.plugin/proc_interrupts.c b/collectors/proc.plugin/proc_interrupts.c index 46290554b..f87684758 100644 --- a/collectors/proc.plugin/proc_interrupts.c +++ b/collectors/proc.plugin/proc_interrupts.c @@ -146,8 +146,6 @@ int do_proc_interrupts(int update_every, usec_t dt) { irr->used = 1; } - // -------------------------------------------------------------------- - static RRDSET *st_system_interrupts = NULL; if(unlikely(!st_system_interrupts)) st_system_interrupts = rrdset_create_localhost( @@ -164,8 +162,6 @@ int do_proc_interrupts(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_STACKED ); - else - rrdset_next(st_system_interrupts); for(l = 0; l < lines ;l++) { struct interrupt *irr = irrindex(irrs, l, cpus); @@ -173,9 +169,9 @@ int do_proc_interrupts(int update_every, usec_t dt) { // some interrupt may have changed without changing the total number of lines // if the same number of interrupts have been added and removed between two // calls of this function. - if(unlikely(!irr->rd || strncmp(irr->rd->name, irr->name, MAX_INTERRUPT_NAME) != 0)) { + if(unlikely(!irr->rd || strncmp(rrddim_name(irr->rd), irr->name, MAX_INTERRUPT_NAME) != 0)) { irr->rd = rrddim_add(st_system_interrupts, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_set_name(st_system_interrupts, irr->rd, irr->name); + rrddim_reset_name(st_system_interrupts, irr->rd, irr->name); // also reset per cpu RRDDIMs to avoid repeating strncmp() in the per core loop if(likely(do_per_core != CONFIG_BOOLEAN_NO)) { @@ -190,8 +186,6 @@ int do_proc_interrupts(int update_every, usec_t dt) { rrdset_done(st_system_interrupts); - // -------------------------------------------------------------------- - if(likely(do_per_core != CONFIG_BOOLEAN_NO)) { static RRDSET **core_st = NULL; static int old_cpus = 0; @@ -228,16 +222,15 @@ int do_proc_interrupts(int update_every, usec_t dt) { char core[50+1]; snprintfz(core, 50, "cpu%d", c); - rrdlabels_add(core_st[c]->state->chart_labels, "cpu", core, RRDLABEL_SRC_AUTO); + rrdlabels_add(core_st[c]->rrdlabels, "cpu", core, RRDLABEL_SRC_AUTO); } - else rrdset_next(core_st[c]); for(l = 0; l < lines ;l++) { struct interrupt *irr = irrindex(irrs, l, cpus); if(irr->used && (do_per_core == CONFIG_BOOLEAN_YES || irr->cpu[c].value)) { if(unlikely(!irr->cpu[c].rd)) { irr->cpu[c].rd = rrddim_add(core_st[c], irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_set_name(core_st[c], irr->cpu[c].rd, irr->name); + rrddim_reset_name(core_st[c], irr->cpu[c].rd, irr->name); } rrddim_set_by_pointer(core_st[c], irr->cpu[c].rd, irr->cpu[c].value); diff --git a/collectors/proc.plugin/proc_loadavg.c b/collectors/proc.plugin/proc_loadavg.c index 8b78ecc9e..d928c8617 100644 --- a/collectors/proc.plugin/proc_loadavg.c +++ b/collectors/proc.plugin/proc_loadavg.c @@ -52,9 +52,6 @@ int do_proc_loadavg(int update_every, usec_t dt) { // //unsigned long long next_pid = str2ull(procfile_lineword(ff, 0, 5)); - - // -------------------------------------------------------------------- - if(next_loadavg_dt <= dt) { if(likely(do_loadavg)) { static RRDSET *load_chart = NULL; @@ -80,8 +77,6 @@ int do_proc_loadavg(int update_every, usec_t dt) { rd_load5 = rrddim_add(load_chart, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); rd_load15 = rrddim_add(load_chart, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(load_chart); rrddim_set_by_pointer(load_chart, rd_load1, (collected_number) (load1 * 1000)); rrddim_set_by_pointer(load_chart, rd_load5, (collected_number) (load5 * 1000)); @@ -90,16 +85,17 @@ int do_proc_loadavg(int update_every, usec_t dt) { next_loadavg_dt = load_chart->update_every * USEC_PER_SEC; } - else next_loadavg_dt = MIN_LOADAVG_UPDATE_EVERY * USEC_PER_SEC; + else + next_loadavg_dt = MIN_LOADAVG_UPDATE_EVERY * USEC_PER_SEC; } - else next_loadavg_dt -= dt; + else + next_loadavg_dt -= dt; - // -------------------------------------------------------------------- if(likely(do_all_processes)) { static RRDSET *processes_chart = NULL; static RRDDIM *rd_active = NULL; - static RRDSETVAR *rd_pidmax; + static const RRDSETVAR_ACQUIRED *rd_pidmax; if(unlikely(!processes_chart)) { processes_chart = rrdset_create_localhost( @@ -118,12 +114,11 @@ int do_proc_loadavg(int update_every, usec_t dt) { ); rd_active = rrddim_add(processes_chart, "active", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - rd_pidmax = rrdsetvar_custom_chart_variable_create(processes_chart, "pidmax"); + rd_pidmax = rrdsetvar_custom_chart_variable_add_and_acquire(processes_chart, "pidmax"); } - else rrdset_next(processes_chart); rrddim_set_by_pointer(processes_chart, rd_active, active_processes); - rrdsetvar_custom_chart_variable_set(rd_pidmax, max_processes); + rrdsetvar_custom_chart_variable_set(processes_chart, rd_pidmax, max_processes); rrdset_done(processes_chart); } diff --git a/collectors/proc.plugin/proc_mdstat.c b/collectors/proc.plugin/proc_mdstat.c index c8015827e..63e0c68eb 100644 --- a/collectors/proc.plugin/proc_mdstat.c +++ b/collectors/proc.plugin/proc_mdstat.c @@ -78,8 +78,8 @@ static inline void make_chart_obsolete(char *name, const char *id_modifier) } static void add_labels_to_mdstat(struct raid *raid, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", raid->name, RRDLABEL_SRC_AUTO); - rrdlabels_add(st->state->chart_labels, "raid_level", raid->level, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", raid->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "raid_level", raid->level, RRDLABEL_SRC_AUTO); } int do_proc_mdstat(int update_every, usec_t dt) @@ -392,8 +392,6 @@ int do_proc_mdstat(int update_every, usec_t dt) } } - // -------------------------------------------------------------------- - if (likely(do_health && redundant_num)) { static RRDSET *st_mdstat_health = NULL; if (unlikely(!st_mdstat_health)) { @@ -413,8 +411,6 @@ int do_proc_mdstat(int update_every, usec_t dt) rrdset_isnot_obsolete(st_mdstat_health); } - else - rrdset_next(st_mdstat_health); if (!redundant_num) { if (likely(make_charts_obsolete)) @@ -435,8 +431,6 @@ int do_proc_mdstat(int update_every, usec_t dt) } } - // -------------------------------------------------------------------- - for (raid_idx = 0; raid_idx < raids_num; raid_idx++) { struct raid *raid = &raids[raid_idx]; char id[50 + 1]; @@ -467,8 +461,6 @@ int do_proc_mdstat(int update_every, usec_t dt) add_labels_to_mdstat(raid, raid->st_disks); } - else - rrdset_next(raid->st_disks); if (unlikely(!raid->rd_inuse && !(raid->rd_inuse = rrddim_find_active(raid->st_disks, "inuse")))) raid->rd_inuse = rrddim_add(raid->st_disks, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -477,12 +469,9 @@ int do_proc_mdstat(int update_every, usec_t dt) rrddim_set_by_pointer(raid->st_disks, raid->rd_inuse, raid->inuse_disks); rrddim_set_by_pointer(raid->st_disks, raid->rd_down, raid->failed_disks); - rrdset_done(raid->st_disks); } - // -------------------------------------------------------------------- - if (likely(do_mismatch)) { snprintfz(id, 50, "%s_mismatch", raid->name); @@ -507,19 +496,14 @@ int do_proc_mdstat(int update_every, usec_t dt) add_labels_to_mdstat(raid, raid->st_mismatch_cnt); } - else - rrdset_next(raid->st_mismatch_cnt); if (unlikely(!raid->rd_mismatch_cnt && !(raid->rd_mismatch_cnt = rrddim_find_active(raid->st_mismatch_cnt, "count")))) raid->rd_mismatch_cnt = rrddim_add(raid->st_mismatch_cnt, "count", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rrddim_set_by_pointer(raid->st_mismatch_cnt, raid->rd_mismatch_cnt, raid->mismatch_cnt); - rrdset_done(raid->st_mismatch_cnt); } - // -------------------------------------------------------------------- - if (likely(do_operations)) { snprintfz(id, 50, "%s_operation", raid->name); @@ -544,8 +528,6 @@ int do_proc_mdstat(int update_every, usec_t dt) add_labels_to_mdstat(raid, raid->st_operation); } - else - rrdset_next(raid->st_operation); if(unlikely(!raid->rd_check && !(raid->rd_check = rrddim_find_active(raid->st_operation, "check")))) raid->rd_check = rrddim_add(raid->st_operation, "check", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE); @@ -560,13 +542,9 @@ int do_proc_mdstat(int update_every, usec_t dt) rrddim_set_by_pointer(raid->st_operation, raid->rd_resync, raid->resync); rrddim_set_by_pointer(raid->st_operation, raid->rd_recovery, raid->recovery); rrddim_set_by_pointer(raid->st_operation, raid->rd_reshape, raid->reshape); - rrdset_done(raid->st_operation); - // -------------------------------------------------------------------- - snprintfz(id, 50, "%s_finish", raid->name); - if (unlikely(!raid->st_finish && !(raid->st_finish = rrdset_find_active_byname_localhost(id)))) { snprintfz(family, 50, "%s (%s)", raid->name, raid->level); @@ -587,20 +565,14 @@ int do_proc_mdstat(int update_every, usec_t dt) add_labels_to_mdstat(raid, raid->st_finish); } - else - rrdset_next(raid->st_finish); if(unlikely(!raid->rd_finish_in && !(raid->rd_finish_in = rrddim_find_active(raid->st_finish, "finish_in")))) raid->rd_finish_in = rrddim_add(raid->st_finish, "finish_in", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rrddim_set_by_pointer(raid->st_finish, raid->rd_finish_in, raid->finish_in); - rrdset_done(raid->st_finish); - // -------------------------------------------------------------------- - snprintfz(id, 50, "%s_speed", raid->name); - if (unlikely(!raid->st_speed && !(raid->st_speed = rrdset_find_active_byname_localhost(id)))) { snprintfz(family, 50, "%s (%s)", raid->name, raid->level); @@ -622,19 +594,14 @@ int do_proc_mdstat(int update_every, usec_t dt) add_labels_to_mdstat(raid, raid->st_speed); } - else - rrdset_next(raid->st_speed); if (unlikely(!raid->rd_speed && !(raid->rd_speed = rrddim_find_active(raid->st_speed, "speed")))) raid->rd_speed = rrddim_add(raid->st_speed, "speed", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rrddim_set_by_pointer(raid->st_speed, raid->rd_speed, raid->speed); - rrdset_done(raid->st_speed); } } else { - // -------------------------------------------------------------------- - if (likely(do_nonredundant)) { snprintfz(id, 50, "%s_availability", raid->name); @@ -659,14 +626,11 @@ int do_proc_mdstat(int update_every, usec_t dt) add_labels_to_mdstat(raid, raid->st_nonredundant); } - else - rrdset_next(raid->st_nonredundant); if (unlikely(!raid->rd_nonredundant && !(raid->rd_nonredundant = rrddim_find_active(raid->st_nonredundant, "available")))) raid->rd_nonredundant = rrddim_add(raid->st_nonredundant, "available", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rrddim_set_by_pointer(raid->st_nonredundant, raid->rd_nonredundant, 1); - rrdset_done(raid->st_nonredundant); } } diff --git a/collectors/proc.plugin/proc_meminfo.c b/collectors/proc.plugin/proc_meminfo.c index f89ddd8d4..2f390c653 100644 --- a/collectors/proc.plugin/proc_meminfo.c +++ b/collectors/proc.plugin/proc_meminfo.c @@ -154,8 +154,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { if (first_ff_read) first_ff_read = 0; - // -------------------------------------------------------------------- - // http://calimeroteknik.free.fr/blag/?article20/really-used-memory-on-gnu-linux unsigned long long MemCached = Cached + SReclaimable - Shmem; unsigned long long MemUsed = MemTotal - MemFree - MemCached - Buffers; @@ -190,13 +188,11 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_cached = rrddim_add(st_system_ram, "cached", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_buffers = rrddim_add(st_system_ram, "buffers", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_system_ram); rrddim_set_by_pointer(st_system_ram, rd_free, MemFree); rrddim_set_by_pointer(st_system_ram, rd_used, MemUsed); rrddim_set_by_pointer(st_system_ram, rd_cached, MemCached); rrddim_set_by_pointer(st_system_ram, rd_buffers, Buffers); - rrdset_done(st_system_ram); } @@ -222,16 +218,12 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_avail = rrddim_add(st_mem_available, "MemAvailable", "avail", 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_available); rrddim_set_by_pointer(st_mem_available, rd_avail, MemAvailable); - rrdset_done(st_mem_available); } } - // -------------------------------------------------------------------- - unsigned long long SwapUsed = SwapTotal - SwapFree; if(do_swap == CONFIG_BOOLEAN_YES || (do_swap == CONFIG_BOOLEAN_AUTO && @@ -263,16 +255,12 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_free = rrddim_add(st_system_swap, "free", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_used = rrddim_add(st_system_swap, "used", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_system_swap); rrddim_set_by_pointer(st_system_swap, rd_used, SwapUsed); rrddim_set_by_pointer(st_system_swap, rd_free, SwapFree); - rrdset_done(st_system_swap); } - // -------------------------------------------------------------------- - if(arl_hwcorrupted->flags & ARL_ENTRY_FLAG_FOUND && (do_hwcorrupt == CONFIG_BOOLEAN_YES || (do_hwcorrupt == CONFIG_BOOLEAN_AUTO && (HardwareCorrupted > 0 || @@ -302,15 +290,11 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_corrupted = rrddim_add(st_mem_hwcorrupt, "HardwareCorrupted", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_hwcorrupt); rrddim_set_by_pointer(st_mem_hwcorrupt, rd_corrupted, HardwareCorrupted); - rrdset_done(st_mem_hwcorrupt); } - // -------------------------------------------------------------------- - if(do_committed) { static RRDSET *st_mem_committed = NULL; static RRDDIM *rd_committed = NULL; @@ -335,15 +319,11 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_committed = rrddim_add(st_mem_committed, "Committed_AS", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_committed); rrddim_set_by_pointer(st_mem_committed, rd_committed, Committed_AS); - rrdset_done(st_mem_committed); } - // -------------------------------------------------------------------- - if(do_writeback) { static RRDSET *st_mem_writeback = NULL; static RRDDIM *rd_dirty = NULL, *rd_writeback = NULL, *rd_fusewriteback = NULL, *rd_nfs_writeback = NULL, *rd_bounce = NULL; @@ -371,14 +351,12 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_nfs_writeback = rrddim_add(st_mem_writeback, "NfsWriteback", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_bounce = rrddim_add(st_mem_writeback, "Bounce", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_writeback); rrddim_set_by_pointer(st_mem_writeback, rd_dirty, Dirty); rrddim_set_by_pointer(st_mem_writeback, rd_writeback, Writeback); rrddim_set_by_pointer(st_mem_writeback, rd_fusewriteback, WritebackTmp); rrddim_set_by_pointer(st_mem_writeback, rd_nfs_writeback, NFS_Unstable); rrddim_set_by_pointer(st_mem_writeback, rd_bounce, Bounce); - rrdset_done(st_mem_writeback); } @@ -414,7 +392,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { if (do_percpu) rd_percpu = rrddim_add(st_mem_kernel, "Percpu", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_kernel); rrddim_set_by_pointer(st_mem_kernel, rd_slab, Slab); rrddim_set_by_pointer(st_mem_kernel, rd_kernelstack, KernelStack); @@ -426,8 +403,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { rrdset_done(st_mem_kernel); } - // -------------------------------------------------------------------- - if(do_slab) { static RRDSET *st_mem_slab = NULL; static RRDDIM *rd_reclaimable = NULL, *rd_unreclaimable = NULL; @@ -453,16 +428,12 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_reclaimable = rrddim_add(st_mem_slab, "reclaimable", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_unreclaimable = rrddim_add(st_mem_slab, "unreclaimable", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_slab); rrddim_set_by_pointer(st_mem_slab, rd_reclaimable, SReclaimable); rrddim_set_by_pointer(st_mem_slab, rd_unreclaimable, SUnreclaim); - rrdset_done(st_mem_slab); } - // -------------------------------------------------------------------- - if(do_hugepages == CONFIG_BOOLEAN_YES || (do_hugepages == CONFIG_BOOLEAN_AUTO && ((Hugepagesize && HugePages_Total) || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { @@ -494,18 +465,14 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_surp = rrddim_add(st_mem_hugepages, "surplus", NULL, Hugepagesize, 1024, RRD_ALGORITHM_ABSOLUTE); rd_rsvd = rrddim_add(st_mem_hugepages, "reserved", NULL, Hugepagesize, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_hugepages); rrddim_set_by_pointer(st_mem_hugepages, rd_used, HugePages_Total - HugePages_Free - HugePages_Rsvd); rrddim_set_by_pointer(st_mem_hugepages, rd_free, HugePages_Free); rrddim_set_by_pointer(st_mem_hugepages, rd_rsvd, HugePages_Rsvd); rrddim_set_by_pointer(st_mem_hugepages, rd_surp, HugePages_Surp); - rrdset_done(st_mem_hugepages); } - // -------------------------------------------------------------------- - if(do_transparent_hugepages == CONFIG_BOOLEAN_YES || (do_transparent_hugepages == CONFIG_BOOLEAN_AUTO && (AnonHugePages || ShmemHugePages || @@ -536,11 +503,9 @@ int do_proc_meminfo(int update_every, usec_t dt) { rd_anonymous = rrddim_add(st_mem_transparent_hugepages, "anonymous", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_shared = rrddim_add(st_mem_transparent_hugepages, "shmem", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_mem_transparent_hugepages); rrddim_set_by_pointer(st_mem_transparent_hugepages, rd_anonymous, AnonHugePages); rrddim_set_by_pointer(st_mem_transparent_hugepages, rd_shared, ShmemHugePages); - rrdset_done(st_mem_transparent_hugepages); } diff --git a/collectors/proc.plugin/proc_net_dev.c b/collectors/proc.plugin/proc_net_dev.c index 79572f442..e124f631f 100644 --- a/collectors/proc.plugin/proc_net_dev.c +++ b/collectors/proc.plugin/proc_net_dev.c @@ -7,6 +7,8 @@ #define STATE_LENGTH_MAX 32 +#define READ_RETRY_PERIOD 60 // seconds + enum { NETDEV_DUPLEX_UNKNOWN, NETDEV_DUPLEX_HALF, @@ -55,6 +57,15 @@ static struct netdev { int configured; int enabled; int updated; + + int carrier_file_exists; + time_t carrier_file_lost_time; + + int duplex_file_exists; + time_t duplex_file_lost_time; + + int speed_file_exists; + time_t speed_file_lost_time; int do_bandwidth; int do_packets; @@ -188,7 +199,7 @@ static struct netdev { RRDDIM *rd_mtu; char *filename_speed; - RRDSETVAR *chart_var_speed; + const RRDSETVAR_ACQUIRED *chart_var_speed; char *filename_duplex; char *filename_operstate; @@ -859,21 +870,37 @@ int do_proc_net_dev(int update_every, usec_t dt) { if ((d->do_carrier != CONFIG_BOOLEAN_NO || d->do_duplex != CONFIG_BOOLEAN_NO || d->do_speed != CONFIG_BOOLEAN_NO) && - d->filename_carrier) { + d->filename_carrier && + (d->carrier_file_exists || + now_monotonic_sec() - d->carrier_file_lost_time > READ_RETRY_PERIOD)) { if (read_single_number_file(d->filename_carrier, &d->carrier)) { - error("Cannot refresh interface %s carrier state by reading '%s'. Stop updating it.", d->name, d->filename_carrier); - freez(d->filename_carrier); - d->filename_carrier = NULL; + if (d->carrier_file_exists) + error( + "Cannot refresh interface %s carrier state by reading '%s'. Next update is in %d seconds.", + d->name, + d->filename_carrier, + READ_RETRY_PERIOD); + d->carrier_file_exists = 0; + d->carrier_file_lost_time = now_monotonic_sec(); + } else { + d->carrier_file_exists = 1; + d->carrier_file_lost_time = 0; } } - if (d->do_duplex != CONFIG_BOOLEAN_NO && d->filename_duplex && (d->carrier || !d->filename_carrier)) { + if (d->do_duplex != CONFIG_BOOLEAN_NO && + d->filename_duplex && + (d->carrier || d->carrier_file_exists) && + (d->duplex_file_exists || + now_monotonic_sec() - d->duplex_file_lost_time > READ_RETRY_PERIOD)) { char buffer[STATE_LENGTH_MAX + 1]; if (read_file(d->filename_duplex, buffer, STATE_LENGTH_MAX)) { - error("Cannot refresh interface %s duplex state by reading '%s'. I will stop updating it.", d->name, d->filename_duplex); - freez(d->filename_duplex); - d->filename_duplex = NULL; + if (d->duplex_file_exists) + error("Cannot refresh interface %s duplex state by reading '%s'.", d->name, d->filename_duplex); + d->duplex_file_exists = 0; + d->duplex_file_lost_time = now_monotonic_sec(); + d->duplex = NETDEV_DUPLEX_UNKNOWN; } else { // values can be unknown, half or full -- just check the first letter for speed if (buffer[0] == 'f') @@ -882,9 +909,11 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->duplex = NETDEV_DUPLEX_HALF; else d->duplex = NETDEV_DUPLEX_UNKNOWN; + d->duplex_file_exists = 1; + d->duplex_file_lost_time = 0; } } else { - d->duplex = 0; + d->duplex = NETDEV_DUPLEX_UNKNOWN; } if(d->do_operstate != CONFIG_BOOLEAN_NO && d->filename_operstate) { @@ -904,7 +933,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { if (d->do_mtu != CONFIG_BOOLEAN_NO && d->filename_mtu) { if (read_single_number_file(d->filename_mtu, &d->mtu)) { - error("Cannot refresh mtu for interface %s by reading '%s'. Stop updating it.", d->name, d->filename_mtu); + error( + "Cannot refresh mtu for interface %s by reading '%s'. Stop updating it.", d->name, d->filename_mtu); freez(d->filename_mtu); d->filename_mtu = NULL; } @@ -921,8 +951,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { // , d->rframe, d->tcollisions, d->tcarrier // ); - // -------------------------------------------------------------------- - if(unlikely(d->do_bandwidth == CONFIG_BOOLEAN_AUTO && (d->rbytes || d->tbytes || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) d->do_bandwidth = CONFIG_BOOLEAN_YES; @@ -958,7 +986,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_tbytes = td; } } - else rrdset_next(d->st_bandwidth); rrddim_set_by_pointer(d->st_bandwidth, d->rd_rbytes, (collected_number)d->rbytes); rrddim_set_by_pointer(d->st_bandwidth, d->rd_tbytes, (collected_number)d->tbytes); @@ -967,31 +994,34 @@ int do_proc_net_dev(int update_every, usec_t dt) { // update the interface speed if(d->filename_speed) { if(unlikely(!d->chart_var_speed)) { - d->chart_var_speed = rrdsetvar_custom_chart_variable_create(d->st_bandwidth, "nic_speed_max"); + d->chart_var_speed = + rrdsetvar_custom_chart_variable_add_and_acquire(d->st_bandwidth, "nic_speed_max"); if(!d->chart_var_speed) { - error("Cannot create interface %s chart variable 'nic_speed_max'. Will not update its speed anymore.", d->name); + error( + "Cannot create interface %s chart variable 'nic_speed_max'. Will not update its speed anymore.", + d->name); freez(d->filename_speed); d->filename_speed = NULL; } } - if(d->filename_speed && d->chart_var_speed) { + if (d->filename_speed && d->chart_var_speed) { int ret = 0; - if (d->carrier || !d->filename_carrier) { + if ((d->carrier || d->carrier_file_exists) && + (d->speed_file_exists || now_monotonic_sec() - d->speed_file_lost_time > READ_RETRY_PERIOD)) { ret = read_single_number_file(d->filename_speed, (unsigned long long *) &d->speed); } else { - d->speed = 0; + d->speed = 0; // TODO: this is wrong, shouldn't use 0 value, but NULL. } if(ret) { - error("Cannot refresh interface %s speed by reading '%s'. Will not update its speed anymore.", d->name, d->filename_speed); - freez(d->filename_speed); - d->filename_speed = NULL; + if (d->speed_file_exists) + error("Cannot refresh interface %s speed by reading '%s'.", d->name, d->filename_speed); + d->speed_file_exists = 0; + d->speed_file_lost_time = now_monotonic_sec(); } else { - rrdsetvar_custom_chart_variable_set(d->chart_var_speed, (NETDATA_DOUBLE) d->speed * KILOBITS_IN_A_MEGABIT); - if(d->do_speed != CONFIG_BOOLEAN_NO) { if(unlikely(!d->st_speed)) { d->st_speed = rrdset_create_localhost( @@ -1015,18 +1045,23 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_speed = rrddim_add(d->st_speed, "speed", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(d->st_speed); rrddim_set_by_pointer(d->st_speed, d->rd_speed, (collected_number)d->speed * KILOBITS_IN_A_MEGABIT); rrdset_done(d->st_speed); } + + rrdsetvar_custom_chart_variable_set( + d->st_bandwidth, d->chart_var_speed, (NETDATA_DOUBLE)d->speed * KILOBITS_IN_A_MEGABIT); + + if (d->speed) { + d->speed_file_exists = 1; + d->speed_file_lost_time = 0; + } } } } } - // -------------------------------------------------------------------- - if(d->do_duplex != CONFIG_BOOLEAN_NO && d->filename_duplex) { if(unlikely(!d->st_duplex)) { d->st_duplex = rrdset_create_localhost( @@ -1052,7 +1087,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_duplex_half = rrddim_add(d->st_duplex, "half", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); d->rd_duplex_unknown = rrddim_add(d->st_duplex, "unknown", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(d->st_duplex); rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_full, (collected_number)(d->duplex == NETDEV_DUPLEX_FULL)); rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_half, (collected_number)(d->duplex == NETDEV_DUPLEX_HALF)); @@ -1060,8 +1094,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_done(d->st_duplex); } - // -------------------------------------------------------------------- - if(d->do_operstate != CONFIG_BOOLEAN_NO && d->filename_operstate) { if(unlikely(!d->st_operstate)) { d->st_operstate = rrdset_create_localhost( @@ -1091,7 +1123,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_operstate_dormant = rrddim_add(d->st_operstate, "dormant", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); d->rd_operstate_unknown = rrddim_add(d->st_operstate, "unknown", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(d->st_operstate); rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_up, (collected_number)(d->operstate == NETDEV_OPERSTATE_UP)); rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_down, (collected_number)(d->operstate == NETDEV_OPERSTATE_DOWN)); @@ -1103,9 +1134,7 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_done(d->st_operstate); } - // -------------------------------------------------------------------- - - if(d->do_carrier != CONFIG_BOOLEAN_NO && d->filename_carrier) { + if(d->do_carrier != CONFIG_BOOLEAN_NO && d->carrier_file_exists) { if(unlikely(!d->st_carrier)) { d->st_carrier = rrdset_create_localhost( d->chart_type_net_carrier @@ -1129,15 +1158,12 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_carrier_up = rrddim_add(d->st_carrier, "up", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); d->rd_carrier_down = rrddim_add(d->st_carrier, "down", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(d->st_carrier); rrddim_set_by_pointer(d->st_carrier, d->rd_carrier_up, (collected_number)(d->carrier == 1)); rrddim_set_by_pointer(d->st_carrier, d->rd_carrier_down, (collected_number)(d->carrier != 1)); rrdset_done(d->st_carrier); } - // -------------------------------------------------------------------- - if(d->do_mtu != CONFIG_BOOLEAN_NO && d->filename_mtu) { if(unlikely(!d->st_mtu)) { d->st_mtu = rrdset_create_localhost( @@ -1161,14 +1187,11 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_mtu = rrddim_add(d->st_mtu, "mtu", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(d->st_mtu); rrddim_set_by_pointer(d->st_mtu, d->rd_mtu, (collected_number)d->mtu); rrdset_done(d->st_mtu); } - // -------------------------------------------------------------------- - if(unlikely(d->do_packets == CONFIG_BOOLEAN_AUTO && (d->rpackets || d->tpackets || d->rmulticast || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) d->do_packets = CONFIG_BOOLEAN_YES; @@ -1207,7 +1230,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_tpackets = td; } } - else rrdset_next(d->st_packets); rrddim_set_by_pointer(d->st_packets, d->rd_rpackets, (collected_number)d->rpackets); rrddim_set_by_pointer(d->st_packets, d->rd_tpackets, (collected_number)d->tpackets); @@ -1215,8 +1237,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_done(d->st_packets); } - // -------------------------------------------------------------------- - if(unlikely(d->do_errors == CONFIG_BOOLEAN_AUTO && (d->rerrors || d->terrors || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) d->do_errors = CONFIG_BOOLEAN_YES; @@ -1254,15 +1274,12 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_terrors = td; } } - else rrdset_next(d->st_errors); rrddim_set_by_pointer(d->st_errors, d->rd_rerrors, (collected_number)d->rerrors); rrddim_set_by_pointer(d->st_errors, d->rd_terrors, (collected_number)d->terrors); rrdset_done(d->st_errors); } - // -------------------------------------------------------------------- - if(unlikely(d->do_drops == CONFIG_BOOLEAN_AUTO && (d->rdrops || d->tdrops || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) d->do_drops = CONFIG_BOOLEAN_YES; @@ -1300,15 +1317,12 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_tdrops = td; } } - else rrdset_next(d->st_drops); rrddim_set_by_pointer(d->st_drops, d->rd_rdrops, (collected_number)d->rdrops); rrddim_set_by_pointer(d->st_drops, d->rd_tdrops, (collected_number)d->tdrops); rrdset_done(d->st_drops); } - // -------------------------------------------------------------------- - if(unlikely(d->do_fifo == CONFIG_BOOLEAN_AUTO && (d->rfifo || d->tfifo || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) d->do_fifo = CONFIG_BOOLEAN_YES; @@ -1346,15 +1360,12 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_tfifo = td; } } - else rrdset_next(d->st_fifo); rrddim_set_by_pointer(d->st_fifo, d->rd_rfifo, (collected_number)d->rfifo); rrddim_set_by_pointer(d->st_fifo, d->rd_tfifo, (collected_number)d->tfifo); rrdset_done(d->st_fifo); } - // -------------------------------------------------------------------- - if(unlikely(d->do_compressed == CONFIG_BOOLEAN_AUTO && (d->rcompressed || d->tcompressed || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) d->do_compressed = CONFIG_BOOLEAN_YES; @@ -1392,15 +1403,12 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_tcompressed = td; } } - else rrdset_next(d->st_compressed); rrddim_set_by_pointer(d->st_compressed, d->rd_rcompressed, (collected_number)d->rcompressed); rrddim_set_by_pointer(d->st_compressed, d->rd_tcompressed, (collected_number)d->tcompressed); rrdset_done(d->st_compressed); } - // -------------------------------------------------------------------- - if(unlikely(d->do_events == CONFIG_BOOLEAN_AUTO && (d->rframe || d->tcollisions || d->tcarrier || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) d->do_events = CONFIG_BOOLEAN_YES; @@ -1431,7 +1439,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { d->rd_tcollisions = rrddim_add(d->st_events, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_tcarrier = rrddim_add(d->st_events, "carrier", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(d->st_events); rrddim_set_by_pointer(d->st_events, d->rd_rframe, (collected_number)d->rframe); rrddim_set_by_pointer(d->st_events, d->rd_tcollisions, (collected_number)d->tcollisions); @@ -1466,8 +1473,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { rd_in = rrddim_add(st_system_net, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_system_net, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); } - else - rrdset_next(st_system_net); rrddim_set_by_pointer(st_system_net, rd_in, (collected_number)system_rbytes); rrddim_set_by_pointer(st_system_net, rd_out, (collected_number)system_tbytes); diff --git a/collectors/proc.plugin/proc_net_ip_vs_stats.c b/collectors/proc.plugin/proc_net_ip_vs_stats.c index 43dcf2a88..2b9c9332e 100644 --- a/collectors/proc.plugin/proc_net_ip_vs_stats.c +++ b/collectors/proc.plugin/proc_net_ip_vs_stats.c @@ -39,9 +39,6 @@ int do_proc_net_ip_vs_stats(int update_every, usec_t dt) { InBytes = strtoull(procfile_lineword(ff, 2, 3), NULL, 16); OutBytes = strtoull(procfile_lineword(ff, 2, 4), NULL, 16); - - // -------------------------------------------------------------------- - if(do_sockets) { static RRDSET *st = NULL; @@ -63,14 +60,11 @@ int do_proc_net_ip_vs_stats(int update_every, usec_t dt) { rrddim_add(st, "connections", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "connections", entries); rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_packets) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -92,15 +86,12 @@ int do_proc_net_ip_vs_stats(int update_every, usec_t dt) { rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "received", InPackets); rrddim_set(st, "sent", OutPackets); rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_bandwidth) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -122,7 +113,6 @@ int do_proc_net_ip_vs_stats(int update_every, usec_t dt) { rrddim_add(st, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "received", InBytes); rrddim_set(st, "sent", OutBytes); diff --git a/collectors/proc.plugin/proc_net_netstat.c b/collectors/proc.plugin/proc_net_netstat.c index ab8206be3..f7635e3d0 100644 --- a/collectors/proc.plugin/proc_net_netstat.c +++ b/collectors/proc.plugin/proc_net_netstat.c @@ -3,14 +3,97 @@ #include "plugin_proc.h" #define RRD_TYPE_NET_NETSTAT "ip" +#define RRD_TYPE_NET_SNMP "ipv4" +#define RRD_TYPE_NET_SNMP6 "ipv6" #define PLUGIN_PROC_MODULE_NETSTAT_NAME "/proc/net/netstat" #define CONFIG_SECTION_PLUGIN_PROC_NETSTAT "plugin:" PLUGIN_PROC_CONFIG_NAME ":" PLUGIN_PROC_MODULE_NETSTAT_NAME -unsigned long long tcpext_TCPSynRetrans = 0; - -static void parse_line_pair(procfile *ff, ARL_BASE *base, size_t header_line, size_t values_line) { - size_t hwords = procfile_linewords(ff, header_line); - size_t vwords = procfile_linewords(ff, values_line); +static struct proc_net_snmp { + // kernel_uint_t ip_Forwarding; + kernel_uint_t ip_DefaultTTL; + kernel_uint_t ip_InReceives; + kernel_uint_t ip_InHdrErrors; + kernel_uint_t ip_InAddrErrors; + kernel_uint_t ip_ForwDatagrams; + kernel_uint_t ip_InUnknownProtos; + kernel_uint_t ip_InDiscards; + kernel_uint_t ip_InDelivers; + kernel_uint_t ip_OutRequests; + kernel_uint_t ip_OutDiscards; + kernel_uint_t ip_OutNoRoutes; + kernel_uint_t ip_ReasmTimeout; + kernel_uint_t ip_ReasmReqds; + kernel_uint_t ip_ReasmOKs; + kernel_uint_t ip_ReasmFails; + kernel_uint_t ip_FragOKs; + kernel_uint_t ip_FragFails; + kernel_uint_t ip_FragCreates; + + kernel_uint_t icmp_InMsgs; + kernel_uint_t icmp_OutMsgs; + kernel_uint_t icmp_InErrors; + kernel_uint_t icmp_OutErrors; + kernel_uint_t icmp_InCsumErrors; + + kernel_uint_t icmpmsg_InEchoReps; + kernel_uint_t icmpmsg_OutEchoReps; + kernel_uint_t icmpmsg_InDestUnreachs; + kernel_uint_t icmpmsg_OutDestUnreachs; + kernel_uint_t icmpmsg_InRedirects; + kernel_uint_t icmpmsg_OutRedirects; + kernel_uint_t icmpmsg_InEchos; + kernel_uint_t icmpmsg_OutEchos; + kernel_uint_t icmpmsg_InRouterAdvert; + kernel_uint_t icmpmsg_OutRouterAdvert; + kernel_uint_t icmpmsg_InRouterSelect; + kernel_uint_t icmpmsg_OutRouterSelect; + kernel_uint_t icmpmsg_InTimeExcds; + kernel_uint_t icmpmsg_OutTimeExcds; + kernel_uint_t icmpmsg_InParmProbs; + kernel_uint_t icmpmsg_OutParmProbs; + kernel_uint_t icmpmsg_InTimestamps; + kernel_uint_t icmpmsg_OutTimestamps; + kernel_uint_t icmpmsg_InTimestampReps; + kernel_uint_t icmpmsg_OutTimestampReps; + + //kernel_uint_t tcp_RtoAlgorithm; + //kernel_uint_t tcp_RtoMin; + //kernel_uint_t tcp_RtoMax; + ssize_t tcp_MaxConn; + kernel_uint_t tcp_ActiveOpens; + kernel_uint_t tcp_PassiveOpens; + kernel_uint_t tcp_AttemptFails; + kernel_uint_t tcp_EstabResets; + kernel_uint_t tcp_CurrEstab; + kernel_uint_t tcp_InSegs; + kernel_uint_t tcp_OutSegs; + kernel_uint_t tcp_RetransSegs; + kernel_uint_t tcp_InErrs; + kernel_uint_t tcp_OutRsts; + kernel_uint_t tcp_InCsumErrors; + + kernel_uint_t udp_InDatagrams; + kernel_uint_t udp_NoPorts; + kernel_uint_t udp_InErrors; + kernel_uint_t udp_OutDatagrams; + kernel_uint_t udp_RcvbufErrors; + kernel_uint_t udp_SndbufErrors; + kernel_uint_t udp_InCsumErrors; + kernel_uint_t udp_IgnoredMulti; + + kernel_uint_t udplite_InDatagrams; + kernel_uint_t udplite_NoPorts; + kernel_uint_t udplite_InErrors; + kernel_uint_t udplite_OutDatagrams; + kernel_uint_t udplite_RcvbufErrors; + kernel_uint_t udplite_SndbufErrors; + kernel_uint_t udplite_InCsumErrors; + kernel_uint_t udplite_IgnoredMulti; +} snmp_root = { 0 }; + +static void parse_line_pair(procfile *ff_netstat, ARL_BASE *base, size_t header_line, size_t values_line) { + size_t hwords = procfile_linewords(ff_netstat, header_line); + size_t vwords = procfile_linewords(ff_netstat, values_line); size_t w; if(unlikely(vwords > hwords)) { @@ -19,7 +102,7 @@ static void parse_line_pair(procfile *ff, ARL_BASE *base, size_t header_line, si } for(w = 1; w < vwords ;w++) { - if(unlikely(arl_check(base, procfile_lineword(ff, header_line, w), procfile_lineword(ff, values_line, w)))) + if(unlikely(arl_check(base, procfile_lineword(ff_netstat, header_line, w), procfile_lineword(ff_netstat, values_line, w)))) break; } } @@ -31,12 +114,38 @@ int do_proc_net_netstat(int update_every, usec_t dt) { do_tcpext_reorder = -1, do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1, do_tcpext_memory = -1, do_tcpext_syn_queue = -1, do_tcpext_accept_queue = -1; + static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1, + do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1, do_tcp_opens = -1, + do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1, do_udplite_packets = -1; + + static int do_ip6_packets = -1, do_ip6_fragsout = -1, do_ip6_fragsin = -1, do_ip6_errors = -1, + do_ip6_udplite_packets = -1, do_ip6_udplite_errors = -1, do_ip6_udp_packets = -1, do_ip6_udp_errors = -1, + do_ip6_bandwidth = -1, do_ip6_mcast = -1, do_ip6_bcast = -1, do_ip6_mcast_p = -1, do_ip6_icmp = -1, + do_ip6_icmp_redir = -1, do_ip6_icmp_errors = -1, do_ip6_icmp_echos = -1, do_ip6_icmp_groupmemb = -1, + do_ip6_icmp_router = -1, do_ip6_icmp_neighbor = -1, do_ip6_icmp_mldv2 = -1, do_ip6_icmp_types = -1, + do_ip6_ect = -1; + static uint32_t hash_ipext = 0, hash_tcpext = 0; - static procfile *ff = NULL; + static uint32_t hash_ip = 0, hash_icmp = 0, hash_tcp = 0, hash_udp = 0, hash_icmpmsg = 0, hash_udplite = 0; + + static procfile *ff_netstat = NULL; + static procfile *ff_snmp = NULL; + static procfile *ff_snmp6 = NULL; static ARL_BASE *arl_tcpext = NULL; static ARL_BASE *arl_ipext = NULL; + static ARL_BASE *arl_ip = NULL; + static ARL_BASE *arl_icmp = NULL; + static ARL_BASE *arl_icmpmsg = NULL; + static ARL_BASE *arl_tcp = NULL; + static ARL_BASE *arl_udp = NULL; + static ARL_BASE *arl_udplite = NULL; + + static ARL_BASE *arl_ipv6 = NULL; + + static const RRDVAR_ACQUIRED *tcp_max_connections_var = NULL; + // -------------------------------------------------------------------- // IP @@ -111,8 +220,103 @@ int do_proc_net_netstat(int update_every, usec_t dt) { static unsigned long long tcpext_TCPReqQFullDrop = 0; static unsigned long long tcpext_TCPReqQFullDoCookies = 0; - // shared: tcpext_TCPSynRetrans - + static unsigned long long tcpext_TCPSynRetrans = 0; + + // IPv6 + static unsigned long long Ip6InReceives = 0ULL; + static unsigned long long Ip6InHdrErrors = 0ULL; + static unsigned long long Ip6InTooBigErrors = 0ULL; + static unsigned long long Ip6InNoRoutes = 0ULL; + static unsigned long long Ip6InAddrErrors = 0ULL; + static unsigned long long Ip6InUnknownProtos = 0ULL; + static unsigned long long Ip6InTruncatedPkts = 0ULL; + static unsigned long long Ip6InDiscards = 0ULL; + static unsigned long long Ip6InDelivers = 0ULL; + static unsigned long long Ip6OutForwDatagrams = 0ULL; + static unsigned long long Ip6OutRequests = 0ULL; + static unsigned long long Ip6OutDiscards = 0ULL; + static unsigned long long Ip6OutNoRoutes = 0ULL; + static unsigned long long Ip6ReasmTimeout = 0ULL; + static unsigned long long Ip6ReasmReqds = 0ULL; + static unsigned long long Ip6ReasmOKs = 0ULL; + static unsigned long long Ip6ReasmFails = 0ULL; + static unsigned long long Ip6FragOKs = 0ULL; + static unsigned long long Ip6FragFails = 0ULL; + static unsigned long long Ip6FragCreates = 0ULL; + static unsigned long long Ip6InMcastPkts = 0ULL; + static unsigned long long Ip6OutMcastPkts = 0ULL; + static unsigned long long Ip6InOctets = 0ULL; + static unsigned long long Ip6OutOctets = 0ULL; + static unsigned long long Ip6InMcastOctets = 0ULL; + static unsigned long long Ip6OutMcastOctets = 0ULL; + static unsigned long long Ip6InBcastOctets = 0ULL; + static unsigned long long Ip6OutBcastOctets = 0ULL; + static unsigned long long Ip6InNoECTPkts = 0ULL; + static unsigned long long Ip6InECT1Pkts = 0ULL; + static unsigned long long Ip6InECT0Pkts = 0ULL; + static unsigned long long Ip6InCEPkts = 0ULL; + static unsigned long long Icmp6InMsgs = 0ULL; + static unsigned long long Icmp6InErrors = 0ULL; + static unsigned long long Icmp6OutMsgs = 0ULL; + static unsigned long long Icmp6OutErrors = 0ULL; + static unsigned long long Icmp6InCsumErrors = 0ULL; + static unsigned long long Icmp6InDestUnreachs = 0ULL; + static unsigned long long Icmp6InPktTooBigs = 0ULL; + static unsigned long long Icmp6InTimeExcds = 0ULL; + static unsigned long long Icmp6InParmProblems = 0ULL; + static unsigned long long Icmp6InEchos = 0ULL; + static unsigned long long Icmp6InEchoReplies = 0ULL; + static unsigned long long Icmp6InGroupMembQueries = 0ULL; + static unsigned long long Icmp6InGroupMembResponses = 0ULL; + static unsigned long long Icmp6InGroupMembReductions = 0ULL; + static unsigned long long Icmp6InRouterSolicits = 0ULL; + static unsigned long long Icmp6InRouterAdvertisements = 0ULL; + static unsigned long long Icmp6InNeighborSolicits = 0ULL; + static unsigned long long Icmp6InNeighborAdvertisements = 0ULL; + static unsigned long long Icmp6InRedirects = 0ULL; + static unsigned long long Icmp6InMLDv2Reports = 0ULL; + static unsigned long long Icmp6OutDestUnreachs = 0ULL; + static unsigned long long Icmp6OutPktTooBigs = 0ULL; + static unsigned long long Icmp6OutTimeExcds = 0ULL; + static unsigned long long Icmp6OutParmProblems = 0ULL; + static unsigned long long Icmp6OutEchos = 0ULL; + static unsigned long long Icmp6OutEchoReplies = 0ULL; + static unsigned long long Icmp6OutGroupMembQueries = 0ULL; + static unsigned long long Icmp6OutGroupMembResponses = 0ULL; + static unsigned long long Icmp6OutGroupMembReductions = 0ULL; + static unsigned long long Icmp6OutRouterSolicits = 0ULL; + static unsigned long long Icmp6OutRouterAdvertisements = 0ULL; + static unsigned long long Icmp6OutNeighborSolicits = 0ULL; + static unsigned long long Icmp6OutNeighborAdvertisements = 0ULL; + static unsigned long long Icmp6OutRedirects = 0ULL; + static unsigned long long Icmp6OutMLDv2Reports = 0ULL; + static unsigned long long Icmp6InType1 = 0ULL; + static unsigned long long Icmp6InType128 = 0ULL; + static unsigned long long Icmp6InType129 = 0ULL; + static unsigned long long Icmp6InType136 = 0ULL; + static unsigned long long Icmp6OutType1 = 0ULL; + static unsigned long long Icmp6OutType128 = 0ULL; + static unsigned long long Icmp6OutType129 = 0ULL; + static unsigned long long Icmp6OutType133 = 0ULL; + static unsigned long long Icmp6OutType135 = 0ULL; + static unsigned long long Icmp6OutType143 = 0ULL; + static unsigned long long Udp6InDatagrams = 0ULL; + static unsigned long long Udp6NoPorts = 0ULL; + static unsigned long long Udp6InErrors = 0ULL; + static unsigned long long Udp6OutDatagrams = 0ULL; + static unsigned long long Udp6RcvbufErrors = 0ULL; + static unsigned long long Udp6SndbufErrors = 0ULL; + static unsigned long long Udp6InCsumErrors = 0ULL; + static unsigned long long Udp6IgnoredMulti = 0ULL; + static unsigned long long UdpLite6InDatagrams = 0ULL; + static unsigned long long UdpLite6NoPorts = 0ULL; + static unsigned long long UdpLite6InErrors = 0ULL; + static unsigned long long UdpLite6OutDatagrams = 0ULL; + static unsigned long long UdpLite6RcvbufErrors = 0ULL; + static unsigned long long UdpLite6SndbufErrors = 0ULL; + static unsigned long long UdpLite6InCsumErrors = 0ULL; + + // prepare for /proc/net/netstat parsing if(unlikely(!arl_ipext)) { hash_ipext = simple_hash("IpExt"); @@ -225,645 +429,2682 @@ int do_proc_net_netstat(int update_every, usec_t dt) { arl_expect(arl_tcpext, "TCPReqQFullDoCookies", &tcpext_TCPReqQFullDoCookies); } - // shared metrics arl_expect(arl_tcpext, "TCPSynRetrans", &tcpext_TCPSynRetrans); } - if(unlikely(!ff)) { + // prepare for /proc/net/snmp parsing + + if(unlikely(!arl_ip)) { + do_ip_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 packets", CONFIG_BOOLEAN_AUTO); + do_ip_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments sent", CONFIG_BOOLEAN_AUTO); + do_ip_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments assembly", CONFIG_BOOLEAN_AUTO); + do_ip_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 errors", CONFIG_BOOLEAN_AUTO); + do_tcp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP connections", CONFIG_BOOLEAN_AUTO); + do_tcp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP packets", CONFIG_BOOLEAN_AUTO); + do_tcp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP errors", CONFIG_BOOLEAN_AUTO); + do_tcp_opens = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP opens", CONFIG_BOOLEAN_AUTO); + do_tcp_handshake = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP handshake issues", CONFIG_BOOLEAN_AUTO); + do_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP packets", CONFIG_BOOLEAN_AUTO); + do_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP errors", CONFIG_BOOLEAN_AUTO); + do_icmp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP packets", CONFIG_BOOLEAN_AUTO); + do_icmpmsg = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP messages", CONFIG_BOOLEAN_AUTO); + do_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDPLite packets", CONFIG_BOOLEAN_AUTO); + + hash_ip = simple_hash("Ip"); + hash_tcp = simple_hash("Tcp"); + hash_udp = simple_hash("Udp"); + hash_icmp = simple_hash("Icmp"); + hash_icmpmsg = simple_hash("IcmpMsg"); + hash_udplite = simple_hash("UdpLite"); + + arl_ip = arl_create("snmp/Ip", arl_callback_str2kernel_uint_t, 60); + // arl_expect(arl_ip, "Forwarding", &snmp_root.ip_Forwarding); + arl_expect(arl_ip, "DefaultTTL", &snmp_root.ip_DefaultTTL); + arl_expect(arl_ip, "InReceives", &snmp_root.ip_InReceives); + arl_expect(arl_ip, "InHdrErrors", &snmp_root.ip_InHdrErrors); + arl_expect(arl_ip, "InAddrErrors", &snmp_root.ip_InAddrErrors); + arl_expect(arl_ip, "ForwDatagrams", &snmp_root.ip_ForwDatagrams); + arl_expect(arl_ip, "InUnknownProtos", &snmp_root.ip_InUnknownProtos); + arl_expect(arl_ip, "InDiscards", &snmp_root.ip_InDiscards); + arl_expect(arl_ip, "InDelivers", &snmp_root.ip_InDelivers); + arl_expect(arl_ip, "OutRequests", &snmp_root.ip_OutRequests); + arl_expect(arl_ip, "OutDiscards", &snmp_root.ip_OutDiscards); + arl_expect(arl_ip, "OutNoRoutes", &snmp_root.ip_OutNoRoutes); + arl_expect(arl_ip, "ReasmTimeout", &snmp_root.ip_ReasmTimeout); + arl_expect(arl_ip, "ReasmReqds", &snmp_root.ip_ReasmReqds); + arl_expect(arl_ip, "ReasmOKs", &snmp_root.ip_ReasmOKs); + arl_expect(arl_ip, "ReasmFails", &snmp_root.ip_ReasmFails); + arl_expect(arl_ip, "FragOKs", &snmp_root.ip_FragOKs); + arl_expect(arl_ip, "FragFails", &snmp_root.ip_FragFails); + arl_expect(arl_ip, "FragCreates", &snmp_root.ip_FragCreates); + + arl_icmp = arl_create("snmp/Icmp", arl_callback_str2kernel_uint_t, 60); + arl_expect(arl_icmp, "InMsgs", &snmp_root.icmp_InMsgs); + arl_expect(arl_icmp, "OutMsgs", &snmp_root.icmp_OutMsgs); + arl_expect(arl_icmp, "InErrors", &snmp_root.icmp_InErrors); + arl_expect(arl_icmp, "OutErrors", &snmp_root.icmp_OutErrors); + arl_expect(arl_icmp, "InCsumErrors", &snmp_root.icmp_InCsumErrors); + + arl_icmpmsg = arl_create("snmp/Icmpmsg", arl_callback_str2kernel_uint_t, 60); + arl_expect(arl_icmpmsg, "InType0", &snmp_root.icmpmsg_InEchoReps); + arl_expect(arl_icmpmsg, "OutType0", &snmp_root.icmpmsg_OutEchoReps); + arl_expect(arl_icmpmsg, "InType3", &snmp_root.icmpmsg_InDestUnreachs); + arl_expect(arl_icmpmsg, "OutType3", &snmp_root.icmpmsg_OutDestUnreachs); + arl_expect(arl_icmpmsg, "InType5", &snmp_root.icmpmsg_InRedirects); + arl_expect(arl_icmpmsg, "OutType5", &snmp_root.icmpmsg_OutRedirects); + arl_expect(arl_icmpmsg, "InType8", &snmp_root.icmpmsg_InEchos); + arl_expect(arl_icmpmsg, "OutType8", &snmp_root.icmpmsg_OutEchos); + arl_expect(arl_icmpmsg, "InType9", &snmp_root.icmpmsg_InRouterAdvert); + arl_expect(arl_icmpmsg, "OutType9", &snmp_root.icmpmsg_OutRouterAdvert); + arl_expect(arl_icmpmsg, "InType10", &snmp_root.icmpmsg_InRouterSelect); + arl_expect(arl_icmpmsg, "OutType10", &snmp_root.icmpmsg_OutRouterSelect); + arl_expect(arl_icmpmsg, "InType11", &snmp_root.icmpmsg_InTimeExcds); + arl_expect(arl_icmpmsg, "OutType11", &snmp_root.icmpmsg_OutTimeExcds); + arl_expect(arl_icmpmsg, "InType12", &snmp_root.icmpmsg_InParmProbs); + arl_expect(arl_icmpmsg, "OutType12", &snmp_root.icmpmsg_OutParmProbs); + arl_expect(arl_icmpmsg, "InType13", &snmp_root.icmpmsg_InTimestamps); + arl_expect(arl_icmpmsg, "OutType13", &snmp_root.icmpmsg_OutTimestamps); + arl_expect(arl_icmpmsg, "InType14", &snmp_root.icmpmsg_InTimestampReps); + arl_expect(arl_icmpmsg, "OutType14", &snmp_root.icmpmsg_OutTimestampReps); + + arl_tcp = arl_create("snmp/Tcp", arl_callback_str2kernel_uint_t, 60); + // arl_expect(arl_tcp, "RtoAlgorithm", &snmp_root.tcp_RtoAlgorithm); + // arl_expect(arl_tcp, "RtoMin", &snmp_root.tcp_RtoMin); + // arl_expect(arl_tcp, "RtoMax", &snmp_root.tcp_RtoMax); + arl_expect_custom(arl_tcp, "MaxConn", arl_callback_ssize_t, &snmp_root.tcp_MaxConn); + arl_expect(arl_tcp, "ActiveOpens", &snmp_root.tcp_ActiveOpens); + arl_expect(arl_tcp, "PassiveOpens", &snmp_root.tcp_PassiveOpens); + arl_expect(arl_tcp, "AttemptFails", &snmp_root.tcp_AttemptFails); + arl_expect(arl_tcp, "EstabResets", &snmp_root.tcp_EstabResets); + arl_expect(arl_tcp, "CurrEstab", &snmp_root.tcp_CurrEstab); + arl_expect(arl_tcp, "InSegs", &snmp_root.tcp_InSegs); + arl_expect(arl_tcp, "OutSegs", &snmp_root.tcp_OutSegs); + arl_expect(arl_tcp, "RetransSegs", &snmp_root.tcp_RetransSegs); + arl_expect(arl_tcp, "InErrs", &snmp_root.tcp_InErrs); + arl_expect(arl_tcp, "OutRsts", &snmp_root.tcp_OutRsts); + arl_expect(arl_tcp, "InCsumErrors", &snmp_root.tcp_InCsumErrors); + + arl_udp = arl_create("snmp/Udp", arl_callback_str2kernel_uint_t, 60); + arl_expect(arl_udp, "InDatagrams", &snmp_root.udp_InDatagrams); + arl_expect(arl_udp, "NoPorts", &snmp_root.udp_NoPorts); + arl_expect(arl_udp, "InErrors", &snmp_root.udp_InErrors); + arl_expect(arl_udp, "OutDatagrams", &snmp_root.udp_OutDatagrams); + arl_expect(arl_udp, "RcvbufErrors", &snmp_root.udp_RcvbufErrors); + arl_expect(arl_udp, "SndbufErrors", &snmp_root.udp_SndbufErrors); + arl_expect(arl_udp, "InCsumErrors", &snmp_root.udp_InCsumErrors); + arl_expect(arl_udp, "IgnoredMulti", &snmp_root.udp_IgnoredMulti); + + arl_udplite = arl_create("snmp/Udplite", arl_callback_str2kernel_uint_t, 60); + arl_expect(arl_udplite, "InDatagrams", &snmp_root.udplite_InDatagrams); + arl_expect(arl_udplite, "NoPorts", &snmp_root.udplite_NoPorts); + arl_expect(arl_udplite, "InErrors", &snmp_root.udplite_InErrors); + arl_expect(arl_udplite, "OutDatagrams", &snmp_root.udplite_OutDatagrams); + arl_expect(arl_udplite, "RcvbufErrors", &snmp_root.udplite_RcvbufErrors); + arl_expect(arl_udplite, "SndbufErrors", &snmp_root.udplite_SndbufErrors); + arl_expect(arl_udplite, "InCsumErrors", &snmp_root.udplite_InCsumErrors); + arl_expect(arl_udplite, "IgnoredMulti", &snmp_root.udplite_IgnoredMulti); + + tcp_max_connections_var = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_max_connections"); + } + + // prepare for /proc/net/snmp6 parsing + + if(unlikely(!arl_ipv6)) { + do_ip6_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_BOOLEAN_AUTO); + do_ip6_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_BOOLEAN_AUTO); + do_ip6_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_BOOLEAN_AUTO); + do_ip6_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_BOOLEAN_AUTO); + do_ip6_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_BOOLEAN_AUTO); + do_ip6_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_BOOLEAN_AUTO); + do_ip6_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_BOOLEAN_AUTO); + do_ip6_udplite_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_BOOLEAN_AUTO); + do_ip6_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_BOOLEAN_AUTO); + do_ip6_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_BOOLEAN_AUTO); + do_ip6_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_BOOLEAN_AUTO); + do_ip6_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_redir = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_echos = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_groupmemb = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_router = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_neighbor = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_mldv2 = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_BOOLEAN_AUTO); + do_ip6_icmp_types = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_BOOLEAN_AUTO); + do_ip6_ect = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ect", CONFIG_BOOLEAN_AUTO); + + arl_ipv6 = arl_create("snmp6", NULL, 60); + arl_expect(arl_ipv6, "Ip6InReceives", &Ip6InReceives); + arl_expect(arl_ipv6, "Ip6InHdrErrors", &Ip6InHdrErrors); + arl_expect(arl_ipv6, "Ip6InTooBigErrors", &Ip6InTooBigErrors); + arl_expect(arl_ipv6, "Ip6InNoRoutes", &Ip6InNoRoutes); + arl_expect(arl_ipv6, "Ip6InAddrErrors", &Ip6InAddrErrors); + arl_expect(arl_ipv6, "Ip6InUnknownProtos", &Ip6InUnknownProtos); + arl_expect(arl_ipv6, "Ip6InTruncatedPkts", &Ip6InTruncatedPkts); + arl_expect(arl_ipv6, "Ip6InDiscards", &Ip6InDiscards); + arl_expect(arl_ipv6, "Ip6InDelivers", &Ip6InDelivers); + arl_expect(arl_ipv6, "Ip6OutForwDatagrams", &Ip6OutForwDatagrams); + arl_expect(arl_ipv6, "Ip6OutRequests", &Ip6OutRequests); + arl_expect(arl_ipv6, "Ip6OutDiscards", &Ip6OutDiscards); + arl_expect(arl_ipv6, "Ip6OutNoRoutes", &Ip6OutNoRoutes); + arl_expect(arl_ipv6, "Ip6ReasmTimeout", &Ip6ReasmTimeout); + arl_expect(arl_ipv6, "Ip6ReasmReqds", &Ip6ReasmReqds); + arl_expect(arl_ipv6, "Ip6ReasmOKs", &Ip6ReasmOKs); + arl_expect(arl_ipv6, "Ip6ReasmFails", &Ip6ReasmFails); + arl_expect(arl_ipv6, "Ip6FragOKs", &Ip6FragOKs); + arl_expect(arl_ipv6, "Ip6FragFails", &Ip6FragFails); + arl_expect(arl_ipv6, "Ip6FragCreates", &Ip6FragCreates); + arl_expect(arl_ipv6, "Ip6InMcastPkts", &Ip6InMcastPkts); + arl_expect(arl_ipv6, "Ip6OutMcastPkts", &Ip6OutMcastPkts); + arl_expect(arl_ipv6, "Ip6InOctets", &Ip6InOctets); + arl_expect(arl_ipv6, "Ip6OutOctets", &Ip6OutOctets); + arl_expect(arl_ipv6, "Ip6InMcastOctets", &Ip6InMcastOctets); + arl_expect(arl_ipv6, "Ip6OutMcastOctets", &Ip6OutMcastOctets); + arl_expect(arl_ipv6, "Ip6InBcastOctets", &Ip6InBcastOctets); + arl_expect(arl_ipv6, "Ip6OutBcastOctets", &Ip6OutBcastOctets); + arl_expect(arl_ipv6, "Ip6InNoECTPkts", &Ip6InNoECTPkts); + arl_expect(arl_ipv6, "Ip6InECT1Pkts", &Ip6InECT1Pkts); + arl_expect(arl_ipv6, "Ip6InECT0Pkts", &Ip6InECT0Pkts); + arl_expect(arl_ipv6, "Ip6InCEPkts", &Ip6InCEPkts); + arl_expect(arl_ipv6, "Icmp6InMsgs", &Icmp6InMsgs); + arl_expect(arl_ipv6, "Icmp6InErrors", &Icmp6InErrors); + arl_expect(arl_ipv6, "Icmp6OutMsgs", &Icmp6OutMsgs); + arl_expect(arl_ipv6, "Icmp6OutErrors", &Icmp6OutErrors); + arl_expect(arl_ipv6, "Icmp6InCsumErrors", &Icmp6InCsumErrors); + arl_expect(arl_ipv6, "Icmp6InDestUnreachs", &Icmp6InDestUnreachs); + arl_expect(arl_ipv6, "Icmp6InPktTooBigs", &Icmp6InPktTooBigs); + arl_expect(arl_ipv6, "Icmp6InTimeExcds", &Icmp6InTimeExcds); + arl_expect(arl_ipv6, "Icmp6InParmProblems", &Icmp6InParmProblems); + arl_expect(arl_ipv6, "Icmp6InEchos", &Icmp6InEchos); + arl_expect(arl_ipv6, "Icmp6InEchoReplies", &Icmp6InEchoReplies); + arl_expect(arl_ipv6, "Icmp6InGroupMembQueries", &Icmp6InGroupMembQueries); + arl_expect(arl_ipv6, "Icmp6InGroupMembResponses", &Icmp6InGroupMembResponses); + arl_expect(arl_ipv6, "Icmp6InGroupMembReductions", &Icmp6InGroupMembReductions); + arl_expect(arl_ipv6, "Icmp6InRouterSolicits", &Icmp6InRouterSolicits); + arl_expect(arl_ipv6, "Icmp6InRouterAdvertisements", &Icmp6InRouterAdvertisements); + arl_expect(arl_ipv6, "Icmp6InNeighborSolicits", &Icmp6InNeighborSolicits); + arl_expect(arl_ipv6, "Icmp6InNeighborAdvertisements", &Icmp6InNeighborAdvertisements); + arl_expect(arl_ipv6, "Icmp6InRedirects", &Icmp6InRedirects); + arl_expect(arl_ipv6, "Icmp6InMLDv2Reports", &Icmp6InMLDv2Reports); + arl_expect(arl_ipv6, "Icmp6OutDestUnreachs", &Icmp6OutDestUnreachs); + arl_expect(arl_ipv6, "Icmp6OutPktTooBigs", &Icmp6OutPktTooBigs); + arl_expect(arl_ipv6, "Icmp6OutTimeExcds", &Icmp6OutTimeExcds); + arl_expect(arl_ipv6, "Icmp6OutParmProblems", &Icmp6OutParmProblems); + arl_expect(arl_ipv6, "Icmp6OutEchos", &Icmp6OutEchos); + arl_expect(arl_ipv6, "Icmp6OutEchoReplies", &Icmp6OutEchoReplies); + arl_expect(arl_ipv6, "Icmp6OutGroupMembQueries", &Icmp6OutGroupMembQueries); + arl_expect(arl_ipv6, "Icmp6OutGroupMembResponses", &Icmp6OutGroupMembResponses); + arl_expect(arl_ipv6, "Icmp6OutGroupMembReductions", &Icmp6OutGroupMembReductions); + arl_expect(arl_ipv6, "Icmp6OutRouterSolicits", &Icmp6OutRouterSolicits); + arl_expect(arl_ipv6, "Icmp6OutRouterAdvertisements", &Icmp6OutRouterAdvertisements); + arl_expect(arl_ipv6, "Icmp6OutNeighborSolicits", &Icmp6OutNeighborSolicits); + arl_expect(arl_ipv6, "Icmp6OutNeighborAdvertisements", &Icmp6OutNeighborAdvertisements); + arl_expect(arl_ipv6, "Icmp6OutRedirects", &Icmp6OutRedirects); + arl_expect(arl_ipv6, "Icmp6OutMLDv2Reports", &Icmp6OutMLDv2Reports); + arl_expect(arl_ipv6, "Icmp6InType1", &Icmp6InType1); + arl_expect(arl_ipv6, "Icmp6InType128", &Icmp6InType128); + arl_expect(arl_ipv6, "Icmp6InType129", &Icmp6InType129); + arl_expect(arl_ipv6, "Icmp6InType136", &Icmp6InType136); + arl_expect(arl_ipv6, "Icmp6OutType1", &Icmp6OutType1); + arl_expect(arl_ipv6, "Icmp6OutType128", &Icmp6OutType128); + arl_expect(arl_ipv6, "Icmp6OutType129", &Icmp6OutType129); + arl_expect(arl_ipv6, "Icmp6OutType133", &Icmp6OutType133); + arl_expect(arl_ipv6, "Icmp6OutType135", &Icmp6OutType135); + arl_expect(arl_ipv6, "Icmp6OutType143", &Icmp6OutType143); + arl_expect(arl_ipv6, "Udp6InDatagrams", &Udp6InDatagrams); + arl_expect(arl_ipv6, "Udp6NoPorts", &Udp6NoPorts); + arl_expect(arl_ipv6, "Udp6InErrors", &Udp6InErrors); + arl_expect(arl_ipv6, "Udp6OutDatagrams", &Udp6OutDatagrams); + arl_expect(arl_ipv6, "Udp6RcvbufErrors", &Udp6RcvbufErrors); + arl_expect(arl_ipv6, "Udp6SndbufErrors", &Udp6SndbufErrors); + arl_expect(arl_ipv6, "Udp6InCsumErrors", &Udp6InCsumErrors); + arl_expect(arl_ipv6, "Udp6IgnoredMulti", &Udp6IgnoredMulti); + arl_expect(arl_ipv6, "UdpLite6InDatagrams", &UdpLite6InDatagrams); + arl_expect(arl_ipv6, "UdpLite6NoPorts", &UdpLite6NoPorts); + arl_expect(arl_ipv6, "UdpLite6InErrors", &UdpLite6InErrors); + arl_expect(arl_ipv6, "UdpLite6OutDatagrams", &UdpLite6OutDatagrams); + arl_expect(arl_ipv6, "UdpLite6RcvbufErrors", &UdpLite6RcvbufErrors); + arl_expect(arl_ipv6, "UdpLite6SndbufErrors", &UdpLite6SndbufErrors); + arl_expect(arl_ipv6, "UdpLite6InCsumErrors", &UdpLite6InCsumErrors); + } + + size_t lines, l, words; + + // parse /proc/net/netstat + + if(unlikely(!ff_netstat)) { char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/netstat"); - ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); - if(unlikely(!ff)) return 1; + ff_netstat = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); + if(unlikely(!ff_netstat)) return 1; } - ff = procfile_readall(ff); - if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time + ff_netstat = procfile_readall(ff_netstat); + if(unlikely(!ff_netstat)) return 0; // we return 0, so that we will retry to open it next time - size_t lines = procfile_lines(ff), l; - size_t words; + lines = procfile_lines(ff_netstat); arl_begin(arl_ipext); arl_begin(arl_tcpext); for(l = 0; l < lines ;l++) { - char *key = procfile_lineword(ff, l, 0); + char *key = procfile_lineword(ff_netstat, l, 0); uint32_t hash = simple_hash(key); if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) { size_t h = l++; - words = procfile_linewords(ff, l); + words = procfile_linewords(ff_netstat, l); if(unlikely(words < 2)) { error("Cannot read /proc/net/netstat IpExt line. Expected 2+ params, read %zu.", words); continue; } - parse_line_pair(ff, arl_ipext, h, l); - - // -------------------------------------------------------------------- - - if(do_bandwidth == CONFIG_BOOLEAN_YES || (do_bandwidth == CONFIG_BOOLEAN_AUTO && - (ipext_InOctets || - ipext_OutOctets || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_bandwidth = CONFIG_BOOLEAN_YES; - static RRDSET *st_system_ip = NULL; - static RRDDIM *rd_in = NULL, *rd_out = NULL; - - if(unlikely(!st_system_ip)) { - st_system_ip = rrdset_create_localhost( - "system" - , RRD_TYPE_NET_NETSTAT - , NULL - , "network" - , NULL - , "IP Bandwidth" - , "kilobits/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_SYSTEM_IP - , update_every - , RRDSET_TYPE_AREA - ); - - rd_in = rrddim_add(st_system_ip, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - rd_out = rrddim_add(st_system_ip, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_system_ip); - - rrddim_set_by_pointer(st_system_ip, rd_in, ipext_InOctets); - rrddim_set_by_pointer(st_system_ip, rd_out, ipext_OutOctets); - - rrdset_done(st_system_ip); + parse_line_pair(ff_netstat, arl_ipext, h, l); + + } + else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) { + size_t h = l++; + + words = procfile_linewords(ff_netstat, l); + if(unlikely(words < 2)) { + error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %zu.", words); + continue; + } + + parse_line_pair(ff_netstat, arl_tcpext, h, l); + } + } + + // parse /proc/net/snmp + + if(unlikely(!ff_snmp)) { + char filename[FILENAME_MAX + 1]; + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/snmp"); + ff_snmp = procfile_open(config_get("plugin:proc:/proc/net/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); + if(unlikely(!ff_snmp)) return 1; + } + + ff_snmp = procfile_readall(ff_snmp); + if(unlikely(!ff_snmp)) return 0; // we return 0, so that we will retry to open it next time + + lines = procfile_lines(ff_snmp); + size_t w; + + for(l = 0; l < lines ;l++) { + char *key = procfile_lineword(ff_snmp, l, 0); + uint32_t hash = simple_hash(key); + + if(unlikely(hash == hash_ip && strcmp(key, "Ip") == 0)) { + size_t h = l++; + + if(strcmp(procfile_lineword(ff_snmp, l, 0), "Ip") != 0) { + error("Cannot read Ip line from /proc/net/snmp."); + break; } - // -------------------------------------------------------------------- - - if(do_inerrors == CONFIG_BOOLEAN_YES || (do_inerrors == CONFIG_BOOLEAN_AUTO && - (ipext_InNoRoutes || - ipext_InTruncatedPkts || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_inerrors = CONFIG_BOOLEAN_YES; - static RRDSET *st_ip_inerrors = NULL; - static RRDDIM *rd_noroutes = NULL, *rd_truncated = NULL, *rd_checksum = NULL; - - if(unlikely(!st_ip_inerrors)) { - st_ip_inerrors = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "inerrors" - , NULL - , "errors" - , NULL - , "IP Input Errors" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_ERRORS - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(st_ip_inerrors, RRDSET_FLAG_DETAIL); - - rd_noroutes = rrddim_add(st_ip_inerrors, "InNoRoutes", "noroutes", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_truncated = rrddim_add(st_ip_inerrors, "InTruncatedPkts", "truncated", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_checksum = rrddim_add(st_ip_inerrors, "InCsumErrors", "checksum", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_ip_inerrors); - - rrddim_set_by_pointer(st_ip_inerrors, rd_noroutes, ipext_InNoRoutes); - rrddim_set_by_pointer(st_ip_inerrors, rd_truncated, ipext_InTruncatedPkts); - rrddim_set_by_pointer(st_ip_inerrors, rd_checksum, ipext_InCsumErrors); - - rrdset_done(st_ip_inerrors); + words = procfile_linewords(ff_snmp, l); + if(words < 3) { + error("Cannot read /proc/net/snmp Ip line. Expected 3+ params, read %zu.", words); + continue; } - // -------------------------------------------------------------------- + arl_begin(arl_ip); + for(w = 1; w < words ; w++) { + if (unlikely(arl_check(arl_ip, procfile_lineword(ff_snmp, h, w), procfile_lineword(ff_snmp, l, w)) != 0)) + break; + } + } + else if(unlikely(hash == hash_icmp && strcmp(key, "Icmp") == 0)) { + size_t h = l++; - if(do_mcast == CONFIG_BOOLEAN_YES || (do_mcast == CONFIG_BOOLEAN_AUTO && - (ipext_InMcastOctets || - ipext_OutMcastOctets || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_mcast = CONFIG_BOOLEAN_YES; - static RRDSET *st_ip_mcast = NULL; - static RRDDIM *rd_in = NULL, *rd_out = NULL; - - if(unlikely(!st_ip_mcast)) { - st_ip_mcast = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "mcast" - , NULL - , "multicast" - , NULL - , "IP Multicast Bandwidth" - , "kilobits/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_MCAST - , update_every - , RRDSET_TYPE_AREA - ); - - rrdset_flag_set(st_ip_mcast, RRDSET_FLAG_DETAIL); - - rd_in = rrddim_add(st_ip_mcast, "InMcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - rd_out = rrddim_add(st_ip_mcast, "OutMcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_ip_mcast); - - rrddim_set_by_pointer(st_ip_mcast, rd_in, ipext_InMcastOctets); - rrddim_set_by_pointer(st_ip_mcast, rd_out, ipext_OutMcastOctets); - - rrdset_done(st_ip_mcast); + if(strcmp(procfile_lineword(ff_snmp, l, 0), "Icmp") != 0) { + error("Cannot read Icmp line from /proc/net/snmp."); + break; } - // -------------------------------------------------------------------- + words = procfile_linewords(ff_snmp, l); + if(words < 3) { + error("Cannot read /proc/net/snmp Icmp line. Expected 3+ params, read %zu.", words); + continue; + } - if(do_bcast == CONFIG_BOOLEAN_YES || (do_bcast == CONFIG_BOOLEAN_AUTO && - (ipext_InBcastOctets || - ipext_OutBcastOctets || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_bcast = CONFIG_BOOLEAN_YES; - - static RRDSET *st_ip_bcast = NULL; - static RRDDIM *rd_in = NULL, *rd_out = NULL; - - if(unlikely(!st_ip_bcast)) { - st_ip_bcast = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "bcast" - , NULL - , "broadcast" - , NULL - , "IP Broadcast Bandwidth" - , "kilobits/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_BCAST - , update_every - , RRDSET_TYPE_AREA - ); - - rrdset_flag_set(st_ip_bcast, RRDSET_FLAG_DETAIL); - - rd_in = rrddim_add(st_ip_bcast, "InBcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - rd_out = rrddim_add(st_ip_bcast, "OutBcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_ip_bcast); - - rrddim_set_by_pointer(st_ip_bcast, rd_in, ipext_InBcastOctets); - rrddim_set_by_pointer(st_ip_bcast, rd_out, ipext_OutBcastOctets); - - rrdset_done(st_ip_bcast); + arl_begin(arl_icmp); + for(w = 1; w < words ; w++) { + if (unlikely(arl_check(arl_icmp, procfile_lineword(ff_snmp, h, w), procfile_lineword(ff_snmp, l, w)) != 0)) + break; } + } + else if(unlikely(hash == hash_icmpmsg && strcmp(key, "IcmpMsg") == 0)) { + size_t h = l++; - // -------------------------------------------------------------------- + if(strcmp(procfile_lineword(ff_snmp, l, 0), "IcmpMsg") != 0) { + error("Cannot read IcmpMsg line from /proc/net/snmp."); + break; + } - if(do_mcast_p == CONFIG_BOOLEAN_YES || (do_mcast_p == CONFIG_BOOLEAN_AUTO && - (ipext_InMcastPkts || - ipext_OutMcastPkts || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_mcast_p = CONFIG_BOOLEAN_YES; - - static RRDSET *st_ip_mcastpkts = NULL; - static RRDDIM *rd_in = NULL, *rd_out = NULL; - - if(unlikely(!st_ip_mcastpkts)) { - st_ip_mcastpkts = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "mcastpkts" - , NULL - , "multicast" - , NULL - , "IP Multicast Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_MCAST_PACKETS - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(st_ip_mcastpkts, RRDSET_FLAG_DETAIL); - - rd_in = rrddim_add(st_ip_mcastpkts, "InMcastPkts", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_out = rrddim_add(st_ip_mcastpkts, "OutMcastPkts", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st_ip_mcastpkts); - - rrddim_set_by_pointer(st_ip_mcastpkts, rd_in, ipext_InMcastPkts); - rrddim_set_by_pointer(st_ip_mcastpkts, rd_out, ipext_OutMcastPkts); - - rrdset_done(st_ip_mcastpkts); + words = procfile_linewords(ff_snmp, l); + if(words < 2) { + error("Cannot read /proc/net/snmp IcmpMsg line. Expected 2+ params, read %zu.", words); + continue; } - // -------------------------------------------------------------------- + arl_begin(arl_icmpmsg); + for(w = 1; w < words ; w++) { + if (unlikely(arl_check(arl_icmpmsg, procfile_lineword(ff_snmp, h, w), procfile_lineword(ff_snmp, l, w)) != 0)) + break; + } + } + else if(unlikely(hash == hash_tcp && strcmp(key, "Tcp") == 0)) { + size_t h = l++; - if(do_bcast_p == CONFIG_BOOLEAN_YES || (do_bcast_p == CONFIG_BOOLEAN_AUTO && - (ipext_InBcastPkts || - ipext_OutBcastPkts || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_bcast_p = CONFIG_BOOLEAN_YES; - - static RRDSET *st_ip_bcastpkts = NULL; - static RRDDIM *rd_in = NULL, *rd_out = NULL; - - if(unlikely(!st_ip_bcastpkts)) { - st_ip_bcastpkts = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "bcastpkts" - , NULL - , "broadcast" - , NULL - , "IP Broadcast Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_BCAST_PACKETS - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(st_ip_bcastpkts, RRDSET_FLAG_DETAIL); - - rd_in = rrddim_add(st_ip_bcastpkts, "InBcastPkts", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_out = rrddim_add(st_ip_bcastpkts, "OutBcastPkts", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_ip_bcastpkts); - - rrddim_set_by_pointer(st_ip_bcastpkts, rd_in, ipext_InBcastPkts); - rrddim_set_by_pointer(st_ip_bcastpkts, rd_out, ipext_OutBcastPkts); - - rrdset_done(st_ip_bcastpkts); + if(strcmp(procfile_lineword(ff_snmp, l, 0), "Tcp") != 0) { + error("Cannot read Tcp line from /proc/net/snmp."); + break; } - // -------------------------------------------------------------------- + words = procfile_linewords(ff_snmp, l); + if(words < 3) { + error("Cannot read /proc/net/snmp Tcp line. Expected 3+ params, read %zu.", words); + continue; + } - if(do_ecn == CONFIG_BOOLEAN_YES || (do_ecn == CONFIG_BOOLEAN_AUTO && - (ipext_InCEPkts || - ipext_InECT0Pkts || - ipext_InECT1Pkts || - ipext_InNoECTPkts || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ecn = CONFIG_BOOLEAN_YES; - - static RRDSET *st_ecnpkts = NULL; - static RRDDIM *rd_cep = NULL, *rd_noectp = NULL, *rd_ectp0 = NULL, *rd_ectp1 = NULL; - - if(unlikely(!st_ecnpkts)) { - st_ecnpkts = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "ecnpkts" - , NULL - , "ecn" - , NULL - , "IP ECN Statistics" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_ECN - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(st_ecnpkts, RRDSET_FLAG_DETAIL); - - rd_cep = rrddim_add(st_ecnpkts, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_noectp = rrddim_add(st_ecnpkts, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_ectp0 = rrddim_add(st_ecnpkts, "InECT0Pkts", "ECTP0", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_ectp1 = rrddim_add(st_ecnpkts, "InECT1Pkts", "ECTP1", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st_ecnpkts); - - rrddim_set_by_pointer(st_ecnpkts, rd_cep, ipext_InCEPkts); - rrddim_set_by_pointer(st_ecnpkts, rd_noectp, ipext_InNoECTPkts); - rrddim_set_by_pointer(st_ecnpkts, rd_ectp0, ipext_InECT0Pkts); - rrddim_set_by_pointer(st_ecnpkts, rd_ectp1, ipext_InECT1Pkts); - - rrdset_done(st_ecnpkts); + arl_begin(arl_tcp); + for(w = 1; w < words ; w++) { + if (unlikely(arl_check(arl_tcp, procfile_lineword(ff_snmp, h, w), procfile_lineword(ff_snmp, l, w)) != 0)) + break; } } - else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) { + else if(unlikely(hash == hash_udp && strcmp(key, "Udp") == 0)) { size_t h = l++; - words = procfile_linewords(ff, l); - if(unlikely(words < 2)) { - error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %zu.", words); + if(strcmp(procfile_lineword(ff_snmp, l, 0), "Udp") != 0) { + error("Cannot read Udp line from /proc/net/snmp."); + break; + } + + words = procfile_linewords(ff_snmp, l); + if(words < 3) { + error("Cannot read /proc/net/snmp Udp line. Expected 3+ params, read %zu.", words); continue; } - parse_line_pair(ff, arl_tcpext, h, l); - - // -------------------------------------------------------------------- - - if(do_tcpext_memory == CONFIG_BOOLEAN_YES || (do_tcpext_memory == CONFIG_BOOLEAN_AUTO && - (tcpext_TCPMemoryPressures || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcpext_memory = CONFIG_BOOLEAN_YES; - - static RRDSET *st_tcpmemorypressures = NULL; - static RRDDIM *rd_pressures = NULL; - - if(unlikely(!st_tcpmemorypressures)) { - st_tcpmemorypressures = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "tcpmemorypressures" - , NULL - , "tcp" - , NULL - , "TCP Memory Pressures" - , "events/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_TCP_MEM - , update_every - , RRDSET_TYPE_LINE - ); - - rd_pressures = rrddim_add(st_tcpmemorypressures, "TCPMemoryPressures", "pressures", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_tcpmemorypressures); - - rrddim_set_by_pointer(st_tcpmemorypressures, rd_pressures, tcpext_TCPMemoryPressures); - - rrdset_done(st_tcpmemorypressures); + arl_begin(arl_udp); + for(w = 1; w < words ; w++) { + if (unlikely(arl_check(arl_udp, procfile_lineword(ff_snmp, h, w), procfile_lineword(ff_snmp, l, w)) != 0)) + break; } + } + else if(unlikely(hash == hash_udplite && strcmp(key, "UdpLite") == 0)) { + size_t h = l++; - // -------------------------------------------------------------------- - - if(do_tcpext_connaborts == CONFIG_BOOLEAN_YES || (do_tcpext_connaborts == CONFIG_BOOLEAN_AUTO && - (tcpext_TCPAbortOnData || - tcpext_TCPAbortOnClose || - tcpext_TCPAbortOnMemory || - tcpext_TCPAbortOnTimeout || - tcpext_TCPAbortOnLinger || - tcpext_TCPAbortFailed || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcpext_connaborts = CONFIG_BOOLEAN_YES; - - static RRDSET *st_tcpconnaborts = NULL; - static RRDDIM *rd_baddata = NULL, *rd_userclosed = NULL, *rd_nomemory = NULL, *rd_timeout = NULL, *rd_linger = NULL, *rd_failed = NULL; - - if(unlikely(!st_tcpconnaborts)) { - st_tcpconnaborts = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "tcpconnaborts" - , NULL - , "tcp" - , NULL - , "TCP Connection Aborts" - , "connections/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_TCP_CONNABORTS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_baddata = rrddim_add(st_tcpconnaborts, "TCPAbortOnData", "baddata", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_userclosed = rrddim_add(st_tcpconnaborts, "TCPAbortOnClose", "userclosed", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_nomemory = rrddim_add(st_tcpconnaborts, "TCPAbortOnMemory", "nomemory", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_timeout = rrddim_add(st_tcpconnaborts, "TCPAbortOnTimeout", "timeout", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_linger = rrddim_add(st_tcpconnaborts, "TCPAbortOnLinger", "linger", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_failed = rrddim_add(st_tcpconnaborts, "TCPAbortFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_tcpconnaborts); - - rrddim_set_by_pointer(st_tcpconnaborts, rd_baddata, tcpext_TCPAbortOnData); - rrddim_set_by_pointer(st_tcpconnaborts, rd_userclosed, tcpext_TCPAbortOnClose); - rrddim_set_by_pointer(st_tcpconnaborts, rd_nomemory, tcpext_TCPAbortOnMemory); - rrddim_set_by_pointer(st_tcpconnaborts, rd_timeout, tcpext_TCPAbortOnTimeout); - rrddim_set_by_pointer(st_tcpconnaborts, rd_linger, tcpext_TCPAbortOnLinger); - rrddim_set_by_pointer(st_tcpconnaborts, rd_failed, tcpext_TCPAbortFailed); - - rrdset_done(st_tcpconnaborts); + if(strcmp(procfile_lineword(ff_snmp, l, 0), "UdpLite") != 0) { + error("Cannot read UdpLite line from /proc/net/snmp."); + break; } - // -------------------------------------------------------------------- + words = procfile_linewords(ff_snmp, l); + if(words < 3) { + error("Cannot read /proc/net/snmp UdpLite line. Expected 3+ params, read %zu.", words); + continue; + } - if(do_tcpext_reorder == CONFIG_BOOLEAN_YES || (do_tcpext_reorder == CONFIG_BOOLEAN_AUTO && - (tcpext_TCPRenoReorder || - tcpext_TCPFACKReorder || - tcpext_TCPSACKReorder || - tcpext_TCPTSReorder || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcpext_reorder = CONFIG_BOOLEAN_YES; - - static RRDSET *st_tcpreorders = NULL; - static RRDDIM *rd_timestamp = NULL, *rd_sack = NULL, *rd_fack = NULL, *rd_reno = NULL; - - if(unlikely(!st_tcpreorders)) { - st_tcpreorders = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "tcpreorders" - , NULL - , "tcp" - , NULL - , "TCP Reordered Packets by Detection Method" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_TCP_REORDERS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_timestamp = rrddim_add(st_tcpreorders, "TCPTSReorder", "timestamp", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_sack = rrddim_add(st_tcpreorders, "TCPSACKReorder", "sack", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_fack = rrddim_add(st_tcpreorders, "TCPFACKReorder", "fack", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_reno = rrddim_add(st_tcpreorders, "TCPRenoReorder", "reno", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_tcpreorders); - - rrddim_set_by_pointer(st_tcpreorders, rd_timestamp, tcpext_TCPTSReorder); - rrddim_set_by_pointer(st_tcpreorders, rd_sack, tcpext_TCPSACKReorder); - rrddim_set_by_pointer(st_tcpreorders, rd_fack, tcpext_TCPFACKReorder); - rrddim_set_by_pointer(st_tcpreorders, rd_reno, tcpext_TCPRenoReorder); - - rrdset_done(st_tcpreorders); + arl_begin(arl_udplite); + for(w = 1; w < words ; w++) { + if (unlikely(arl_check(arl_udplite, procfile_lineword(ff_snmp, h, w), procfile_lineword(ff_snmp, l, w)) != 0)) + break; } + } + } + + // parse /proc/net/snmp + + if(unlikely(!ff_snmp6)) { + char filename[FILENAME_MAX + 1]; + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/snmp6"); + ff_snmp6 = procfile_open(config_get("plugin:proc:/proc/net/snmp6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); + if(unlikely(!ff_snmp6)) + return 1; + } + + ff_snmp6 = procfile_readall(ff_snmp6); + if(unlikely(!ff_snmp6)) + return 0; // we return 0, so that we will retry to open it next time - // -------------------------------------------------------------------- + lines = procfile_lines(ff_snmp6); - if(do_tcpext_ofo == CONFIG_BOOLEAN_YES || (do_tcpext_ofo == CONFIG_BOOLEAN_AUTO && - (tcpext_TCPOFOQueue || - tcpext_TCPOFODrop || - tcpext_TCPOFOMerge || + arl_begin(arl_ipv6); + + for(l = 0; l < lines ;l++) { + size_t words = procfile_linewords(ff_snmp6, l); + if(unlikely(words < 2)) { + if(unlikely(words)) error("Cannot read /proc/net/snmp6 line %zu. Expected 2 params, read %zu.", l, words); + continue; + } + + if(unlikely(arl_check(arl_ipv6, + procfile_lineword(ff_snmp6, l, 0), + procfile_lineword(ff_snmp6, l, 1)))) break; + } + + // netstat IpExt charts + + if(do_bandwidth == CONFIG_BOOLEAN_YES || (do_bandwidth == CONFIG_BOOLEAN_AUTO && + (ipext_InOctets || + ipext_OutOctets || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_bandwidth = CONFIG_BOOLEAN_YES; + static RRDSET *st_system_ip = NULL; + static RRDDIM *rd_in = NULL, *rd_out = NULL; + + if(unlikely(!st_system_ip)) { + st_system_ip = rrdset_create_localhost( + "system" + , RRD_TYPE_NET_NETSTAT + , NULL + , "network" + , NULL + , "IP Bandwidth" + , "kilobits/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_SYSTEM_IP + , update_every + , RRDSET_TYPE_AREA + ); + + rd_in = rrddim_add(st_system_ip, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + rd_out = rrddim_add(st_system_ip, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_system_ip, rd_in, ipext_InOctets); + rrddim_set_by_pointer(st_system_ip, rd_out, ipext_OutOctets); + rrdset_done(st_system_ip); + } + + if(do_inerrors == CONFIG_BOOLEAN_YES || (do_inerrors == CONFIG_BOOLEAN_AUTO && + (ipext_InNoRoutes || + ipext_InTruncatedPkts || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_inerrors = CONFIG_BOOLEAN_YES; + static RRDSET *st_ip_inerrors = NULL; + static RRDDIM *rd_noroutes = NULL, *rd_truncated = NULL, *rd_checksum = NULL; + + if(unlikely(!st_ip_inerrors)) { + st_ip_inerrors = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "inerrors" + , NULL + , "errors" + , NULL + , "IP Input Errors" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_ERRORS + , update_every + , RRDSET_TYPE_LINE + ); + + rrdset_flag_set(st_ip_inerrors, RRDSET_FLAG_DETAIL); + + rd_noroutes = rrddim_add(st_ip_inerrors, "InNoRoutes", "noroutes", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_truncated = rrddim_add(st_ip_inerrors, "InTruncatedPkts", "truncated", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_checksum = rrddim_add(st_ip_inerrors, "InCsumErrors", "checksum", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ip_inerrors, rd_noroutes, ipext_InNoRoutes); + rrddim_set_by_pointer(st_ip_inerrors, rd_truncated, ipext_InTruncatedPkts); + rrddim_set_by_pointer(st_ip_inerrors, rd_checksum, ipext_InCsumErrors); + rrdset_done(st_ip_inerrors); + } + + if(do_mcast == CONFIG_BOOLEAN_YES || (do_mcast == CONFIG_BOOLEAN_AUTO && + (ipext_InMcastOctets || + ipext_OutMcastOctets || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_mcast = CONFIG_BOOLEAN_YES; + static RRDSET *st_ip_mcast = NULL; + static RRDDIM *rd_in = NULL, *rd_out = NULL; + + if(unlikely(!st_ip_mcast)) { + st_ip_mcast = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "mcast" + , NULL + , "multicast" + , NULL + , "IP Multicast Bandwidth" + , "kilobits/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_MCAST + , update_every + , RRDSET_TYPE_AREA + ); + + rrdset_flag_set(st_ip_mcast, RRDSET_FLAG_DETAIL); + + rd_in = rrddim_add(st_ip_mcast, "InMcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + rd_out = rrddim_add(st_ip_mcast, "OutMcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ip_mcast, rd_in, ipext_InMcastOctets); + rrddim_set_by_pointer(st_ip_mcast, rd_out, ipext_OutMcastOctets); + + rrdset_done(st_ip_mcast); + } + + // -------------------------------------------------------------------- + + if(do_bcast == CONFIG_BOOLEAN_YES || (do_bcast == CONFIG_BOOLEAN_AUTO && + (ipext_InBcastOctets || + ipext_OutBcastOctets || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_bcast = CONFIG_BOOLEAN_YES; + + static RRDSET *st_ip_bcast = NULL; + static RRDDIM *rd_in = NULL, *rd_out = NULL; + + if(unlikely(!st_ip_bcast)) { + st_ip_bcast = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "bcast" + , NULL + , "broadcast" + , NULL + , "IP Broadcast Bandwidth" + , "kilobits/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_BCAST + , update_every + , RRDSET_TYPE_AREA + ); + + rrdset_flag_set(st_ip_bcast, RRDSET_FLAG_DETAIL); + + rd_in = rrddim_add(st_ip_bcast, "InBcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + rd_out = rrddim_add(st_ip_bcast, "OutBcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ip_bcast, rd_in, ipext_InBcastOctets); + rrddim_set_by_pointer(st_ip_bcast, rd_out, ipext_OutBcastOctets); + + rrdset_done(st_ip_bcast); + } + + // -------------------------------------------------------------------- + + if(do_mcast_p == CONFIG_BOOLEAN_YES || (do_mcast_p == CONFIG_BOOLEAN_AUTO && + (ipext_InMcastPkts || + ipext_OutMcastPkts || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_mcast_p = CONFIG_BOOLEAN_YES; + + static RRDSET *st_ip_mcastpkts = NULL; + static RRDDIM *rd_in = NULL, *rd_out = NULL; + + if(unlikely(!st_ip_mcastpkts)) { + st_ip_mcastpkts = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "mcastpkts" + , NULL + , "multicast" + , NULL + , "IP Multicast Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_MCAST_PACKETS + , update_every + , RRDSET_TYPE_LINE + ); + + rrdset_flag_set(st_ip_mcastpkts, RRDSET_FLAG_DETAIL); + + rd_in = rrddim_add(st_ip_mcastpkts, "InMcastPkts", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_out = rrddim_add(st_ip_mcastpkts, "OutMcastPkts", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ip_mcastpkts, rd_in, ipext_InMcastPkts); + rrddim_set_by_pointer(st_ip_mcastpkts, rd_out, ipext_OutMcastPkts); + rrdset_done(st_ip_mcastpkts); + } + + if(do_bcast_p == CONFIG_BOOLEAN_YES || (do_bcast_p == CONFIG_BOOLEAN_AUTO && + (ipext_InBcastPkts || + ipext_OutBcastPkts || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_bcast_p = CONFIG_BOOLEAN_YES; + + static RRDSET *st_ip_bcastpkts = NULL; + static RRDDIM *rd_in = NULL, *rd_out = NULL; + + if(unlikely(!st_ip_bcastpkts)) { + st_ip_bcastpkts = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "bcastpkts" + , NULL + , "broadcast" + , NULL + , "IP Broadcast Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_BCAST_PACKETS + , update_every + , RRDSET_TYPE_LINE + ); + + rrdset_flag_set(st_ip_bcastpkts, RRDSET_FLAG_DETAIL); + + rd_in = rrddim_add(st_ip_bcastpkts, "InBcastPkts", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_out = rrddim_add(st_ip_bcastpkts, "OutBcastPkts", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ip_bcastpkts, rd_in, ipext_InBcastPkts); + rrddim_set_by_pointer(st_ip_bcastpkts, rd_out, ipext_OutBcastPkts); + rrdset_done(st_ip_bcastpkts); + } + + if(do_ecn == CONFIG_BOOLEAN_YES || (do_ecn == CONFIG_BOOLEAN_AUTO && + (ipext_InCEPkts || + ipext_InECT0Pkts || + ipext_InECT1Pkts || + ipext_InNoECTPkts || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ecn = CONFIG_BOOLEAN_YES; + + static RRDSET *st_ecnpkts = NULL; + static RRDDIM *rd_cep = NULL, *rd_noectp = NULL, *rd_ectp0 = NULL, *rd_ectp1 = NULL; + + if(unlikely(!st_ecnpkts)) { + st_ecnpkts = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "ecnpkts" + , NULL + , "ecn" + , NULL + , "IP ECN Statistics" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_ECN + , update_every + , RRDSET_TYPE_LINE + ); + + rrdset_flag_set(st_ecnpkts, RRDSET_FLAG_DETAIL); + + rd_cep = rrddim_add(st_ecnpkts, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_noectp = rrddim_add(st_ecnpkts, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_ectp0 = rrddim_add(st_ecnpkts, "InECT0Pkts", "ECTP0", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_ectp1 = rrddim_add(st_ecnpkts, "InECT1Pkts", "ECTP1", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ecnpkts, rd_cep, ipext_InCEPkts); + rrddim_set_by_pointer(st_ecnpkts, rd_noectp, ipext_InNoECTPkts); + rrddim_set_by_pointer(st_ecnpkts, rd_ectp0, ipext_InECT0Pkts); + rrddim_set_by_pointer(st_ecnpkts, rd_ectp1, ipext_InECT1Pkts); + rrdset_done(st_ecnpkts); + } + + // netstat TcpExt charts + + if(do_tcpext_memory == CONFIG_BOOLEAN_YES || (do_tcpext_memory == CONFIG_BOOLEAN_AUTO && + (tcpext_TCPMemoryPressures || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcpext_memory = CONFIG_BOOLEAN_YES; + + static RRDSET *st_tcpmemorypressures = NULL; + static RRDDIM *rd_pressures = NULL; + + if(unlikely(!st_tcpmemorypressures)) { + st_tcpmemorypressures = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "tcpmemorypressures" + , NULL + , "tcp" + , NULL + , "TCP Memory Pressures" + , "events/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_TCP_MEM + , update_every + , RRDSET_TYPE_LINE + ); + + rd_pressures = rrddim_add(st_tcpmemorypressures, "TCPMemoryPressures", "pressures", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_tcpmemorypressures, rd_pressures, tcpext_TCPMemoryPressures); + rrdset_done(st_tcpmemorypressures); + } + + if(do_tcpext_connaborts == CONFIG_BOOLEAN_YES || (do_tcpext_connaborts == CONFIG_BOOLEAN_AUTO && + (tcpext_TCPAbortOnData || + tcpext_TCPAbortOnClose || + tcpext_TCPAbortOnMemory || + tcpext_TCPAbortOnTimeout || + tcpext_TCPAbortOnLinger || + tcpext_TCPAbortFailed || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcpext_ofo = CONFIG_BOOLEAN_YES; - - static RRDSET *st_ip_tcpofo = NULL; - static RRDDIM *rd_inqueue = NULL, *rd_dropped = NULL, *rd_merged = NULL, *rd_pruned = NULL; - - if(unlikely(!st_ip_tcpofo)) { - - st_ip_tcpofo = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "tcpofo" - , NULL - , "tcp" - , NULL - , "TCP Out-Of-Order Queue" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_TCP_OFO - , update_every - , RRDSET_TYPE_LINE - ); - - rd_inqueue = rrddim_add(st_ip_tcpofo, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_dropped = rrddim_add(st_ip_tcpofo, "TCPOFODrop", "dropped", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_merged = rrddim_add(st_ip_tcpofo, "TCPOFOMerge", "merged", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_pruned = rrddim_add(st_ip_tcpofo, "OfoPruned", "pruned", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_ip_tcpofo); - - rrddim_set_by_pointer(st_ip_tcpofo, rd_inqueue, tcpext_TCPOFOQueue); - rrddim_set_by_pointer(st_ip_tcpofo, rd_dropped, tcpext_TCPOFODrop); - rrddim_set_by_pointer(st_ip_tcpofo, rd_merged, tcpext_TCPOFOMerge); - rrddim_set_by_pointer(st_ip_tcpofo, rd_pruned, tcpext_OfoPruned); - - rrdset_done(st_ip_tcpofo); + do_tcpext_connaborts = CONFIG_BOOLEAN_YES; + + static RRDSET *st_tcpconnaborts = NULL; + static RRDDIM *rd_baddata = NULL, *rd_userclosed = NULL, *rd_nomemory = NULL, *rd_timeout = NULL, *rd_linger = NULL, *rd_failed = NULL; + + if(unlikely(!st_tcpconnaborts)) { + st_tcpconnaborts = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "tcpconnaborts" + , NULL + , "tcp" + , NULL + , "TCP Connection Aborts" + , "connections/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_TCP_CONNABORTS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_baddata = rrddim_add(st_tcpconnaborts, "TCPAbortOnData", "baddata", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_userclosed = rrddim_add(st_tcpconnaborts, "TCPAbortOnClose", "userclosed", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_nomemory = rrddim_add(st_tcpconnaborts, "TCPAbortOnMemory", "nomemory", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_timeout = rrddim_add(st_tcpconnaborts, "TCPAbortOnTimeout", "timeout", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_linger = rrddim_add(st_tcpconnaborts, "TCPAbortOnLinger", "linger", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_failed = rrddim_add(st_tcpconnaborts, "TCPAbortFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_tcpconnaborts, rd_baddata, tcpext_TCPAbortOnData); + rrddim_set_by_pointer(st_tcpconnaborts, rd_userclosed, tcpext_TCPAbortOnClose); + rrddim_set_by_pointer(st_tcpconnaborts, rd_nomemory, tcpext_TCPAbortOnMemory); + rrddim_set_by_pointer(st_tcpconnaborts, rd_timeout, tcpext_TCPAbortOnTimeout); + rrddim_set_by_pointer(st_tcpconnaborts, rd_linger, tcpext_TCPAbortOnLinger); + rrddim_set_by_pointer(st_tcpconnaborts, rd_failed, tcpext_TCPAbortFailed); + rrdset_done(st_tcpconnaborts); + } + + if(do_tcpext_reorder == CONFIG_BOOLEAN_YES || (do_tcpext_reorder == CONFIG_BOOLEAN_AUTO && + (tcpext_TCPRenoReorder || + tcpext_TCPFACKReorder || + tcpext_TCPSACKReorder || + tcpext_TCPTSReorder || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcpext_reorder = CONFIG_BOOLEAN_YES; + + static RRDSET *st_tcpreorders = NULL; + static RRDDIM *rd_timestamp = NULL, *rd_sack = NULL, *rd_fack = NULL, *rd_reno = NULL; + + if(unlikely(!st_tcpreorders)) { + st_tcpreorders = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "tcpreorders" + , NULL + , "tcp" + , NULL + , "TCP Reordered Packets by Detection Method" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_TCP_REORDERS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_timestamp = rrddim_add(st_tcpreorders, "TCPTSReorder", "timestamp", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_sack = rrddim_add(st_tcpreorders, "TCPSACKReorder", "sack", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_fack = rrddim_add(st_tcpreorders, "TCPFACKReorder", "fack", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_reno = rrddim_add(st_tcpreorders, "TCPRenoReorder", "reno", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_tcpreorders, rd_timestamp, tcpext_TCPTSReorder); + rrddim_set_by_pointer(st_tcpreorders, rd_sack, tcpext_TCPSACKReorder); + rrddim_set_by_pointer(st_tcpreorders, rd_fack, tcpext_TCPFACKReorder); + rrddim_set_by_pointer(st_tcpreorders, rd_reno, tcpext_TCPRenoReorder); + rrdset_done(st_tcpreorders); + } + + // -------------------------------------------------------------------- + + if(do_tcpext_ofo == CONFIG_BOOLEAN_YES || (do_tcpext_ofo == CONFIG_BOOLEAN_AUTO && + (tcpext_TCPOFOQueue || + tcpext_TCPOFODrop || + tcpext_TCPOFOMerge || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcpext_ofo = CONFIG_BOOLEAN_YES; + + static RRDSET *st_ip_tcpofo = NULL; + static RRDDIM *rd_inqueue = NULL, *rd_dropped = NULL, *rd_merged = NULL, *rd_pruned = NULL; + + if(unlikely(!st_ip_tcpofo)) { + + st_ip_tcpofo = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "tcpofo" + , NULL + , "tcp" + , NULL + , "TCP Out-Of-Order Queue" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_TCP_OFO + , update_every + , RRDSET_TYPE_LINE + ); + + rd_inqueue = rrddim_add(st_ip_tcpofo, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_dropped = rrddim_add(st_ip_tcpofo, "TCPOFODrop", "dropped", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_merged = rrddim_add(st_ip_tcpofo, "TCPOFOMerge", "merged", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_pruned = rrddim_add(st_ip_tcpofo, "OfoPruned", "pruned", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ip_tcpofo, rd_inqueue, tcpext_TCPOFOQueue); + rrddim_set_by_pointer(st_ip_tcpofo, rd_dropped, tcpext_TCPOFODrop); + rrddim_set_by_pointer(st_ip_tcpofo, rd_merged, tcpext_TCPOFOMerge); + rrddim_set_by_pointer(st_ip_tcpofo, rd_pruned, tcpext_OfoPruned); + rrdset_done(st_ip_tcpofo); + } + + if(do_tcpext_syscookies == CONFIG_BOOLEAN_YES || (do_tcpext_syscookies == CONFIG_BOOLEAN_AUTO && + (tcpext_SyncookiesSent || + tcpext_SyncookiesRecv || + tcpext_SyncookiesFailed || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcpext_syscookies = CONFIG_BOOLEAN_YES; + + static RRDSET *st_syncookies = NULL; + static RRDDIM *rd_received = NULL, *rd_sent = NULL, *rd_failed = NULL; + + if(unlikely(!st_syncookies)) { + + st_syncookies = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "tcpsyncookies" + , NULL + , "tcp" + , NULL + , "TCP SYN Cookies" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_TCP_SYNCOOKIES + , update_every + , RRDSET_TYPE_LINE + ); + + rd_received = rrddim_add(st_syncookies, "SyncookiesRecv", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_sent = rrddim_add(st_syncookies, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_failed = rrddim_add(st_syncookies, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_syncookies, rd_received, tcpext_SyncookiesRecv); + rrddim_set_by_pointer(st_syncookies, rd_sent, tcpext_SyncookiesSent); + rrddim_set_by_pointer(st_syncookies, rd_failed, tcpext_SyncookiesFailed); + rrdset_done(st_syncookies); + } + + if(do_tcpext_syn_queue == CONFIG_BOOLEAN_YES || (do_tcpext_syn_queue == CONFIG_BOOLEAN_AUTO && + (tcpext_TCPReqQFullDrop || + tcpext_TCPReqQFullDoCookies || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcpext_syn_queue = CONFIG_BOOLEAN_YES; + + static RRDSET *st_syn_queue = NULL; + static RRDDIM + *rd_TCPReqQFullDrop = NULL, + *rd_TCPReqQFullDoCookies = NULL; + + if(unlikely(!st_syn_queue)) { + + st_syn_queue = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "tcp_syn_queue" + , NULL + , "tcp" + , NULL + , "TCP SYN Queue Issues" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_TCP_SYN_QUEUE + , update_every + , RRDSET_TYPE_LINE + ); + + rd_TCPReqQFullDrop = rrddim_add(st_syn_queue, "TCPReqQFullDrop", "drops", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_TCPReqQFullDoCookies = rrddim_add(st_syn_queue, "TCPReqQFullDoCookies", "cookies", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_syn_queue, rd_TCPReqQFullDrop, tcpext_TCPReqQFullDrop); + rrddim_set_by_pointer(st_syn_queue, rd_TCPReqQFullDoCookies, tcpext_TCPReqQFullDoCookies); + rrdset_done(st_syn_queue); + } + + if(do_tcpext_accept_queue == CONFIG_BOOLEAN_YES || (do_tcpext_accept_queue == CONFIG_BOOLEAN_AUTO && + (tcpext_ListenOverflows || + tcpext_ListenDrops || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcpext_accept_queue = CONFIG_BOOLEAN_YES; + + static RRDSET *st_accept_queue = NULL; + static RRDDIM *rd_overflows = NULL, + *rd_drops = NULL; + + if(unlikely(!st_accept_queue)) { + + st_accept_queue = rrdset_create_localhost( + RRD_TYPE_NET_NETSTAT + , "tcp_accept_queue" + , NULL + , "tcp" + , NULL + , "TCP Accept Queue Issues" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IP_TCP_ACCEPT_QUEUE + , update_every + , RRDSET_TYPE_LINE + ); + + rd_overflows = rrddim_add(st_accept_queue, "ListenOverflows", "overflows", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_drops = rrddim_add(st_accept_queue, "ListenDrops", "drops", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_accept_queue, rd_overflows, tcpext_ListenOverflows); + rrddim_set_by_pointer(st_accept_queue, rd_drops, tcpext_ListenDrops); + rrdset_done(st_accept_queue); + } + + // snmp Ip charts + + if(do_ip_packets == CONFIG_BOOLEAN_YES || (do_ip_packets == CONFIG_BOOLEAN_AUTO && + (snmp_root.ip_OutRequests || + snmp_root.ip_InReceives || + snmp_root.ip_ForwDatagrams || + snmp_root.ip_InDelivers || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip_packets = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_InReceives = NULL, + *rd_OutRequests = NULL, + *rd_ForwDatagrams = NULL, + *rd_InDelivers = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "packets" + , NULL + , "packets" + , NULL + , "IPv4 Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_PACKETS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InReceives = rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutRequests = rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_ForwDatagrams = rrddim_add(st, "ForwDatagrams", "forwarded", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InDelivers = rrddim_add(st, "InDelivers", "delivered", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_OutRequests, (collected_number)snmp_root.ip_OutRequests); + rrddim_set_by_pointer(st, rd_InReceives, (collected_number)snmp_root.ip_InReceives); + rrddim_set_by_pointer(st, rd_ForwDatagrams, (collected_number)snmp_root.ip_ForwDatagrams); + rrddim_set_by_pointer(st, rd_InDelivers, (collected_number)snmp_root.ip_InDelivers); + rrdset_done(st); + } + + if(do_ip_fragsout == CONFIG_BOOLEAN_YES || (do_ip_fragsout == CONFIG_BOOLEAN_AUTO && + (snmp_root.ip_FragOKs || + snmp_root.ip_FragFails || + snmp_root.ip_FragCreates || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip_fragsout = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_FragOKs = NULL, + *rd_FragFails = NULL, + *rd_FragCreates = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "fragsout" + , NULL + , "fragments" + , NULL + , "IPv4 Fragments Sent" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_FRAGMENTS + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_FragOKs = rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_FragFails = rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_FragCreates = rrddim_add(st, "FragCreates", "created", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_FragOKs, (collected_number)snmp_root.ip_FragOKs); + rrddim_set_by_pointer(st, rd_FragFails, (collected_number)snmp_root.ip_FragFails); + rrddim_set_by_pointer(st, rd_FragCreates, (collected_number)snmp_root.ip_FragCreates); + rrdset_done(st); + } + + if(do_ip_fragsin == CONFIG_BOOLEAN_YES || (do_ip_fragsin == CONFIG_BOOLEAN_AUTO && + (snmp_root.ip_ReasmOKs || + snmp_root.ip_ReasmFails || + snmp_root.ip_ReasmReqds || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip_fragsin = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_ReasmOKs = NULL, + *rd_ReasmFails = NULL, + *rd_ReasmReqds = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "fragsin" + , NULL + , "fragments" + , NULL + , "IPv4 Fragments Reassembly" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_FRAGMENTS + 1 + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_ReasmOKs = rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_ReasmFails = rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_ReasmReqds = rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_ReasmOKs, (collected_number)snmp_root.ip_ReasmOKs); + rrddim_set_by_pointer(st, rd_ReasmFails, (collected_number)snmp_root.ip_ReasmFails); + rrddim_set_by_pointer(st, rd_ReasmReqds, (collected_number)snmp_root.ip_ReasmReqds); + rrdset_done(st); + } + + if(do_ip_errors == CONFIG_BOOLEAN_YES || (do_ip_errors == CONFIG_BOOLEAN_AUTO && + (snmp_root.ip_InDiscards || + snmp_root.ip_OutDiscards || + snmp_root.ip_InHdrErrors || + snmp_root.ip_InAddrErrors || + snmp_root.ip_InUnknownProtos || + snmp_root.ip_OutNoRoutes || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip_errors = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_InDiscards = NULL, + *rd_OutDiscards = NULL, + *rd_InHdrErrors = NULL, + *rd_OutNoRoutes = NULL, + *rd_InAddrErrors = NULL, + *rd_InUnknownProtos = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "errors" + , NULL + , "errors" + , NULL + , "IPv4 Errors" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_ERRORS + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_InDiscards = rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutDiscards = rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + + rd_InHdrErrors = rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutNoRoutes = rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + + rd_InAddrErrors = rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InUnknownProtos = rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InDiscards, (collected_number)snmp_root.ip_InDiscards); + rrddim_set_by_pointer(st, rd_OutDiscards, (collected_number)snmp_root.ip_OutDiscards); + rrddim_set_by_pointer(st, rd_InHdrErrors, (collected_number)snmp_root.ip_InHdrErrors); + rrddim_set_by_pointer(st, rd_InAddrErrors, (collected_number)snmp_root.ip_InAddrErrors); + rrddim_set_by_pointer(st, rd_InUnknownProtos, (collected_number)snmp_root.ip_InUnknownProtos); + rrddim_set_by_pointer(st, rd_OutNoRoutes, (collected_number)snmp_root.ip_OutNoRoutes); + rrdset_done(st); + } + + // snmp Icmp charts + + if(do_icmp_packets == CONFIG_BOOLEAN_YES || (do_icmp_packets == CONFIG_BOOLEAN_AUTO && + (snmp_root.icmp_InMsgs || + snmp_root.icmp_OutMsgs || + snmp_root.icmp_InErrors || + snmp_root.icmp_OutErrors || + snmp_root.icmp_InCsumErrors || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_icmp_packets = CONFIG_BOOLEAN_YES; + + { + static RRDSET *st_packets = NULL; + static RRDDIM *rd_InMsgs = NULL, + *rd_OutMsgs = NULL; + + if(unlikely(!st_packets)) { + st_packets = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "icmp" + , NULL + , "icmp" + , NULL + , "IPv4 ICMP Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_ICMP + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InMsgs = rrddim_add(st_packets, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutMsgs = rrddim_add(st_packets, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - // -------------------------------------------------------------------- - - if(do_tcpext_syscookies == CONFIG_BOOLEAN_YES || (do_tcpext_syscookies == CONFIG_BOOLEAN_AUTO && - (tcpext_SyncookiesSent || - tcpext_SyncookiesRecv || - tcpext_SyncookiesFailed || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcpext_syscookies = CONFIG_BOOLEAN_YES; - - static RRDSET *st_syncookies = NULL; - static RRDDIM *rd_received = NULL, *rd_sent = NULL, *rd_failed = NULL; - - if(unlikely(!st_syncookies)) { - - st_syncookies = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "tcpsyncookies" - , NULL - , "tcp" - , NULL - , "TCP SYN Cookies" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_TCP_SYNCOOKIES - , update_every - , RRDSET_TYPE_LINE - ); - - rd_received = rrddim_add(st_syncookies, "SyncookiesRecv", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_sent = rrddim_add(st_syncookies, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_failed = rrddim_add(st_syncookies, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_syncookies); - - rrddim_set_by_pointer(st_syncookies, rd_received, tcpext_SyncookiesRecv); - rrddim_set_by_pointer(st_syncookies, rd_sent, tcpext_SyncookiesSent); - rrddim_set_by_pointer(st_syncookies, rd_failed, tcpext_SyncookiesFailed); - - rrdset_done(st_syncookies); + rrddim_set_by_pointer(st_packets, rd_InMsgs, (collected_number)snmp_root.icmp_InMsgs); + rrddim_set_by_pointer(st_packets, rd_OutMsgs, (collected_number)snmp_root.icmp_OutMsgs); + rrdset_done(st_packets); + } + + { + static RRDSET *st_errors = NULL; + static RRDDIM *rd_InErrors = NULL, + *rd_OutErrors = NULL, + *rd_InCsumErrors = NULL; + + if(unlikely(!st_errors)) { + st_errors = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "icmp_errors" + , NULL + , "icmp" + , NULL + , "IPv4 ICMP Errors" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_ICMP + 1 + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InErrors = rrddim_add(st_errors, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutErrors = rrddim_add(st_errors, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCsumErrors = rrddim_add(st_errors, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - // -------------------------------------------------------------------- - - if(do_tcpext_syn_queue == CONFIG_BOOLEAN_YES || (do_tcpext_syn_queue == CONFIG_BOOLEAN_AUTO && - (tcpext_TCPReqQFullDrop || - tcpext_TCPReqQFullDoCookies || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcpext_syn_queue = CONFIG_BOOLEAN_YES; - - static RRDSET *st_syn_queue = NULL; - static RRDDIM - *rd_TCPReqQFullDrop = NULL, - *rd_TCPReqQFullDoCookies = NULL; - - if(unlikely(!st_syn_queue)) { - - st_syn_queue = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "tcp_syn_queue" - , NULL - , "tcp" - , NULL - , "TCP SYN Queue Issues" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_TCP_SYN_QUEUE - , update_every - , RRDSET_TYPE_LINE - ); - - rd_TCPReqQFullDrop = rrddim_add(st_syn_queue, "TCPReqQFullDrop", "drops", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_TCPReqQFullDoCookies = rrddim_add(st_syn_queue, "TCPReqQFullDoCookies", "cookies", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_syn_queue); - - rrddim_set_by_pointer(st_syn_queue, rd_TCPReqQFullDrop, tcpext_TCPReqQFullDrop); - rrddim_set_by_pointer(st_syn_queue, rd_TCPReqQFullDoCookies, tcpext_TCPReqQFullDoCookies); - - rrdset_done(st_syn_queue); + rrddim_set_by_pointer(st_errors, rd_InErrors, (collected_number)snmp_root.icmp_InErrors); + rrddim_set_by_pointer(st_errors, rd_OutErrors, (collected_number)snmp_root.icmp_OutErrors); + rrddim_set_by_pointer(st_errors, rd_InCsumErrors, (collected_number)snmp_root.icmp_InCsumErrors); + rrdset_done(st_errors); + } + } + + // snmp IcmpMsg charts + + if(do_icmpmsg == CONFIG_BOOLEAN_YES || (do_icmpmsg == CONFIG_BOOLEAN_AUTO && + (snmp_root.icmpmsg_InEchoReps || + snmp_root.icmpmsg_OutEchoReps || + snmp_root.icmpmsg_InDestUnreachs || + snmp_root.icmpmsg_OutDestUnreachs || + snmp_root.icmpmsg_InRedirects || + snmp_root.icmpmsg_OutRedirects || + snmp_root.icmpmsg_InEchos || + snmp_root.icmpmsg_OutEchos || + snmp_root.icmpmsg_InRouterAdvert || + snmp_root.icmpmsg_OutRouterAdvert || + snmp_root.icmpmsg_InRouterSelect || + snmp_root.icmpmsg_OutRouterSelect || + snmp_root.icmpmsg_InTimeExcds || + snmp_root.icmpmsg_OutTimeExcds || + snmp_root.icmpmsg_InParmProbs || + snmp_root.icmpmsg_OutParmProbs || + snmp_root.icmpmsg_InTimestamps || + snmp_root.icmpmsg_OutTimestamps || + snmp_root.icmpmsg_InTimestampReps || + snmp_root.icmpmsg_OutTimestampReps || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_icmpmsg = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_InEchoReps = NULL, + *rd_OutEchoReps = NULL, + *rd_InDestUnreachs = NULL, + *rd_OutDestUnreachs = NULL, + *rd_InRedirects = NULL, + *rd_OutRedirects = NULL, + *rd_InEchos = NULL, + *rd_OutEchos = NULL, + *rd_InRouterAdvert = NULL, + *rd_OutRouterAdvert = NULL, + *rd_InRouterSelect = NULL, + *rd_OutRouterSelect = NULL, + *rd_InTimeExcds = NULL, + *rd_OutTimeExcds = NULL, + *rd_InParmProbs = NULL, + *rd_OutParmProbs = NULL, + *rd_InTimestamps = NULL, + *rd_OutTimestamps = NULL, + *rd_InTimestampReps = NULL, + *rd_OutTimestampReps = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "icmpmsg" + , NULL + , "icmp" + , NULL + , "IPv4 ICMP Messages" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_ICMP + 2 + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InEchoReps = rrddim_add(st, "InType0", "InEchoReps", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutEchoReps = rrddim_add(st, "OutType0", "OutEchoReps", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InDestUnreachs = rrddim_add(st, "InType3", "InDestUnreachs", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutDestUnreachs = rrddim_add(st, "OutType3", "OutDestUnreachs", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InRedirects = rrddim_add(st, "InType5", "InRedirects", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutRedirects = rrddim_add(st, "OutType5", "OutRedirects", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InEchos = rrddim_add(st, "InType8", "InEchos", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutEchos = rrddim_add(st, "OutType8", "OutEchos", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InRouterAdvert = rrddim_add(st, "InType9", "InRouterAdvert", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutRouterAdvert = rrddim_add(st, "OutType9", "OutRouterAdvert", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InRouterSelect = rrddim_add(st, "InType10", "InRouterSelect", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutRouterSelect = rrddim_add(st, "OutType10", "OutRouterSelect", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InTimeExcds = rrddim_add(st, "InType11", "InTimeExcds", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutTimeExcds = rrddim_add(st, "OutType11", "OutTimeExcds", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InParmProbs = rrddim_add(st, "InType12", "InParmProbs", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutParmProbs = rrddim_add(st, "OutType12", "OutParmProbs", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InTimestamps = rrddim_add(st, "InType13", "InTimestamps", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutTimestamps = rrddim_add(st, "OutType13", "OutTimestamps", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InTimestampReps = rrddim_add(st, "InType14", "InTimestampReps", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutTimestampReps = rrddim_add(st, "OutType14", "OutTimestampReps", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InEchoReps, (collected_number)snmp_root.icmpmsg_InEchoReps); + rrddim_set_by_pointer(st, rd_OutEchoReps, (collected_number)snmp_root.icmpmsg_OutEchoReps); + rrddim_set_by_pointer(st, rd_InDestUnreachs, (collected_number)snmp_root.icmpmsg_InDestUnreachs); + rrddim_set_by_pointer(st, rd_OutDestUnreachs, (collected_number)snmp_root.icmpmsg_OutDestUnreachs); + rrddim_set_by_pointer(st, rd_InRedirects, (collected_number)snmp_root.icmpmsg_InRedirects); + rrddim_set_by_pointer(st, rd_OutRedirects, (collected_number)snmp_root.icmpmsg_OutRedirects); + rrddim_set_by_pointer(st, rd_InEchos, (collected_number)snmp_root.icmpmsg_InEchos); + rrddim_set_by_pointer(st, rd_OutEchos, (collected_number)snmp_root.icmpmsg_OutEchos); + rrddim_set_by_pointer(st, rd_InRouterAdvert, (collected_number)snmp_root.icmpmsg_InRouterAdvert); + rrddim_set_by_pointer(st, rd_OutRouterAdvert, (collected_number)snmp_root.icmpmsg_OutRouterAdvert); + rrddim_set_by_pointer(st, rd_InRouterSelect, (collected_number)snmp_root.icmpmsg_InRouterSelect); + rrddim_set_by_pointer(st, rd_OutRouterSelect, (collected_number)snmp_root.icmpmsg_OutRouterSelect); + rrddim_set_by_pointer(st, rd_InTimeExcds, (collected_number)snmp_root.icmpmsg_InTimeExcds); + rrddim_set_by_pointer(st, rd_OutTimeExcds, (collected_number)snmp_root.icmpmsg_OutTimeExcds); + rrddim_set_by_pointer(st, rd_InParmProbs, (collected_number)snmp_root.icmpmsg_InParmProbs); + rrddim_set_by_pointer(st, rd_OutParmProbs, (collected_number)snmp_root.icmpmsg_OutParmProbs); + rrddim_set_by_pointer(st, rd_InTimestamps, (collected_number)snmp_root.icmpmsg_InTimestamps); + rrddim_set_by_pointer(st, rd_OutTimestamps, (collected_number)snmp_root.icmpmsg_OutTimestamps); + rrddim_set_by_pointer(st, rd_InTimestampReps, (collected_number)snmp_root.icmpmsg_InTimestampReps); + rrddim_set_by_pointer(st, rd_OutTimestampReps, (collected_number)snmp_root.icmpmsg_OutTimestampReps); + + rrdset_done(st); + } + + // snmp Tcp charts + + // this is smart enough to update it, only when it is changed + rrdvar_custom_host_variable_set(localhost, tcp_max_connections_var, snmp_root.tcp_MaxConn); + + // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html + if(do_tcp_sockets == CONFIG_BOOLEAN_YES || (do_tcp_sockets == CONFIG_BOOLEAN_AUTO && + (snmp_root.tcp_CurrEstab || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcp_sockets = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_CurrEstab = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "tcpsock" + , NULL + , "tcp" + , NULL + , "IPv4 TCP Connections" + , "active connections" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_TCP + , update_every + , RRDSET_TYPE_LINE + ); + + rd_CurrEstab = rrddim_add(st, "CurrEstab", "connections", 1, 1, RRD_ALGORITHM_ABSOLUTE); + } + + rrddim_set_by_pointer(st, rd_CurrEstab, (collected_number)snmp_root.tcp_CurrEstab); + rrdset_done(st); + } + + if(do_tcp_packets == CONFIG_BOOLEAN_YES || (do_tcp_packets == CONFIG_BOOLEAN_AUTO && + (snmp_root.tcp_InSegs || + snmp_root.tcp_OutSegs || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcp_packets = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_InSegs = NULL, + *rd_OutSegs = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "tcppackets" + , NULL + , "tcp" + , NULL + , "IPv4 TCP Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_TCP + 4 + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InSegs = rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutSegs = rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InSegs, (collected_number)snmp_root.tcp_InSegs); + rrddim_set_by_pointer(st, rd_OutSegs, (collected_number)snmp_root.tcp_OutSegs); + rrdset_done(st); + } + + // -------------------------------------------------------------------- + + if(do_tcp_errors == CONFIG_BOOLEAN_YES || (do_tcp_errors == CONFIG_BOOLEAN_AUTO && + (snmp_root.tcp_InErrs || + snmp_root.tcp_InCsumErrors || + snmp_root.tcp_RetransSegs || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcp_errors = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_InErrs = NULL, + *rd_InCsumErrors = NULL, + *rd_RetransSegs = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "tcperrors" + , NULL + , "tcp" + , NULL + , "IPv4 TCP Errors" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_TCP + 20 + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_InErrs = rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_RetransSegs = rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InErrs, (collected_number)snmp_root.tcp_InErrs); + rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.tcp_InCsumErrors); + rrddim_set_by_pointer(st, rd_RetransSegs, (collected_number)snmp_root.tcp_RetransSegs); + rrdset_done(st); + } + + if(do_tcp_opens == CONFIG_BOOLEAN_YES || (do_tcp_opens == CONFIG_BOOLEAN_AUTO && + (snmp_root.tcp_ActiveOpens || + snmp_root.tcp_PassiveOpens || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcp_opens = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_ActiveOpens = NULL, + *rd_PassiveOpens = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "tcpopens" + , NULL + , "tcp" + , NULL + , "IPv4 TCP Opens" + , "connections/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_TCP + 5 + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_ActiveOpens = rrddim_add(st, "ActiveOpens", "active", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_PassiveOpens = rrddim_add(st, "PassiveOpens", "passive", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_ActiveOpens, (collected_number)snmp_root.tcp_ActiveOpens); + rrddim_set_by_pointer(st, rd_PassiveOpens, (collected_number)snmp_root.tcp_PassiveOpens); + rrdset_done(st); + } + + if(do_tcp_handshake == CONFIG_BOOLEAN_YES || (do_tcp_handshake == CONFIG_BOOLEAN_AUTO && + (snmp_root.tcp_EstabResets || + snmp_root.tcp_OutRsts || + snmp_root.tcp_AttemptFails || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_tcp_handshake = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_EstabResets = NULL, + *rd_OutRsts = NULL, + *rd_AttemptFails = NULL, + *rd_TCPSynRetrans = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "tcphandshake" + , NULL + , "tcp" + , NULL + , "IPv4 TCP Handshake Issues" + , "events/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_TCP + 30 + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_EstabResets = rrddim_add(st, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutRsts = rrddim_add(st, "OutRsts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_AttemptFails = rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_TCPSynRetrans = rrddim_add(st, "TCPSynRetrans", "SynRetrans", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_EstabResets, (collected_number)snmp_root.tcp_EstabResets); + rrddim_set_by_pointer(st, rd_OutRsts, (collected_number)snmp_root.tcp_OutRsts); + rrddim_set_by_pointer(st, rd_AttemptFails, (collected_number)snmp_root.tcp_AttemptFails); + rrddim_set_by_pointer(st, rd_TCPSynRetrans, tcpext_TCPSynRetrans); + rrdset_done(st); + } + + // snmp Udp charts + + // see http://net-snmp.sourceforge.net/docs/mibs/udp.html + if(do_udp_packets == CONFIG_BOOLEAN_YES || (do_udp_packets == CONFIG_BOOLEAN_AUTO && + (snmp_root.udp_InDatagrams || + snmp_root.udp_OutDatagrams || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_udp_packets = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_InDatagrams = NULL, + *rd_OutDatagrams = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "udppackets" + , NULL + , "udp" + , NULL + , "IPv4 UDP Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_UDP + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InDatagrams = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutDatagrams = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InDatagrams, (collected_number)snmp_root.udp_InDatagrams); + rrddim_set_by_pointer(st, rd_OutDatagrams, (collected_number)snmp_root.udp_OutDatagrams); + rrdset_done(st); + } + + // -------------------------------------------------------------------- + + if(do_udp_errors == CONFIG_BOOLEAN_YES || (do_udp_errors == CONFIG_BOOLEAN_AUTO && + (snmp_root.udp_InErrors || + snmp_root.udp_NoPorts || + snmp_root.udp_RcvbufErrors || + snmp_root.udp_SndbufErrors || + snmp_root.udp_InCsumErrors || + snmp_root.udp_IgnoredMulti || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_udp_errors = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_RcvbufErrors = NULL, + *rd_SndbufErrors = NULL, + *rd_InErrors = NULL, + *rd_NoPorts = NULL, + *rd_InCsumErrors = NULL, + *rd_IgnoredMulti = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "udperrors" + , NULL + , "udp" + , NULL + , "IPv4 UDP Errors" + , "events/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_UDP + 10 + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_IgnoredMulti = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InErrors, (collected_number)snmp_root.udp_InErrors); + rrddim_set_by_pointer(st, rd_NoPorts, (collected_number)snmp_root.udp_NoPorts); + rrddim_set_by_pointer(st, rd_RcvbufErrors, (collected_number)snmp_root.udp_RcvbufErrors); + rrddim_set_by_pointer(st, rd_SndbufErrors, (collected_number)snmp_root.udp_SndbufErrors); + rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.udp_InCsumErrors); + rrddim_set_by_pointer(st, rd_IgnoredMulti, (collected_number)snmp_root.udp_IgnoredMulti); + rrdset_done(st); + } + + // snmp UdpLite charts + + if(do_udplite_packets == CONFIG_BOOLEAN_YES || (do_udplite_packets == CONFIG_BOOLEAN_AUTO && + (snmp_root.udplite_InDatagrams || + snmp_root.udplite_OutDatagrams || + snmp_root.udplite_NoPorts || + snmp_root.udplite_InErrors || + snmp_root.udplite_InCsumErrors || + snmp_root.udplite_RcvbufErrors || + snmp_root.udplite_SndbufErrors || + snmp_root.udplite_IgnoredMulti || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_udplite_packets = CONFIG_BOOLEAN_YES; + + { + static RRDSET *st = NULL; + static RRDDIM *rd_InDatagrams = NULL, + *rd_OutDatagrams = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "udplite" + , NULL + , "udplite" + , NULL + , "IPv4 UDPLite Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_UDPLITE + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InDatagrams = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutDatagrams = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - // -------------------------------------------------------------------- - - if(do_tcpext_accept_queue == CONFIG_BOOLEAN_YES || (do_tcpext_accept_queue == CONFIG_BOOLEAN_AUTO && - (tcpext_ListenOverflows || - tcpext_ListenDrops || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcpext_accept_queue = CONFIG_BOOLEAN_YES; - - static RRDSET *st_accept_queue = NULL; - static RRDDIM *rd_overflows = NULL, - *rd_drops = NULL; - - if(unlikely(!st_accept_queue)) { - - st_accept_queue = rrdset_create_localhost( - RRD_TYPE_NET_NETSTAT - , "tcp_accept_queue" - , NULL - , "tcp" - , NULL - , "TCP Accept Queue Issues" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NETSTAT_NAME - , NETDATA_CHART_PRIO_IP_TCP_ACCEPT_QUEUE - , update_every - , RRDSET_TYPE_LINE - ); - - rd_overflows = rrddim_add(st_accept_queue, "ListenOverflows", "overflows", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_drops = rrddim_add(st_accept_queue, "ListenDrops", "drops", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else - rrdset_next(st_accept_queue); - - rrddim_set_by_pointer(st_accept_queue, rd_overflows, tcpext_ListenOverflows); - rrddim_set_by_pointer(st_accept_queue, rd_drops, tcpext_ListenDrops); - - rrdset_done(st_accept_queue); + rrddim_set_by_pointer(st, rd_InDatagrams, (collected_number)snmp_root.udplite_InDatagrams); + rrddim_set_by_pointer(st, rd_OutDatagrams, (collected_number)snmp_root.udplite_OutDatagrams); + rrdset_done(st); + } + + { + static RRDSET *st = NULL; + static RRDDIM *rd_RcvbufErrors = NULL, + *rd_SndbufErrors = NULL, + *rd_InErrors = NULL, + *rd_NoPorts = NULL, + *rd_InCsumErrors = NULL, + *rd_IgnoredMulti = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP + , "udplite_errors" + , NULL + , "udplite" + , NULL + , "IPv4 UDPLite Errors" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV4_UDPLITE + 10 + , update_every + , RRDSET_TYPE_LINE); + + rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_IgnoredMulti = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } + rrddim_set_by_pointer(st, rd_NoPorts, (collected_number)snmp_root.udplite_NoPorts); + rrddim_set_by_pointer(st, rd_InErrors, (collected_number)snmp_root.udplite_InErrors); + rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.udplite_InCsumErrors); + rrddim_set_by_pointer(st, rd_RcvbufErrors, (collected_number)snmp_root.udplite_RcvbufErrors); + rrddim_set_by_pointer(st, rd_SndbufErrors, (collected_number)snmp_root.udplite_SndbufErrors); + rrddim_set_by_pointer(st, rd_IgnoredMulti, (collected_number)snmp_root.udplite_IgnoredMulti); + rrdset_done(st); } } + // snmp6 charts + + if(do_ip6_bandwidth == CONFIG_BOOLEAN_YES || (do_ip6_bandwidth == CONFIG_BOOLEAN_AUTO && + (Ip6InOctets || + Ip6OutOctets || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_bandwidth = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_received = NULL, + *rd_sent = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + "system" + , "ipv6" + , NULL + , "network" + , NULL + , "IPv6 Bandwidth" + , "kilobits/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_SYSTEM_IPV6 + , update_every + , RRDSET_TYPE_AREA + ); + + rd_received = rrddim_add(st, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + rd_sent = rrddim_add(st, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_received, Ip6InOctets); + rrddim_set_by_pointer(st, rd_sent, Ip6OutOctets); + rrdset_done(st); + } + + if(do_ip6_packets == CONFIG_BOOLEAN_YES || (do_ip6_packets == CONFIG_BOOLEAN_AUTO && + (Ip6InReceives || + Ip6OutRequests || + Ip6InDelivers || + Ip6OutForwDatagrams || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_packets = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_received = NULL, + *rd_sent = NULL, + *rd_forwarded = NULL, + *rd_delivers = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "packets" + , NULL + , "packets" + , NULL + , "IPv6 Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_PACKETS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_received = rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_sent = rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_forwarded = rrddim_add(st, "OutForwDatagrams", "forwarded", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_delivers = rrddim_add(st, "InDelivers", "delivers", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_received, Ip6InReceives); + rrddim_set_by_pointer(st, rd_sent, Ip6OutRequests); + rrddim_set_by_pointer(st, rd_forwarded, Ip6OutForwDatagrams); + rrddim_set_by_pointer(st, rd_delivers, Ip6InDelivers); + rrdset_done(st); + } + + if(do_ip6_fragsout == CONFIG_BOOLEAN_YES || (do_ip6_fragsout == CONFIG_BOOLEAN_AUTO && + (Ip6FragOKs || + Ip6FragFails || + Ip6FragCreates || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_fragsout = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_ok = NULL, + *rd_failed = NULL, + *rd_all = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "fragsout" + , NULL + , "fragments6" + , NULL + , "IPv6 Fragments Sent" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_FRAGSOUT + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_ok = rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_failed = rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_all = rrddim_add(st, "FragCreates", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_ok, Ip6FragOKs); + rrddim_set_by_pointer(st, rd_failed, Ip6FragFails); + rrddim_set_by_pointer(st, rd_all, Ip6FragCreates); + rrdset_done(st); + } + + if(do_ip6_fragsin == CONFIG_BOOLEAN_YES || (do_ip6_fragsin == CONFIG_BOOLEAN_AUTO && + (Ip6ReasmOKs || + Ip6ReasmFails || + Ip6ReasmTimeout || + Ip6ReasmReqds || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_fragsin = CONFIG_BOOLEAN_YES; + + static RRDSET *st = NULL; + static RRDDIM *rd_ok = NULL, + *rd_failed = NULL, + *rd_timeout = NULL, + *rd_all = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "fragsin" + , NULL + , "fragments6" + , NULL + , "IPv6 Fragments Reassembly" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_FRAGSIN + , update_every + , RRDSET_TYPE_LINE); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_ok = rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_failed = rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_timeout = rrddim_add(st, "ReasmTimeout", "timeout", -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_all = rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_ok, Ip6ReasmOKs); + rrddim_set_by_pointer(st, rd_failed, Ip6ReasmFails); + rrddim_set_by_pointer(st, rd_timeout, Ip6ReasmTimeout); + rrddim_set_by_pointer(st, rd_all, Ip6ReasmReqds); + rrdset_done(st); + } + + if(do_ip6_errors == CONFIG_BOOLEAN_YES || (do_ip6_errors == CONFIG_BOOLEAN_AUTO && + (Ip6InDiscards || + Ip6OutDiscards || + Ip6InHdrErrors || + Ip6InAddrErrors || + Ip6InUnknownProtos || + Ip6InTooBigErrors || + Ip6InTruncatedPkts || + Ip6InNoRoutes || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_errors = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InDiscards = NULL, + *rd_OutDiscards = NULL, + *rd_InHdrErrors = NULL, + *rd_InAddrErrors = NULL, + *rd_InUnknownProtos = NULL, + *rd_InTooBigErrors = NULL, + *rd_InTruncatedPkts = NULL, + *rd_InNoRoutes = NULL, + *rd_OutNoRoutes = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "errors" + , NULL + , "errors" + , NULL + , "IPv6 Errors" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ERRORS + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_InDiscards = rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutDiscards = rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InHdrErrors = rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InAddrErrors = rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InUnknownProtos = rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InTooBigErrors = rrddim_add(st, "InTooBigErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InTruncatedPkts = rrddim_add(st, "InTruncatedPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InNoRoutes = rrddim_add(st, "InNoRoutes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutNoRoutes = rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InDiscards, Ip6InDiscards); + rrddim_set_by_pointer(st, rd_OutDiscards, Ip6OutDiscards); + rrddim_set_by_pointer(st, rd_InHdrErrors, Ip6InHdrErrors); + rrddim_set_by_pointer(st, rd_InAddrErrors, Ip6InAddrErrors); + rrddim_set_by_pointer(st, rd_InUnknownProtos, Ip6InUnknownProtos); + rrddim_set_by_pointer(st, rd_InTooBigErrors, Ip6InTooBigErrors); + rrddim_set_by_pointer(st, rd_InTruncatedPkts, Ip6InTruncatedPkts); + rrddim_set_by_pointer(st, rd_InNoRoutes, Ip6InNoRoutes); + rrddim_set_by_pointer(st, rd_OutNoRoutes, Ip6OutNoRoutes); + rrdset_done(st); + } + + if(do_ip6_udp_packets == CONFIG_BOOLEAN_YES || (do_ip6_udp_packets == CONFIG_BOOLEAN_AUTO && + (Udp6InDatagrams || + Udp6OutDatagrams || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_udp_packets = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_received = NULL, + *rd_sent = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "udppackets" + , NULL + , "udp6" + , NULL + , "IPv6 UDP Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_UDP_PACKETS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_received = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_sent = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_received, Udp6InDatagrams); + rrddim_set_by_pointer(st, rd_sent, Udp6OutDatagrams); + rrdset_done(st); + } + + if(do_ip6_udp_errors == CONFIG_BOOLEAN_YES || (do_ip6_udp_errors == CONFIG_BOOLEAN_AUTO && + (Udp6InErrors || + Udp6NoPorts || + Udp6RcvbufErrors || + Udp6SndbufErrors || + Udp6InCsumErrors || + Udp6IgnoredMulti || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_udp_errors = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_RcvbufErrors = NULL, + *rd_SndbufErrors = NULL, + *rd_InErrors = NULL, + *rd_NoPorts = NULL, + *rd_InCsumErrors = NULL, + *rd_IgnoredMulti = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "udperrors" + , NULL + , "udp6" + , NULL + , "IPv6 UDP Errors" + , "events/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_UDP_ERRORS + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_IgnoredMulti = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_RcvbufErrors, Udp6RcvbufErrors); + rrddim_set_by_pointer(st, rd_SndbufErrors, Udp6SndbufErrors); + rrddim_set_by_pointer(st, rd_InErrors, Udp6InErrors); + rrddim_set_by_pointer(st, rd_NoPorts, Udp6NoPorts); + rrddim_set_by_pointer(st, rd_InCsumErrors, Udp6InCsumErrors); + rrddim_set_by_pointer(st, rd_IgnoredMulti, Udp6IgnoredMulti); + rrdset_done(st); + } + + if(do_ip6_udplite_packets == CONFIG_BOOLEAN_YES || (do_ip6_udplite_packets == CONFIG_BOOLEAN_AUTO && + (UdpLite6InDatagrams || + UdpLite6OutDatagrams || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_udplite_packets = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_received = NULL, + *rd_sent = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "udplitepackets" + , NULL + , "udplite6" + , NULL + , "IPv6 UDPlite Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_UDPLITE_PACKETS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_received = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_sent = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_received, UdpLite6InDatagrams); + rrddim_set_by_pointer(st, rd_sent, UdpLite6OutDatagrams); + rrdset_done(st); + } + + if(do_ip6_udplite_errors == CONFIG_BOOLEAN_YES || (do_ip6_udplite_errors == CONFIG_BOOLEAN_AUTO && + (UdpLite6InErrors || + UdpLite6NoPorts || + UdpLite6RcvbufErrors || + UdpLite6SndbufErrors || + Udp6InCsumErrors || + UdpLite6InCsumErrors || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_udplite_errors = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_RcvbufErrors = NULL, + *rd_SndbufErrors = NULL, + *rd_InErrors = NULL, + *rd_NoPorts = NULL, + *rd_InCsumErrors = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "udpliteerrors" + , NULL + , "udplite6" + , NULL + , "IPv6 UDP Lite Errors" + , "events/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_UDPLITE_ERRORS + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InErrors, UdpLite6InErrors); + rrddim_set_by_pointer(st, rd_NoPorts, UdpLite6NoPorts); + rrddim_set_by_pointer(st, rd_RcvbufErrors, UdpLite6RcvbufErrors); + rrddim_set_by_pointer(st, rd_SndbufErrors, UdpLite6SndbufErrors); + rrddim_set_by_pointer(st, rd_InCsumErrors, UdpLite6InCsumErrors); + rrdset_done(st); + } + + if(do_ip6_mcast == CONFIG_BOOLEAN_YES || (do_ip6_mcast == CONFIG_BOOLEAN_AUTO && + (Ip6OutMcastOctets || + Ip6InMcastOctets || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_mcast = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_Ip6InMcastOctets = NULL, + *rd_Ip6OutMcastOctets = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "mcast" + , NULL + , "multicast6" + , NULL + , "IPv6 Multicast Bandwidth" + , "kilobits/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_MCAST + , update_every + , RRDSET_TYPE_AREA + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_Ip6InMcastOctets = rrddim_add(st, "InMcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + rd_Ip6OutMcastOctets = rrddim_add(st, "OutMcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_Ip6InMcastOctets, Ip6InMcastOctets); + rrddim_set_by_pointer(st, rd_Ip6OutMcastOctets, Ip6OutMcastOctets); + rrdset_done(st); + } + + if(do_ip6_bcast == CONFIG_BOOLEAN_YES || (do_ip6_bcast == CONFIG_BOOLEAN_AUTO && + (Ip6OutBcastOctets || + Ip6InBcastOctets || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_bcast = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_Ip6InBcastOctets = NULL, + *rd_Ip6OutBcastOctets = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "bcast" + , NULL + , "broadcast6" + , NULL + , "IPv6 Broadcast Bandwidth" + , "kilobits/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_BCAST + , update_every + , RRDSET_TYPE_AREA + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_Ip6InBcastOctets = rrddim_add(st, "InBcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + rd_Ip6OutBcastOctets = rrddim_add(st, "OutBcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_Ip6InBcastOctets, Ip6InBcastOctets); + rrddim_set_by_pointer(st, rd_Ip6OutBcastOctets, Ip6OutBcastOctets); + rrdset_done(st); + } + + if(do_ip6_mcast_p == CONFIG_BOOLEAN_YES || (do_ip6_mcast_p == CONFIG_BOOLEAN_AUTO && + (Ip6OutMcastPkts || + Ip6InMcastPkts || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_mcast_p = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_Ip6InMcastPkts = NULL, + *rd_Ip6OutMcastPkts = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "mcastpkts" + , NULL + , "multicast6" + , NULL + , "IPv6 Multicast Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_MCAST_PACKETS + , update_every + , RRDSET_TYPE_LINE + ); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + + rd_Ip6InMcastPkts = rrddim_add(st, "InMcastPkts", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_Ip6OutMcastPkts = rrddim_add(st, "OutMcastPkts", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_Ip6InMcastPkts, Ip6InMcastPkts); + rrddim_set_by_pointer(st, rd_Ip6OutMcastPkts, Ip6OutMcastPkts); + rrdset_done(st); + } + + if(do_ip6_icmp == CONFIG_BOOLEAN_YES || (do_ip6_icmp == CONFIG_BOOLEAN_AUTO && + (Icmp6InMsgs || + Icmp6OutMsgs || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_Icmp6InMsgs = NULL, + *rd_Icmp6OutMsgs = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmp" + , NULL + , "icmp6" + , NULL + , "IPv6 ICMP Messages" + , "messages/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP + , update_every + , RRDSET_TYPE_LINE + ); + + rd_Icmp6InMsgs = rrddim_add(st, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_Icmp6OutMsgs = rrddim_add(st, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_Icmp6InMsgs, Icmp6InMsgs); + rrddim_set_by_pointer(st, rd_Icmp6OutMsgs, Icmp6OutMsgs); + rrdset_done(st); + } + + if(do_ip6_icmp_redir == CONFIG_BOOLEAN_YES || (do_ip6_icmp_redir == CONFIG_BOOLEAN_AUTO && + (Icmp6InRedirects || + Icmp6OutRedirects || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_redir = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_Icmp6InRedirects = NULL, + *rd_Icmp6OutRedirects = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmpredir" + , NULL + , "icmp6" + , NULL + , "IPv6 ICMP Redirects" + , "redirects/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_REDIR + , update_every + , RRDSET_TYPE_LINE + ); + + rd_Icmp6InRedirects = rrddim_add(st, "InRedirects", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_Icmp6OutRedirects = rrddim_add(st, "OutRedirects", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_Icmp6InRedirects, Icmp6InRedirects); + rrddim_set_by_pointer(st, rd_Icmp6OutRedirects, Icmp6OutRedirects); + rrdset_done(st); + } + + if(do_ip6_icmp_errors == CONFIG_BOOLEAN_YES || (do_ip6_icmp_errors == CONFIG_BOOLEAN_AUTO && + (Icmp6InErrors || + Icmp6OutErrors || + Icmp6InCsumErrors || + Icmp6InDestUnreachs || + Icmp6InPktTooBigs || + Icmp6InTimeExcds || + Icmp6InParmProblems || + Icmp6OutDestUnreachs || + Icmp6OutPktTooBigs || + Icmp6OutTimeExcds || + Icmp6OutParmProblems || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_errors = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InErrors = NULL, + *rd_OutErrors = NULL, + *rd_InCsumErrors = NULL, + *rd_InDestUnreachs = NULL, + *rd_InPktTooBigs = NULL, + *rd_InTimeExcds = NULL, + *rd_InParmProblems = NULL, + *rd_OutDestUnreachs = NULL, + *rd_OutPktTooBigs = NULL, + *rd_OutTimeExcds = NULL, + *rd_OutParmProblems = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmperrors" + , NULL + , "icmp6" + , NULL + , "IPv6 ICMP Errors" + , "errors/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_ERRORS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutErrors = rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InDestUnreachs = rrddim_add(st, "InDestUnreachs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InPktTooBigs = rrddim_add(st, "InPktTooBigs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InTimeExcds = rrddim_add(st, "InTimeExcds", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InParmProblems = rrddim_add(st, "InParmProblems", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutDestUnreachs = rrddim_add(st, "OutDestUnreachs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutPktTooBigs = rrddim_add(st, "OutPktTooBigs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutTimeExcds = rrddim_add(st, "OutTimeExcds", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutParmProblems = rrddim_add(st, "OutParmProblems", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InErrors, Icmp6InErrors); + rrddim_set_by_pointer(st, rd_OutErrors, Icmp6OutErrors); + rrddim_set_by_pointer(st, rd_InCsumErrors, Icmp6InCsumErrors); + rrddim_set_by_pointer(st, rd_InDestUnreachs, Icmp6InDestUnreachs); + rrddim_set_by_pointer(st, rd_InPktTooBigs, Icmp6InPktTooBigs); + rrddim_set_by_pointer(st, rd_InTimeExcds, Icmp6InTimeExcds); + rrddim_set_by_pointer(st, rd_InParmProblems, Icmp6InParmProblems); + rrddim_set_by_pointer(st, rd_OutDestUnreachs, Icmp6OutDestUnreachs); + rrddim_set_by_pointer(st, rd_OutPktTooBigs, Icmp6OutPktTooBigs); + rrddim_set_by_pointer(st, rd_OutTimeExcds, Icmp6OutTimeExcds); + rrddim_set_by_pointer(st, rd_OutParmProblems, Icmp6OutParmProblems); + rrdset_done(st); + } + + if(do_ip6_icmp_echos == CONFIG_BOOLEAN_YES || (do_ip6_icmp_echos == CONFIG_BOOLEAN_AUTO && + (Icmp6InEchos || + Icmp6OutEchos || + Icmp6InEchoReplies || + Icmp6OutEchoReplies || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_echos = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InEchos = NULL, + *rd_OutEchos = NULL, + *rd_InEchoReplies = NULL, + *rd_OutEchoReplies = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmpechos" + , NULL + , "icmp6" + , NULL + , "IPv6 ICMP Echo" + , "messages/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_ECHOS + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InEchos = rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutEchos = rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InEchoReplies = rrddim_add(st, "InEchoReplies", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutEchoReplies = rrddim_add(st, "OutEchoReplies", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InEchos, Icmp6InEchos); + rrddim_set_by_pointer(st, rd_OutEchos, Icmp6OutEchos); + rrddim_set_by_pointer(st, rd_InEchoReplies, Icmp6InEchoReplies); + rrddim_set_by_pointer(st, rd_OutEchoReplies, Icmp6OutEchoReplies); + rrdset_done(st); + } + + if(do_ip6_icmp_groupmemb == CONFIG_BOOLEAN_YES || (do_ip6_icmp_groupmemb == CONFIG_BOOLEAN_AUTO && + (Icmp6InGroupMembQueries || + Icmp6OutGroupMembQueries || + Icmp6InGroupMembResponses || + Icmp6OutGroupMembResponses || + Icmp6InGroupMembReductions || + Icmp6OutGroupMembReductions || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_groupmemb = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InQueries = NULL, + *rd_OutQueries = NULL, + *rd_InResponses = NULL, + *rd_OutResponses = NULL, + *rd_InReductions = NULL, + *rd_OutReductions = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "groupmemb" + , NULL + , "icmp6" + , NULL + , "IPv6 ICMP Group Membership" + , "messages/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_GROUPMEMB + , update_every + , RRDSET_TYPE_LINE); + + rd_InQueries = rrddim_add(st, "InQueries", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutQueries = rrddim_add(st, "OutQueries", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InResponses = rrddim_add(st, "InResponses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutResponses = rrddim_add(st, "OutResponses", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InReductions = rrddim_add(st, "InReductions", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutReductions = rrddim_add(st, "OutReductions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InQueries, Icmp6InGroupMembQueries); + rrddim_set_by_pointer(st, rd_OutQueries, Icmp6OutGroupMembQueries); + rrddim_set_by_pointer(st, rd_InResponses, Icmp6InGroupMembResponses); + rrddim_set_by_pointer(st, rd_OutResponses, Icmp6OutGroupMembResponses); + rrddim_set_by_pointer(st, rd_InReductions, Icmp6InGroupMembReductions); + rrddim_set_by_pointer(st, rd_OutReductions, Icmp6OutGroupMembReductions); + rrdset_done(st); + } + + if(do_ip6_icmp_router == CONFIG_BOOLEAN_YES || (do_ip6_icmp_router == CONFIG_BOOLEAN_AUTO && + (Icmp6InRouterSolicits || + Icmp6OutRouterSolicits || + Icmp6InRouterAdvertisements || + Icmp6OutRouterAdvertisements || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_router = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InSolicits = NULL, + *rd_OutSolicits = NULL, + *rd_InAdvertisements = NULL, + *rd_OutAdvertisements = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmprouter" + , NULL + , "icmp6" + , NULL + , "IPv6 Router Messages" + , "messages/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_ROUTER + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InSolicits = rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutSolicits = rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InAdvertisements = rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutAdvertisements = rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InSolicits, Icmp6InRouterSolicits); + rrddim_set_by_pointer(st, rd_OutSolicits, Icmp6OutRouterSolicits); + rrddim_set_by_pointer(st, rd_InAdvertisements, Icmp6InRouterAdvertisements); + rrddim_set_by_pointer(st, rd_OutAdvertisements, Icmp6OutRouterAdvertisements); + rrdset_done(st); + } + + if(do_ip6_icmp_neighbor == CONFIG_BOOLEAN_YES || (do_ip6_icmp_neighbor == CONFIG_BOOLEAN_AUTO && + (Icmp6InNeighborSolicits || + Icmp6OutNeighborSolicits || + Icmp6InNeighborAdvertisements || + Icmp6OutNeighborAdvertisements || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_neighbor = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InSolicits = NULL, + *rd_OutSolicits = NULL, + *rd_InAdvertisements = NULL, + *rd_OutAdvertisements = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmpneighbor" + , NULL + , "icmp6" + , NULL + , "IPv6 Neighbor Messages" + , "messages/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_NEIGHBOR + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InSolicits = rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutSolicits = rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InAdvertisements = rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutAdvertisements = rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InSolicits, Icmp6InNeighborSolicits); + rrddim_set_by_pointer(st, rd_OutSolicits, Icmp6OutNeighborSolicits); + rrddim_set_by_pointer(st, rd_InAdvertisements, Icmp6InNeighborAdvertisements); + rrddim_set_by_pointer(st, rd_OutAdvertisements, Icmp6OutNeighborAdvertisements); + rrdset_done(st); + } + + if(do_ip6_icmp_mldv2 == CONFIG_BOOLEAN_YES || (do_ip6_icmp_mldv2 == CONFIG_BOOLEAN_AUTO && + (Icmp6InMLDv2Reports || + Icmp6OutMLDv2Reports || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_mldv2 = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InMLDv2Reports = NULL, + *rd_OutMLDv2Reports = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmpmldv2" + , NULL + , "icmp6" + , NULL + , "IPv6 ICMP MLDv2 Reports" + , "reports/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_LDV2 + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InMLDv2Reports = rrddim_add(st, "InMLDv2Reports", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutMLDv2Reports = rrddim_add(st, "OutMLDv2Reports", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InMLDv2Reports, Icmp6InMLDv2Reports); + rrddim_set_by_pointer(st, rd_OutMLDv2Reports, Icmp6OutMLDv2Reports); + rrdset_done(st); + } + + if(do_ip6_icmp_types == CONFIG_BOOLEAN_YES || (do_ip6_icmp_types == CONFIG_BOOLEAN_AUTO && + (Icmp6InType1 || + Icmp6InType128 || + Icmp6InType129 || + Icmp6InType136 || + Icmp6OutType1 || + Icmp6OutType128 || + Icmp6OutType129 || + Icmp6OutType133 || + Icmp6OutType135 || + Icmp6OutType143 || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_icmp_types = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InType1 = NULL, + *rd_InType128 = NULL, + *rd_InType129 = NULL, + *rd_InType136 = NULL, + *rd_OutType1 = NULL, + *rd_OutType128 = NULL, + *rd_OutType129 = NULL, + *rd_OutType133 = NULL, + *rd_OutType135 = NULL, + *rd_OutType143 = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "icmptypes" + , NULL + , "icmp6" + , NULL + , "IPv6 ICMP Types" + , "messages/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ICMP_TYPES + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InType1 = rrddim_add(st, "InType1", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InType128 = rrddim_add(st, "InType128", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InType129 = rrddim_add(st, "InType129", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InType136 = rrddim_add(st, "InType136", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutType1 = rrddim_add(st, "OutType1", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutType128 = rrddim_add(st, "OutType128", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutType129 = rrddim_add(st, "OutType129", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutType133 = rrddim_add(st, "OutType133", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutType135 = rrddim_add(st, "OutType135", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_OutType143 = rrddim_add(st, "OutType143", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InType1, Icmp6InType1); + rrddim_set_by_pointer(st, rd_InType128, Icmp6InType128); + rrddim_set_by_pointer(st, rd_InType129, Icmp6InType129); + rrddim_set_by_pointer(st, rd_InType136, Icmp6InType136); + rrddim_set_by_pointer(st, rd_OutType1, Icmp6OutType1); + rrddim_set_by_pointer(st, rd_OutType128, Icmp6OutType128); + rrddim_set_by_pointer(st, rd_OutType129, Icmp6OutType129); + rrddim_set_by_pointer(st, rd_OutType133, Icmp6OutType133); + rrddim_set_by_pointer(st, rd_OutType135, Icmp6OutType135); + rrddim_set_by_pointer(st, rd_OutType143, Icmp6OutType143); + rrdset_done(st); + } + + if(do_ip6_ect == CONFIG_BOOLEAN_YES || (do_ip6_ect == CONFIG_BOOLEAN_AUTO && + (Ip6InNoECTPkts || + Ip6InECT1Pkts || + Ip6InECT0Pkts || + Ip6InCEPkts || + netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { + do_ip6_ect = CONFIG_BOOLEAN_YES; + static RRDSET *st = NULL; + static RRDDIM *rd_InNoECTPkts = NULL, + *rd_InECT1Pkts = NULL, + *rd_InECT0Pkts = NULL, + *rd_InCEPkts = NULL; + + if(unlikely(!st)) { + st = rrdset_create_localhost( + RRD_TYPE_NET_SNMP6 + , "ect" + , NULL + , "packets" + , NULL + , "IPv6 ECT Packets" + , "packets/s" + , PLUGIN_PROC_NAME + , PLUGIN_PROC_MODULE_NETSTAT_NAME + , NETDATA_CHART_PRIO_IPV6_ECT + , update_every + , RRDSET_TYPE_LINE + ); + + rd_InNoECTPkts = rrddim_add(st, "InNoECTPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InECT1Pkts = rrddim_add(st, "InECT1Pkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InECT0Pkts = rrddim_add(st, "InECT0Pkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_InCEPkts = rrddim_add(st, "InCEPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st, rd_InNoECTPkts, Ip6InNoECTPkts); + rrddim_set_by_pointer(st, rd_InECT1Pkts, Ip6InECT1Pkts); + rrddim_set_by_pointer(st, rd_InECT0Pkts, Ip6InECT0Pkts); + rrddim_set_by_pointer(st, rd_InCEPkts, Ip6InCEPkts); + rrdset_done(st); + } + return 0; } diff --git a/collectors/proc.plugin/proc_net_rpc_nfs.c b/collectors/proc.plugin/proc_net_rpc_nfs.c index f5702859c..b1ff4e05a 100644 --- a/collectors/proc.plugin/proc_net_rpc_nfs.c +++ b/collectors/proc.plugin/proc_net_rpc_nfs.c @@ -275,8 +275,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - if(do_net == 2) { static RRDSET *st = NULL; static RRDDIM *rd_udp = NULL, @@ -303,7 +301,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { rd_udp = rrddim_add(st, "udp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_tcp = rrddim_add(st, "tcp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); // ignore net_count, net_tcp_connections (void)net_count; @@ -314,8 +311,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_rpc == 2) { static RRDSET *st = NULL; static RRDDIM *rd_calls = NULL, @@ -343,7 +338,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { rd_retransmits = rrddim_add(st, "retransmits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_auth_refresh = rrddim_add(st, "auth_refresh", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_calls, rpc_calls); rrddim_set_by_pointer(st, rd_retransmits, rpc_retransmits); @@ -351,8 +345,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_proc2 == 2) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -371,7 +363,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); } - else rrdset_next(st); size_t i; for(i = 0; nfs_proc2_values[i].present ; i++) { @@ -384,8 +375,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_proc3 == 2) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -404,7 +393,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); } - else rrdset_next(st); size_t i; for(i = 0; nfs_proc3_values[i].present ; i++) { @@ -417,8 +405,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_proc4 == 2) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -437,7 +423,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); } - else rrdset_next(st); size_t i; for(i = 0; nfs_proc4_values[i].present ; i++) { diff --git a/collectors/proc.plugin/proc_net_rpc_nfsd.c b/collectors/proc.plugin/proc_net_rpc_nfsd.c index 48f218e44..bd1da8889 100644 --- a/collectors/proc.plugin/proc_net_rpc_nfsd.c +++ b/collectors/proc.plugin/proc_net_rpc_nfsd.c @@ -225,8 +225,8 @@ struct nfsd_procs nfsd4_ops_values[] = { int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { (void)dt; static procfile *ff = NULL; - static int do_rc = -1, do_fh = -1, do_io = -1, do_th = -1, do_ra = -1, do_net = -1, do_rpc = -1, do_proc2 = -1, do_proc3 = -1, do_proc4 = -1, do_proc4ops = -1; - static int ra_warning = 0, proc2_warning = 0, proc3_warning = 0, proc4_warning = 0, proc4ops_warning = 0; + static int do_rc = -1, do_fh = -1, do_io = -1, do_th = -1, do_net = -1, do_rpc = -1, do_proc2 = -1, do_proc3 = -1, do_proc4 = -1, do_proc4ops = -1; + static int proc2_warning = 0, proc3_warning = 0, proc4_warning = 0, proc4ops_warning = 0; if(unlikely(!ff)) { char filename[FILENAME_MAX + 1]; @@ -243,7 +243,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { do_fh = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "file handles", 1); do_io = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "I/O", 1); do_th = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "threads", 1); - do_ra = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "read ahead", 1); do_net = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "network", 1); do_rpc = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "rpc", 1); do_proc2 = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v2 procedures", 1); @@ -258,7 +257,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { if(do_fh) do_fh = 1; if(do_io) do_io = 1; if(do_th) do_th = 1; - if(do_ra) do_ra = 1; if(do_net) do_net = 1; if(do_rpc) do_rpc = 1; if(do_proc2) do_proc2 = 1; @@ -273,7 +271,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { unsigned long long fh_stale = 0; unsigned long long io_read = 0, io_write = 0; unsigned long long th_threads = 0; - unsigned long long ra_size = 0, ra_hist10 = 0, ra_hist20 = 0, ra_hist30 = 0, ra_hist40 = 0, ra_hist50 = 0, ra_hist60 = 0, ra_hist70 = 0, ra_hist80 = 0, ra_hist90 = 0, ra_hist100 = 0, ra_none = 0; unsigned long long net_count = 0, net_udp_count = 0, net_tcp_count = 0, net_tcp_connections = 0; unsigned long long rpc_calls = 0, rpc_bad_format = 0, rpc_bad_auth = 0, rpc_bad_client = 0; @@ -336,38 +333,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { do_th = 2; } - else if(do_ra == 1 && strcmp(type, "ra") == 0) { - if(unlikely(words < 13)) { - error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 13); - continue; - } - - // readahead cache has been disabled since 2019 (kernel 5.4) - // https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/fs/nfsd/vfs.c?id=501cb1849f865960501d19d54e6a5af306f9b6fd - - ra_size = str2ull(procfile_lineword(ff, l, 1)); - ra_hist10 = str2ull(procfile_lineword(ff, l, 2)); - ra_hist20 = str2ull(procfile_lineword(ff, l, 3)); - ra_hist30 = str2ull(procfile_lineword(ff, l, 4)); - ra_hist40 = str2ull(procfile_lineword(ff, l, 5)); - ra_hist50 = str2ull(procfile_lineword(ff, l, 6)); - ra_hist60 = str2ull(procfile_lineword(ff, l, 7)); - ra_hist70 = str2ull(procfile_lineword(ff, l, 8)); - ra_hist80 = str2ull(procfile_lineword(ff, l, 9)); - ra_hist90 = str2ull(procfile_lineword(ff, l, 10)); - ra_hist100 = str2ull(procfile_lineword(ff, l, 11)); - ra_none = str2ull(procfile_lineword(ff, l, 12)); - - unsigned long long sum = ra_hist10 + ra_hist20 + ra_hist30 + ra_hist40 + ra_hist50 + ra_hist60 + ra_hist70 + ra_hist80 + ra_hist90 + ra_hist100 + ra_none; - if(sum == 0ULL) { - if(!ra_warning) { - info("Disabling /proc/net/rpc/nfsd read ahead histogram. It seems unused on this machine. It will be enabled automatically when found with data in it."); - ra_warning = 1; - } - do_ra = -1; - } - else do_ra = 2; - } else if(do_net == 1 && strcmp(type, "net") == 0) { if(unlikely(words < 5)) { error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 5); @@ -484,8 +449,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { } } - // -------------------------------------------------------------------- - if(do_rc == 2) { static RRDSET *st = NULL; static RRDDIM *rd_hits = NULL, @@ -512,7 +475,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rd_misses = rrddim_add(st, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_nocache = rrddim_add(st, "nocache", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_hits, rc_hits); rrddim_set_by_pointer(st, rd_misses, rc_misses); @@ -520,8 +482,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_fh == 2) { static RRDSET *st = NULL; static RRDDIM *rd_stale = NULL; @@ -545,14 +505,11 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rd_stale = rrddim_add(st, "stale", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_stale, fh_stale); rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_io == 2) { static RRDSET *st = NULL; static RRDDIM *rd_read = NULL, @@ -577,15 +534,12 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rd_read = rrddim_add(st, "read", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL); rd_write = rrddim_add(st, "write", NULL, -1, 1000, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_read, io_read); rrddim_set_by_pointer(st, rd_write, io_write); rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_th == 2) { static RRDSET *st = NULL; static RRDDIM *rd_threads = NULL; @@ -608,78 +562,11 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rd_threads = rrddim_add(st, "threads", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_threads, th_threads); rrdset_done(st); - - } - - // -------------------------------------------------------------------- - - if(do_ra == 2) { - static RRDSET *st = NULL; - static RRDDIM *rd_ra_hist10 = NULL, - *rd_ra_hist20 = NULL, - *rd_ra_hist30 = NULL, - *rd_ra_hist40 = NULL, - *rd_ra_hist50 = NULL, - *rd_ra_hist60 = NULL, - *rd_ra_hist70 = NULL, - *rd_ra_hist80 = NULL, - *rd_ra_hist90 = NULL, - *rd_ra_hist100 = NULL, - *rd_ra_none = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - "nfsd" - , "readahead" - , NULL - , "readahead" - , NULL - , "NFS Server Read Ahead Depth" - , "percentage" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NFSD_NAME - , NETDATA_CHART_PRIO_NFSD_READAHEAD - , update_every - , RRDSET_TYPE_STACKED - ); - - rd_ra_hist10 = rrddim_add(st, "10%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist20 = rrddim_add(st, "20%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist30 = rrddim_add(st, "30%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist40 = rrddim_add(st, "40%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist50 = rrddim_add(st, "50%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist60 = rrddim_add(st, "60%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist70 = rrddim_add(st, "70%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist80 = rrddim_add(st, "80%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist90 = rrddim_add(st, "90%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_hist100 = rrddim_add(st, "100%", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - rd_ra_none = rrddim_add(st, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); - } - else rrdset_next(st); - - // ignore ra_size - (void)ra_size; - - rrddim_set_by_pointer(st, rd_ra_hist10, ra_hist10); - rrddim_set_by_pointer(st, rd_ra_hist20, ra_hist20); - rrddim_set_by_pointer(st, rd_ra_hist30, ra_hist30); - rrddim_set_by_pointer(st, rd_ra_hist40, ra_hist40); - rrddim_set_by_pointer(st, rd_ra_hist50, ra_hist50); - rrddim_set_by_pointer(st, rd_ra_hist60, ra_hist60); - rrddim_set_by_pointer(st, rd_ra_hist70, ra_hist70); - rrddim_set_by_pointer(st, rd_ra_hist80, ra_hist80); - rrddim_set_by_pointer(st, rd_ra_hist90, ra_hist90); - rrddim_set_by_pointer(st, rd_ra_hist100,ra_hist100); - rrddim_set_by_pointer(st, rd_ra_none, ra_none); - rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_net == 2) { static RRDSET *st = NULL; static RRDDIM *rd_udp = NULL, @@ -705,7 +592,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rd_udp = rrddim_add(st, "udp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_tcp = rrddim_add(st, "tcp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); // ignore net_count, net_tcp_connections (void)net_count; @@ -716,8 +602,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_rpc == 2) { static RRDSET *st = NULL; static RRDDIM *rd_calls = NULL, @@ -745,7 +629,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rd_bad_format = rrddim_add(st, "bad_format", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_bad_auth = rrddim_add(st, "bad_auth", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); // ignore rpc_bad_client (void)rpc_bad_client; @@ -756,8 +639,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_proc2 == 2) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -776,7 +657,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); } - else rrdset_next(st); size_t i; for(i = 0; nfsd_proc2_values[i].present ; i++) { @@ -789,8 +669,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_proc3 == 2) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -809,7 +687,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); } - else rrdset_next(st); size_t i; for(i = 0; nfsd_proc3_values[i].present ; i++) { @@ -822,8 +699,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_proc4 == 2) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -842,7 +717,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); } - else rrdset_next(st); size_t i; for(i = 0; nfsd_proc4_values[i].present ; i++) { @@ -855,8 +729,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { rrdset_done(st); } - // -------------------------------------------------------------------- - if(do_proc4ops == 2) { static RRDSET *st = NULL; if(unlikely(!st)) { @@ -875,7 +747,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); } - else rrdset_next(st); size_t i; for(i = 0; nfsd4_ops_values[i].present ; i++) { diff --git a/collectors/proc.plugin/proc_net_sctp_snmp.c b/collectors/proc.plugin/proc_net_sctp_snmp.c index 343cc5afb..292449a73 100644 --- a/collectors/proc.plugin/proc_net_sctp_snmp.c +++ b/collectors/proc.plugin/proc_net_sctp_snmp.c @@ -148,7 +148,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { rd_established = rrddim_add(st, "SctpCurrEstab", "established", 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_established, SctpCurrEstab); rrdset_done(st); @@ -190,7 +189,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { rd_aborted = rrddim_add(st, "SctpAborteds", "aborted", -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_shutdown = rrddim_add(st, "SctpShutdowns", "shutdown", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_active, SctpActiveEstabs); rrddim_set_by_pointer(st, rd_passive, SctpPassiveEstabs); @@ -230,7 +228,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { rd_received = rrddim_add(st, "SctpInSCTPPacks", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_sent = rrddim_add(st, "SctpOutSCTPPacks", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_received, SctpInSCTPPacks); rrddim_set_by_pointer(st, rd_sent, SctpOutSCTPPacks); @@ -268,7 +265,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { rd_invalid = rrddim_add(st, "SctpOutOfBlues", "invalid", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_csum = rrddim_add(st, "SctpChecksumErrors", "checksum", 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_invalid, SctpOutOfBlues); rrddim_set_by_pointer(st, rd_csum, SctpChecksumErrors); @@ -306,7 +302,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { rd_reassembled = rrddim_add(st, "SctpReasmUsrMsgs", "reassembled", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_fragmented = rrddim_add(st, "SctpFragUsrMsgs", "fragmented", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_reassembled, SctpReasmUsrMsgs); rrddim_set_by_pointer(st, rd_fragmented, SctpFragUsrMsgs); @@ -357,7 +352,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { rd_OutOrder = rrddim_add(st, "SctpOutOrderChunks", "OutOrder", -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_OutUnorder = rrddim_add(st, "SctpOutUnorderChunks", "OutUnorder", -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_InCtrl, SctpInCtrlChunks); rrddim_set_by_pointer(st, rd_InOrder, SctpInOrderChunks); diff --git a/collectors/proc.plugin/proc_net_snmp.c b/collectors/proc.plugin/proc_net_snmp.c deleted file mode 100644 index b03a6ac74..000000000 --- a/collectors/proc.plugin/proc_net_snmp.c +++ /dev/null @@ -1,1130 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "plugin_proc.h" -#define PLUGIN_PROC_MODULE_NET_SNMP_NAME "/proc/net/snmp" - -#define RRD_TYPE_NET_SNMP "ipv4" - -static struct proc_net_snmp { - // kernel_uint_t ip_Forwarding; - kernel_uint_t ip_DefaultTTL; - kernel_uint_t ip_InReceives; - kernel_uint_t ip_InHdrErrors; - kernel_uint_t ip_InAddrErrors; - kernel_uint_t ip_ForwDatagrams; - kernel_uint_t ip_InUnknownProtos; - kernel_uint_t ip_InDiscards; - kernel_uint_t ip_InDelivers; - kernel_uint_t ip_OutRequests; - kernel_uint_t ip_OutDiscards; - kernel_uint_t ip_OutNoRoutes; - kernel_uint_t ip_ReasmTimeout; - kernel_uint_t ip_ReasmReqds; - kernel_uint_t ip_ReasmOKs; - kernel_uint_t ip_ReasmFails; - kernel_uint_t ip_FragOKs; - kernel_uint_t ip_FragFails; - kernel_uint_t ip_FragCreates; - - kernel_uint_t icmp_InMsgs; - kernel_uint_t icmp_OutMsgs; - kernel_uint_t icmp_InErrors; - kernel_uint_t icmp_OutErrors; - kernel_uint_t icmp_InCsumErrors; - - kernel_uint_t icmpmsg_InEchoReps; - kernel_uint_t icmpmsg_OutEchoReps; - kernel_uint_t icmpmsg_InDestUnreachs; - kernel_uint_t icmpmsg_OutDestUnreachs; - kernel_uint_t icmpmsg_InRedirects; - kernel_uint_t icmpmsg_OutRedirects; - kernel_uint_t icmpmsg_InEchos; - kernel_uint_t icmpmsg_OutEchos; - kernel_uint_t icmpmsg_InRouterAdvert; - kernel_uint_t icmpmsg_OutRouterAdvert; - kernel_uint_t icmpmsg_InRouterSelect; - kernel_uint_t icmpmsg_OutRouterSelect; - kernel_uint_t icmpmsg_InTimeExcds; - kernel_uint_t icmpmsg_OutTimeExcds; - kernel_uint_t icmpmsg_InParmProbs; - kernel_uint_t icmpmsg_OutParmProbs; - kernel_uint_t icmpmsg_InTimestamps; - kernel_uint_t icmpmsg_OutTimestamps; - kernel_uint_t icmpmsg_InTimestampReps; - kernel_uint_t icmpmsg_OutTimestampReps; - - //kernel_uint_t tcp_RtoAlgorithm; - //kernel_uint_t tcp_RtoMin; - //kernel_uint_t tcp_RtoMax; - ssize_t tcp_MaxConn; - kernel_uint_t tcp_ActiveOpens; - kernel_uint_t tcp_PassiveOpens; - kernel_uint_t tcp_AttemptFails; - kernel_uint_t tcp_EstabResets; - kernel_uint_t tcp_CurrEstab; - kernel_uint_t tcp_InSegs; - kernel_uint_t tcp_OutSegs; - kernel_uint_t tcp_RetransSegs; - kernel_uint_t tcp_InErrs; - kernel_uint_t tcp_OutRsts; - kernel_uint_t tcp_InCsumErrors; - - kernel_uint_t udp_InDatagrams; - kernel_uint_t udp_NoPorts; - kernel_uint_t udp_InErrors; - kernel_uint_t udp_OutDatagrams; - kernel_uint_t udp_RcvbufErrors; - kernel_uint_t udp_SndbufErrors; - kernel_uint_t udp_InCsumErrors; - kernel_uint_t udp_IgnoredMulti; - - kernel_uint_t udplite_InDatagrams; - kernel_uint_t udplite_NoPorts; - kernel_uint_t udplite_InErrors; - kernel_uint_t udplite_OutDatagrams; - kernel_uint_t udplite_RcvbufErrors; - kernel_uint_t udplite_SndbufErrors; - kernel_uint_t udplite_InCsumErrors; - kernel_uint_t udplite_IgnoredMulti; -} snmp_root = { 0 }; - -int do_proc_net_snmp(int update_every, usec_t dt) { - (void)dt; - - static procfile *ff = NULL; - static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1, - do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1, do_tcp_opens = -1, - do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1, do_udplite_packets = -1; - static uint32_t hash_ip = 0, hash_icmp = 0, hash_tcp = 0, hash_udp = 0, hash_icmpmsg = 0, hash_udplite = 0; - - static ARL_BASE *arl_ip = NULL, - *arl_icmp = NULL, - *arl_icmpmsg = NULL, - *arl_tcp = NULL, - *arl_udp = NULL, - *arl_udplite = NULL; - - static RRDVAR *tcp_max_connections_var = NULL; - - if(unlikely(!arl_ip)) { - do_ip_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 packets", CONFIG_BOOLEAN_AUTO); - do_ip_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments sent", CONFIG_BOOLEAN_AUTO); - do_ip_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments assembly", CONFIG_BOOLEAN_AUTO); - do_ip_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 errors", CONFIG_BOOLEAN_AUTO); - do_tcp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP connections", CONFIG_BOOLEAN_AUTO); - do_tcp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP packets", CONFIG_BOOLEAN_AUTO); - do_tcp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP errors", CONFIG_BOOLEAN_AUTO); - do_tcp_opens = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP opens", CONFIG_BOOLEAN_AUTO); - do_tcp_handshake = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP handshake issues", CONFIG_BOOLEAN_AUTO); - do_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP packets", CONFIG_BOOLEAN_AUTO); - do_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP errors", CONFIG_BOOLEAN_AUTO); - do_icmp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP packets", CONFIG_BOOLEAN_AUTO); - do_icmpmsg = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP messages", CONFIG_BOOLEAN_AUTO); - do_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDPLite packets", CONFIG_BOOLEAN_AUTO); - - hash_ip = simple_hash("Ip"); - hash_tcp = simple_hash("Tcp"); - hash_udp = simple_hash("Udp"); - hash_icmp = simple_hash("Icmp"); - hash_icmpmsg = simple_hash("IcmpMsg"); - hash_udplite = simple_hash("UdpLite"); - - arl_ip = arl_create("snmp/Ip", arl_callback_str2kernel_uint_t, 60); - // arl_expect(arl_ip, "Forwarding", &snmp_root.ip_Forwarding); - arl_expect(arl_ip, "DefaultTTL", &snmp_root.ip_DefaultTTL); - arl_expect(arl_ip, "InReceives", &snmp_root.ip_InReceives); - arl_expect(arl_ip, "InHdrErrors", &snmp_root.ip_InHdrErrors); - arl_expect(arl_ip, "InAddrErrors", &snmp_root.ip_InAddrErrors); - arl_expect(arl_ip, "ForwDatagrams", &snmp_root.ip_ForwDatagrams); - arl_expect(arl_ip, "InUnknownProtos", &snmp_root.ip_InUnknownProtos); - arl_expect(arl_ip, "InDiscards", &snmp_root.ip_InDiscards); - arl_expect(arl_ip, "InDelivers", &snmp_root.ip_InDelivers); - arl_expect(arl_ip, "OutRequests", &snmp_root.ip_OutRequests); - arl_expect(arl_ip, "OutDiscards", &snmp_root.ip_OutDiscards); - arl_expect(arl_ip, "OutNoRoutes", &snmp_root.ip_OutNoRoutes); - arl_expect(arl_ip, "ReasmTimeout", &snmp_root.ip_ReasmTimeout); - arl_expect(arl_ip, "ReasmReqds", &snmp_root.ip_ReasmReqds); - arl_expect(arl_ip, "ReasmOKs", &snmp_root.ip_ReasmOKs); - arl_expect(arl_ip, "ReasmFails", &snmp_root.ip_ReasmFails); - arl_expect(arl_ip, "FragOKs", &snmp_root.ip_FragOKs); - arl_expect(arl_ip, "FragFails", &snmp_root.ip_FragFails); - arl_expect(arl_ip, "FragCreates", &snmp_root.ip_FragCreates); - - arl_icmp = arl_create("snmp/Icmp", arl_callback_str2kernel_uint_t, 60); - arl_expect(arl_icmp, "InMsgs", &snmp_root.icmp_InMsgs); - arl_expect(arl_icmp, "OutMsgs", &snmp_root.icmp_OutMsgs); - arl_expect(arl_icmp, "InErrors", &snmp_root.icmp_InErrors); - arl_expect(arl_icmp, "OutErrors", &snmp_root.icmp_OutErrors); - arl_expect(arl_icmp, "InCsumErrors", &snmp_root.icmp_InCsumErrors); - - arl_icmpmsg = arl_create("snmp/Icmpmsg", arl_callback_str2kernel_uint_t, 60); - arl_expect(arl_icmpmsg, "InType0", &snmp_root.icmpmsg_InEchoReps); - arl_expect(arl_icmpmsg, "OutType0", &snmp_root.icmpmsg_OutEchoReps); - arl_expect(arl_icmpmsg, "InType3", &snmp_root.icmpmsg_InDestUnreachs); - arl_expect(arl_icmpmsg, "OutType3", &snmp_root.icmpmsg_OutDestUnreachs); - arl_expect(arl_icmpmsg, "InType5", &snmp_root.icmpmsg_InRedirects); - arl_expect(arl_icmpmsg, "OutType5", &snmp_root.icmpmsg_OutRedirects); - arl_expect(arl_icmpmsg, "InType8", &snmp_root.icmpmsg_InEchos); - arl_expect(arl_icmpmsg, "OutType8", &snmp_root.icmpmsg_OutEchos); - arl_expect(arl_icmpmsg, "InType9", &snmp_root.icmpmsg_InRouterAdvert); - arl_expect(arl_icmpmsg, "OutType9", &snmp_root.icmpmsg_OutRouterAdvert); - arl_expect(arl_icmpmsg, "InType10", &snmp_root.icmpmsg_InRouterSelect); - arl_expect(arl_icmpmsg, "OutType10", &snmp_root.icmpmsg_OutRouterSelect); - arl_expect(arl_icmpmsg, "InType11", &snmp_root.icmpmsg_InTimeExcds); - arl_expect(arl_icmpmsg, "OutType11", &snmp_root.icmpmsg_OutTimeExcds); - arl_expect(arl_icmpmsg, "InType12", &snmp_root.icmpmsg_InParmProbs); - arl_expect(arl_icmpmsg, "OutType12", &snmp_root.icmpmsg_OutParmProbs); - arl_expect(arl_icmpmsg, "InType13", &snmp_root.icmpmsg_InTimestamps); - arl_expect(arl_icmpmsg, "OutType13", &snmp_root.icmpmsg_OutTimestamps); - arl_expect(arl_icmpmsg, "InType14", &snmp_root.icmpmsg_InTimestampReps); - arl_expect(arl_icmpmsg, "OutType14", &snmp_root.icmpmsg_OutTimestampReps); - - arl_tcp = arl_create("snmp/Tcp", arl_callback_str2kernel_uint_t, 60); - // arl_expect(arl_tcp, "RtoAlgorithm", &snmp_root.tcp_RtoAlgorithm); - // arl_expect(arl_tcp, "RtoMin", &snmp_root.tcp_RtoMin); - // arl_expect(arl_tcp, "RtoMax", &snmp_root.tcp_RtoMax); - arl_expect_custom(arl_tcp, "MaxConn", arl_callback_ssize_t, &snmp_root.tcp_MaxConn); - arl_expect(arl_tcp, "ActiveOpens", &snmp_root.tcp_ActiveOpens); - arl_expect(arl_tcp, "PassiveOpens", &snmp_root.tcp_PassiveOpens); - arl_expect(arl_tcp, "AttemptFails", &snmp_root.tcp_AttemptFails); - arl_expect(arl_tcp, "EstabResets", &snmp_root.tcp_EstabResets); - arl_expect(arl_tcp, "CurrEstab", &snmp_root.tcp_CurrEstab); - arl_expect(arl_tcp, "InSegs", &snmp_root.tcp_InSegs); - arl_expect(arl_tcp, "OutSegs", &snmp_root.tcp_OutSegs); - arl_expect(arl_tcp, "RetransSegs", &snmp_root.tcp_RetransSegs); - arl_expect(arl_tcp, "InErrs", &snmp_root.tcp_InErrs); - arl_expect(arl_tcp, "OutRsts", &snmp_root.tcp_OutRsts); - arl_expect(arl_tcp, "InCsumErrors", &snmp_root.tcp_InCsumErrors); - - arl_udp = arl_create("snmp/Udp", arl_callback_str2kernel_uint_t, 60); - arl_expect(arl_udp, "InDatagrams", &snmp_root.udp_InDatagrams); - arl_expect(arl_udp, "NoPorts", &snmp_root.udp_NoPorts); - arl_expect(arl_udp, "InErrors", &snmp_root.udp_InErrors); - arl_expect(arl_udp, "OutDatagrams", &snmp_root.udp_OutDatagrams); - arl_expect(arl_udp, "RcvbufErrors", &snmp_root.udp_RcvbufErrors); - arl_expect(arl_udp, "SndbufErrors", &snmp_root.udp_SndbufErrors); - arl_expect(arl_udp, "InCsumErrors", &snmp_root.udp_InCsumErrors); - arl_expect(arl_udp, "IgnoredMulti", &snmp_root.udp_IgnoredMulti); - - arl_udplite = arl_create("snmp/Udplite", arl_callback_str2kernel_uint_t, 60); - arl_expect(arl_udplite, "InDatagrams", &snmp_root.udplite_InDatagrams); - arl_expect(arl_udplite, "NoPorts", &snmp_root.udplite_NoPorts); - arl_expect(arl_udplite, "InErrors", &snmp_root.udplite_InErrors); - arl_expect(arl_udplite, "OutDatagrams", &snmp_root.udplite_OutDatagrams); - arl_expect(arl_udplite, "RcvbufErrors", &snmp_root.udplite_RcvbufErrors); - arl_expect(arl_udplite, "SndbufErrors", &snmp_root.udplite_SndbufErrors); - arl_expect(arl_udplite, "InCsumErrors", &snmp_root.udplite_InCsumErrors); - arl_expect(arl_udplite, "IgnoredMulti", &snmp_root.udplite_IgnoredMulti); - - tcp_max_connections_var = rrdvar_custom_host_variable_create(localhost, "tcp_max_connections"); - } - - if(unlikely(!ff)) { - char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/snmp"); - ff = procfile_open(config_get("plugin:proc:/proc/net/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); - if(unlikely(!ff)) return 1; - } - - ff = procfile_readall(ff); - if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time - - size_t lines = procfile_lines(ff), l; - size_t words, w; - - for(l = 0; l < lines ;l++) { - char *key = procfile_lineword(ff, l, 0); - uint32_t hash = simple_hash(key); - - if(unlikely(hash == hash_ip && strcmp(key, "Ip") == 0)) { - size_t h = l++; - - if(strcmp(procfile_lineword(ff, l, 0), "Ip") != 0) { - error("Cannot read Ip line from /proc/net/snmp."); - break; - } - - words = procfile_linewords(ff, l); - if(words < 3) { - error("Cannot read /proc/net/snmp Ip line. Expected 3+ params, read %zu.", words); - continue; - } - - arl_begin(arl_ip); - for(w = 1; w < words ; w++) { - if (unlikely(arl_check(arl_ip, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0)) - break; - } - - // -------------------------------------------------------------------- - - if(do_ip_packets == CONFIG_BOOLEAN_YES || (do_ip_packets == CONFIG_BOOLEAN_AUTO && - (snmp_root.ip_OutRequests || - snmp_root.ip_InReceives || - snmp_root.ip_ForwDatagrams || - snmp_root.ip_InDelivers || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_packets = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_InReceives = NULL, - *rd_OutRequests = NULL, - *rd_ForwDatagrams = NULL, - *rd_InDelivers = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "packets" - , NULL - , "packets" - , NULL - , "IPv4 Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_PACKETS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InReceives = rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutRequests = rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_ForwDatagrams = rrddim_add(st, "ForwDatagrams", "forwarded", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InDelivers = rrddim_add(st, "InDelivers", "delivered", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_OutRequests, (collected_number)snmp_root.ip_OutRequests); - rrddim_set_by_pointer(st, rd_InReceives, (collected_number)snmp_root.ip_InReceives); - rrddim_set_by_pointer(st, rd_ForwDatagrams, (collected_number)snmp_root.ip_ForwDatagrams); - rrddim_set_by_pointer(st, rd_InDelivers, (collected_number)snmp_root.ip_InDelivers); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ip_fragsout == CONFIG_BOOLEAN_YES || (do_ip_fragsout == CONFIG_BOOLEAN_AUTO && - (snmp_root.ip_FragOKs || - snmp_root.ip_FragFails || - snmp_root.ip_FragCreates || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_fragsout = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_FragOKs = NULL, - *rd_FragFails = NULL, - *rd_FragCreates = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "fragsout" - , NULL - , "fragments" - , NULL - , "IPv4 Fragments Sent" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_FRAGMENTS - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_FragOKs = rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_FragFails = rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_FragCreates = rrddim_add(st, "FragCreates", "created", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_FragOKs, (collected_number)snmp_root.ip_FragOKs); - rrddim_set_by_pointer(st, rd_FragFails, (collected_number)snmp_root.ip_FragFails); - rrddim_set_by_pointer(st, rd_FragCreates, (collected_number)snmp_root.ip_FragCreates); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ip_fragsin == CONFIG_BOOLEAN_YES || (do_ip_fragsin == CONFIG_BOOLEAN_AUTO && - (snmp_root.ip_ReasmOKs || - snmp_root.ip_ReasmFails || - snmp_root.ip_ReasmReqds || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_fragsin = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_ReasmOKs = NULL, - *rd_ReasmFails = NULL, - *rd_ReasmReqds = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "fragsin" - , NULL - , "fragments" - , NULL - , "IPv4 Fragments Reassembly" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_FRAGMENTS + 1 - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_ReasmOKs = rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_ReasmFails = rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_ReasmReqds = rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_ReasmOKs, (collected_number)snmp_root.ip_ReasmOKs); - rrddim_set_by_pointer(st, rd_ReasmFails, (collected_number)snmp_root.ip_ReasmFails); - rrddim_set_by_pointer(st, rd_ReasmReqds, (collected_number)snmp_root.ip_ReasmReqds); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ip_errors == CONFIG_BOOLEAN_YES || (do_ip_errors == CONFIG_BOOLEAN_AUTO && - (snmp_root.ip_InDiscards || - snmp_root.ip_OutDiscards || - snmp_root.ip_InHdrErrors || - snmp_root.ip_InAddrErrors || - snmp_root.ip_InUnknownProtos || - snmp_root.ip_OutNoRoutes || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_errors = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_InDiscards = NULL, - *rd_OutDiscards = NULL, - *rd_InHdrErrors = NULL, - *rd_OutNoRoutes = NULL, - *rd_InAddrErrors = NULL, - *rd_InUnknownProtos = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "errors" - , NULL - , "errors" - , NULL - , "IPv4 Errors" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_ERRORS - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_InDiscards = rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutDiscards = rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - - rd_InHdrErrors = rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutNoRoutes = rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - - rd_InAddrErrors = rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InUnknownProtos = rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InDiscards, (collected_number)snmp_root.ip_InDiscards); - rrddim_set_by_pointer(st, rd_OutDiscards, (collected_number)snmp_root.ip_OutDiscards); - rrddim_set_by_pointer(st, rd_InHdrErrors, (collected_number)snmp_root.ip_InHdrErrors); - rrddim_set_by_pointer(st, rd_InAddrErrors, (collected_number)snmp_root.ip_InAddrErrors); - rrddim_set_by_pointer(st, rd_InUnknownProtos, (collected_number)snmp_root.ip_InUnknownProtos); - rrddim_set_by_pointer(st, rd_OutNoRoutes, (collected_number)snmp_root.ip_OutNoRoutes); - rrdset_done(st); - } - } - else if(unlikely(hash == hash_icmp && strcmp(key, "Icmp") == 0)) { - size_t h = l++; - - if(strcmp(procfile_lineword(ff, l, 0), "Icmp") != 0) { - error("Cannot read Icmp line from /proc/net/snmp."); - break; - } - - words = procfile_linewords(ff, l); - if(words < 3) { - error("Cannot read /proc/net/snmp Icmp line. Expected 3+ params, read %zu.", words); - continue; - } - - arl_begin(arl_icmp); - for(w = 1; w < words ; w++) { - if (unlikely(arl_check(arl_icmp, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0)) - break; - } - - // -------------------------------------------------------------------- - - if(do_icmp_packets == CONFIG_BOOLEAN_YES || (do_icmp_packets == CONFIG_BOOLEAN_AUTO && - (snmp_root.icmp_InMsgs || - snmp_root.icmp_OutMsgs || - snmp_root.icmp_InErrors || - snmp_root.icmp_OutErrors || - snmp_root.icmp_InCsumErrors || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_packets = CONFIG_BOOLEAN_YES; - - { - static RRDSET *st_packets = NULL; - static RRDDIM *rd_InMsgs = NULL, - *rd_OutMsgs = NULL; - - if(unlikely(!st_packets)) { - st_packets = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "icmp" - , NULL - , "icmp" - , NULL - , "IPv4 ICMP Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_ICMP - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InMsgs = rrddim_add(st_packets, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutMsgs = rrddim_add(st_packets, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st_packets); - - rrddim_set_by_pointer(st_packets, rd_InMsgs, (collected_number)snmp_root.icmp_InMsgs); - rrddim_set_by_pointer(st_packets, rd_OutMsgs, (collected_number)snmp_root.icmp_OutMsgs); - - rrdset_done(st_packets); - } - - { - static RRDSET *st_errors = NULL; - static RRDDIM *rd_InErrors = NULL, - *rd_OutErrors = NULL, - *rd_InCsumErrors = NULL; - - if(unlikely(!st_errors)) { - st_errors = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "icmp_errors" - , NULL - , "icmp" - , NULL - , "IPv4 ICMP Errors" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_ICMP + 1 - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InErrors = rrddim_add(st_errors, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutErrors = rrddim_add(st_errors, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCsumErrors = rrddim_add(st_errors, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st_errors); - - rrddim_set_by_pointer(st_errors, rd_InErrors, (collected_number)snmp_root.icmp_InErrors); - rrddim_set_by_pointer(st_errors, rd_OutErrors, (collected_number)snmp_root.icmp_OutErrors); - rrddim_set_by_pointer(st_errors, rd_InCsumErrors, (collected_number)snmp_root.icmp_InCsumErrors); - - rrdset_done(st_errors); - } - } - } - else if(unlikely(hash == hash_icmpmsg && strcmp(key, "IcmpMsg") == 0)) { - size_t h = l++; - - if(strcmp(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) { - error("Cannot read IcmpMsg line from /proc/net/snmp."); - break; - } - - words = procfile_linewords(ff, l); - if(words < 2) { - error("Cannot read /proc/net/snmp IcmpMsg line. Expected 2+ params, read %zu.", words); - continue; - } - - arl_begin(arl_icmpmsg); - for(w = 1; w < words ; w++) { - if (unlikely(arl_check(arl_icmpmsg, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0)) - break; - } - - // -------------------------------------------------------------------- - - if(do_icmpmsg == CONFIG_BOOLEAN_YES || (do_icmpmsg == CONFIG_BOOLEAN_AUTO && - (snmp_root.icmpmsg_InEchoReps || - snmp_root.icmpmsg_OutEchoReps || - snmp_root.icmpmsg_InDestUnreachs || - snmp_root.icmpmsg_OutDestUnreachs || - snmp_root.icmpmsg_InRedirects || - snmp_root.icmpmsg_OutRedirects || - snmp_root.icmpmsg_InEchos || - snmp_root.icmpmsg_OutEchos || - snmp_root.icmpmsg_InRouterAdvert || - snmp_root.icmpmsg_OutRouterAdvert || - snmp_root.icmpmsg_InRouterSelect || - snmp_root.icmpmsg_OutRouterSelect || - snmp_root.icmpmsg_InTimeExcds || - snmp_root.icmpmsg_OutTimeExcds || - snmp_root.icmpmsg_InParmProbs || - snmp_root.icmpmsg_OutParmProbs || - snmp_root.icmpmsg_InTimestamps || - snmp_root.icmpmsg_OutTimestamps || - snmp_root.icmpmsg_InTimestampReps || - snmp_root.icmpmsg_OutTimestampReps || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmpmsg = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_InEchoReps = NULL, - *rd_OutEchoReps = NULL, - *rd_InDestUnreachs = NULL, - *rd_OutDestUnreachs = NULL, - *rd_InRedirects = NULL, - *rd_OutRedirects = NULL, - *rd_InEchos = NULL, - *rd_OutEchos = NULL, - *rd_InRouterAdvert = NULL, - *rd_OutRouterAdvert = NULL, - *rd_InRouterSelect = NULL, - *rd_OutRouterSelect = NULL, - *rd_InTimeExcds = NULL, - *rd_OutTimeExcds = NULL, - *rd_InParmProbs = NULL, - *rd_OutParmProbs = NULL, - *rd_InTimestamps = NULL, - *rd_OutTimestamps = NULL, - *rd_InTimestampReps = NULL, - *rd_OutTimestampReps = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "icmpmsg" - , NULL - , "icmp" - , NULL - , "IPv4 ICMP Messages" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_ICMP + 2 - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InEchoReps = rrddim_add(st, "InType0", "InEchoReps", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutEchoReps = rrddim_add(st, "OutType0", "OutEchoReps", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InDestUnreachs = rrddim_add(st, "InType3", "InDestUnreachs", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutDestUnreachs = rrddim_add(st, "OutType3", "OutDestUnreachs", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InRedirects = rrddim_add(st, "InType5", "InRedirects", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutRedirects = rrddim_add(st, "OutType5", "OutRedirects", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InEchos = rrddim_add(st, "InType8", "InEchos", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutEchos = rrddim_add(st, "OutType8", "OutEchos", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InRouterAdvert = rrddim_add(st, "InType9", "InRouterAdvert", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutRouterAdvert = rrddim_add(st, "OutType9", "OutRouterAdvert", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InRouterSelect = rrddim_add(st, "InType10", "InRouterSelect", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutRouterSelect = rrddim_add(st, "OutType10", "OutRouterSelect", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InTimeExcds = rrddim_add(st, "InType11", "InTimeExcds", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutTimeExcds = rrddim_add(st, "OutType11", "OutTimeExcds", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InParmProbs = rrddim_add(st, "InType12", "InParmProbs", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutParmProbs = rrddim_add(st, "OutType12", "OutParmProbs", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InTimestamps = rrddim_add(st, "InType13", "InTimestamps", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutTimestamps = rrddim_add(st, "OutType13", "OutTimestamps", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InTimestampReps = rrddim_add(st, "InType14", "InTimestampReps", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutTimestampReps = rrddim_add(st, "OutType14", "OutTimestampReps", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InEchoReps, (collected_number)snmp_root.icmpmsg_InEchoReps); - rrddim_set_by_pointer(st, rd_OutEchoReps, (collected_number)snmp_root.icmpmsg_OutEchoReps); - rrddim_set_by_pointer(st, rd_InDestUnreachs, (collected_number)snmp_root.icmpmsg_InDestUnreachs); - rrddim_set_by_pointer(st, rd_OutDestUnreachs, (collected_number)snmp_root.icmpmsg_OutDestUnreachs); - rrddim_set_by_pointer(st, rd_InRedirects, (collected_number)snmp_root.icmpmsg_InRedirects); - rrddim_set_by_pointer(st, rd_OutRedirects, (collected_number)snmp_root.icmpmsg_OutRedirects); - rrddim_set_by_pointer(st, rd_InEchos, (collected_number)snmp_root.icmpmsg_InEchos); - rrddim_set_by_pointer(st, rd_OutEchos, (collected_number)snmp_root.icmpmsg_OutEchos); - rrddim_set_by_pointer(st, rd_InRouterAdvert, (collected_number)snmp_root.icmpmsg_InRouterAdvert); - rrddim_set_by_pointer(st, rd_OutRouterAdvert, (collected_number)snmp_root.icmpmsg_OutRouterAdvert); - rrddim_set_by_pointer(st, rd_InRouterSelect, (collected_number)snmp_root.icmpmsg_InRouterSelect); - rrddim_set_by_pointer(st, rd_OutRouterSelect, (collected_number)snmp_root.icmpmsg_OutRouterSelect); - rrddim_set_by_pointer(st, rd_InTimeExcds, (collected_number)snmp_root.icmpmsg_InTimeExcds); - rrddim_set_by_pointer(st, rd_OutTimeExcds, (collected_number)snmp_root.icmpmsg_OutTimeExcds); - rrddim_set_by_pointer(st, rd_InParmProbs, (collected_number)snmp_root.icmpmsg_InParmProbs); - rrddim_set_by_pointer(st, rd_OutParmProbs, (collected_number)snmp_root.icmpmsg_OutParmProbs); - rrddim_set_by_pointer(st, rd_InTimestamps, (collected_number)snmp_root.icmpmsg_InTimestamps); - rrddim_set_by_pointer(st, rd_OutTimestamps, (collected_number)snmp_root.icmpmsg_OutTimestamps); - rrddim_set_by_pointer(st, rd_InTimestampReps, (collected_number)snmp_root.icmpmsg_InTimestampReps); - rrddim_set_by_pointer(st, rd_OutTimestampReps, (collected_number)snmp_root.icmpmsg_OutTimestampReps); - - rrdset_done(st); - } - } - else if(unlikely(hash == hash_tcp && strcmp(key, "Tcp") == 0)) { - size_t h = l++; - - if(strcmp(procfile_lineword(ff, l, 0), "Tcp") != 0) { - error("Cannot read Tcp line from /proc/net/snmp."); - break; - } - - words = procfile_linewords(ff, l); - if(words < 3) { - error("Cannot read /proc/net/snmp Tcp line. Expected 3+ params, read %zu.", words); - continue; - } - - arl_begin(arl_tcp); - for(w = 1; w < words ; w++) { - if (unlikely(arl_check(arl_tcp, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0)) - break; - } - - // -------------------------------------------------------------------- - - // this is smart enough to update it, only when it is changed - rrdvar_custom_host_variable_set(localhost, tcp_max_connections_var, snmp_root.tcp_MaxConn); - - // -------------------------------------------------------------------- - - // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html - if(do_tcp_sockets == CONFIG_BOOLEAN_YES || (do_tcp_sockets == CONFIG_BOOLEAN_AUTO && - (snmp_root.tcp_CurrEstab || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcp_sockets = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_CurrEstab = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "tcpsock" - , NULL - , "tcp" - , NULL - , "IPv4 TCP Connections" - , "active connections" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_TCP - , update_every - , RRDSET_TYPE_LINE - ); - - rd_CurrEstab = rrddim_add(st, "CurrEstab", "connections", 1, 1, RRD_ALGORITHM_ABSOLUTE); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_CurrEstab, (collected_number)snmp_root.tcp_CurrEstab); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_tcp_packets == CONFIG_BOOLEAN_YES || (do_tcp_packets == CONFIG_BOOLEAN_AUTO && - (snmp_root.tcp_InSegs || - snmp_root.tcp_OutSegs || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcp_packets = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_InSegs = NULL, - *rd_OutSegs = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "tcppackets" - , NULL - , "tcp" - , NULL - , "IPv4 TCP Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_TCP + 4 - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InSegs = rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutSegs = rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InSegs, (collected_number)snmp_root.tcp_InSegs); - rrddim_set_by_pointer(st, rd_OutSegs, (collected_number)snmp_root.tcp_OutSegs); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_tcp_errors == CONFIG_BOOLEAN_YES || (do_tcp_errors == CONFIG_BOOLEAN_AUTO && - (snmp_root.tcp_InErrs || - snmp_root.tcp_InCsumErrors || - snmp_root.tcp_RetransSegs || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcp_errors = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_InErrs = NULL, - *rd_InCsumErrors = NULL, - *rd_RetransSegs = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "tcperrors" - , NULL - , "tcp" - , NULL - , "IPv4 TCP Errors" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_TCP + 20 - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_InErrs = rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_RetransSegs = rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InErrs, (collected_number)snmp_root.tcp_InErrs); - rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.tcp_InCsumErrors); - rrddim_set_by_pointer(st, rd_RetransSegs, (collected_number)snmp_root.tcp_RetransSegs); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_tcp_opens == CONFIG_BOOLEAN_YES || (do_tcp_opens == CONFIG_BOOLEAN_AUTO && - (snmp_root.tcp_ActiveOpens || - snmp_root.tcp_PassiveOpens || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcp_opens = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_ActiveOpens = NULL, - *rd_PassiveOpens = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "tcpopens" - , NULL - , "tcp" - , NULL - , "IPv4 TCP Opens" - , "connections/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_TCP + 5 - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_ActiveOpens = rrddim_add(st, "ActiveOpens", "active", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_PassiveOpens = rrddim_add(st, "PassiveOpens", "passive", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_ActiveOpens, (collected_number)snmp_root.tcp_ActiveOpens); - rrddim_set_by_pointer(st, rd_PassiveOpens, (collected_number)snmp_root.tcp_PassiveOpens); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_tcp_handshake == CONFIG_BOOLEAN_YES || (do_tcp_handshake == CONFIG_BOOLEAN_AUTO && - (snmp_root.tcp_EstabResets || - snmp_root.tcp_OutRsts || - snmp_root.tcp_AttemptFails || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_tcp_handshake = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_EstabResets = NULL, - *rd_OutRsts = NULL, - *rd_AttemptFails = NULL, - *rd_TCPSynRetrans = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "tcphandshake" - , NULL - , "tcp" - , NULL - , "IPv4 TCP Handshake Issues" - , "events/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_TCP + 30 - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_EstabResets = rrddim_add(st, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutRsts = rrddim_add(st, "OutRsts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_AttemptFails = rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_TCPSynRetrans = rrddim_add(st, "TCPSynRetrans", "SynRetrans", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_EstabResets, (collected_number)snmp_root.tcp_EstabResets); - rrddim_set_by_pointer(st, rd_OutRsts, (collected_number)snmp_root.tcp_OutRsts); - rrddim_set_by_pointer(st, rd_AttemptFails, (collected_number)snmp_root.tcp_AttemptFails); - rrddim_set_by_pointer(st, rd_TCPSynRetrans, tcpext_TCPSynRetrans); - rrdset_done(st); - } - } - else if(unlikely(hash == hash_udp && strcmp(key, "Udp") == 0)) { - size_t h = l++; - - if(strcmp(procfile_lineword(ff, l, 0), "Udp") != 0) { - error("Cannot read Udp line from /proc/net/snmp."); - break; - } - - words = procfile_linewords(ff, l); - if(words < 3) { - error("Cannot read /proc/net/snmp Udp line. Expected 3+ params, read %zu.", words); - continue; - } - - arl_begin(arl_udp); - for(w = 1; w < words ; w++) { - if (unlikely(arl_check(arl_udp, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0)) - break; - } - - // -------------------------------------------------------------------- - - // see http://net-snmp.sourceforge.net/docs/mibs/udp.html - if(do_udp_packets == CONFIG_BOOLEAN_YES || (do_udp_packets == CONFIG_BOOLEAN_AUTO && - (snmp_root.udp_InDatagrams || - snmp_root.udp_OutDatagrams || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_udp_packets = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_InDatagrams = NULL, - *rd_OutDatagrams = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "udppackets" - , NULL - , "udp" - , NULL - , "IPv4 UDP Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_UDP - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InDatagrams = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutDatagrams = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InDatagrams, (collected_number)snmp_root.udp_InDatagrams); - rrddim_set_by_pointer(st, rd_OutDatagrams, (collected_number)snmp_root.udp_OutDatagrams); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_udp_errors == CONFIG_BOOLEAN_YES || (do_udp_errors == CONFIG_BOOLEAN_AUTO && - (snmp_root.udp_InErrors || - snmp_root.udp_NoPorts || - snmp_root.udp_RcvbufErrors || - snmp_root.udp_SndbufErrors || - snmp_root.udp_InCsumErrors || - snmp_root.udp_IgnoredMulti || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_udp_errors = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_RcvbufErrors = NULL, - *rd_SndbufErrors = NULL, - *rd_InErrors = NULL, - *rd_NoPorts = NULL, - *rd_InCsumErrors = NULL, - *rd_IgnoredMulti = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "udperrors" - , NULL - , "udp" - , NULL - , "IPv4 UDP Errors" - , "events/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_UDP + 10 - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_IgnoredMulti = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InErrors, (collected_number)snmp_root.udp_InErrors); - rrddim_set_by_pointer(st, rd_NoPorts, (collected_number)snmp_root.udp_NoPorts); - rrddim_set_by_pointer(st, rd_RcvbufErrors, (collected_number)snmp_root.udp_RcvbufErrors); - rrddim_set_by_pointer(st, rd_SndbufErrors, (collected_number)snmp_root.udp_SndbufErrors); - rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.udp_InCsumErrors); - rrddim_set_by_pointer(st, rd_IgnoredMulti, (collected_number)snmp_root.udp_IgnoredMulti); - rrdset_done(st); - } - } - else if(unlikely(hash == hash_udplite && strcmp(key, "UdpLite") == 0)) { - size_t h = l++; - - if(strcmp(procfile_lineword(ff, l, 0), "UdpLite") != 0) { - error("Cannot read UdpLite line from /proc/net/snmp."); - break; - } - - words = procfile_linewords(ff, l); - if(words < 3) { - error("Cannot read /proc/net/snmp UdpLite line. Expected 3+ params, read %zu.", words); - continue; - } - - arl_begin(arl_udplite); - for(w = 1; w < words ; w++) { - if (unlikely(arl_check(arl_udplite, procfile_lineword(ff, h, w), procfile_lineword(ff, l, w)) != 0)) - break; - } - - // -------------------------------------------------------------------- - - if(do_udplite_packets == CONFIG_BOOLEAN_YES || (do_udplite_packets == CONFIG_BOOLEAN_AUTO && - (snmp_root.udplite_InDatagrams || - snmp_root.udplite_OutDatagrams || - snmp_root.udplite_NoPorts || - snmp_root.udplite_InErrors || - snmp_root.udplite_InCsumErrors || - snmp_root.udplite_RcvbufErrors || - snmp_root.udplite_SndbufErrors || - snmp_root.udplite_IgnoredMulti || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_udplite_packets = CONFIG_BOOLEAN_YES; - - { - static RRDSET *st = NULL; - static RRDDIM *rd_InDatagrams = NULL, - *rd_OutDatagrams = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "udplite" - , NULL - , "udplite" - , NULL - , "IPv4 UDPLite Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_UDPLITE - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InDatagrams = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutDatagrams = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InDatagrams, (collected_number)snmp_root.udplite_InDatagrams); - rrddim_set_by_pointer(st, rd_OutDatagrams, (collected_number)snmp_root.udplite_OutDatagrams); - rrdset_done(st); - } - - { - static RRDSET *st = NULL; - static RRDDIM *rd_RcvbufErrors = NULL, - *rd_SndbufErrors = NULL, - *rd_InErrors = NULL, - *rd_NoPorts = NULL, - *rd_InCsumErrors = NULL, - *rd_IgnoredMulti = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP - , "udplite_errors" - , NULL - , "udplite" - , NULL - , "IPv4 UDPLite Errors" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP_NAME - , NETDATA_CHART_PRIO_IPV4_UDPLITE + 10 - , update_every - , RRDSET_TYPE_LINE); - - rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_IgnoredMulti = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_NoPorts, (collected_number)snmp_root.udplite_NoPorts); - rrddim_set_by_pointer(st, rd_InErrors, (collected_number)snmp_root.udplite_InErrors); - rrddim_set_by_pointer(st, rd_InCsumErrors, (collected_number)snmp_root.udplite_InCsumErrors); - rrddim_set_by_pointer(st, rd_RcvbufErrors, (collected_number)snmp_root.udplite_RcvbufErrors); - rrddim_set_by_pointer(st, rd_SndbufErrors, (collected_number)snmp_root.udplite_SndbufErrors); - rrddim_set_by_pointer(st, rd_IgnoredMulti, (collected_number)snmp_root.udplite_IgnoredMulti); - rrdset_done(st); - } - } - } - } - - return 0; -} - diff --git a/collectors/proc.plugin/proc_net_snmp6.c b/collectors/proc.plugin/proc_net_snmp6.c deleted file mode 100644 index 445e0dcab..000000000 --- a/collectors/proc.plugin/proc_net_snmp6.c +++ /dev/null @@ -1,1293 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "plugin_proc.h" - -#define RRD_TYPE_NET_SNMP6 "ipv6" -#define PLUGIN_PROC_MODULE_NET_SNMP6_NAME "/proc/net/snmp6" - -int do_proc_net_snmp6(int update_every, usec_t dt) { - (void)dt; - - static procfile *ff = NULL; - - static int do_ip_packets = -1, - do_ip_fragsout = -1, - do_ip_fragsin = -1, - do_ip_errors = -1, - do_udplite_packets = -1, - do_udplite_errors = -1, - do_udp_packets = -1, - do_udp_errors = -1, - do_bandwidth = -1, - do_mcast = -1, - do_bcast = -1, - do_mcast_p = -1, - do_icmp = -1, - do_icmp_redir = -1, - do_icmp_errors = -1, - do_icmp_echos = -1, - do_icmp_groupmemb = -1, - do_icmp_router = -1, - do_icmp_neighbor = -1, - do_icmp_mldv2 = -1, - do_icmp_types = -1, - do_ect = -1; - - static ARL_BASE *arl_base = NULL; - - static unsigned long long Ip6InReceives = 0ULL; - static unsigned long long Ip6InHdrErrors = 0ULL; - static unsigned long long Ip6InTooBigErrors = 0ULL; - static unsigned long long Ip6InNoRoutes = 0ULL; - static unsigned long long Ip6InAddrErrors = 0ULL; - static unsigned long long Ip6InUnknownProtos = 0ULL; - static unsigned long long Ip6InTruncatedPkts = 0ULL; - static unsigned long long Ip6InDiscards = 0ULL; - static unsigned long long Ip6InDelivers = 0ULL; - static unsigned long long Ip6OutForwDatagrams = 0ULL; - static unsigned long long Ip6OutRequests = 0ULL; - static unsigned long long Ip6OutDiscards = 0ULL; - static unsigned long long Ip6OutNoRoutes = 0ULL; - static unsigned long long Ip6ReasmTimeout = 0ULL; - static unsigned long long Ip6ReasmReqds = 0ULL; - static unsigned long long Ip6ReasmOKs = 0ULL; - static unsigned long long Ip6ReasmFails = 0ULL; - static unsigned long long Ip6FragOKs = 0ULL; - static unsigned long long Ip6FragFails = 0ULL; - static unsigned long long Ip6FragCreates = 0ULL; - static unsigned long long Ip6InMcastPkts = 0ULL; - static unsigned long long Ip6OutMcastPkts = 0ULL; - static unsigned long long Ip6InOctets = 0ULL; - static unsigned long long Ip6OutOctets = 0ULL; - static unsigned long long Ip6InMcastOctets = 0ULL; - static unsigned long long Ip6OutMcastOctets = 0ULL; - static unsigned long long Ip6InBcastOctets = 0ULL; - static unsigned long long Ip6OutBcastOctets = 0ULL; - static unsigned long long Ip6InNoECTPkts = 0ULL; - static unsigned long long Ip6InECT1Pkts = 0ULL; - static unsigned long long Ip6InECT0Pkts = 0ULL; - static unsigned long long Ip6InCEPkts = 0ULL; - static unsigned long long Icmp6InMsgs = 0ULL; - static unsigned long long Icmp6InErrors = 0ULL; - static unsigned long long Icmp6OutMsgs = 0ULL; - static unsigned long long Icmp6OutErrors = 0ULL; - static unsigned long long Icmp6InCsumErrors = 0ULL; - static unsigned long long Icmp6InDestUnreachs = 0ULL; - static unsigned long long Icmp6InPktTooBigs = 0ULL; - static unsigned long long Icmp6InTimeExcds = 0ULL; - static unsigned long long Icmp6InParmProblems = 0ULL; - static unsigned long long Icmp6InEchos = 0ULL; - static unsigned long long Icmp6InEchoReplies = 0ULL; - static unsigned long long Icmp6InGroupMembQueries = 0ULL; - static unsigned long long Icmp6InGroupMembResponses = 0ULL; - static unsigned long long Icmp6InGroupMembReductions = 0ULL; - static unsigned long long Icmp6InRouterSolicits = 0ULL; - static unsigned long long Icmp6InRouterAdvertisements = 0ULL; - static unsigned long long Icmp6InNeighborSolicits = 0ULL; - static unsigned long long Icmp6InNeighborAdvertisements = 0ULL; - static unsigned long long Icmp6InRedirects = 0ULL; - static unsigned long long Icmp6InMLDv2Reports = 0ULL; - static unsigned long long Icmp6OutDestUnreachs = 0ULL; - static unsigned long long Icmp6OutPktTooBigs = 0ULL; - static unsigned long long Icmp6OutTimeExcds = 0ULL; - static unsigned long long Icmp6OutParmProblems = 0ULL; - static unsigned long long Icmp6OutEchos = 0ULL; - static unsigned long long Icmp6OutEchoReplies = 0ULL; - static unsigned long long Icmp6OutGroupMembQueries = 0ULL; - static unsigned long long Icmp6OutGroupMembResponses = 0ULL; - static unsigned long long Icmp6OutGroupMembReductions = 0ULL; - static unsigned long long Icmp6OutRouterSolicits = 0ULL; - static unsigned long long Icmp6OutRouterAdvertisements = 0ULL; - static unsigned long long Icmp6OutNeighborSolicits = 0ULL; - static unsigned long long Icmp6OutNeighborAdvertisements = 0ULL; - static unsigned long long Icmp6OutRedirects = 0ULL; - static unsigned long long Icmp6OutMLDv2Reports = 0ULL; - static unsigned long long Icmp6InType1 = 0ULL; - static unsigned long long Icmp6InType128 = 0ULL; - static unsigned long long Icmp6InType129 = 0ULL; - static unsigned long long Icmp6InType136 = 0ULL; - static unsigned long long Icmp6OutType1 = 0ULL; - static unsigned long long Icmp6OutType128 = 0ULL; - static unsigned long long Icmp6OutType129 = 0ULL; - static unsigned long long Icmp6OutType133 = 0ULL; - static unsigned long long Icmp6OutType135 = 0ULL; - static unsigned long long Icmp6OutType143 = 0ULL; - static unsigned long long Udp6InDatagrams = 0ULL; - static unsigned long long Udp6NoPorts = 0ULL; - static unsigned long long Udp6InErrors = 0ULL; - static unsigned long long Udp6OutDatagrams = 0ULL; - static unsigned long long Udp6RcvbufErrors = 0ULL; - static unsigned long long Udp6SndbufErrors = 0ULL; - static unsigned long long Udp6InCsumErrors = 0ULL; - static unsigned long long Udp6IgnoredMulti = 0ULL; - static unsigned long long UdpLite6InDatagrams = 0ULL; - static unsigned long long UdpLite6NoPorts = 0ULL; - static unsigned long long UdpLite6InErrors = 0ULL; - static unsigned long long UdpLite6OutDatagrams = 0ULL; - static unsigned long long UdpLite6RcvbufErrors = 0ULL; - static unsigned long long UdpLite6SndbufErrors = 0ULL; - static unsigned long long UdpLite6InCsumErrors = 0ULL; - - if(unlikely(!arl_base)) { - do_ip_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_BOOLEAN_AUTO); - do_ip_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_BOOLEAN_AUTO); - do_ip_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_BOOLEAN_AUTO); - do_ip_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_BOOLEAN_AUTO); - do_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_BOOLEAN_AUTO); - do_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_BOOLEAN_AUTO); - do_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_BOOLEAN_AUTO); - do_udplite_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_BOOLEAN_AUTO); - do_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_BOOLEAN_AUTO); - do_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_BOOLEAN_AUTO); - do_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_BOOLEAN_AUTO); - do_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_BOOLEAN_AUTO); - do_icmp = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp", CONFIG_BOOLEAN_AUTO); - do_icmp_redir = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_BOOLEAN_AUTO); - do_icmp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_BOOLEAN_AUTO); - do_icmp_echos = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_BOOLEAN_AUTO); - do_icmp_groupmemb = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_BOOLEAN_AUTO); - do_icmp_router = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_BOOLEAN_AUTO); - do_icmp_neighbor = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_BOOLEAN_AUTO); - do_icmp_mldv2 = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_BOOLEAN_AUTO); - do_icmp_types = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_BOOLEAN_AUTO); - do_ect = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ect", CONFIG_BOOLEAN_AUTO); - - arl_base = arl_create("snmp6", NULL, 60); - arl_expect(arl_base, "Ip6InReceives", &Ip6InReceives); - arl_expect(arl_base, "Ip6InHdrErrors", &Ip6InHdrErrors); - arl_expect(arl_base, "Ip6InTooBigErrors", &Ip6InTooBigErrors); - arl_expect(arl_base, "Ip6InNoRoutes", &Ip6InNoRoutes); - arl_expect(arl_base, "Ip6InAddrErrors", &Ip6InAddrErrors); - arl_expect(arl_base, "Ip6InUnknownProtos", &Ip6InUnknownProtos); - arl_expect(arl_base, "Ip6InTruncatedPkts", &Ip6InTruncatedPkts); - arl_expect(arl_base, "Ip6InDiscards", &Ip6InDiscards); - arl_expect(arl_base, "Ip6InDelivers", &Ip6InDelivers); - arl_expect(arl_base, "Ip6OutForwDatagrams", &Ip6OutForwDatagrams); - arl_expect(arl_base, "Ip6OutRequests", &Ip6OutRequests); - arl_expect(arl_base, "Ip6OutDiscards", &Ip6OutDiscards); - arl_expect(arl_base, "Ip6OutNoRoutes", &Ip6OutNoRoutes); - arl_expect(arl_base, "Ip6ReasmTimeout", &Ip6ReasmTimeout); - arl_expect(arl_base, "Ip6ReasmReqds", &Ip6ReasmReqds); - arl_expect(arl_base, "Ip6ReasmOKs", &Ip6ReasmOKs); - arl_expect(arl_base, "Ip6ReasmFails", &Ip6ReasmFails); - arl_expect(arl_base, "Ip6FragOKs", &Ip6FragOKs); - arl_expect(arl_base, "Ip6FragFails", &Ip6FragFails); - arl_expect(arl_base, "Ip6FragCreates", &Ip6FragCreates); - arl_expect(arl_base, "Ip6InMcastPkts", &Ip6InMcastPkts); - arl_expect(arl_base, "Ip6OutMcastPkts", &Ip6OutMcastPkts); - arl_expect(arl_base, "Ip6InOctets", &Ip6InOctets); - arl_expect(arl_base, "Ip6OutOctets", &Ip6OutOctets); - arl_expect(arl_base, "Ip6InMcastOctets", &Ip6InMcastOctets); - arl_expect(arl_base, "Ip6OutMcastOctets", &Ip6OutMcastOctets); - arl_expect(arl_base, "Ip6InBcastOctets", &Ip6InBcastOctets); - arl_expect(arl_base, "Ip6OutBcastOctets", &Ip6OutBcastOctets); - arl_expect(arl_base, "Ip6InNoECTPkts", &Ip6InNoECTPkts); - arl_expect(arl_base, "Ip6InECT1Pkts", &Ip6InECT1Pkts); - arl_expect(arl_base, "Ip6InECT0Pkts", &Ip6InECT0Pkts); - arl_expect(arl_base, "Ip6InCEPkts", &Ip6InCEPkts); - arl_expect(arl_base, "Icmp6InMsgs", &Icmp6InMsgs); - arl_expect(arl_base, "Icmp6InErrors", &Icmp6InErrors); - arl_expect(arl_base, "Icmp6OutMsgs", &Icmp6OutMsgs); - arl_expect(arl_base, "Icmp6OutErrors", &Icmp6OutErrors); - arl_expect(arl_base, "Icmp6InCsumErrors", &Icmp6InCsumErrors); - arl_expect(arl_base, "Icmp6InDestUnreachs", &Icmp6InDestUnreachs); - arl_expect(arl_base, "Icmp6InPktTooBigs", &Icmp6InPktTooBigs); - arl_expect(arl_base, "Icmp6InTimeExcds", &Icmp6InTimeExcds); - arl_expect(arl_base, "Icmp6InParmProblems", &Icmp6InParmProblems); - arl_expect(arl_base, "Icmp6InEchos", &Icmp6InEchos); - arl_expect(arl_base, "Icmp6InEchoReplies", &Icmp6InEchoReplies); - arl_expect(arl_base, "Icmp6InGroupMembQueries", &Icmp6InGroupMembQueries); - arl_expect(arl_base, "Icmp6InGroupMembResponses", &Icmp6InGroupMembResponses); - arl_expect(arl_base, "Icmp6InGroupMembReductions", &Icmp6InGroupMembReductions); - arl_expect(arl_base, "Icmp6InRouterSolicits", &Icmp6InRouterSolicits); - arl_expect(arl_base, "Icmp6InRouterAdvertisements", &Icmp6InRouterAdvertisements); - arl_expect(arl_base, "Icmp6InNeighborSolicits", &Icmp6InNeighborSolicits); - arl_expect(arl_base, "Icmp6InNeighborAdvertisements", &Icmp6InNeighborAdvertisements); - arl_expect(arl_base, "Icmp6InRedirects", &Icmp6InRedirects); - arl_expect(arl_base, "Icmp6InMLDv2Reports", &Icmp6InMLDv2Reports); - arl_expect(arl_base, "Icmp6OutDestUnreachs", &Icmp6OutDestUnreachs); - arl_expect(arl_base, "Icmp6OutPktTooBigs", &Icmp6OutPktTooBigs); - arl_expect(arl_base, "Icmp6OutTimeExcds", &Icmp6OutTimeExcds); - arl_expect(arl_base, "Icmp6OutParmProblems", &Icmp6OutParmProblems); - arl_expect(arl_base, "Icmp6OutEchos", &Icmp6OutEchos); - arl_expect(arl_base, "Icmp6OutEchoReplies", &Icmp6OutEchoReplies); - arl_expect(arl_base, "Icmp6OutGroupMembQueries", &Icmp6OutGroupMembQueries); - arl_expect(arl_base, "Icmp6OutGroupMembResponses", &Icmp6OutGroupMembResponses); - arl_expect(arl_base, "Icmp6OutGroupMembReductions", &Icmp6OutGroupMembReductions); - arl_expect(arl_base, "Icmp6OutRouterSolicits", &Icmp6OutRouterSolicits); - arl_expect(arl_base, "Icmp6OutRouterAdvertisements", &Icmp6OutRouterAdvertisements); - arl_expect(arl_base, "Icmp6OutNeighborSolicits", &Icmp6OutNeighborSolicits); - arl_expect(arl_base, "Icmp6OutNeighborAdvertisements", &Icmp6OutNeighborAdvertisements); - arl_expect(arl_base, "Icmp6OutRedirects", &Icmp6OutRedirects); - arl_expect(arl_base, "Icmp6OutMLDv2Reports", &Icmp6OutMLDv2Reports); - arl_expect(arl_base, "Icmp6InType1", &Icmp6InType1); - arl_expect(arl_base, "Icmp6InType128", &Icmp6InType128); - arl_expect(arl_base, "Icmp6InType129", &Icmp6InType129); - arl_expect(arl_base, "Icmp6InType136", &Icmp6InType136); - arl_expect(arl_base, "Icmp6OutType1", &Icmp6OutType1); - arl_expect(arl_base, "Icmp6OutType128", &Icmp6OutType128); - arl_expect(arl_base, "Icmp6OutType129", &Icmp6OutType129); - arl_expect(arl_base, "Icmp6OutType133", &Icmp6OutType133); - arl_expect(arl_base, "Icmp6OutType135", &Icmp6OutType135); - arl_expect(arl_base, "Icmp6OutType143", &Icmp6OutType143); - arl_expect(arl_base, "Udp6InDatagrams", &Udp6InDatagrams); - arl_expect(arl_base, "Udp6NoPorts", &Udp6NoPorts); - arl_expect(arl_base, "Udp6InErrors", &Udp6InErrors); - arl_expect(arl_base, "Udp6OutDatagrams", &Udp6OutDatagrams); - arl_expect(arl_base, "Udp6RcvbufErrors", &Udp6RcvbufErrors); - arl_expect(arl_base, "Udp6SndbufErrors", &Udp6SndbufErrors); - arl_expect(arl_base, "Udp6InCsumErrors", &Udp6InCsumErrors); - arl_expect(arl_base, "Udp6IgnoredMulti", &Udp6IgnoredMulti); - arl_expect(arl_base, "UdpLite6InDatagrams", &UdpLite6InDatagrams); - arl_expect(arl_base, "UdpLite6NoPorts", &UdpLite6NoPorts); - arl_expect(arl_base, "UdpLite6InErrors", &UdpLite6InErrors); - arl_expect(arl_base, "UdpLite6OutDatagrams", &UdpLite6OutDatagrams); - arl_expect(arl_base, "UdpLite6RcvbufErrors", &UdpLite6RcvbufErrors); - arl_expect(arl_base, "UdpLite6SndbufErrors", &UdpLite6SndbufErrors); - arl_expect(arl_base, "UdpLite6InCsumErrors", &UdpLite6InCsumErrors); - } - - if(unlikely(!ff)) { - char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/snmp6"); - ff = procfile_open(config_get("plugin:proc:/proc/net/snmp6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); - if(unlikely(!ff)) - return 1; - } - - ff = procfile_readall(ff); - if(unlikely(!ff)) - return 0; // we return 0, so that we will retry to open it next time - - size_t lines = procfile_lines(ff), l; - - arl_begin(arl_base); - - for(l = 0; l < lines ;l++) { - size_t words = procfile_linewords(ff, l); - if(unlikely(words < 2)) { - if(unlikely(words)) error("Cannot read /proc/net/snmp6 line %zu. Expected 2 params, read %zu.", l, words); - continue; - } - - if(unlikely(arl_check(arl_base, - procfile_lineword(ff, l, 0), - procfile_lineword(ff, l, 1)))) break; - } - - // -------------------------------------------------------------------- - - if(do_bandwidth == CONFIG_BOOLEAN_YES || (do_bandwidth == CONFIG_BOOLEAN_AUTO && - (Ip6InOctets || - Ip6OutOctets || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_bandwidth = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_received = NULL, - *rd_sent = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - "system" - , "ipv6" - , NULL - , "network" - , NULL - , "IPv6 Bandwidth" - , "kilobits/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_SYSTEM_IPV6 - , update_every - , RRDSET_TYPE_AREA - ); - - rd_received = rrddim_add(st, "InOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - rd_sent = rrddim_add(st, "OutOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_received, Ip6InOctets); - rrddim_set_by_pointer(st, rd_sent, Ip6OutOctets); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ip_packets == CONFIG_BOOLEAN_YES || (do_ip_packets == CONFIG_BOOLEAN_AUTO && - (Ip6InReceives || - Ip6OutRequests || - Ip6InDelivers || - Ip6OutForwDatagrams || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_packets = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_received = NULL, - *rd_sent = NULL, - *rd_forwarded = NULL, - *rd_delivers = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "packets" - , NULL - , "packets" - , NULL - , "IPv6 Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_PACKETS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_received = rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_sent = rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_forwarded = rrddim_add(st, "OutForwDatagrams", "forwarded", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_delivers = rrddim_add(st, "InDelivers", "delivers", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_received, Ip6InReceives); - rrddim_set_by_pointer(st, rd_sent, Ip6OutRequests); - rrddim_set_by_pointer(st, rd_forwarded, Ip6OutForwDatagrams); - rrddim_set_by_pointer(st, rd_delivers, Ip6InDelivers); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ip_fragsout == CONFIG_BOOLEAN_YES || (do_ip_fragsout == CONFIG_BOOLEAN_AUTO && - (Ip6FragOKs || - Ip6FragFails || - Ip6FragCreates || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_fragsout = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_ok = NULL, - *rd_failed = NULL, - *rd_all = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "fragsout" - , NULL - , "fragments6" - , NULL - , "IPv6 Fragments Sent" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_FRAGSOUT - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_ok = rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_failed = rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_all = rrddim_add(st, "FragCreates", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_ok, Ip6FragOKs); - rrddim_set_by_pointer(st, rd_failed, Ip6FragFails); - rrddim_set_by_pointer(st, rd_all, Ip6FragCreates); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ip_fragsin == CONFIG_BOOLEAN_YES || (do_ip_fragsin == CONFIG_BOOLEAN_AUTO && - (Ip6ReasmOKs || - Ip6ReasmFails || - Ip6ReasmTimeout || - Ip6ReasmReqds || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_fragsin = CONFIG_BOOLEAN_YES; - - static RRDSET *st = NULL; - static RRDDIM *rd_ok = NULL, - *rd_failed = NULL, - *rd_timeout = NULL, - *rd_all = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "fragsin" - , NULL - , "fragments6" - , NULL - , "IPv6 Fragments Reassembly" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_FRAGSIN - , update_every - , RRDSET_TYPE_LINE); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_ok = rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_failed = rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_timeout = rrddim_add(st, "ReasmTimeout", "timeout", -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_all = rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_ok, Ip6ReasmOKs); - rrddim_set_by_pointer(st, rd_failed, Ip6ReasmFails); - rrddim_set_by_pointer(st, rd_timeout, Ip6ReasmTimeout); - rrddim_set_by_pointer(st, rd_all, Ip6ReasmReqds); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ip_errors == CONFIG_BOOLEAN_YES || (do_ip_errors == CONFIG_BOOLEAN_AUTO && - (Ip6InDiscards || - Ip6OutDiscards || - Ip6InHdrErrors || - Ip6InAddrErrors || - Ip6InUnknownProtos || - Ip6InTooBigErrors || - Ip6InTruncatedPkts || - Ip6InNoRoutes || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ip_errors = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InDiscards = NULL, - *rd_OutDiscards = NULL, - *rd_InHdrErrors = NULL, - *rd_InAddrErrors = NULL, - *rd_InUnknownProtos = NULL, - *rd_InTooBigErrors = NULL, - *rd_InTruncatedPkts = NULL, - *rd_InNoRoutes = NULL, - *rd_OutNoRoutes = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "errors" - , NULL - , "errors" - , NULL - , "IPv6 Errors" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ERRORS - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_InDiscards = rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutDiscards = rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InHdrErrors = rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InAddrErrors = rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InUnknownProtos = rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InTooBigErrors = rrddim_add(st, "InTooBigErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InTruncatedPkts = rrddim_add(st, "InTruncatedPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InNoRoutes = rrddim_add(st, "InNoRoutes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutNoRoutes = rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InDiscards, Ip6InDiscards); - rrddim_set_by_pointer(st, rd_OutDiscards, Ip6OutDiscards); - rrddim_set_by_pointer(st, rd_InHdrErrors, Ip6InHdrErrors); - rrddim_set_by_pointer(st, rd_InAddrErrors, Ip6InAddrErrors); - rrddim_set_by_pointer(st, rd_InUnknownProtos, Ip6InUnknownProtos); - rrddim_set_by_pointer(st, rd_InTooBigErrors, Ip6InTooBigErrors); - rrddim_set_by_pointer(st, rd_InTruncatedPkts, Ip6InTruncatedPkts); - rrddim_set_by_pointer(st, rd_InNoRoutes, Ip6InNoRoutes); - rrddim_set_by_pointer(st, rd_OutNoRoutes, Ip6OutNoRoutes); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_udp_packets == CONFIG_BOOLEAN_YES || (do_udp_packets == CONFIG_BOOLEAN_AUTO && - (Udp6InDatagrams || - Udp6OutDatagrams || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_udp_packets = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_received = NULL, - *rd_sent = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "udppackets" - , NULL - , "udp6" - , NULL - , "IPv6 UDP Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_UDP_PACKETS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_received = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_sent = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_received, Udp6InDatagrams); - rrddim_set_by_pointer(st, rd_sent, Udp6OutDatagrams); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_udp_errors == CONFIG_BOOLEAN_YES || (do_udp_errors == CONFIG_BOOLEAN_AUTO && - (Udp6InErrors || - Udp6NoPorts || - Udp6RcvbufErrors || - Udp6SndbufErrors || - Udp6InCsumErrors || - Udp6IgnoredMulti || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_udp_errors = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_RcvbufErrors = NULL, - *rd_SndbufErrors = NULL, - *rd_InErrors = NULL, - *rd_NoPorts = NULL, - *rd_InCsumErrors = NULL, - *rd_IgnoredMulti = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "udperrors" - , NULL - , "udp6" - , NULL - , "IPv6 UDP Errors" - , "events/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_UDP_ERRORS - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_IgnoredMulti = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_RcvbufErrors, Udp6RcvbufErrors); - rrddim_set_by_pointer(st, rd_SndbufErrors, Udp6SndbufErrors); - rrddim_set_by_pointer(st, rd_InErrors, Udp6InErrors); - rrddim_set_by_pointer(st, rd_NoPorts, Udp6NoPorts); - rrddim_set_by_pointer(st, rd_InCsumErrors, Udp6InCsumErrors); - rrddim_set_by_pointer(st, rd_IgnoredMulti, Udp6IgnoredMulti); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_udplite_packets == CONFIG_BOOLEAN_YES || (do_udplite_packets == CONFIG_BOOLEAN_AUTO && - (UdpLite6InDatagrams || - UdpLite6OutDatagrams || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_udplite_packets = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_received = NULL, - *rd_sent = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "udplitepackets" - , NULL - , "udplite6" - , NULL - , "IPv6 UDPlite Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_UDPLITE_PACKETS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_received = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_sent = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_received, UdpLite6InDatagrams); - rrddim_set_by_pointer(st, rd_sent, UdpLite6OutDatagrams); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_udplite_errors == CONFIG_BOOLEAN_YES || (do_udplite_errors == CONFIG_BOOLEAN_AUTO && - (UdpLite6InErrors || - UdpLite6NoPorts || - UdpLite6RcvbufErrors || - UdpLite6SndbufErrors || - Udp6InCsumErrors || - UdpLite6InCsumErrors || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_udplite_errors = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_RcvbufErrors = NULL, - *rd_SndbufErrors = NULL, - *rd_InErrors = NULL, - *rd_NoPorts = NULL, - *rd_InCsumErrors = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "udpliteerrors" - , NULL - , "udplite6" - , NULL - , "IPv6 UDP Lite Errors" - , "events/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_UDPLITE_ERRORS - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_RcvbufErrors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_SndbufErrors = rrddim_add(st, "SndbufErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_NoPorts = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InErrors, UdpLite6InErrors); - rrddim_set_by_pointer(st, rd_NoPorts, UdpLite6NoPorts); - rrddim_set_by_pointer(st, rd_RcvbufErrors, UdpLite6RcvbufErrors); - rrddim_set_by_pointer(st, rd_SndbufErrors, UdpLite6SndbufErrors); - rrddim_set_by_pointer(st, rd_InCsumErrors, UdpLite6InCsumErrors); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_mcast == CONFIG_BOOLEAN_YES || (do_mcast == CONFIG_BOOLEAN_AUTO && - (Ip6OutMcastOctets || - Ip6InMcastOctets || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_mcast = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_Ip6InMcastOctets = NULL, - *rd_Ip6OutMcastOctets = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "mcast" - , NULL - , "multicast6" - , NULL - , "IPv6 Multicast Bandwidth" - , "kilobits/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_MCAST - , update_every - , RRDSET_TYPE_AREA - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_Ip6InMcastOctets = rrddim_add(st, "InMcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - rd_Ip6OutMcastOctets = rrddim_add(st, "OutMcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_Ip6InMcastOctets, Ip6InMcastOctets); - rrddim_set_by_pointer(st, rd_Ip6OutMcastOctets, Ip6OutMcastOctets); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_bcast == CONFIG_BOOLEAN_YES || (do_bcast == CONFIG_BOOLEAN_AUTO && - (Ip6OutBcastOctets || - Ip6InBcastOctets || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_bcast = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_Ip6InBcastOctets = NULL, - *rd_Ip6OutBcastOctets = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "bcast" - , NULL - , "broadcast6" - , NULL - , "IPv6 Broadcast Bandwidth" - , "kilobits/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_BCAST - , update_every - , RRDSET_TYPE_AREA - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_Ip6InBcastOctets = rrddim_add(st, "InBcastOctets", "received", 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - rd_Ip6OutBcastOctets = rrddim_add(st, "OutBcastOctets", "sent", -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_Ip6InBcastOctets, Ip6InBcastOctets); - rrddim_set_by_pointer(st, rd_Ip6OutBcastOctets, Ip6OutBcastOctets); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_mcast_p == CONFIG_BOOLEAN_YES || (do_mcast_p == CONFIG_BOOLEAN_AUTO && - (Ip6OutMcastPkts || - Ip6InMcastPkts || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_mcast_p = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_Ip6InMcastPkts = NULL, - *rd_Ip6OutMcastPkts = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "mcastpkts" - , NULL - , "multicast6" - , NULL - , "IPv6 Multicast Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_MCAST_PACKETS - , update_every - , RRDSET_TYPE_LINE - ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rd_Ip6InMcastPkts = rrddim_add(st, "InMcastPkts", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_Ip6OutMcastPkts = rrddim_add(st, "OutMcastPkts", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_Ip6InMcastPkts, Ip6InMcastPkts); - rrddim_set_by_pointer(st, rd_Ip6OutMcastPkts, Ip6OutMcastPkts); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp == CONFIG_BOOLEAN_YES || (do_icmp == CONFIG_BOOLEAN_AUTO && - (Icmp6InMsgs || - Icmp6OutMsgs || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_Icmp6InMsgs = NULL, - *rd_Icmp6OutMsgs = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmp" - , NULL - , "icmp6" - , NULL - , "IPv6 ICMP Messages" - , "messages/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP - , update_every - , RRDSET_TYPE_LINE - ); - - rd_Icmp6InMsgs = rrddim_add(st, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_Icmp6OutMsgs = rrddim_add(st, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_Icmp6InMsgs, Icmp6InMsgs); - rrddim_set_by_pointer(st, rd_Icmp6OutMsgs, Icmp6OutMsgs); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_redir == CONFIG_BOOLEAN_YES || (do_icmp_redir == CONFIG_BOOLEAN_AUTO && - (Icmp6InRedirects || - Icmp6OutRedirects || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_redir = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_Icmp6InRedirects = NULL, - *rd_Icmp6OutRedirects = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmpredir" - , NULL - , "icmp6" - , NULL - , "IPv6 ICMP Redirects" - , "redirects/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_REDIR - , update_every - , RRDSET_TYPE_LINE - ); - - rd_Icmp6InRedirects = rrddim_add(st, "InRedirects", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_Icmp6OutRedirects = rrddim_add(st, "OutRedirects", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_Icmp6InRedirects, Icmp6InRedirects); - rrddim_set_by_pointer(st, rd_Icmp6OutRedirects, Icmp6OutRedirects); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_errors == CONFIG_BOOLEAN_YES || (do_icmp_errors == CONFIG_BOOLEAN_AUTO && - (Icmp6InErrors || - Icmp6OutErrors || - Icmp6InCsumErrors || - Icmp6InDestUnreachs || - Icmp6InPktTooBigs || - Icmp6InTimeExcds || - Icmp6InParmProblems || - Icmp6OutDestUnreachs || - Icmp6OutPktTooBigs || - Icmp6OutTimeExcds || - Icmp6OutParmProblems || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_errors = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InErrors = NULL, - *rd_OutErrors = NULL, - *rd_InCsumErrors = NULL, - *rd_InDestUnreachs = NULL, - *rd_InPktTooBigs = NULL, - *rd_InTimeExcds = NULL, - *rd_InParmProblems = NULL, - *rd_OutDestUnreachs = NULL, - *rd_OutPktTooBigs = NULL, - *rd_OutTimeExcds = NULL, - *rd_OutParmProblems = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmperrors" - , NULL - , "icmp6" - , NULL - , "IPv6 ICMP Errors" - , "errors/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_ERRORS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InErrors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutErrors = rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCsumErrors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InDestUnreachs = rrddim_add(st, "InDestUnreachs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InPktTooBigs = rrddim_add(st, "InPktTooBigs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InTimeExcds = rrddim_add(st, "InTimeExcds", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InParmProblems = rrddim_add(st, "InParmProblems", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutDestUnreachs = rrddim_add(st, "OutDestUnreachs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutPktTooBigs = rrddim_add(st, "OutPktTooBigs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutTimeExcds = rrddim_add(st, "OutTimeExcds", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutParmProblems = rrddim_add(st, "OutParmProblems", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InErrors, Icmp6InErrors); - rrddim_set_by_pointer(st, rd_OutErrors, Icmp6OutErrors); - rrddim_set_by_pointer(st, rd_InCsumErrors, Icmp6InCsumErrors); - rrddim_set_by_pointer(st, rd_InDestUnreachs, Icmp6InDestUnreachs); - rrddim_set_by_pointer(st, rd_InPktTooBigs, Icmp6InPktTooBigs); - rrddim_set_by_pointer(st, rd_InTimeExcds, Icmp6InTimeExcds); - rrddim_set_by_pointer(st, rd_InParmProblems, Icmp6InParmProblems); - rrddim_set_by_pointer(st, rd_OutDestUnreachs, Icmp6OutDestUnreachs); - rrddim_set_by_pointer(st, rd_OutPktTooBigs, Icmp6OutPktTooBigs); - rrddim_set_by_pointer(st, rd_OutTimeExcds, Icmp6OutTimeExcds); - rrddim_set_by_pointer(st, rd_OutParmProblems, Icmp6OutParmProblems); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_echos == CONFIG_BOOLEAN_YES || (do_icmp_echos == CONFIG_BOOLEAN_AUTO && - (Icmp6InEchos || - Icmp6OutEchos || - Icmp6InEchoReplies || - Icmp6OutEchoReplies || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_echos = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InEchos = NULL, - *rd_OutEchos = NULL, - *rd_InEchoReplies = NULL, - *rd_OutEchoReplies = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmpechos" - , NULL - , "icmp6" - , NULL - , "IPv6 ICMP Echo" - , "messages/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_ECHOS - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InEchos = rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutEchos = rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InEchoReplies = rrddim_add(st, "InEchoReplies", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutEchoReplies = rrddim_add(st, "OutEchoReplies", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InEchos, Icmp6InEchos); - rrddim_set_by_pointer(st, rd_OutEchos, Icmp6OutEchos); - rrddim_set_by_pointer(st, rd_InEchoReplies, Icmp6InEchoReplies); - rrddim_set_by_pointer(st, rd_OutEchoReplies, Icmp6OutEchoReplies); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_groupmemb == CONFIG_BOOLEAN_YES || (do_icmp_groupmemb == CONFIG_BOOLEAN_AUTO && - (Icmp6InGroupMembQueries || - Icmp6OutGroupMembQueries || - Icmp6InGroupMembResponses || - Icmp6OutGroupMembResponses || - Icmp6InGroupMembReductions || - Icmp6OutGroupMembReductions || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_groupmemb = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InQueries = NULL, - *rd_OutQueries = NULL, - *rd_InResponses = NULL, - *rd_OutResponses = NULL, - *rd_InReductions = NULL, - *rd_OutReductions = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "groupmemb" - , NULL - , "icmp6" - , NULL - , "IPv6 ICMP Group Membership" - , "messages/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_GROUPMEMB - , update_every - , RRDSET_TYPE_LINE); - - rd_InQueries = rrddim_add(st, "InQueries", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutQueries = rrddim_add(st, "OutQueries", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InResponses = rrddim_add(st, "InResponses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutResponses = rrddim_add(st, "OutResponses", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InReductions = rrddim_add(st, "InReductions", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutReductions = rrddim_add(st, "OutReductions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InQueries, Icmp6InGroupMembQueries); - rrddim_set_by_pointer(st, rd_OutQueries, Icmp6OutGroupMembQueries); - rrddim_set_by_pointer(st, rd_InResponses, Icmp6InGroupMembResponses); - rrddim_set_by_pointer(st, rd_OutResponses, Icmp6OutGroupMembResponses); - rrddim_set_by_pointer(st, rd_InReductions, Icmp6InGroupMembReductions); - rrddim_set_by_pointer(st, rd_OutReductions, Icmp6OutGroupMembReductions); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_router == CONFIG_BOOLEAN_YES || (do_icmp_router == CONFIG_BOOLEAN_AUTO && - (Icmp6InRouterSolicits || - Icmp6OutRouterSolicits || - Icmp6InRouterAdvertisements || - Icmp6OutRouterAdvertisements || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_router = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InSolicits = NULL, - *rd_OutSolicits = NULL, - *rd_InAdvertisements = NULL, - *rd_OutAdvertisements = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmprouter" - , NULL - , "icmp6" - , NULL - , "IPv6 Router Messages" - , "messages/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_ROUTER - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InSolicits = rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutSolicits = rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InAdvertisements = rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutAdvertisements = rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InSolicits, Icmp6InRouterSolicits); - rrddim_set_by_pointer(st, rd_OutSolicits, Icmp6OutRouterSolicits); - rrddim_set_by_pointer(st, rd_InAdvertisements, Icmp6InRouterAdvertisements); - rrddim_set_by_pointer(st, rd_OutAdvertisements, Icmp6OutRouterAdvertisements); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_neighbor == CONFIG_BOOLEAN_YES || (do_icmp_neighbor == CONFIG_BOOLEAN_AUTO && - (Icmp6InNeighborSolicits || - Icmp6OutNeighborSolicits || - Icmp6InNeighborAdvertisements || - Icmp6OutNeighborAdvertisements || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_neighbor = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InSolicits = NULL, - *rd_OutSolicits = NULL, - *rd_InAdvertisements = NULL, - *rd_OutAdvertisements = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmpneighbor" - , NULL - , "icmp6" - , NULL - , "IPv6 Neighbor Messages" - , "messages/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_NEIGHBOR - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InSolicits = rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutSolicits = rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InAdvertisements = rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutAdvertisements = rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InSolicits, Icmp6InNeighborSolicits); - rrddim_set_by_pointer(st, rd_OutSolicits, Icmp6OutNeighborSolicits); - rrddim_set_by_pointer(st, rd_InAdvertisements, Icmp6InNeighborAdvertisements); - rrddim_set_by_pointer(st, rd_OutAdvertisements, Icmp6OutNeighborAdvertisements); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_mldv2 == CONFIG_BOOLEAN_YES || (do_icmp_mldv2 == CONFIG_BOOLEAN_AUTO && - (Icmp6InMLDv2Reports || - Icmp6OutMLDv2Reports || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_mldv2 = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InMLDv2Reports = NULL, - *rd_OutMLDv2Reports = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmpmldv2" - , NULL - , "icmp6" - , NULL - , "IPv6 ICMP MLDv2 Reports" - , "reports/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_LDV2 - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InMLDv2Reports = rrddim_add(st, "InMLDv2Reports", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutMLDv2Reports = rrddim_add(st, "OutMLDv2Reports", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InMLDv2Reports, Icmp6InMLDv2Reports); - rrddim_set_by_pointer(st, rd_OutMLDv2Reports, Icmp6OutMLDv2Reports); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_icmp_types == CONFIG_BOOLEAN_YES || (do_icmp_types == CONFIG_BOOLEAN_AUTO && - (Icmp6InType1 || - Icmp6InType128 || - Icmp6InType129 || - Icmp6InType136 || - Icmp6OutType1 || - Icmp6OutType128 || - Icmp6OutType129 || - Icmp6OutType133 || - Icmp6OutType135 || - Icmp6OutType143 || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_icmp_types = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InType1 = NULL, - *rd_InType128 = NULL, - *rd_InType129 = NULL, - *rd_InType136 = NULL, - *rd_OutType1 = NULL, - *rd_OutType128 = NULL, - *rd_OutType129 = NULL, - *rd_OutType133 = NULL, - *rd_OutType135 = NULL, - *rd_OutType143 = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "icmptypes" - , NULL - , "icmp6" - , NULL - , "IPv6 ICMP Types" - , "messages/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ICMP_TYPES - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InType1 = rrddim_add(st, "InType1", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InType128 = rrddim_add(st, "InType128", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InType129 = rrddim_add(st, "InType129", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InType136 = rrddim_add(st, "InType136", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutType1 = rrddim_add(st, "OutType1", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutType128 = rrddim_add(st, "OutType128", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutType129 = rrddim_add(st, "OutType129", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutType133 = rrddim_add(st, "OutType133", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutType135 = rrddim_add(st, "OutType135", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_OutType143 = rrddim_add(st, "OutType143", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InType1, Icmp6InType1); - rrddim_set_by_pointer(st, rd_InType128, Icmp6InType128); - rrddim_set_by_pointer(st, rd_InType129, Icmp6InType129); - rrddim_set_by_pointer(st, rd_InType136, Icmp6InType136); - rrddim_set_by_pointer(st, rd_OutType1, Icmp6OutType1); - rrddim_set_by_pointer(st, rd_OutType128, Icmp6OutType128); - rrddim_set_by_pointer(st, rd_OutType129, Icmp6OutType129); - rrddim_set_by_pointer(st, rd_OutType133, Icmp6OutType133); - rrddim_set_by_pointer(st, rd_OutType135, Icmp6OutType135); - rrddim_set_by_pointer(st, rd_OutType143, Icmp6OutType143); - rrdset_done(st); - } - - // -------------------------------------------------------------------- - - if(do_ect == CONFIG_BOOLEAN_YES || (do_ect == CONFIG_BOOLEAN_AUTO && - (Ip6InNoECTPkts || - Ip6InECT1Pkts || - Ip6InECT0Pkts || - Ip6InCEPkts || - netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) { - do_ect = CONFIG_BOOLEAN_YES; - static RRDSET *st = NULL; - static RRDDIM *rd_InNoECTPkts = NULL, - *rd_InECT1Pkts = NULL, - *rd_InECT0Pkts = NULL, - *rd_InCEPkts = NULL; - - if(unlikely(!st)) { - st = rrdset_create_localhost( - RRD_TYPE_NET_SNMP6 - , "ect" - , NULL - , "packets" - , NULL - , "IPv6 ECT Packets" - , "packets/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_NET_SNMP6_NAME - , NETDATA_CHART_PRIO_IPV6_ECT - , update_every - , RRDSET_TYPE_LINE - ); - - rd_InNoECTPkts = rrddim_add(st, "InNoECTPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InECT1Pkts = rrddim_add(st, "InECT1Pkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InECT0Pkts = rrddim_add(st, "InECT0Pkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rd_InCEPkts = rrddim_add(st, "InCEPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); - - rrddim_set_by_pointer(st, rd_InNoECTPkts, Ip6InNoECTPkts); - rrddim_set_by_pointer(st, rd_InECT1Pkts, Ip6InECT1Pkts); - rrddim_set_by_pointer(st, rd_InECT0Pkts, Ip6InECT0Pkts); - rrddim_set_by_pointer(st, rd_InCEPkts, Ip6InCEPkts); - rrdset_done(st); - } - - return 0; -} - diff --git a/collectors/proc.plugin/proc_net_sockstat.c b/collectors/proc.plugin/proc_net_sockstat.c index 994cbad7b..e94b891ca 100644 --- a/collectors/proc.plugin/proc_net_sockstat.c +++ b/collectors/proc.plugin/proc_net_sockstat.c @@ -27,14 +27,14 @@ static struct proc_net_sockstat { static int read_tcp_mem(void) { static char *filename = NULL; - static RRDVAR *tcp_mem_low_threshold = NULL, + static const RRDVAR_ACQUIRED *tcp_mem_low_threshold = NULL, *tcp_mem_pressure_threshold = NULL, *tcp_mem_high_threshold = NULL; if(unlikely(!tcp_mem_low_threshold)) { - tcp_mem_low_threshold = rrdvar_custom_host_variable_create(localhost, "tcp_mem_low"); - tcp_mem_pressure_threshold = rrdvar_custom_host_variable_create(localhost, "tcp_mem_pressure"); - tcp_mem_high_threshold = rrdvar_custom_host_variable_create(localhost, "tcp_mem_high"); + tcp_mem_low_threshold = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_mem_low"); + tcp_mem_pressure_threshold = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_mem_pressure"); + tcp_mem_high_threshold = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_mem_high"); } if(unlikely(!filename)) { @@ -69,7 +69,7 @@ static int read_tcp_mem(void) { static kernel_uint_t read_tcp_max_orphans(void) { static char *filename = NULL; - static RRDVAR *tcp_max_orphans_var = NULL; + static const RRDVAR_ACQUIRED *tcp_max_orphans_var = NULL; if(unlikely(!filename)) { char buffer[FILENAME_MAX + 1]; @@ -81,7 +81,7 @@ static kernel_uint_t read_tcp_max_orphans(void) { if(read_single_number_file(filename, &tcp_max_orphans) == 0) { if(unlikely(!tcp_max_orphans_var)) - tcp_max_orphans_var = rrdvar_custom_host_variable_create(localhost, "tcp_max_orphans"); + tcp_max_orphans_var = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_max_orphans"); rrdvar_custom_host_variable_set(localhost, tcp_max_orphans_var, tcp_max_orphans); return tcp_max_orphans; @@ -244,7 +244,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_used = rrddim_add(st, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_used, (collected_number)sockstat_root.sockets_used); rrdset_done(st); @@ -287,7 +286,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rd_timewait = rrddim_add(st, "timewait", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.tcp_inuse); rrddim_set_by_pointer(st, rd_orphan, (collected_number)sockstat_root.tcp_orphan); @@ -323,7 +321,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_mem = rrddim_add(st, "mem", NULL, sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_mem, (collected_number)sockstat_root.tcp_mem); rrdset_done(st); @@ -357,7 +354,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.udp_inuse); rrdset_done(st); @@ -391,7 +387,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_mem = rrddim_add(st, "mem", NULL, sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_mem, (collected_number)sockstat_root.udp_mem); rrdset_done(st); @@ -425,7 +420,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.udplite_inuse); rrdset_done(st); @@ -459,7 +453,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.raw_inuse); rrdset_done(st); @@ -493,7 +486,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.frag_inuse); rrdset_done(st); @@ -527,7 +519,6 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { rd_mem = rrddim_add(st, "mem", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_mem, (collected_number)sockstat_root.frag_memory); rrdset_done(st); diff --git a/collectors/proc.plugin/proc_net_sockstat6.c b/collectors/proc.plugin/proc_net_sockstat6.c index ce8c9e093..065cf6055 100644 --- a/collectors/proc.plugin/proc_net_sockstat6.c +++ b/collectors/proc.plugin/proc_net_sockstat6.c @@ -137,7 +137,6 @@ int do_proc_net_sockstat6(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat6_root.tcp6_inuse); rrdset_done(st); @@ -171,7 +170,6 @@ int do_proc_net_sockstat6(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat6_root.udp6_inuse); rrdset_done(st); @@ -205,7 +203,6 @@ int do_proc_net_sockstat6(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat6_root.udplite6_inuse); rrdset_done(st); @@ -239,7 +236,6 @@ int do_proc_net_sockstat6(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat6_root.raw6_inuse); rrdset_done(st); @@ -273,7 +269,6 @@ int do_proc_net_sockstat6(int update_every, usec_t dt) { rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat6_root.frag6_inuse); rrdset_done(st); diff --git a/collectors/proc.plugin/proc_net_softnet_stat.c b/collectors/proc.plugin/proc_net_softnet_stat.c index 1f704a427..65239246a 100644 --- a/collectors/proc.plugin/proc_net_softnet_stat.c +++ b/collectors/proc.plugin/proc_net_softnet_stat.c @@ -101,7 +101,6 @@ int do_proc_net_softnet_stat(int update_every, usec_t dt) { if(unlikely(softnet_column_name(w))) rrddim_add(st, softnet_column_name(w), NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); for(w = 0; w < allocated_columns ;w++) if(unlikely(softnet_column_name(w))) @@ -137,7 +136,6 @@ int do_proc_net_softnet_stat(int update_every, usec_t dt) { if(unlikely(softnet_column_name(w))) rrddim_add(st, softnet_column_name(w), NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); for(w = 0; w < allocated_columns ;w++) if(unlikely(softnet_column_name(w))) diff --git a/collectors/proc.plugin/proc_net_stat_conntrack.c b/collectors/proc.plugin/proc_net_stat_conntrack.c index 642e33f8e..f9dbdf47c 100644 --- a/collectors/proc.plugin/proc_net_stat_conntrack.c +++ b/collectors/proc.plugin/proc_net_stat_conntrack.c @@ -12,7 +12,7 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { static usec_t get_max_every = 10 * USEC_PER_SEC, usec_since_last_max = 0; static int read_full = 1; static char *nf_conntrack_filename, *nf_conntrack_count_filename, *nf_conntrack_max_filename; - static RRDVAR *rrdvar_max = NULL; + static const RRDVAR_ACQUIRED *rrdvar_max = NULL; unsigned long long aentries = 0, asearched = 0, afound = 0, anew = 0, ainvalid = 0, aignore = 0, adelete = 0, adelete_list = 0, ainsert = 0, ainsert_failed = 0, adrop = 0, aearly_drop = 0, aicmp_error = 0, aexpect_new = 0, aexpect_create = 0, aexpect_delete = 0, asearch_restart = 0; @@ -50,7 +50,7 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { if(!do_sockets && !read_full) return 1; - rrdvar_max = rrdvar_custom_host_variable_create(localhost, "netfilter_conntrack_max"); + rrdvar_max = rrdvar_custom_host_variable_add_and_acquire(localhost, "netfilter_conntrack_max"); } if(likely(read_full)) { @@ -152,7 +152,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { rd_connections = rrddim_add(st, "connections", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_connections, aentries); rrdset_done(st); @@ -187,7 +186,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { rd_ignore = rrddim_add(st, "ignore", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_invalid = rrddim_add(st, "invalid", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_new, anew); rrddim_set_by_pointer(st, rd_ignore, aignore); @@ -225,7 +223,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { rd_deleted = rrddim_add(st, "deleted", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_delete_list = rrddim_add(st, "delete_list", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_inserted, ainsert); rrddim_set_by_pointer(st, rd_deleted, adelete); @@ -262,7 +259,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { rd_deleted = rrddim_add(st, "deleted", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_new = rrddim_add(st, "new", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_created, aexpect_create); rrddim_set_by_pointer(st, rd_deleted, aexpect_delete); @@ -299,7 +295,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { rd_restarted = rrddim_add(st, "restarted", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_found = rrddim_add(st, "found", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_searched, asearched); rrddim_set_by_pointer(st, rd_restarted, asearch_restart); @@ -338,7 +333,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { rd_drop = rrddim_add(st, "drop", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rd_early_drop = rrddim_add(st, "early_drop", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd_icmp_error, aicmp_error); rrddim_set_by_pointer(st, rd_insert_failed, ainsert_failed); diff --git a/collectors/proc.plugin/proc_net_stat_synproxy.c b/collectors/proc.plugin/proc_net_stat_synproxy.c index c74c5374d..0a74b3575 100644 --- a/collectors/proc.plugin/proc_net_stat_synproxy.c +++ b/collectors/proc.plugin/proc_net_stat_synproxy.c @@ -80,7 +80,6 @@ int do_proc_net_stat_synproxy(int update_every, usec_t dt) { rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "received", syn_received); rrdset_done(st); @@ -111,7 +110,6 @@ int do_proc_net_stat_synproxy(int update_every, usec_t dt) { rrddim_add(st, "reopened", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "reopened", conn_reopened); rrdset_done(st); @@ -144,7 +142,6 @@ int do_proc_net_stat_synproxy(int update_every, usec_t dt) { rrddim_add(st, "invalid", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); rrddim_add(st, "retransmits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st); rrddim_set(st, "valid", cookie_valid); rrddim_set(st, "invalid", cookie_invalid); diff --git a/collectors/proc.plugin/proc_net_wireless.c b/collectors/proc.plugin/proc_net_wireless.c index c6ee4ff70..08ab2eada 100644 --- a/collectors/proc.plugin/proc_net_wireless.c +++ b/collectors/proc.plugin/proc_net_wireless.c @@ -199,7 +199,7 @@ static void configure_device(int do_status, int do_quality, int do_discarded_pac } static void add_labels_to_wireless(struct netwireless *w, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", w->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", w->name, RRDLABEL_SRC_AUTO); } int do_proc_net_wireless(int update_every, usec_t dt) @@ -269,8 +269,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) add_labels_to_wireless(wireless_dev, wireless_dev->st_status); } - else - rrdset_next(wireless_dev->st_status); rrddim_set_by_pointer(wireless_dev->st_status, wireless_dev->rd_status, (collected_number)wireless_dev->status); @@ -302,8 +300,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) add_labels_to_wireless(wireless_dev, wireless_dev->st_link); } - else - rrdset_next(wireless_dev->st_link); if (unlikely(!wireless_dev->st_level)) { wireless_dev->st_level = rrdset_create_localhost( @@ -325,8 +321,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) add_labels_to_wireless(wireless_dev, wireless_dev->st_level); } - else - rrdset_next(wireless_dev->st_level); if (unlikely(!wireless_dev->st_noise)) { wireless_dev->st_noise = rrdset_create_localhost( @@ -348,8 +342,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) add_labels_to_wireless(wireless_dev, wireless_dev->st_noise); } - else - rrdset_next(wireless_dev->st_noise); rrddim_set_by_pointer(wireless_dev->st_link, wireless_dev->rd_link, (collected_number)wireless_dev->link); rrdset_done(wireless_dev->st_link); @@ -393,8 +385,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) add_labels_to_wireless(wireless_dev, wireless_dev->st_discarded_packets); } - else - rrdset_next(wireless_dev->st_discarded_packets); rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_nwid, (collected_number)wireless_dev->nwid); rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_crypt, (collected_number)wireless_dev->crypt); @@ -429,11 +419,8 @@ int do_proc_net_wireless(int update_every, usec_t dt) add_labels_to_wireless(wireless_dev, wireless_dev->st_missed_beacon); } - else - rrdset_next(wireless_dev->st_missed_beacon); rrddim_set_by_pointer(wireless_dev->st_missed_beacon, wireless_dev->rd_missed_beacon, (collected_number)wireless_dev->missed_beacon); - rrdset_done(wireless_dev->st_missed_beacon); } diff --git a/collectors/proc.plugin/proc_pagetypeinfo.c b/collectors/proc.plugin/proc_pagetypeinfo.c index 017edc49a..dc006aa59 100644 --- a/collectors/proc.plugin/proc_pagetypeinfo.c +++ b/collectors/proc.plugin/proc_pagetypeinfo.c @@ -79,7 +79,7 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { static RRDSET **st_nodezonetype = NULL; // Local temp variables - size_t l, o, p; + long unsigned int l, o, p; struct pageline *pgl = NULL; // -------------------------------------------------------------------- @@ -149,7 +149,8 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { pageorders_cnt -= 9; if (pageorders_cnt > MAX_PAGETYPE_ORDER) { - error("PLUGIN: PROC_PAGETYPEINFO: pageorder found (%lu) is higher than max %d", pageorders_cnt, MAX_PAGETYPE_ORDER); + error("PLUGIN: PROC_PAGETYPEINFO: pageorder found (%lu) is higher than max %d", + (long unsigned int) pageorders_cnt, MAX_PAGETYPE_ORDER); return 1; } @@ -157,7 +158,8 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { if (!pagelines) { pagelines = callocz(pagelines_cnt, sizeof(struct pageline)); if (!pagelines) { - error("PLUGIN: PROC_PAGETYPEINFO: Cannot allocate %lu pagelines of %lu B", pagelines_cnt, sizeof(struct pageline)); + error("PLUGIN: PROC_PAGETYPEINFO: Cannot allocate %lu pagelines of %lu B", + (long unsigned int) pagelines_cnt, (long unsigned int) sizeof(struct pageline)); return 1; } } @@ -261,9 +263,9 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { char node[50+1]; snprintfz(node, 50, "node%d", pgl->node); - rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_id", node, RRDLABEL_SRC_AUTO); - rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_zone", pgl->zone, RRDLABEL_SRC_AUTO); - rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_type", pgl->type, RRDLABEL_SRC_AUTO); + rrdlabels_add(st_nodezonetype[p]->rrdlabels, "node_id", node, RRDLABEL_SRC_AUTO); + rrdlabels_add(st_nodezonetype[p]->rrdlabels, "node_zone", pgl->zone, RRDLABEL_SRC_AUTO); + rrdlabels_add(st_nodezonetype[p]->rrdlabels, "node_type", pgl->type, RRDLABEL_SRC_AUTO); for (o = 0; o < pageorders_cnt; o++) { char dimid[3+1]; @@ -289,7 +291,8 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { size_t words = procfile_linewords(ff, l); if (words != 7+pageorders_cnt) { - error("PLUGIN: PROC_PAGETYPEINFO: Unable to read line %lu, %lu words found instead of %lu", l+1, words, 7+pageorders_cnt); + error("PLUGIN: PROC_PAGETYPEINFO: Unable to read line %lu, %lu words found instead of %lu", + l+1, (long unsigned int) words, (long unsigned int) 7+pageorders_cnt); break; } @@ -313,10 +316,8 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { // Global system per order if (st_order) { - rrdset_next(st_order); - for (o = 0; o < pageorders_cnt; o++) { + for (o = 0; o < pageorders_cnt; o++) rrddim_set_by_pointer(st_order, systemorders[o].rd, systemorders[o].size); - } rrdset_done(st_order); } @@ -327,10 +328,8 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { if (!st_nodezonetype[p]) continue; - rrdset_next(st_nodezonetype[p]); for (o = 0; o < pageorders_cnt; o++) rrddim_set_by_pointer(st_nodezonetype[p], pagelines[p].rd[o], pagelines[p].free_pages_size[o]); - rrdset_done(st_nodezonetype[p]); } } diff --git a/collectors/proc.plugin/proc_pressure.c b/collectors/proc.plugin/proc_pressure.c index 66884dbcb..6649aa630 100644 --- a/collectors/proc.plugin/proc_pressure.c +++ b/collectors/proc.plugin/proc_pressure.c @@ -91,9 +91,8 @@ static void proc_pressure_do_resource(procfile *ff, int res_idx, int some) { rrddim_add(pcs->share_time.st, some ? "some 60" : "full 60", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE); pcs->share_time.rd300 = rrddim_add(pcs->share_time.st, some ? "some 300" : "full 300", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE); - } else { - rrdset_next(pcs->share_time.st); } + pcs->share_time.value10 = strtod(procfile_lineword(ff, some ? 0 : 1, 2), NULL); pcs->share_time.value60 = strtod(procfile_lineword(ff, some ? 0 : 1, 4), NULL); pcs->share_time.value300 = strtod(procfile_lineword(ff, some ? 0 : 1, 6), NULL); @@ -113,9 +112,8 @@ static void proc_pressure_do_resource(procfile *ff, int res_idx, int some) { pressure_update_every, RRDSET_TYPE_LINE); pcs->total_time.rdtotal = rrddim_add(pcs->total_time.st, "time", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - } else { - rrdset_next(pcs->total_time.st); } + pcs->total_time.value_total = str2ull(procfile_lineword(ff, some ? 0 : 1, 8)) / 1000; } diff --git a/collectors/proc.plugin/proc_pressure.h b/collectors/proc.plugin/proc_pressure.h index a421cf8a4..0cb233152 100644 --- a/collectors/proc.plugin/proc_pressure.h +++ b/collectors/proc.plugin/proc_pressure.h @@ -38,6 +38,6 @@ struct pressure { } some, full; }; -extern void update_pressure_charts(struct pressure_charts *charts); +void update_pressure_charts(struct pressure_charts *charts); #endif //NETDATA_PROC_PRESSURE_H diff --git a/collectors/proc.plugin/proc_self_mountinfo.c b/collectors/proc.plugin/proc_self_mountinfo.c index 4456d5978..9310f2ffc 100644 --- a/collectors/proc.plugin/proc_self_mountinfo.c +++ b/collectors/proc.plugin/proc_self_mountinfo.c @@ -227,7 +227,8 @@ struct mountinfo *mountinfo_read(int do_statvfs) { struct mountinfo *root = NULL, *last = NULL, *mi = NULL; // create a dictionary to track uniqueness - DICTIONARY *dict = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED|DICTIONARY_FLAG_DONT_OVERWRITE_VALUE|DICTIONARY_FLAG_NAME_LINK_DONT_CLONE); + DICTIONARY *dict = dictionary_create( + DICT_OPTION_SINGLE_THREADED | DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_NAME_LINK_DONT_CLONE); unsigned long l, lines = procfile_lines(ff); for(l = 0; l < lines ;l++) { diff --git a/collectors/proc.plugin/proc_self_mountinfo.h b/collectors/proc.plugin/proc_self_mountinfo.h index b915550a7..4bd24d2d2 100644 --- a/collectors/proc.plugin/proc_self_mountinfo.h +++ b/collectors/proc.plugin/proc_self_mountinfo.h @@ -51,11 +51,11 @@ struct mountinfo { struct mountinfo *next; }; -extern struct mountinfo *mountinfo_find(struct mountinfo *root, unsigned long major, unsigned long minor, char *device); -extern struct mountinfo *mountinfo_find_by_filesystem_mount_source(struct mountinfo *root, const char *filesystem, const char *mount_source); -extern struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *root, const char *filesystem, const char *super_options); +struct mountinfo *mountinfo_find(struct mountinfo *root, unsigned long major, unsigned long minor, char *device); +struct mountinfo *mountinfo_find_by_filesystem_mount_source(struct mountinfo *root, const char *filesystem, const char *mount_source); +struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *root, const char *filesystem, const char *super_options); -extern void mountinfo_free_all(struct mountinfo *mi); -extern struct mountinfo *mountinfo_read(int do_statvfs); +void mountinfo_free_all(struct mountinfo *mi); +struct mountinfo *mountinfo_read(int do_statvfs); #endif /* NETDATA_PROC_SELF_MOUNTINFO_H */ diff --git a/collectors/proc.plugin/proc_softirqs.c b/collectors/proc.plugin/proc_softirqs.c index 7eff28c98..4c4df7668 100644 --- a/collectors/proc.plugin/proc_softirqs.c +++ b/collectors/proc.plugin/proc_softirqs.c @@ -128,7 +128,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { // -------------------------------------------------------------------- static RRDSET *st_system_softirqs = NULL; - if(unlikely(!st_system_softirqs)) + if(unlikely(!st_system_softirqs)) { st_system_softirqs = rrdset_create_localhost( "system" , "softirqs" @@ -143,8 +143,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_STACKED ); - else - rrdset_next(st_system_softirqs); + } for(l = 0; l < lines ;l++) { struct interrupt *irr = irrindex(irrs, l, cpus); @@ -153,9 +152,9 @@ int do_proc_softirqs(int update_every, usec_t dt) { // some interrupt may have changed without changing the total number of lines // if the same number of interrupts have been added and removed between two // calls of this function. - if(unlikely(!irr->rd || strncmp(irr->name, irr->rd->name, MAX_INTERRUPT_NAME) != 0)) { + if(unlikely(!irr->rd || strncmp(irr->name, rrddim_name(irr->rd), MAX_INTERRUPT_NAME) != 0)) { irr->rd = rrddim_add(st_system_softirqs, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_set_name(st_system_softirqs, irr->rd, irr->name); + rrddim_reset_name(st_system_softirqs, irr->rd, irr->name); // also reset per cpu RRDDIMs to avoid repeating strncmp() in the per core loop if(likely(do_per_core != CONFIG_BOOLEAN_NO)) { @@ -220,10 +219,8 @@ int do_proc_softirqs(int update_every, usec_t dt) { char core[50+1]; snprintfz(core, 50, "cpu%d", c); - rrdlabels_add(core_st[c]->state->chart_labels, "cpu", core, RRDLABEL_SRC_AUTO); + rrdlabels_add(core_st[c]->rrdlabels, "cpu", core, RRDLABEL_SRC_AUTO); } - else - rrdset_next(core_st[c]); for(l = 0; l < lines ;l++) { struct interrupt *irr = irrindex(irrs, l, cpus); @@ -231,7 +228,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { if(irr->used && (do_per_core == CONFIG_BOOLEAN_YES || irr->cpu[c].value)) { if(unlikely(!irr->cpu[c].rd)) { irr->cpu[c].rd = rrddim_add(core_st[c], irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_set_name(core_st[c], irr->cpu[c].rd, irr->name); + rrddim_reset_name(core_st[c], irr->cpu[c].rd, irr->name); } rrddim_set_by_pointer(core_st[c], irr->cpu[c].rd, irr->cpu[c].value); diff --git a/collectors/proc.plugin/proc_spl_kstat_zfs.c b/collectors/proc.plugin/proc_spl_kstat_zfs.c index fae112249..8938d6431 100644 --- a/collectors/proc.plugin/proc_spl_kstat_zfs.c +++ b/collectors/proc.plugin/proc_spl_kstat_zfs.c @@ -252,8 +252,8 @@ void disable_zfs_pool_state(struct zfs_pool *pool) pool->disabled = 1; } -int update_zfs_pool_state_chart(const char *name, void *pool_p, void *update_every_p) -{ +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; @@ -285,8 +285,7 @@ int update_zfs_pool_state_chart(const char *name, void *pool_p, void *update_eve 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); - } else - rrdset_next(pool->st); + } rrddim_set_by_pointer(pool->st, pool->rd_online, pool->online); rrddim_set_by_pointer(pool->st, pool->rd_degraded, pool->degraded); @@ -321,7 +320,7 @@ int do_proc_spl_kstat_zfs_pool_state(int update_every, usec_t dt) 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(DICTIONARY_FLAG_SINGLE_THREADED); + zfs_pools = dictionary_create(DICT_OPTION_SINGLE_THREADED); do_zfs_pool_state = 1; } diff --git a/collectors/proc.plugin/proc_stat.c b/collectors/proc.plugin/proc_stat.c index 6faba55a9..33fe93234 100644 --- a/collectors/proc.plugin/proc_stat.c +++ b/collectors/proc.plugin/proc_stat.c @@ -481,7 +481,7 @@ int do_proc_stat(int update_every, usec_t dt) { static uint32_t hash_intr, hash_ctxt, hash_processes, hash_procs_running, hash_procs_blocked; static char *core_throttle_count_filename = NULL, *package_throttle_count_filename = NULL, *scaling_cur_freq_filename = NULL, *time_in_state_filename = NULL, *schedstat_filename = NULL, *cpuidle_name_filename = NULL, *cpuidle_time_filename = NULL; - static RRDVAR *cpus_var = NULL; + static const RRDVAR_ACQUIRED *cpus_var = NULL; static int accurate_freq_avail = 0, accurate_freq_is_used = 0; size_t cores_found = (size_t)processors; @@ -713,9 +713,8 @@ int do_proc_stat(int update_every, usec_t dt) { rrddim_hide(cpu_chart->st, "idle"); if(unlikely(core == 0 && cpus_var == NULL)) - cpus_var = rrdvar_custom_host_variable_create(localhost, "active_processors"); + cpus_var = rrdvar_custom_host_variable_add_and_acquire(localhost, "active_processors"); } - else rrdset_next(cpu_chart->st); rrddim_set_by_pointer(cpu_chart->st, cpu_chart->rd_user, user); rrddim_set_by_pointer(cpu_chart->st, cpu_chart->rd_nice, nice); @@ -756,7 +755,6 @@ int do_proc_stat(int update_every, usec_t dt) { rd_interrupts = rrddim_add(st_intr, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_intr); rrddim_set_by_pointer(st_intr, rd_interrupts, value); rrdset_done(st_intr); @@ -786,7 +784,6 @@ int do_proc_stat(int update_every, usec_t dt) { rd_switches = rrddim_add(st_ctxt, "switches", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_ctxt); rrddim_set_by_pointer(st_ctxt, rd_switches, value); rrdset_done(st_ctxt); @@ -828,7 +825,6 @@ int do_proc_stat(int update_every, usec_t dt) { rd_started = rrddim_add(st_forks, "started", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_forks); rrddim_set_by_pointer(st_forks, rd_started, processes); rrdset_done(st_forks); @@ -860,7 +856,6 @@ int do_proc_stat(int update_every, usec_t dt) { rd_running = rrddim_add(st_processes, "running", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rd_blocked = rrddim_add(st_processes, "blocked", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st_processes); rrddim_set_by_pointer(st_processes, rd_running, running); rrddim_set_by_pointer(st_processes, rd_blocked, blocked); @@ -875,7 +870,7 @@ int do_proc_stat(int update_every, usec_t dt) { static RRDSET *st_core_throttle_count = NULL; - if (unlikely(!st_core_throttle_count)) + if (unlikely(!st_core_throttle_count)) { st_core_throttle_count = rrdset_create_localhost( "cpu" , "core_throttling" @@ -890,8 +885,7 @@ int do_proc_stat(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - else - rrdset_next(st_core_throttle_count); + } chart_per_core_files(&all_cpu_charts[1], all_cpu_charts_size - 1, CORE_THROTTLE_COUNT_INDEX, st_core_throttle_count, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrdset_done(st_core_throttle_count); @@ -905,7 +899,7 @@ int do_proc_stat(int update_every, usec_t dt) { static RRDSET *st_package_throttle_count = NULL; - if(unlikely(!st_package_throttle_count)) + if(unlikely(!st_package_throttle_count)) { st_package_throttle_count = rrdset_create_localhost( "cpu" , "package_throttling" @@ -920,8 +914,7 @@ int do_proc_stat(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - else - rrdset_next(st_package_throttle_count); + } chart_per_core_files(&all_cpu_charts[1], all_cpu_charts_size - 1, PACKAGE_THROTTLE_COUNT_INDEX, st_package_throttle_count, 1, 1, RRD_ALGORITHM_INCREMENTAL); rrdset_done(st_package_throttle_count); @@ -954,7 +947,7 @@ int do_proc_stat(int update_every, usec_t dt) { static RRDSET *st_scaling_cur_freq = NULL; - if(unlikely(!st_scaling_cur_freq)) + if(unlikely(!st_scaling_cur_freq)) { st_scaling_cur_freq = rrdset_create_localhost( "cpu" , "cpufreq" @@ -969,8 +962,7 @@ int do_proc_stat(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - else - rrdset_next(st_scaling_cur_freq); + } chart_per_core_files(&all_cpu_charts[1], all_cpu_charts_size - 1, CPU_FREQ_INDEX, st_scaling_cur_freq, 1, 1000, RRD_ALGORITHM_ABSOLUTE); rrdset_done(st_scaling_cur_freq); @@ -1041,7 +1033,7 @@ int do_proc_stat(int update_every, usec_t dt) { char corebuf[50+1]; snprintfz(corebuf, 50, "cpu%zu", core); - rrdlabels_add(cpuidle_charts[core].st->state->chart_labels, "cpu", corebuf, RRDLABEL_SRC_AUTO); + rrdlabels_add(cpuidle_charts[core].st->rrdlabels, "cpu", corebuf, RRDLABEL_SRC_AUTO); char cpuidle_dim_id[RRD_ID_LENGTH_MAX + 1]; cpuidle_charts[core].active_time_rd = rrddim_add(cpuidle_charts[core].st, "active", "C0 (active)", 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); @@ -1054,8 +1046,6 @@ int do_proc_stat(int update_every, usec_t dt) { 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } } - else - rrdset_next(cpuidle_charts[core].st); rrddim_set_by_pointer(cpuidle_charts[core].st, cpuidle_charts[core].active_time_rd, cpuidle_charts[core].active_time); for(state = 0; state < cpuidle_charts[core].cpuidle_state_len; state++) { diff --git a/collectors/proc.plugin/proc_sys_kernel_random_entropy_avail.c b/collectors/proc.plugin/proc_sys_kernel_random_entropy_avail.c index 20d2116ce..a04d43039 100644 --- a/collectors/proc.plugin/proc_sys_kernel_random_entropy_avail.c +++ b/collectors/proc.plugin/proc_sys_kernel_random_entropy_avail.c @@ -40,10 +40,8 @@ int do_proc_sys_kernel_random_entropy_avail(int update_every, usec_t dt) { rd = rrddim_add(st, "entropy", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else rrdset_next(st); rrddim_set_by_pointer(st, rd, entropy); rrdset_done(st); - return 0; } diff --git a/collectors/proc.plugin/proc_uptime.c b/collectors/proc.plugin/proc_uptime.c index 28b00e0da..ddab7269b 100644 --- a/collectors/proc.plugin/proc_uptime.c +++ b/collectors/proc.plugin/proc_uptime.c @@ -35,12 +35,8 @@ int do_proc_uptime(int update_every, usec_t dt) { rd = rrddim_add(st, "uptime", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st); rrddim_set_by_pointer(st, rd, uptime_msec(uptime_filename)); - rrdset_done(st); - return 0; } diff --git a/collectors/proc.plugin/proc_vmstat.c b/collectors/proc.plugin/proc_vmstat.c index c1a137161..b8defc455 100644 --- a/collectors/proc.plugin/proc_vmstat.c +++ b/collectors/proc.plugin/proc_vmstat.c @@ -138,7 +138,6 @@ int do_proc_vmstat(int update_every, usec_t dt) { rd_in = rrddim_add(st_swapio, "in", NULL, sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_swapio, "out", NULL, -sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_swapio); rrddim_set_by_pointer(st_swapio, rd_in, pswpin); rrddim_set_by_pointer(st_swapio, rd_out, pswpout); @@ -170,7 +169,6 @@ int do_proc_vmstat(int update_every, usec_t dt) { rd_in = rrddim_add(st_io, "in", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_io, "out", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_io); rrddim_set_by_pointer(st_io, rd_in, pgpgin); rrddim_set_by_pointer(st_io, rd_out, pgpgout); @@ -204,7 +202,6 @@ int do_proc_vmstat(int update_every, usec_t dt) { rd_minor = rrddim_add(st_pgfaults, "minor", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_major = rrddim_add(st_pgfaults, "major", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_pgfaults); rrddim_set_by_pointer(st_pgfaults, rd_minor, pgfault); rrddim_set_by_pointer(st_pgfaults, rd_major, pgmajfault); @@ -240,7 +237,6 @@ int do_proc_vmstat(int update_every, usec_t dt) { rd_oom_kill = rrddim_add(st_oom_kill, "kills", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_oom_kill); rrddim_set_by_pointer(st_oom_kill, rd_oom_kill, oom_kill); rrdset_done(st_oom_kill); @@ -295,7 +291,6 @@ int do_proc_vmstat(int update_every, usec_t dt) { rd_hint_faults_local = rrddim_add(st_numa, "hint_faults_local", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_pages_migrated = rrddim_add(st_numa, "pages_migrated", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(st_numa); rrddim_set_by_pointer(st_numa, rd_local, numa_local); rrddim_set_by_pointer(st_numa, rd_foreign, numa_foreign); diff --git a/collectors/proc.plugin/sys_block_zram.c b/collectors/proc.plugin/sys_block_zram.c index ddd1e7ae0..6bae54243 100644 --- a/collectors/proc.plugin/sys_block_zram.c +++ b/collectors/proc.plugin/sys_block_zram.c @@ -33,8 +33,6 @@ typedef struct zram_device { RRDDIM *rd_alloc_efficiency; } ZRAM_DEVICE; - // -------------------------------------------------------------------- - static int try_get_zram_major_number(procfile *file) { size_t i; unsigned int lines = procfile_lines(file); @@ -75,7 +73,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , RRDSET_TYPE_AREA); d->rd_compr_data_size = rrddim_add(d->st_usage, "compressed", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); d->rd_metadata_size = rrddim_add(d->st_usage, "metadata", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_usage->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_usage->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_savings.%s", name); d->st_savings = rrdset_create_localhost( @@ -93,7 +91,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , RRDSET_TYPE_AREA); d->rd_savings_size = rrddim_add(d->st_savings, "savings", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); d->rd_original_size = rrddim_add(d->st_savings, "original", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_savings->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_savings->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_ratio.%s", name); d->st_comp_ratio = rrdset_create_localhost( @@ -110,7 +108,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , update_every , RRDSET_TYPE_LINE); d->rd_comp_ratio = rrddim_add(d->st_comp_ratio, "ratio", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_comp_ratio->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_comp_ratio->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_efficiency.%s", name); d->st_alloc_efficiency = rrdset_create_localhost( @@ -127,7 +125,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , update_every , RRDSET_TYPE_LINE); d->rd_alloc_efficiency = rrddim_add(d->st_alloc_efficiency, "percent", NULL, 1, 10000, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_alloc_efficiency->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_alloc_efficiency->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); } static int init_devices(DICTIONARY *devices, unsigned int zram_id, int update_every) { @@ -177,9 +175,8 @@ static void free_device(DICTIONARY *dict, const char *name) rrdset_obsolete_and_pointer_null(d->st_savings); rrdset_obsolete_and_pointer_null(d->st_alloc_efficiency); rrdset_obsolete_and_pointer_null(d->st_comp_ratio); - dictionary_del_having_write_lock(dict, name); + dictionary_del(dict, name); } - // -------------------------------------------------------------------- static inline int read_mm_stat(procfile *ff, MM_STAT *stats) { ff = procfile_readall(ff); @@ -204,61 +201,51 @@ static inline int read_mm_stat(procfile *ff, MM_STAT *stats) { return 0; } -static inline int _collect_zram_metrics(const char* name, ZRAM_DEVICE *d, int advance, DICTIONARY* dict) { +static int collect_zram_metrics(const DICTIONARY_ITEM *item, void *entry, void *data) { + const char *name = dictionary_acquired_item_name(item); + ZRAM_DEVICE *dev = entry; + DICTIONARY *dict = data; + MM_STAT mm; int value; - if (unlikely(read_mm_stat(d->file, &mm) < 0)) - { + + if (unlikely(read_mm_stat(dev->file, &mm) < 0)) { free_device(dict, name); return -1; } - if (likely(advance)) - { - rrdset_next(d->st_usage); - rrdset_next(d->st_savings); - rrdset_next(d->st_comp_ratio); - rrdset_next(d->st_alloc_efficiency); - } // zram_usage - rrddim_set_by_pointer(d->st_usage, d->rd_compr_data_size, mm.compr_data_size); - rrddim_set_by_pointer(d->st_usage, d->rd_metadata_size, mm.mem_used_total - mm.compr_data_size); - rrdset_done(d->st_usage); + rrddim_set_by_pointer(dev->st_usage, dev->rd_compr_data_size, mm.compr_data_size); + rrddim_set_by_pointer(dev->st_usage, dev->rd_metadata_size, mm.mem_used_total - mm.compr_data_size); + rrdset_done(dev->st_usage); + // zram_savings - rrddim_set_by_pointer(d->st_savings, d->rd_savings_size, mm.compr_data_size - mm.orig_data_size); - rrddim_set_by_pointer(d->st_savings, d->rd_original_size, mm.orig_data_size); - rrdset_done(d->st_savings); + rrddim_set_by_pointer(dev->st_savings, dev->rd_savings_size, mm.compr_data_size - mm.orig_data_size); + rrddim_set_by_pointer(dev->st_savings, dev->rd_original_size, mm.orig_data_size); + rrdset_done(dev->st_savings); + // zram_ratio value = mm.compr_data_size == 0 ? 1 : mm.orig_data_size * 100 / mm.compr_data_size; - rrddim_set_by_pointer(d->st_comp_ratio, d->rd_comp_ratio, value); - rrdset_done(d->st_comp_ratio); + rrddim_set_by_pointer(dev->st_comp_ratio, dev->rd_comp_ratio, value); + rrdset_done(dev->st_comp_ratio); + // zram_efficiency value = mm.mem_used_total == 0 ? 100 : (mm.compr_data_size * 1000000 / mm.mem_used_total); - rrddim_set_by_pointer(d->st_alloc_efficiency, d->rd_alloc_efficiency, value); - rrdset_done(d->st_alloc_efficiency); - return 0; -} - -static int collect_first_zram_metrics(const char *name, void *entry, void *data) { - // collect without calling rrdset_next (init only) - return _collect_zram_metrics(name, (ZRAM_DEVICE *)entry, 0, (DICTIONARY *)data); -} + rrddim_set_by_pointer(dev->st_alloc_efficiency, dev->rd_alloc_efficiency, value); + rrdset_done(dev->st_alloc_efficiency); -static int collect_zram_metrics(const char *name, void *entry, void *data) { - (void)name; - // collect with calling rrdset_next - return _collect_zram_metrics(name, (ZRAM_DEVICE *)entry, 1, (DICTIONARY *)data); + return 0; } - // -------------------------------------------------------------------- - int do_sys_block_zram(int update_every, usec_t dt) { - (void)dt; static procfile *ff = NULL; static DICTIONARY *devices = NULL; static int initialized = 0; static int device_count = 0; int zram_id = -1; + + (void)dt; + if (unlikely(!initialized)) { initialized = 1; @@ -280,17 +267,13 @@ int do_sys_block_zram(int update_every, usec_t dt) { } procfile_close(ff); - devices = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED); + devices = dictionary_create(DICT_OPTION_SINGLE_THREADED); device_count = init_devices(devices, (unsigned int)zram_id, update_every); - if (device_count < 1) - return 1; - dictionary_walkthrough_write(devices, collect_first_zram_metrics, devices); - } - else - { - if (unlikely(device_count < 1)) - return 1; - dictionary_walkthrough_write(devices, collect_zram_metrics, devices); } + + if (unlikely(device_count < 1)) + return 1; + + dictionary_walkthrough_write(devices, collect_zram_metrics, devices); return 0; }
\ No newline at end of file diff --git a/collectors/proc.plugin/sys_class_infiniband.c b/collectors/proc.plugin/sys_class_infiniband.c index 7e63bcbb4..fca0cb8a2 100644 --- a/collectors/proc.plugin/sys_class_infiniband.c +++ b/collectors/proc.plugin/sys_class_infiniband.c @@ -184,7 +184,7 @@ static struct ibport { RRDSET *st_hwpackets; RRDSET *st_hwerrors; - RRDSETVAR *stv_speed; + const RRDSETVAR_ACQUIRED *stv_speed; usec_t speed_last_collected_usec; @@ -543,15 +543,14 @@ int do_sys_class_infiniband(int update_every, usec_t dt) // x4 lanes multiplier as per Documentation/ABI/stable/sysfs-class-infiniband FOREACH_COUNTER_BYTES(GEN_RRD_DIM_ADD_CUSTOM, port, 4 * 8 * port->width, 1024, RRD_ALGORITHM_INCREMENTAL) - port->stv_speed = rrdsetvar_custom_chart_variable_create(port->st_bytes, "link_speed"); - } else - rrdset_next(port->st_bytes); + port->stv_speed = rrdsetvar_custom_chart_variable_add_and_acquire(port->st_bytes, "link_speed"); + } // Link read values to dimensions FOREACH_COUNTER_BYTES(GEN_RRD_DIM_SETP, port) // For link speed set only variable - rrdsetvar_custom_chart_variable_set(port->stv_speed, port->speed); + rrdsetvar_custom_chart_variable_set(port->st_bytes, port->stv_speed, port->speed); rrdset_done(port->st_bytes); } @@ -578,8 +577,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) // Create Dimensions rrdset_flag_set(port->st_packets, RRDSET_FLAG_DETAIL); FOREACH_COUNTER_PACKETS(GEN_RRD_DIM_ADD, port) - } else - rrdset_next(port->st_packets); + } // Link read values to dimensions FOREACH_COUNTER_PACKETS(GEN_RRD_DIM_SETP, port) @@ -608,8 +606,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) // Create Dimensions rrdset_flag_set(port->st_errors, RRDSET_FLAG_DETAIL); FOREACH_COUNTER_ERRORS(GEN_RRD_DIM_ADD, port) - } else - rrdset_next(port->st_errors); + } // Link read values to dimensions FOREACH_COUNTER_ERRORS(GEN_RRD_DIM_SETP, port) @@ -658,8 +655,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) port->name); port->do_hwerrors = CONFIG_BOOLEAN_NO; } - } else - rrdset_next(port->st_hwerrors); + } } if (port->do_hwpackets != CONFIG_BOOLEAN_NO) { @@ -695,8 +691,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) port->name); port->do_hwpackets = CONFIG_BOOLEAN_NO; } - } else - rrdset_next(port->st_hwpackets); + } } // Update values to rrd (done by vendor-specific function) diff --git a/collectors/proc.plugin/sys_class_power_supply.c b/collectors/proc.plugin/sys_class_power_supply.c index a80d46e93..dde421503 100644 --- a/collectors/proc.plugin/sys_class_power_supply.c +++ b/collectors/proc.plugin/sys_class_power_supply.c @@ -113,7 +113,7 @@ void power_supply_free(struct power_supply *ps) { } static void add_labels_to_power_supply(struct power_supply *ps, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", ps->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", ps->name, RRDLABEL_SRC_AUTO); } int do_sys_class_power_supply(int update_every, usec_t dt) { @@ -365,8 +365,6 @@ int do_sys_class_power_supply(int update_every, usec_t dt) { add_labels_to_power_supply(ps, ps->capacity->st); } - else - rrdset_next(ps->capacity->st); if(unlikely(!ps->capacity->rd)) ps->capacity->rd = rrddim_add(ps->capacity->st, "capacity", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rrddim_set_by_pointer(ps->capacity->st, ps->capacity->rd, ps->capacity->value); @@ -398,8 +396,6 @@ int do_sys_class_power_supply(int update_every, usec_t dt) { add_labels_to_power_supply(ps, pr->st); } - else - rrdset_next(pr->st); struct ps_property_dim *pd; for(pd = pr->property_dim_root; pd; pd = pd->next) { diff --git a/collectors/proc.plugin/sys_devices_system_edac_mc.c b/collectors/proc.plugin/sys_devices_system_edac_mc.c index 290157903..13d209781 100644 --- a/collectors/proc.plugin/sys_devices_system_edac_mc.c +++ b/collectors/proc.plugin/sys_devices_system_edac_mc.c @@ -78,8 +78,8 @@ int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt) { struct mc *m; if(unlikely(do_ce == -1)) { - do_ce = config_get_boolean_ondemand("plugin:proc:/sys/devices/system/edac/mc", "enable ECC memory correctable errors", CONFIG_BOOLEAN_AUTO); - do_ue = config_get_boolean_ondemand("plugin:proc:/sys/devices/system/edac/mc", "enable ECC memory uncorrectable errors", CONFIG_BOOLEAN_AUTO); + do_ce = config_get_boolean_ondemand("plugin:proc:/sys/devices/system/edac/mc", "enable ECC memory correctable errors", CONFIG_BOOLEAN_YES); + do_ue = config_get_boolean_ondemand("plugin:proc:/sys/devices/system/edac/mc", "enable ECC memory uncorrectable errors", CONFIG_BOOLEAN_YES); } if(do_ce != CONFIG_BOOLEAN_NO) { @@ -150,8 +150,6 @@ int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); } - else - rrdset_next(ce_st); for(m = mc_root; m; m = m->next) { if (m->ce_count_filename && m->ce_updated) { @@ -189,8 +187,6 @@ int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); } - else - rrdset_next(ue_st); for(m = mc_root; m; m = m->next) { if (m->ue_count_filename && m->ue_updated) { diff --git a/collectors/proc.plugin/sys_devices_system_node.c b/collectors/proc.plugin/sys_devices_system_node.c index fd3394309..90aafd56a 100644 --- a/collectors/proc.plugin/sys_devices_system_node.c +++ b/collectors/proc.plugin/sys_devices_system_node.c @@ -115,7 +115,7 @@ int do_proc_sys_devices_system_node(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdlabels_add(m->numastat_st->state->chart_labels, "numa_node", m->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(m->numastat_st->rrdlabels, "numa_node", m->name, RRDLABEL_SRC_AUTO); rrdset_flag_set(m->numastat_st, RRDSET_FLAG_DETAIL); @@ -127,7 +127,6 @@ int do_proc_sys_devices_system_node(int update_every, usec_t dt) { rrddim_add(m->numastat_st, "other_node", "other", 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else rrdset_next(m->numastat_st); size_t lines = procfile_lines(m->numastat_ff), l; for(l = 0; l < lines; l++) { diff --git a/collectors/proc.plugin/sys_fs_btrfs.c b/collectors/proc.plugin/sys_fs_btrfs.c index 158587a8f..3b9841fec 100644 --- a/collectors/proc.plugin/sys_fs_btrfs.c +++ b/collectors/proc.plugin/sys_fs_btrfs.c @@ -449,8 +449,8 @@ static inline int find_all_btrfs_pools(const char *path) { } static void add_labels_to_btrfs(BTRFS_NODE *n, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", n->id, RRDLABEL_SRC_AUTO); - rrdlabels_add(st->state->chart_labels, "device_label", n->label, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", n->id, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_label", n->label, RRDLABEL_SRC_AUTO); } int do_sys_fs_btrfs(int update_every, usec_t dt) { @@ -587,7 +587,6 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) { add_labels_to_btrfs(node, node->st_allocation_disks); } - else rrdset_next(node->st_allocation_disks); // unsigned long long disk_used = node->allocation_data_disk_used + node->allocation_metadata_disk_used + node->allocation_system_disk_used; unsigned long long disk_total = node->allocation_data_disk_total + node->allocation_metadata_disk_total + node->allocation_system_disk_total; @@ -642,7 +641,6 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) { add_labels_to_btrfs(node, node->st_allocation_data); } - else rrdset_next(node->st_allocation_data); rrddim_set_by_pointer(node->st_allocation_data, node->rd_allocation_data_free, node->allocation_data_total_bytes - node->allocation_data_bytes_used); rrddim_set_by_pointer(node->st_allocation_data, node->rd_allocation_data_used, node->allocation_data_bytes_used); @@ -688,7 +686,6 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) { add_labels_to_btrfs(node, node->st_allocation_metadata); } - else rrdset_next(node->st_allocation_metadata); rrddim_set_by_pointer(node->st_allocation_metadata, node->rd_allocation_metadata_free, node->allocation_metadata_total_bytes - node->allocation_metadata_bytes_used - node->allocation_global_rsv_size); rrddim_set_by_pointer(node->st_allocation_metadata, node->rd_allocation_metadata_used, node->allocation_metadata_bytes_used); @@ -734,7 +731,6 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) { add_labels_to_btrfs(node, node->st_allocation_system); } - else rrdset_next(node->st_allocation_system); rrddim_set_by_pointer(node->st_allocation_system, node->rd_allocation_system_free, node->allocation_system_total_bytes - node->allocation_system_bytes_used); rrddim_set_by_pointer(node->st_allocation_system, node->rd_allocation_system_used, node->allocation_system_bytes_used); diff --git a/collectors/proc.plugin/sys_kernel_mm_ksm.c b/collectors/proc.plugin/sys_kernel_mm_ksm.c index a0e5690fe..e586d5554 100644 --- a/collectors/proc.plugin/sys_kernel_mm_ksm.c +++ b/collectors/proc.plugin/sys_kernel_mm_ksm.c @@ -119,8 +119,6 @@ int do_sys_kernel_mm_ksm(int update_every, usec_t dt) { rd_volatile = rrddim_add(st_mem_ksm, "volatile", NULL, -1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); //rd_to_scan = rrddim_add(st_mem_ksm, "to_scan", "to scan", -1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_mem_ksm); rrddim_set_by_pointer(st_mem_ksm, rd_shared, pages_shared * page_size); rrddim_set_by_pointer(st_mem_ksm, rd_unshared, pages_unshared * page_size); @@ -156,8 +154,6 @@ int do_sys_kernel_mm_ksm(int update_every, usec_t dt) { rd_savings = rrddim_add(st_mem_ksm_savings, "savings", NULL, -1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); rd_offered = rrddim_add(st_mem_ksm_savings, "offered", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_mem_ksm_savings); rrddim_set_by_pointer(st_mem_ksm_savings, rd_savings, saved * page_size); rrddim_set_by_pointer(st_mem_ksm_savings, rd_offered, offered * page_size); @@ -189,11 +185,8 @@ int do_sys_kernel_mm_ksm(int update_every, usec_t dt) { rd_savings = rrddim_add(st_mem_ksm_ratios, "savings", NULL, 1, 10000, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_mem_ksm_ratios); rrddim_set_by_pointer(st_mem_ksm_ratios, rd_savings, offered ? (saved * 1000000) / offered : 0); - rrdset_done(st_mem_ksm_ratios); } diff --git a/collectors/proc.plugin/zfs_common.c b/collectors/proc.plugin/zfs_common.c index 330bcf18b..cca0ae0e6 100644 --- a/collectors/proc.plugin/zfs_common.c +++ b/collectors/proc.plugin/zfs_common.c @@ -67,8 +67,6 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_arc_target_min_size = rrddim_add(st_arc_size, "min", "min (hard limit)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); rd_arc_target_max_size = rrddim_add(st_arc_size, "max", "max (high water)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_arc_size); rrddim_set_by_pointer(st_arc_size, rd_arc_size, arcstats.size); rrddim_set_by_pointer(st_arc_size, rd_arc_target_size, arcstats.c); @@ -105,8 +103,6 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_l2_asize = rrddim_add(st_l2_size, "actual", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); rd_l2_size = rrddim_add(st_l2_size, "size", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_l2_size); rrddim_set_by_pointer(st_l2_size, rd_l2_size, arcstats.l2_size); rrddim_set_by_pointer(st_l2_size, rd_l2_asize, arcstats.l2_asize); @@ -149,8 +145,6 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z if(arcstats.l2exist) rd_l2read = rrddim_add(st_reads, "l2reads", "l2", 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else - rrdset_next(st_reads); rrddim_set_by_pointer(st_reads, rd_aread, aread); rrddim_set_by_pointer(st_reads, rd_dread, dread); @@ -191,8 +185,6 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_l2_read_bytes = rrddim_add(st_l2bytes, "read", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL); rd_l2_write_bytes = rrddim_add(st_l2bytes, "write", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL); } - else - rrdset_next(st_l2bytes); rrddim_set_by_pointer(st_l2bytes, rd_l2_read_bytes, arcstats.l2_read_bytes); rrddim_set_by_pointer(st_l2bytes, rd_l2_write_bytes, arcstats.l2_write_bytes); @@ -227,12 +219,38 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_ahits = rrddim_add(st_ahits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_amisses = rrddim_add(st_ahits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_ahits); rrddim_set_by_pointer(st_ahits, rd_ahits, arcstats.hits); rrddim_set_by_pointer(st_ahits, rd_amisses, arcstats.misses); rrdset_done(st_ahits); + + static RRDSET *st_ahits_rate = NULL; + static RRDDIM *rd_ahits_rate = NULL; + static RRDDIM *rd_amisses_rate = NULL; + + if (unlikely(!st_ahits_rate)) { + st_ahits_rate = rrdset_create_localhost( + "zfs" + , "hits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS ARC Hits Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_HITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_ahits_rate = rrddim_add(st_ahits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_amisses_rate = rrddim_add(st_ahits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_ahits_rate, rd_ahits_rate, arcstats.hits); + rrddim_set_by_pointer(st_ahits_rate, rd_amisses_rate, arcstats.misses); + rrdset_done(st_ahits_rate); } // -------------------------------------------------------------------- @@ -263,12 +281,38 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_dhits = rrddim_add(st_dhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_dmisses = rrddim_add(st_dhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_dhits); rrddim_set_by_pointer(st_dhits, rd_dhits, dhit); rrddim_set_by_pointer(st_dhits, rd_dmisses, dmiss); rrdset_done(st_dhits); + + static RRDSET *st_dhits_rate = NULL; + static RRDDIM *rd_dhits_rate = NULL; + static RRDDIM *rd_dmisses_rate = NULL; + + if (unlikely(!st_dhits_rate)) { + st_dhits_rate = rrdset_create_localhost( + "zfs" + , "dhits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS Demand Hits Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_DHITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_dhits_rate = rrddim_add(st_dhits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_dmisses_rate = rrddim_add(st_dhits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_dhits_rate, rd_dhits_rate, dhit); + rrddim_set_by_pointer(st_dhits_rate, rd_dmisses_rate, dmiss); + rrdset_done(st_dhits_rate); } // -------------------------------------------------------------------- @@ -299,12 +343,38 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_phits = rrddim_add(st_phits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_pmisses = rrddim_add(st_phits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_phits); rrddim_set_by_pointer(st_phits, rd_phits, phit); rrddim_set_by_pointer(st_phits, rd_pmisses, pmiss); rrdset_done(st_phits); + + static RRDSET *st_phits_rate = NULL; + static RRDDIM *rd_phits_rate = NULL; + static RRDDIM *rd_pmisses_rate = NULL; + + if (unlikely(!st_phits_rate)) { + st_phits_rate = rrdset_create_localhost( + "zfs" + , "phits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS Prefetch Hits Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_PHITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_phits_rate = rrddim_add(st_phits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_pmisses_rate = rrddim_add(st_phits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_phits_rate, rd_phits_rate, phit); + rrddim_set_by_pointer(st_phits_rate, rd_pmisses_rate, pmiss); + rrdset_done(st_phits_rate); } // -------------------------------------------------------------------- @@ -335,12 +405,38 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_mhits = rrddim_add(st_mhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_mmisses = rrddim_add(st_mhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_mhits); rrddim_set_by_pointer(st_mhits, rd_mhits, mhit); rrddim_set_by_pointer(st_mhits, rd_mmisses, mmiss); rrdset_done(st_mhits); + + static RRDSET *st_mhits_rate = NULL; + static RRDDIM *rd_mhits_rate = NULL; + static RRDDIM *rd_mmisses_rate = NULL; + + if (unlikely(!st_mhits_rate)) { + st_mhits_rate = rrdset_create_localhost( + "zfs" + , "mhits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS Metadata Hits Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_MHITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_mhits_rate = rrddim_add(st_mhits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_mmisses_rate = rrddim_add(st_mhits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_mhits_rate, rd_mhits_rate, mhit); + rrddim_set_by_pointer(st_mhits_rate, rd_mmisses_rate, mmiss); + rrdset_done(st_mhits_rate); } // -------------------------------------------------------------------- @@ -371,12 +467,38 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_l2hits = rrddim_add(st_l2hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_l2misses = rrddim_add(st_l2hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_l2hits); rrddim_set_by_pointer(st_l2hits, rd_l2hits, l2hit); rrddim_set_by_pointer(st_l2hits, rd_l2misses, l2miss); rrdset_done(st_l2hits); + + static RRDSET *st_l2hits_rate = NULL; + static RRDDIM *rd_l2hits_rate = NULL; + static RRDDIM *rd_l2misses_rate = NULL; + + if (unlikely(!st_l2hits_rate)) { + st_l2hits_rate = rrdset_create_localhost( + "zfs" + , "l2hits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS L2 Hits Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_L2HITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_l2hits_rate = rrddim_add(st_l2hits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_l2misses_rate = rrddim_add(st_l2hits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_l2hits_rate, rd_l2hits_rate, l2hit); + rrddim_set_by_pointer(st_l2hits_rate, rd_l2misses_rate, l2miss); + rrdset_done(st_l2hits_rate); } // -------------------------------------------------------------------- @@ -414,8 +536,6 @@ void generate_charts_arcstats(const char *plugin, const char *module, int show_z rd_mru = rrddim_add(st_list_hits, "mru", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_mrug = rrddim_add(st_list_hits, "mrug", "mru ghost", 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else - rrdset_next(st_list_hits); rrddim_set_by_pointer(st_list_hits, rd_mfu, arcstats.mfu_hits); rrddim_set_by_pointer(st_list_hits, rd_mru, arcstats.mru_hits); @@ -480,8 +600,6 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_most_recent = rrddim_add(st_arc_size_breakdown, "recent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL); rd_most_frequent = rrddim_add(st_arc_size_breakdown, "frequent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL); } - else - rrdset_next(st_arc_size_breakdown); rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_recent, mru_size); rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_frequent, mfu_size); @@ -528,8 +646,6 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_indirect = rrddim_add(st_memory, "indirect", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); #endif } - else - rrdset_next(st_memory); #ifndef __FreeBSD__ rrddim_set_by_pointer(st_memory, rd_direct, arcstats.memory_direct_count); @@ -576,8 +692,6 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_mutex_misses = rrddim_add(st_important_ops, "mtxmis", "mutex miss", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_hash_collisions = rrddim_add(st_important_ops, "hash_collisions", "hash collisions", 1, 1, RRD_ALGORITHM_INCREMENTAL); } - else - rrdset_next(st_important_ops); rrddim_set_by_pointer(st_important_ops, rd_deleted, arcstats.deleted); rrddim_set_by_pointer(st_important_ops, rd_evict_skips, arcstats.evict_skip); @@ -614,12 +728,38 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_actual_hits = rrddim_add(st_actual_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_actual_misses = rrddim_add(st_actual_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_actual_hits); rrddim_set_by_pointer(st_actual_hits, rd_actual_hits, real_hits); rrddim_set_by_pointer(st_actual_hits, rd_actual_misses, real_misses); rrdset_done(st_actual_hits); + + static RRDSET *st_actual_hits_rate = NULL; + static RRDDIM *rd_actual_hits_rate = NULL; + static RRDDIM *rd_actual_misses_rate = NULL; + + if (unlikely(!st_actual_hits_rate)) { + st_actual_hits_rate = rrdset_create_localhost( + "zfs" + , "actual_hits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS Actual Cache Hits Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_ACTUAL_HITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_actual_hits_rate = rrddim_add(st_actual_hits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_actual_misses_rate = rrddim_add(st_actual_hits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_actual_hits_rate, rd_actual_hits_rate, real_hits); + rrddim_set_by_pointer(st_actual_hits_rate, rd_actual_misses_rate, real_misses); + rrdset_done(st_actual_hits_rate); } // -------------------------------------------------------------------- @@ -650,12 +790,38 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_demand_data_hits = rrddim_add(st_demand_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_demand_data_misses = rrddim_add(st_demand_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_demand_data_hits); rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_hits, arcstats.demand_data_hits); rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_misses, arcstats.demand_data_misses); rrdset_done(st_demand_data_hits); + + static RRDSET *st_demand_data_hits_rate = NULL; + static RRDDIM *rd_demand_data_hits_rate = NULL; + static RRDDIM *rd_demand_data_misses_rate = NULL; + + if (unlikely(!st_demand_data_hits_rate)) { + st_demand_data_hits_rate = rrdset_create_localhost( + "zfs" + , "demand_data_hits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS Data Demand Efficiency Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_DEMAND_DATA_HITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_demand_data_hits_rate = rrddim_add(st_demand_data_hits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_demand_data_misses_rate = rrddim_add(st_demand_data_hits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_demand_data_hits_rate, rd_demand_data_hits_rate, arcstats.demand_data_hits); + rrddim_set_by_pointer(st_demand_data_hits_rate, rd_demand_data_misses_rate, arcstats.demand_data_misses); + rrdset_done(st_demand_data_hits_rate); } // -------------------------------------------------------------------- @@ -687,12 +853,38 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_prefetch_data_hits = rrddim_add(st_prefetch_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rd_prefetch_data_misses = rrddim_add(st_prefetch_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); } - else - rrdset_next(st_prefetch_data_hits); rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_hits, arcstats.prefetch_data_hits); rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_misses, arcstats.prefetch_data_misses); rrdset_done(st_prefetch_data_hits); + + static RRDSET *st_prefetch_data_hits_rate = NULL; + static RRDDIM *rd_prefetch_data_hits_rate = NULL; + static RRDDIM *rd_prefetch_data_misses_rate = NULL; + + if (unlikely(!st_prefetch_data_hits_rate)) { + st_prefetch_data_hits_rate = rrdset_create_localhost( + "zfs" + , "prefetch_data_hits_rate" + , NULL + , ZFS_FAMILY_EFFICIENCY + , NULL + , "ZFS Data Prefetch Efficiency Rate" + , "events/s" + , plugin + , module + , NETDATA_CHART_PRIO_ZFS_PREFETCH_DATA_HITS + 1 + , update_every + , RRDSET_TYPE_STACKED + ); + + rd_prefetch_data_hits_rate = rrddim_add(st_prefetch_data_hits_rate, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_prefetch_data_misses_rate = rrddim_add(st_prefetch_data_hits_rate, "misses", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + } + + rrddim_set_by_pointer(st_prefetch_data_hits_rate, rd_prefetch_data_hits_rate, arcstats.prefetch_data_hits); + rrddim_set_by_pointer(st_prefetch_data_hits_rate, rd_prefetch_data_misses_rate, arcstats.prefetch_data_misses); + rrdset_done(st_prefetch_data_hits_rate); } // -------------------------------------------------------------------- @@ -723,8 +915,6 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_hash_elements_current = rrddim_add(st_hash_elements, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rd_hash_elements_max = rrddim_add(st_hash_elements, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_hash_elements); rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_current, arcstats.hash_elements); rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_max, arcstats.hash_elements_max); @@ -759,8 +949,6 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho rd_hash_chains_current = rrddim_add(st_hash_chains, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); rd_hash_chains_max = rrddim_add(st_hash_chains, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } - else - rrdset_next(st_hash_chains); rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_current, arcstats.hash_chains); rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_max, arcstats.hash_chain_max); @@ -769,4 +957,4 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int sho // -------------------------------------------------------------------- -}
\ No newline at end of file +} |