diff options
Diffstat (limited to 'src/collectors/proc.plugin')
27 files changed, 607 insertions, 743 deletions
diff --git a/src/collectors/proc.plugin/README.md b/src/collectors/proc.plugin/README.md index 79bfd8645..8523309c7 100644 --- a/src/collectors/proc.plugin/README.md +++ b/src/collectors/proc.plugin/README.md @@ -6,35 +6,35 @@ This plugin is not an external plugin, but one of Netdata's threads. In detail, it collects metrics from: -- `/proc/net/dev` (all network interfaces for all their values) -- `/proc/diskstats` (all disks for all their values) -- `/proc/mdstat` (status of RAID arrays) -- `/proc/net/snmp` (total IPv4, TCP and UDP usage) -- `/proc/net/snmp6` (total IPv6 usage) -- `/proc/net/netstat` (more IPv4 usage) -- `/proc/net/wireless` (wireless extension) -- `/proc/net/stat/nf_conntrack` (connection tracking performance) -- `/proc/net/stat/synproxy` (synproxy performance) -- `/proc/net/ip_vs/stats` (IPVS connection statistics) -- `/proc/stat` (CPU utilization and attributes) -- `/proc/meminfo` (memory information) -- `/proc/vmstat` (system performance) -- `/proc/net/rpc/nfsd` (NFS server statistics for both v3 and v4 NFS servers) -- `/sys/fs/cgroup` (Control Groups - Linux Containers) -- `/proc/self/mountinfo` (mount points) -- `/proc/interrupts` (total and per core hardware interrupts) -- `/proc/softirqs` (total and per core software interrupts) -- `/proc/loadavg` (system load and total processes running) -- `/proc/pressure/{cpu,memory,io}` (pressure stall information) -- `/proc/sys/kernel/random/entropy_avail` (random numbers pool availability - used in cryptography) -- `/proc/spl/kstat/zfs/arcstats` (status of ZFS adaptive replacement cache) -- `/proc/spl/kstat/zfs/pool/state` (state of ZFS pools) -- `/sys/class/power_supply` (power supply properties) -- `/sys/class/infiniband` (infiniband interconnect) -- `/sys/class/drm` (AMD GPUs) -- `ipc` (IPC semaphores and message queues) -- `ksm` Kernel Same-Page Merging performance (several files under `/sys/kernel/mm/ksm`). -- `netdata` (internal Netdata resources utilization) +- `/proc/net/dev` (all network interfaces for all their values) +- `/proc/diskstats` (all disks for all their values) +- `/proc/mdstat` (status of RAID arrays) +- `/proc/net/snmp` (total IPv4, TCP and UDP usage) +- `/proc/net/snmp6` (total IPv6 usage) +- `/proc/net/netstat` (more IPv4 usage) +- `/proc/net/wireless` (wireless extension) +- `/proc/net/stat/nf_conntrack` (connection tracking performance) +- `/proc/net/stat/synproxy` (synproxy performance) +- `/proc/net/ip_vs/stats` (IPVS connection statistics) +- `/proc/stat` (CPU utilization and attributes) +- `/proc/meminfo` (memory information) +- `/proc/vmstat` (system performance) +- `/proc/net/rpc/nfsd` (NFS server statistics for both v3 and v4 NFS servers) +- `/sys/fs/cgroup` (Control Groups - Linux Containers) +- `/proc/self/mountinfo` (mount points) +- `/proc/interrupts` (total and per core hardware interrupts) +- `/proc/softirqs` (total and per core software interrupts) +- `/proc/loadavg` (system load and total processes running) +- `/proc/pressure/{cpu,memory,io}` (pressure stall information) +- `/proc/sys/kernel/random/entropy_avail` (random numbers pool availability - used in cryptography) +- `/proc/spl/kstat/zfs/arcstats` (status of ZFS adaptive replacement cache) +- `/proc/spl/kstat/zfs/pool/state` (state of ZFS pools) +- `/sys/class/power_supply` (power supply properties) +- `/sys/class/infiniband` (infiniband interconnect) +- `/sys/class/drm` (AMD GPUs) +- `ipc` (IPC semaphores and message queues) +- `ksm` Kernel Same-Page Merging performance (several files under `/sys/kernel/mm/ksm`). +- `netdata` (internal Netdata resources utilization) - - - @@ -48,47 +48,47 @@ Hopefully, the Linux kernel provides many metrics that can provide deep insights ### Monitored disk metrics -- **I/O bandwidth/s (kb/s)** +- **I/O bandwidth/s (kb/s)** The amount of data transferred from and to the disk. -- **Amount of discarded data (kb/s)** -- **I/O operations/s** +- **Amount of discarded data (kb/s)** +- **I/O operations/s** The number of I/O operations completed. -- **Extended I/O operations/s** +- **Extended I/O operations/s** The number of extended I/O operations completed. -- **Queued I/O operations** +- **Queued I/O operations** The number of currently queued I/O operations. For traditional disks that execute commands one after another, one of them is being run by the disk and the rest are just waiting in a queue. -- **Backlog size (time in ms)** +- **Backlog size (time in ms)** The expected duration of the currently queued I/O operations. -- **Utilization (time percentage)** +- **Utilization (time percentage)** The percentage of time the disk was busy with something. This is a very interesting metric, since for most disks, that execute commands sequentially, **this is the key indication of congestion**. A sequential disk that is 100% of the available time busy, has no time to do anything more, so even if the bandwidth or the number of operations executed by the disk is low, its capacity has been reached. Of course, for newer disk technologies (like fusion cards) that are capable to execute multiple commands in parallel, this metric is just meaningless. -- **Average I/O operation time (ms)** +- **Average I/O operation time (ms)** The average time for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. -- **Average I/O operation time for extended operations (ms)** +- **Average I/O operation time for extended operations (ms)** The average time for extended I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. -- **Average I/O operation size (kb)** +- **Average I/O operation size (kb)** The average amount of data of the completed I/O operations. -- **Average amount of discarded data (kb)** +- **Average amount of discarded data (kb)** The average amount of data of the completed discard operations. -- **Average Service Time (ms)** +- **Average Service Time (ms)** The average service time for completed I/O operations. This metric is calculated using the total busy time of the disk and the number of completed operations. If the disk is able to execute multiple parallel operations the reporting average service time will be misleading. -- **Average Service Time for extended I/O operations (ms)** +- **Average Service Time for extended I/O operations (ms)** The average service time for completed extended I/O operations. -- **Merged I/O operations/s** +- **Merged I/O operations/s** The Linux kernel is capable of merging I/O operations. So, if two requests to read data from the disk are adjacent, the Linux kernel may merge them to one before giving them to disk. This metric measures the number of operations that have been merged by the Linux kernel. -- **Merged discard operations/s** -- **Total I/O time** +- **Merged discard operations/s** +- **Total I/O time** The sum of the duration of all completed I/O operations. This number can exceed the interval if the disk is able to execute multiple I/O operations in parallel. -- **Space usage** +- **Space usage** For mounted disks, Netdata will provide a chart for their space, with 3 dimensions: - 1. free - 2. used - 3. reserved for root -- **inode usage** + 1. free + 2. used + 3. reserved for root +- **inode usage** For mounted disks, Netdata will provide a chart for their inodes (number of file and directories), with 3 dimensions: - 1. free - 2. used - 3. reserved for root + 1. free + 2. used + 3. reserved for root ### disk names @@ -100,9 +100,9 @@ By default, Netdata will enable monitoring metrics only when they are not zero. Netdata categorizes all block devices in 3 categories: -1. physical disks (i.e. block devices that do not have child devices and are not partitions) -2. virtual disks (i.e. block devices that have child devices - like RAID devices) -3. disk partitions (i.e. block devices that are part of a physical disk) +1. physical disks (i.e. block devices that do not have child devices and are not partitions) +2. virtual disks (i.e. block devices that have child devices - like RAID devices) +3. disk partitions (i.e. block devices that are part of a physical disk) Performance metrics are enabled by default for all disk devices, except partitions and not-mounted virtual disks. Of course, you can enable/disable monitoring any block device by editing the Netdata configuration file. @@ -118,7 +118,7 @@ mv netdata.conf.new netdata.conf Then edit `netdata.conf` and find the following section. This is the basic plugin configuration. -``` +```text [plugin:proc:/proc/diskstats] # enable new disks detected at runtime = yes # performance metrics for physical disks = auto @@ -133,7 +133,7 @@ Then edit `netdata.conf` and find the following section. This is the basic plugi # extended operations for all disks = auto # backlog for all disks = auto # bcache for all disks = auto - # bcache priority stats update every = 0 + # bcache priority stats update every = off # remove charts of removed disks = yes # path to get block device = /sys/block/%s # path to get block device bcache = /sys/block/%s/bcache @@ -152,25 +152,25 @@ Then edit `netdata.conf` and find the following section. This is the basic plugi For each virtual disk, physical disk and partition you will have a section like this: -``` +```text [plugin:proc:/proc/diskstats:sda] - # enable = yes - # enable performance metrics = auto - # bandwidth = auto - # operations = auto - # merged operations = auto - # i/o time = auto - # queued operations = auto - # utilization percentage = auto + # enable = yes + # enable performance metrics = auto + # bandwidth = auto + # operations = auto + # merged operations = auto + # i/o time = auto + # queued operations = auto + # utilization percentage = auto # extended operations = auto - # backlog = auto + # backlog = auto ``` For all configuration options: -- `auto` = enable monitoring if the collected values are not zero -- `yes` = enable monitoring -- `no` = disable monitoring +- `auto` = enable monitoring if the collected values are not zero +- `yes` = enable monitoring +- `no` = disable monitoring Of course, to set options, you will have to uncomment them. The comments show the internal defaults. @@ -180,14 +180,14 @@ After saving `/etc/netdata/netdata.conf`, restart your Netdata to apply them. You can pretty easy disable performance metrics for individual device, for ex.: -``` +```text [plugin:proc:/proc/diskstats:sda] - enable performance metrics = no + enable performance metrics = no ``` But sometimes you need disable performance metrics for all devices with the same type, to do it you need to figure out device type from `/proc/diskstats` for ex.: -``` +```text 7 0 loop0 1651 0 3452 168 0 0 0 0 0 8 168 7 1 loop1 4955 0 11924 880 0 0 0 0 0 64 880 7 2 loop2 36 0 216 4 0 0 0 0 0 4 4 @@ -200,7 +200,7 @@ But sometimes you need disable performance metrics for all devices with the same All zram devices starts with `251` number and all loop devices starts with `7`. So, to disable performance metrics for all loop devices you could add `performance metrics for disks with major 7 = no` to `[plugin:proc:/proc/diskstats]` section. -``` +```text [plugin:proc:/proc/diskstats] performance metrics for disks with major 7 = no ``` @@ -209,34 +209,34 @@ So, to disable performance metrics for all loop devices you could add `performan ### Monitored RAID array metrics -1. **Health** Number of failed disks in every array (aggregate chart). +1. **Health** Number of failed disks in every array (aggregate chart). -2. **Disks stats** +2. **Disks stats** -- total (number of devices array ideally would have) -- inuse (number of devices currently are in use) + - total (number of devices array ideally would have) + - inuse (number of devices currently are in use) -3. **Mismatch count** +3. **Mismatch count** -- unsynchronized blocks + - unsynchronized blocks -4. **Current status** +4. **Current status** -- resync in percent -- recovery in percent -- reshape in percent -- check in percent + - resync in percent + - recovery in percent + - reshape in percent + - check in percent -5. **Operation status** (if resync/recovery/reshape/check is active) +5. **Operation status** (if resync/recovery/reshape/check is active) -- finish in minutes -- speed in megabytes/s + - finish in minutes + - speed in megabytes/s -6. **Nonredundant array availability** +6. **Non-redundant array availability** #### configuration -``` +```text [plugin:proc:/proc/mdstat] # faulty devices = yes # nonredundant arrays availability = yes @@ -267,7 +267,7 @@ If your system has more than 50 processors and you would like to see the CPU the state charts that are automatically disabled, you can set the following boolean options in the `[plugin:proc:/proc/stat]` section. -```conf +```text keep per core files open = yes keep cpuidle files open = yes core_throttle_count = yes @@ -311,50 +311,50 @@ each state. ### Monitored memory metrics -- Amount of memory swapped in/out -- Amount of memory paged from/to disk -- Number of memory page faults -- Number of out of memory kills -- Number of NUMA events +- Amount of memory swapped in/out +- Amount of memory paged from/to disk +- Number of memory page faults +- Number of out of memory kills +- Number of NUMA events ### Configuration -```conf +```text [plugin:proc:/proc/vmstat] - filename to monitor = /proc/vmstat - swap i/o = auto - disk i/o = yes - memory page faults = yes - out of memory kills = yes - system-wide numa metric summary = auto + filename to monitor = /proc/vmstat + swap i/o = auto + disk i/o = yes + memory page faults = yes + out of memory kills = yes + system-wide numa metric summary = auto ``` ## Monitoring Network Interfaces ### Monitored network interface metrics -- **Physical Network Interfaces Aggregated Bandwidth (kilobits/s)** +- **Physical Network Interfaces Aggregated Bandwidth (kilobits/s)** The amount of data received and sent through all physical interfaces in the system. This is the source of data for the Net Inbound and Net Outbound dials in the System Overview section. -- **Bandwidth (kilobits/s)** +- **Bandwidth (kilobits/s)** The amount of data received and sent through the interface. -- **Packets (packets/s)** +- **Packets (packets/s)** The number of packets received, packets sent, and multicast packets transmitted through the interface. -- **Interface Errors (errors/s)** +- **Interface Errors (errors/s)** The number of errors for the inbound and outbound traffic on the interface. -- **Interface Drops (drops/s)** +- **Interface Drops (drops/s)** The number of packets dropped for the inbound and outbound traffic on the interface. -- **Interface FIFO Buffer Errors (errors/s)** +- **Interface FIFO Buffer Errors (errors/s)** The number of FIFO buffer errors encountered while receiving and transmitting data through the interface. -- **Compressed Packets (packets/s)** +- **Compressed Packets (packets/s)** The number of compressed packets transmitted or received by the device driver. -- **Network Interface Events (events/s)** +- **Network Interface Events (events/s)** The number of packet framing errors, collisions detected on the interface, and carrier losses detected by the device driver. By default Netdata will enable monitoring metrics only when they are not zero. If they are constantly zero they are ignored. Metrics that will start having values, after Netdata is started, will be detected and charts will be automatically added to the dashboard (a refresh of the dashboard is needed for them to appear though). @@ -363,7 +363,7 @@ By default Netdata will enable monitoring metrics only when they are not zero. I The settings for monitoring wireless is in the `[plugin:proc:/proc/net/wireless]` section of your `netdata.conf` file. -```conf +```text status for all interfaces = yes quality for all interfaces = yes discarded packets for all interfaces = yes @@ -372,62 +372,62 @@ The settings for monitoring wireless is in the `[plugin:proc:/proc/net/wireless] You can set the following values for each configuration option: -- `auto` = enable monitoring if the collected values are not zero -- `yes` = enable monitoring -- `no` = disable monitoring +- `auto` = enable monitoring if the collected values are not zero +- `yes` = enable monitoring +- `no` = disable monitoring #### Monitored wireless interface metrics -- **Status** +- **Status** The current state of the interface. This is a device-dependent option. -- **Link** - Overall quality of the link. +- **Link** + Overall quality of the link. -- **Level** +- **Level** Received signal strength (RSSI), which indicates how strong the received signal is. - -- **Noise** - Background noise level. - -- **Discarded packets** - Discarded packets for: Number of packets received with a different NWID or ESSID (`nwid`), unable to decrypt (`crypt`), hardware was not able to properly re-assemble the link layer fragments (`frag`), packets failed to deliver (`retry`), and packets lost in relation with specific wireless operations (`misc`). - -- **Missed beacon** + +- **Noise** + Background noise level. + +- **Discarded packets** + Discarded packets for: Number of packets received with a different NWID or ESSID (`nwid`), unable to decrypt (`crypt`), hardware was not able to properly re-assemble the link layer fragments (`frag`), packets failed to deliver (`retry`), and packets lost in relation with specific wireless operations (`misc`). + +- **Missed beacon** Number of periodic beacons from the cell or the access point the interface has missed. - -#### Wireless configuration + +#### Wireless configuration #### alerts There are several alerts defined in `health.d/net.conf`. -The tricky ones are `inbound packets dropped` and `inbound packets dropped ratio`. They have quite a strict policy so that they warn users about possible issues. These alerts can be annoying for some network configurations. It is especially true for some bonding configurations if an interface is a child or a bonding interface itself. If it is expected to have a certain number of drops on an interface for a certain network configuration, a separate alert with different triggering thresholds can be created or the existing one can be disabled for this specific interface. It can be done with the help of the [families](/src/health/REFERENCE.md#alert-line-families) line in the alert configuration. For example, if you want to disable the `inbound packets dropped` alert for `eth0`, set `families: !eth0 *` in the alert definition for `template: inbound_packets_dropped`. +The tricky ones are `inbound packets dropped` and `inbound packets dropped ratio`. They have quite a strict policy so that they warn users about possible issues. These alerts can be annoying for some network configurations. It is especially true for some bonding configurations if an interface is a child or a bonding interface itself. If it is expected to have a certain number of drops on an interface for a certain network configuration, a separate alert with different triggering thresholds can be created or the existing one can be disabled for this specific interface. It can be done with the help of the families line in the alert configuration. For example, if you want to disable the `inbound packets dropped` alert for `eth0`, set `families: !eth0 *` in the alert definition for `template: inbound_packets_dropped`. #### configuration Module configuration: -``` +```text [plugin:proc:/proc/net/dev] - # filename to monitor = /proc/net/dev - # path to get virtual interfaces = /sys/devices/virtual/net/%s - # path to get net device speed = /sys/class/net/%s/speed - # enable new interfaces detected at runtime = auto - # bandwidth for all interfaces = auto - # packets for all interfaces = auto - # errors for all interfaces = auto - # drops for all interfaces = auto - # fifo for all interfaces = auto - # compressed packets for all interfaces = auto - # frames, collisions, carrier counters for all interfaces = auto - # disable by default interfaces matching = lo fireqos* *-ifb - # refresh interface speed every seconds = 10 + # filename to monitor = /proc/net/dev + # path to get virtual interfaces = /sys/devices/virtual/net/%s + # path to get net device speed = /sys/class/net/%s/speed + # enable new interfaces detected at runtime = auto + # bandwidth for all interfaces = auto + # packets for all interfaces = auto + # errors for all interfaces = auto + # drops for all interfaces = auto + # fifo for all interfaces = auto + # compressed packets for all interfaces = auto + # frames, collisions, carrier counters for all interfaces = auto + # disable by default interfaces matching = lo fireqos* *-ifb + # refresh interface speed every seconds = 10 ``` Per interface configuration: -``` +```text [plugin:proc:/proc/net/dev:enp0s3] # enabled = yes # virtual = no @@ -444,8 +444,6 @@ Per interface configuration: ![image6](https://cloud.githubusercontent.com/assets/2662304/14253733/53550b16-fa95-11e5-8d9d-4ed171df4735.gif) ---- - SYNPROXY is a TCP SYN packets proxy. It can be used to protect any TCP server (like a web server) from SYN floods and similar DDos attacks. SYNPROXY is a netfilter module, in the Linux kernel (since version 3.12). It is optimized to handle millions of packets per second utilizing all CPUs available without any concurrency locking between the connections. @@ -454,8 +452,8 @@ The net effect of this, is that the real servers will not notice any change duri Netdata does not enable SYNPROXY. It just uses the SYNPROXY metrics exposed by your kernel, so you will first need to configure it. The hard way is to run iptables SYNPROXY commands directly on the console. An easier way is to use [FireHOL](https://firehol.org/), which, is a firewall manager for iptables. FireHOL can configure SYNPROXY using the following setup guides: -- **[Working with SYNPROXY](https://github.com/firehol/firehol/wiki/Working-with-SYNPROXY)** -- **[Working with SYNPROXY and traps](https://github.com/firehol/firehol/wiki/Working-with-SYNPROXY-and-traps)** +- **[Working with SYNPROXY](https://github.com/firehol/firehol/wiki/Working-with-SYNPROXY)** +- **[Working with SYNPROXY and traps](https://github.com/firehol/firehol/wiki/Working-with-SYNPROXY-and-traps)** ### Real-time monitoring of Linux Anti-DDoS @@ -463,10 +461,10 @@ Netdata is able to monitor in real-time (per second updates) the operation of th It visualizes 4 charts: -1. TCP SYN Packets received on ports operated by SYNPROXY -2. TCP Cookies (valid, invalid, retransmits) -3. Connections Reopened -4. Entries used +1. TCP SYN Packets received on ports operated by SYNPROXY +2. TCP Cookies (valid, invalid, retransmits) +3. Connections Reopened +4. Entries used Example image: @@ -483,37 +481,37 @@ battery capacity. Depending on the underlying driver, it may provide the following charts and metrics: -1. Capacity: The power supply capacity expressed as a percentage. +1. Capacity: The power supply capacity expressed as a percentage. - - capacity_now + - capacity_now -2. Charge: The charge for the power supply, expressed as amphours. +2. Charge: The charge for the power supply, expressed as amp-hours. - - charge_full_design - - charge_full - - charge_now - - charge_empty - - charge_empty_design + - charge_full_design + - charge_full + - charge_now + - charge_empty + - charge_empty_design -3. Energy: The energy for the power supply, expressed as watthours. +3. Energy: The energy for the power supply, expressed as watthours. - - energy_full_design - - energy_full - - energy_now - - energy_empty - - energy_empty_design + - energy_full_design + - energy_full + - energy_now + - energy_empty + - energy_empty_design -4. Voltage: The voltage for the power supply, expressed as volts. +4. Voltage: The voltage for the power supply, expressed as volts. - - voltage_max_design - - voltage_max - - voltage_now - - voltage_min - - voltage_min_design + - voltage_max_design + - voltage_max + - voltage_now + - voltage_min + - voltage_min_design -#### configuration +### configuration -``` +```text [plugin:proc:/sys/class/power_supply] # battery capacity = yes # battery charge = no @@ -524,18 +522,18 @@ and metrics: # directory to monitor = /sys/class/power_supply ``` -#### notes +### notes -- Most drivers provide at least the first chart. Battery powered ACPI +- Most drivers provide at least the first chart. Battery powered ACPI compliant systems (like most laptops) provide all but the third, but do not provide all of the metrics for each chart. -- Current, energy, and voltages are reported with a *very* high precision +- Current, energy, and voltages are reported with a *very* high precision by the power_supply framework. Usually, this is far higher than the actual hardware supports reporting, so expect to see changes in these charts jump instead of scaling smoothly. -- If `max` or `full` attribute is defined by the driver, but not a +- If `max` or `full` attribute is defined by the driver, but not a corresponding `min` or `empty` attribute, then Netdata will still provide the corresponding `min` or `empty`, which will then always read as zero. This way, alerts which match on these will still work. @@ -548,17 +546,17 @@ This module monitors every active Infiniband port. It provides generic counters Each port will have its counters metrics monitored, grouped in the following charts: -- **Bandwidth usage** +- **Bandwidth usage** Sent/Received data, in KB/s -- **Packets Statistics** +- **Packets Statistics** Sent/Received packets, in 3 categories: total, unicast and multicast. -- **Errors Statistics** +- **Errors Statistics** Many errors counters are provided, presenting statistics for: - - Packets: malformed, sent/received discarded by card/switch, missing resource - - Link: downed, recovered, integrity error, minor error - - Other events: Tick Wait to send, buffer overrun + - Packets: malformed, sent/received discarded by card/switch, missing resource + - Link: downed, recovered, integrity error, minor error + - Other events: Tick Wait to send, buffer overrun If your vendor is supported, you'll also get HW-Counters statistics. These being vendor specific, please refer to their documentation. @@ -568,7 +566,7 @@ If your vendor is supported, you'll also get HW-Counters statistics. These being Default configuration will monitor only enabled infiniband ports, and refresh newly activated or created ports every 30 seconds -``` +```text [plugin:proc:/sys/class/infiniband] # dirname to monitor = /sys/class/infiniband # bandwidth counters = yes @@ -578,7 +576,7 @@ Default configuration will monitor only enabled infiniband ports, and refresh ne # hardware errors counters = auto # monitor only ports being active = auto # disable by default interfaces matching = - # refresh ports state every seconds = 30 + # refresh ports state every = 30s ``` ## AMD GPUs @@ -589,45 +587,46 @@ This module monitors every AMD GPU card discovered at agent startup. The following charts will be provided: -- **GPU utilization** -- **GPU memory utilization** -- **GPU clock frequency** -- **GPU memory clock frequency** -- **VRAM memory usage percentage** -- **VRAM memory usage** -- **visible VRAM memory usage percentage** -- **visible VRAM memory usage** -- **GTT memory usage percentage** -- **GTT memory usage** +- **GPU utilization** +- **GPU memory utilization** +- **GPU clock frequency** +- **GPU memory clock frequency** +- **VRAM memory usage percentage** +- **VRAM memory usage** +- **visible VRAM memory usage percentage** +- **visible VRAM memory usage** +- **GTT memory usage percentage** +- **GTT memory usage** ### configuration The `drm` path can be configured if it differs from the default: -``` +```text [plugin:proc:/sys/class/drm] # directory to monitor = /sys/class/drm ``` -> [!NOTE] -> Temperature, fan speed, voltage and power metrics for AMD GPUs can be monitored using the [Sensors](/src/collectors/charts.d.plugin/sensors/README.md) plugin. +> **Note** +> +> Temperature, fan speed, voltage and power metrics for AMD GPUs can be monitored using the [Sensors](/src/go/plugin/go.d/modules/sensors/README.md) plugin. ## IPC ### Monitored IPC metrics -- **number of messages in message queues** -- **amount of memory used by message queues** -- **number of semaphores** -- **number of semaphore arrays** -- **number of shared memory segments** -- **amount of memory used by shared memory segments** +- **number of messages in message queues** +- **amount of memory used by message queues** +- **number of semaphores** +- **number of semaphore arrays** +- **number of shared memory segments** +- **amount of memory used by shared memory segments** As far as the message queue charts are dynamic, sane limits are applied for the number of dimensions per chart (the limit is configurable). ### configuration -``` +```text [plugin:proc:ipc] # message queues = yes # semaphore totals = yes @@ -636,5 +635,3 @@ As far as the message queue charts are dynamic, sane limits are applied for the # shm filename to monitor = /proc/sysvipc/shm # max dimensions in memory allowed = 50 ``` - - diff --git a/src/collectors/proc.plugin/integrations/system_statistics.md b/src/collectors/proc.plugin/integrations/system_statistics.md index 0b6e38820..1381bdb1d 100644 --- a/src/collectors/proc.plugin/integrations/system_statistics.md +++ b/src/collectors/proc.plugin/integrations/system_statistics.md @@ -150,8 +150,8 @@ The file format is a modified INI syntax. The general structure is: [section2] option3 = some third value ``` -You can edit the configuration file using the `edit-config` script from the -Netdata [config directory](/docs/netdata-agent/configuration/README.md#the-netdata-config-directory). +You can edit the configuration file using the [`edit-config`](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#edit-a-configuration-file-using-edit-config) script from the +Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#the-netdata-config-directory). ```bash cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata diff --git a/src/collectors/proc.plugin/ipc.c b/src/collectors/proc.plugin/ipc.c index 5b47116b9..c280254ac 100644 --- a/src/collectors/proc.plugin/ipc.c +++ b/src/collectors/proc.plugin/ipc.c @@ -182,7 +182,7 @@ static inline int ipc_sem_get_status(struct ipc_status *st) { return 0; } -int ipc_msq_get_info(char *msg_filename, struct message_queue **message_queue_root) { +static int ipc_msq_get_info(const char *msg_filename, struct message_queue **message_queue_root) { static procfile *ff; struct message_queue *msq; @@ -238,7 +238,7 @@ int ipc_msq_get_info(char *msg_filename, struct message_queue **message_queue_ro return 0; } -int ipc_shm_get_info(char *shm_filename, struct shm_stats *shm) { +static int ipc_shm_get_info(const char *shm_filename, struct shm_stats *shm) { static procfile *ff; if(unlikely(!ff)) { @@ -287,10 +287,10 @@ int do_ipc(int update_every, usec_t dt) { static const RRDVAR_ACQUIRED *arrays_max = NULL, *semaphores_max = NULL; static RRDSET *st_arrays = NULL; static RRDDIM *rd_arrays = NULL; - static char *msg_filename = NULL; + static const char *msg_filename = NULL; static struct message_queue *message_queue_root = NULL; static long long dimensions_limit; - static char *shm_filename = NULL; + static const char *shm_filename = NULL; if(unlikely(do_sem == -1)) { do_msg = config_get_boolean("plugin:proc:ipc", "message queues", CONFIG_BOOLEAN_YES); diff --git a/src/collectors/proc.plugin/plugin_proc.c b/src/collectors/proc.plugin/plugin_proc.c index b4a856467..0a1903ca0 100644 --- a/src/collectors/proc.plugin/plugin_proc.c +++ b/src/collectors/proc.plugin/plugin_proc.c @@ -226,9 +226,8 @@ void *proc_main(void *ptr) worker_register_job_name(i, proc_modules[i].dim); } - usec_t step = localhost->rrd_update_every * USEC_PER_SEC; heartbeat_t hb; - heartbeat_init(&hb); + heartbeat_init(&hb, localhost->rrd_update_every * USEC_PER_SEC); inside_lxc_container = is_lxcfs_proc_mounted(); is_mem_swap_enabled = is_swap_enabled(); @@ -245,7 +244,7 @@ void *proc_main(void *ptr) while(service_running(SERVICE_COLLECTORS)) { worker_is_idle(); - usec_t hb_dt = heartbeat_next(&hb, step); + usec_t hb_dt = heartbeat_next(&hb); if(unlikely(!service_running(SERVICE_COLLECTORS))) break; @@ -279,7 +278,7 @@ int get_numa_node_count(void) char name[FILENAME_MAX + 1]; snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/node"); - char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name); + const char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name); DIR *dir = opendir(dirname); if (dir) { diff --git a/src/collectors/proc.plugin/proc_diskstats.c b/src/collectors/proc.plugin/proc_diskstats.c index 015a985cc..2c7320aa1 100644 --- a/src/collectors/proc.plugin/proc_diskstats.c +++ b/src/collectors/proc.plugin/proc_diskstats.c @@ -81,30 +81,25 @@ static struct disk { usec_t bcache_priority_stats_elapsed_usec; ND_DISK_IO disk_io; + ND_DISK_OPS disk_ops; + ND_DISK_QOPS disk_qops; + ND_DISK_UTIL disk_util; + ND_DISK_BUSY disk_busy; + ND_DISK_IOTIME disk_iotime; + ND_DISK_AWAIT disk_await; + ND_DISK_SVCTM disk_svctm; + ND_DISK_AVGSZ disk_avgsz; RRDSET *st_ext_io; RRDDIM *rd_io_discards; - RRDSET *st_ops; - RRDDIM *rd_ops_reads; - RRDDIM *rd_ops_writes; - RRDSET *st_ext_ops; RRDDIM *rd_ops_discards; RRDDIM *rd_ops_flushes; - RRDSET *st_qops; - RRDDIM *rd_qops_operations; - RRDSET *st_backlog; RRDDIM *rd_backlog_backlog; - RRDSET *st_busy; - RRDDIM *rd_busy_busy; - - RRDSET *st_util; - RRDDIM *rd_util_utilization; - RRDSET *st_mops; RRDDIM *rd_mops_reads; RRDDIM *rd_mops_writes; @@ -112,32 +107,17 @@ static struct disk { RRDSET *st_ext_mops; RRDDIM *rd_mops_discards; - RRDSET *st_iotime; - RRDDIM *rd_iotime_reads; - RRDDIM *rd_iotime_writes; - RRDSET *st_ext_iotime; RRDDIM *rd_iotime_discards; RRDDIM *rd_iotime_flushes; - RRDSET *st_await; - RRDDIM *rd_await_reads; - RRDDIM *rd_await_writes; - RRDSET *st_ext_await; RRDDIM *rd_await_discards; RRDDIM *rd_await_flushes; - RRDSET *st_avgsz; - RRDDIM *rd_avgsz_reads; - RRDDIM *rd_avgsz_writes; - RRDSET *st_ext_avgsz; RRDDIM *rd_avgsz_discards; - RRDSET *st_svctm; - RRDDIM *rd_svctm_svctm; - RRDSET *st_bcache_size; RRDDIM *rd_bcache_dirty_size; @@ -180,16 +160,16 @@ static struct disk { #define rrdset_obsolete_and_pointer_null(st) do { if(st) { rrdset_is_obsolete___safe_from_collector_thread(st); (st) = NULL; } } while(st) -static char *path_to_sys_dev_block_major_minor_string = NULL; -static char *path_to_sys_block_device = NULL; -static char *path_to_sys_block_device_bcache = NULL; -static char *path_to_sys_devices_virtual_block_device = NULL; -static char *path_to_device_mapper = NULL; -static char *path_to_dev_disk = NULL; -static char *path_to_sys_block = NULL; -static char *path_to_device_label = NULL; -static char *path_to_device_id = NULL; -static char *path_to_veritas_volume_groups = NULL; +static const char *path_to_sys_dev_block_major_minor_string = NULL; +static const char *path_to_sys_block_device = NULL; +static const char *path_to_sys_block_device_bcache = NULL; +static const char *path_to_sys_devices_virtual_block_device = NULL; +static const char *path_to_device_mapper = NULL; +static const char *path_to_dev_disk = NULL; +static const char *path_to_sys_block = NULL; +static const char *path_to_device_label = NULL; +static const char *path_to_device_id = NULL; +static const char *path_to_veritas_volume_groups = NULL; static int name_disks_by_id = CONFIG_BOOLEAN_NO; static int global_bcache_priority_stats_update_every = 0; // disabled by default @@ -998,7 +978,7 @@ static void disk_labels_cb(RRDSET *st, void *data) { add_labels_to_disk(data, st); } -static int diskstats_function_block_devices(BUFFER *wb, const char *function __maybe_unused) { +static int diskstats_function_block_devices(BUFFER *wb, const char *function __maybe_unused, BUFFER *payload __maybe_unused, const char *source __maybe_unused) { buffer_flush(wb); wb->content_type = CT_APPLICATION_JSON; buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT); @@ -1049,21 +1029,21 @@ static int diskstats_function_block_devices(BUFFER *wb, const char *function __m max_io = MAX(max_io, io_total); } // Backlog and Busy Time - double busy_perc = rrddim_get_last_stored_value(d->rd_util_utilization, &max_busy_perc, 1); - double busy_time = rrddim_get_last_stored_value(d->rd_busy_busy, &max_busy_time, 1); + double busy_perc = rrddim_get_last_stored_value(d->disk_util.rd_util, &max_busy_perc, 1); + double busy_time = rrddim_get_last_stored_value(d->disk_busy.rd_busy, &max_busy_time, 1); double backlog_time = rrddim_get_last_stored_value(d->rd_backlog_backlog, &max_backlog_time, 1); // IOPS - double iops_reads = rrddim_get_last_stored_value(d->rd_ops_reads, &max_iops_reads, 1); - double iops_writes = rrddim_get_last_stored_value(d->rd_ops_writes, &max_iops_writes, 1); + double iops_reads = rrddim_get_last_stored_value(d->disk_ops.rd_ops_reads, &max_iops_reads, 1); + double iops_writes = rrddim_get_last_stored_value(d->disk_ops.rd_ops_writes, &max_iops_writes, 1); // IO Time - double iops_time_reads = rrddim_get_last_stored_value(d->rd_iotime_reads, &max_iops_time_reads, 1); - double iops_time_writes = rrddim_get_last_stored_value(d->rd_iotime_writes, &max_iops_time_writes, 1); + double iops_time_reads = rrddim_get_last_stored_value(d->disk_iotime.rd_reads_ms, &max_iops_time_reads, 1); + double iops_time_writes = rrddim_get_last_stored_value(d->disk_iotime.rd_writes_ms, &max_iops_time_writes, 1); // Avg IO Time - double iops_avg_time_read = rrddim_get_last_stored_value(d->rd_await_reads, &max_iops_avg_time_read, 1); - double iops_avg_time_write = rrddim_get_last_stored_value(d->rd_await_writes, &max_iops_avg_time_write, 1); + double iops_avg_time_read = rrddim_get_last_stored_value(d->disk_await.rd_await_reads, &max_iops_avg_time_read, 1); + double iops_avg_time_write = rrddim_get_last_stored_value(d->disk_await.rd_await_writes, &max_iops_avg_time_write, 1); // Avg IO Size - double iops_avg_size_read = rrddim_get_last_stored_value(d->rd_avgsz_reads, &max_iops_avg_size_read, 1); - double iops_avg_size_write = rrddim_get_last_stored_value(d->rd_avgsz_writes, &max_iops_avg_size_write, 1); + double iops_avg_size_read = rrddim_get_last_stored_value(d->disk_avgsz.rd_avgsz_reads, &max_iops_avg_size_read, 1); + double iops_avg_size_write = rrddim_get_last_stored_value(d->disk_avgsz.rd_avgsz_writes, &max_iops_avg_size_write, 1); buffer_json_add_array_item_double(wb, io_reads); @@ -1287,23 +1267,25 @@ static void diskstats_cleanup_disks() { if (unlikely(global_cleanup_removed_disks && !d->updated)) { struct disk *t = d; - rrdset_obsolete_and_pointer_null(d->st_avgsz); + rrdset_obsolete_and_pointer_null(d->disk_io.st_io); + rrdset_obsolete_and_pointer_null(d->disk_ops.st_ops); + rrdset_obsolete_and_pointer_null(d->disk_qops.st_qops); + rrdset_obsolete_and_pointer_null(d->disk_util.st_util); + rrdset_obsolete_and_pointer_null(d->disk_busy.st_busy); + rrdset_obsolete_and_pointer_null(d->disk_iotime.st_iotime); + rrdset_obsolete_and_pointer_null(d->disk_await.st_await); + rrdset_obsolete_and_pointer_null(d->disk_svctm.st_svctm); + + rrdset_obsolete_and_pointer_null(d->disk_avgsz.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->disk_io.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); rrdset_obsolete_and_pointer_null(d->st_bcache); rrdset_obsolete_and_pointer_null(d->st_bcache_bypass); rrdset_obsolete_and_pointer_null(d->st_bcache_rates); @@ -1374,7 +1356,7 @@ int do_proc_diskstats(int update_every, usec_t dt) { global_do_ext = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "extended operations for all disks", global_do_ext); global_do_backlog = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "backlog for all disks", global_do_backlog); global_do_bcache = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bcache for all disks", global_do_bcache); - global_bcache_priority_stats_update_every = (int)config_get_number(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bcache priority stats update every", global_bcache_priority_stats_update_every); + global_bcache_priority_stats_update_every = (int)config_get_duration_seconds(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bcache priority stats update every", global_bcache_priority_stats_update_every); global_cleanup_removed_disks = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "remove charts of removed disks" , global_cleanup_removed_disks); @@ -1421,7 +1403,8 @@ int do_proc_diskstats(int update_every, usec_t dt) { SIMPLE_PATTERN_EXACT, true); rrd_function_add_inline(localhost, NULL, "block-devices", 10, - RRDFUNCTIONS_PRIORITY_DEFAULT, RRDFUNCTIONS_DISKSTATS_HELP, + RRDFUNCTIONS_PRIORITY_DEFAULT, RRDFUNCTIONS_VERSION_DEFAULT, + RRDFUNCTIONS_DISKSTATS_HELP, "top", HTTP_ACCESS_ANONYMOUS_DATA, diskstats_function_block_devices); } @@ -1453,18 +1436,17 @@ int do_proc_diskstats(int update_every, usec_t dt) { char *disk; unsigned long major = 0, minor = 0; - collected_number reads = 0, mreads = 0, readsectors = 0, readms = 0, - writes = 0, mwrites = 0, writesectors = 0, writems = 0, + collected_number rd_ios = 0, mreads = 0, readsectors = 0, readms = 0, wr_ios = 0, mwrites = 0, writesectors = 0, writems = 0, queued_ios = 0, busy_ms = 0, backlog_ms = 0, discards = 0, mdiscards = 0, discardsectors = 0, discardms = 0, flushes = 0, flushms = 0; - collected_number last_reads = 0, last_readsectors = 0, last_readms = 0, - last_writes = 0, last_writesectors = 0, last_writems = 0, - last_busy_ms = 0, - last_discards = 0, last_discardsectors = 0, last_discardms = 0, - last_flushes = 0, last_flushms = 0; + collected_number last_rd_ios = 0, last_readsectors = 0, last_readms = 0, + last_wr_ios = 0, last_writesectors = 0, last_writems = 0, + last_busy_ms = 0, + last_discards = 0, last_discardsectors = 0, last_discardms = 0, + last_flushes = 0, last_flushms = 0; size_t words = procfile_linewords(ff, l); if(unlikely(words < 14)) continue; @@ -1475,8 +1457,8 @@ int do_proc_diskstats(int update_every, usec_t dt) { // # of reads completed # of writes completed // This is the total number of reads or writes completed successfully. - reads = str2ull(procfile_lineword(ff, l, 3), NULL); // rd_ios - writes = str2ull(procfile_lineword(ff, l, 7), NULL); // wr_ios + rd_ios = str2ull(procfile_lineword(ff, l, 3), NULL); // rd_ios + wr_ios = str2ull(procfile_lineword(ff, l, 7), NULL); // wr_ios // # of reads merged # of writes merged // Reads and writes which are adjacent to each other may be merged for @@ -1615,33 +1597,15 @@ int do_proc_diskstats(int update_every, usec_t dt) { if (d->do_ops == CONFIG_BOOLEAN_YES || d->do_ops == CONFIG_BOOLEAN_AUTO) { d->do_ops = CONFIG_BOOLEAN_YES; - if(unlikely(!d->st_ops)) { - d->st_ops = rrdset_create_localhost( - "disk_ops" - , d->chart_id - , d->disk - , family - , "disk.ops" - , "Disk Completed I/O Operations" - , "operations/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_OPS - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(d->st_ops, RRDSET_FLAG_DETAIL); - - d->rd_ops_reads = rrddim_add(d->st_ops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - d->rd_ops_writes = rrddim_add(d->st_ops, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - - add_labels_to_disk(d, d->st_ops); - } + last_rd_ios = d->disk_ops.rd_ops_reads ? d->disk_ops.rd_ops_reads->collector.last_collected_value : 0; + last_wr_ios = d->disk_ops.rd_ops_writes ? d->disk_ops.rd_ops_writes->collector.last_collected_value : 0; - 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); + common_disk_ops(&d->disk_ops, + d->chart_id, + d->disk, rd_ios, wr_ios, + update_every, + disk_labels_cb, + d); } if (do_dc_stats && d->do_ops == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { @@ -1661,8 +1625,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_ext_ops, RRDSET_FLAG_DETAIL); - d->rd_ops_discards = rrddim_add(d->st_ext_ops, "discards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); if (do_fl_stats) d->rd_ops_flushes = rrddim_add(d->st_ext_ops, "flushes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1679,31 +1641,14 @@ int do_proc_diskstats(int update_every, usec_t dt) { if (d->do_qops == CONFIG_BOOLEAN_YES || d->do_qops == CONFIG_BOOLEAN_AUTO) { d->do_qops = CONFIG_BOOLEAN_YES; - if(unlikely(!d->st_qops)) { - d->st_qops = rrdset_create_localhost( - "disk_qops" - , d->chart_id - , d->disk - , family - , "disk.qops" - , "Disk Current I/O Operations" - , "operations" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_QOPS - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(d->st_qops, RRDSET_FLAG_DETAIL); - - d->rd_qops_operations = rrddim_add(d->st_qops, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - - add_labels_to_disk(d, d->st_qops); - } - - rrddim_set_by_pointer(d->st_qops, d->rd_qops_operations, queued_ios); - rrdset_done(d->st_qops); + common_disk_qops( + &d->disk_qops, + d->chart_id, + d->disk, + queued_ios, + update_every, + disk_labels_cb, + d); } if (d->do_backlog == CONFIG_BOOLEAN_YES || d->do_backlog == CONFIG_BOOLEAN_AUTO) { @@ -1725,8 +1670,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_AREA ); - rrdset_flag_set(d->st_backlog, RRDSET_FLAG_DETAIL); - d->rd_backlog_backlog = rrddim_add(d->st_backlog, "backlog", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); add_labels_to_disk(d, d->st_backlog); @@ -1739,61 +1682,28 @@ int do_proc_diskstats(int update_every, usec_t dt) { if (d->do_util == CONFIG_BOOLEAN_YES || d->do_util == CONFIG_BOOLEAN_AUTO) { d->do_util = CONFIG_BOOLEAN_YES; - if(unlikely(!d->st_busy)) { - d->st_busy = rrdset_create_localhost( - "disk_busy" - , d->chart_id - , d->disk - , family - , "disk.busy" - , "Disk Busy Time" - , "milliseconds" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_BUSY - , update_every - , RRDSET_TYPE_AREA - ); - - rrdset_flag_set(d->st_busy, RRDSET_FLAG_DETAIL); - - d->rd_busy_busy = rrddim_add(d->st_busy, "busy", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - - add_labels_to_disk(d, 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->chart_id - , d->disk - , family - , "disk.util" - , "Disk Utilization Time" - , "% of time working" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_UTIL - , update_every - , RRDSET_TYPE_AREA - ); - - rrdset_flag_set(d->st_util, RRDSET_FLAG_DETAIL); + last_busy_ms = d->disk_busy.rd_busy ? d->disk_busy.rd_busy->collector.last_collected_value : 0; - d->rd_util_utilization = rrddim_add(d->st_util, "utilization", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - - add_labels_to_disk(d, d->st_util); - } + common_disk_busy(&d->disk_busy, + d->chart_id, + d->disk, + busy_ms, + update_every, + disk_labels_cb, + d); collected_number disk_utilization = (busy_ms - last_busy_ms) / (10 * update_every); if (disk_utilization > 100) disk_utilization = 100; - rrddim_set_by_pointer(d->st_util, d->rd_util_utilization, disk_utilization); - rrdset_done(d->st_util); + common_disk_util(&d->disk_util, + d->chart_id, + d->disk, + disk_utilization, + update_every, + disk_labels_cb, + d); + } if (d->do_mops == CONFIG_BOOLEAN_YES || d->do_mops == CONFIG_BOOLEAN_AUTO) { @@ -1815,8 +1725,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_mops, RRDSET_FLAG_DETAIL); - d->rd_mops_reads = rrddim_add(d->st_mops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_mops_writes = rrddim_add(d->st_mops, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1847,8 +1755,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_ext_mops, RRDSET_FLAG_DETAIL); - d->rd_mops_discards = rrddim_add(d->st_ext_mops, "discards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); add_labels_to_disk(d, d->st_ext_mops); @@ -1861,33 +1767,18 @@ int do_proc_diskstats(int update_every, usec_t dt) { if (d->do_iotime == CONFIG_BOOLEAN_YES || d->do_iotime == CONFIG_BOOLEAN_AUTO) { d->do_iotime = CONFIG_BOOLEAN_YES; - if(unlikely(!d->st_iotime)) { - d->st_iotime = rrdset_create_localhost( - "disk_iotime" - , d->chart_id - , d->disk - , family - , "disk.iotime" - , "Disk Total I/O Time" - , "milliseconds/s" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_IOTIME - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(d->st_iotime, RRDSET_FLAG_DETAIL); - - d->rd_iotime_reads = rrddim_add(d->st_iotime, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - d->rd_iotime_writes = rrddim_add(d->st_iotime, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - - add_labels_to_disk(d, 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); + last_readms = d->disk_iotime.rd_reads_ms ? d->disk_iotime.rd_reads_ms->collector.last_collected_value : 0; + last_writems = d->disk_iotime.rd_writes_ms ? d->disk_iotime.rd_writes_ms->collector.last_collected_value : 0; + + common_disk_iotime( + &d->disk_iotime, + d->chart_id, + d->disk, + readms, + writems, + update_every, + disk_labels_cb, + d); } if(do_dc_stats && d->do_iotime == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { @@ -1907,8 +1798,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_ext_iotime, RRDSET_FLAG_DETAIL); - d->rd_iotime_discards = rrddim_add(d->st_ext_iotime, "discards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); if (do_fl_stats) d->rd_iotime_flushes = rrddim_add(d->st_ext_iotime, "flushes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1928,36 +1817,19 @@ int do_proc_diskstats(int update_every, usec_t dt) { if(likely(dt)) { if ((d->do_iotime == CONFIG_BOOLEAN_YES || d->do_iotime == CONFIG_BOOLEAN_AUTO) && (d->do_ops == CONFIG_BOOLEAN_YES || d->do_ops == CONFIG_BOOLEAN_AUTO)) { - if(unlikely(!d->st_await)) { - d->st_await = rrdset_create_localhost( - "disk_await" - , d->chart_id - , d->disk - , family - , "disk.await" - , "Average Completed I/O Operation Time" - , "milliseconds/operation" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_AWAIT - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(d->st_await, RRDSET_FLAG_DETAIL); - - d->rd_await_reads = rrddim_add(d->st_await, "reads", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); - d->rd_await_writes = rrddim_add(d->st_await, "writes", NULL, -1, 1000, RRD_ALGORITHM_ABSOLUTE); - - add_labels_to_disk(d, d->st_await); - } - double read_avg = (reads - last_reads) ? (double)(readms - last_readms) / (reads - last_reads) : 0; - double write_avg = (writes - last_writes) ? (double)(writems - last_writems) / (writes - last_writes) : 0; - - rrddim_set_by_pointer(d->st_await, d->rd_await_reads, (collected_number)(read_avg * 1000)); - rrddim_set_by_pointer(d->st_await, d->rd_await_writes, (collected_number)(write_avg * 1000)); - rrdset_done(d->st_await); + double read_ms_avg = (rd_ios - last_rd_ios) ? (double)(readms - last_readms) / (rd_ios - last_rd_ios) : 0; + double write_ms_avg = (wr_ios - last_wr_ios) ? (double)(writems - last_writems) / (wr_ios - last_wr_ios) : 0; + + common_disk_await( + &d->disk_await, + d->chart_id, + d->disk, + read_ms_avg, + write_ms_avg, + update_every, + disk_labels_cb, + d); } if (do_dc_stats && d->do_iotime == CONFIG_BOOLEAN_YES && d->do_ops == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { @@ -1977,8 +1849,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_ext_await, RRDSET_FLAG_DETAIL); - d->rd_await_discards = rrddim_add(d->st_ext_await, "discards", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); if (do_fl_stats) d->rd_await_flushes = rrddim_add(d->st_ext_await, "flushes", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); @@ -2001,33 +1871,19 @@ int do_proc_diskstats(int update_every, usec_t dt) { if ((d->do_io == CONFIG_BOOLEAN_YES || d->do_io == CONFIG_BOOLEAN_AUTO) && (d->do_ops == CONFIG_BOOLEAN_YES || d->do_ops == CONFIG_BOOLEAN_AUTO)) { - if(unlikely(!d->st_avgsz)) { - d->st_avgsz = rrdset_create_localhost( - "disk_avgsz" - , d->chart_id - , d->disk - , family - , "disk.avgsz" - , "Average Completed I/O Operation Bandwidth" - , "KiB/operation" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_AVGSZ - , update_every - , RRDSET_TYPE_AREA - ); - - rrdset_flag_set(d->st_avgsz, RRDSET_FLAG_DETAIL); - - d->rd_avgsz_reads = rrddim_add(d->st_avgsz, "reads", NULL, SECTOR_SIZE, 1024, RRD_ALGORITHM_ABSOLUTE); - d->rd_avgsz_writes = rrddim_add(d->st_avgsz, "writes", NULL, SECTOR_SIZE * -1, 1024, RRD_ALGORITHM_ABSOLUTE); - - add_labels_to_disk(d, 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); - rrdset_done(d->st_avgsz); + kernel_uint_t avg_read_bytes = SECTOR_SIZE * ((rd_ios - last_rd_ios) ? (readsectors - last_readsectors) / (rd_ios - last_rd_ios) : 0); + kernel_uint_t avg_write_bytes = SECTOR_SIZE * ((wr_ios - last_wr_ios) ? (writesectors - last_writesectors) / (wr_ios - last_wr_ios) : 0); + + common_disk_avgsz( + &d->disk_avgsz, + d->chart_id, + d->disk, + avg_read_bytes, + avg_write_bytes, + update_every, + disk_labels_cb, + d); } if(do_dc_stats && d->do_io == CONFIG_BOOLEAN_YES && d->do_ops == CONFIG_BOOLEAN_YES && d->do_ext != CONFIG_BOOLEAN_NO) { @@ -2047,8 +1903,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_AREA ); - rrdset_flag_set(d->st_ext_avgsz, RRDSET_FLAG_DETAIL); - d->rd_avgsz_discards = rrddim_add(d->st_ext_avgsz, "discards", NULL, SECTOR_SIZE, 1024, RRD_ALGORITHM_ABSOLUTE); add_labels_to_disk(d, d->st_ext_avgsz); @@ -2063,36 +1917,20 @@ int do_proc_diskstats(int update_every, usec_t dt) { if ((d->do_util == CONFIG_BOOLEAN_YES || d->do_util == CONFIG_BOOLEAN_AUTO) && (d->do_ops == CONFIG_BOOLEAN_YES || d->do_ops == CONFIG_BOOLEAN_AUTO)) { - if(unlikely(!d->st_svctm)) { - d->st_svctm = rrdset_create_localhost( - "disk_svctm" - , d->chart_id - , d->disk - , family - , "disk.svctm" - , "Average Service Time" - , "milliseconds/operation" - , PLUGIN_PROC_NAME - , PLUGIN_PROC_MODULE_DISKSTATS_NAME - , NETDATA_CHART_PRIO_DISK_SVCTM - , update_every - , RRDSET_TYPE_LINE - ); - - rrdset_flag_set(d->st_svctm, RRDSET_FLAG_DETAIL); - - d->rd_svctm_svctm = rrddim_add(d->st_svctm, "svctm", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); - - add_labels_to_disk(d, d->st_svctm); - } double svctm_avg = - ((reads - last_reads) + (writes - last_writes)) ? - (double)(busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : + ((rd_ios - last_rd_ios) + (wr_ios - last_wr_ios)) ? + (double) (busy_ms - last_busy_ms) / ((rd_ios - last_rd_ios) + (wr_ios - last_wr_ios)) : 0; - rrddim_set_by_pointer(d->st_svctm, d->rd_svctm_svctm, (collected_number)(svctm_avg * 1000)); - rrdset_done(d->st_svctm); + common_disk_svctm( + &d->disk_svctm, + d->chart_id, + d->disk, + svctm_avg, + update_every, + disk_labels_cb, + d); } } @@ -2331,8 +2169,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_bcache, RRDSET_FLAG_DETAIL); - d->rd_bcache_hits = rrddim_add(d->st_bcache, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_bcache_misses = rrddim_add(d->st_bcache, "misses", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_bcache_miss_collisions = rrddim_add(d->st_bcache, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -2365,8 +2201,6 @@ int do_proc_diskstats(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_bcache_bypass, RRDSET_FLAG_DETAIL); - d->rd_bcache_bypass_hits = rrddim_add(d->st_bcache_bypass, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_bcache_bypass_misses = rrddim_add(d->st_bcache_bypass, "misses", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); diff --git a/src/collectors/proc.plugin/proc_mdstat.c b/src/collectors/proc.plugin/proc_mdstat.c index 3857d9ec4..47c4f0d2b 100644 --- a/src/collectors/proc.plugin/proc_mdstat.c +++ b/src/collectors/proc.plugin/proc_mdstat.c @@ -89,7 +89,7 @@ int do_proc_mdstat(int update_every, usec_t dt) static int do_health = -1, do_nonredundant = -1, do_disks = -1, do_operations = -1, do_mismatch = -1, do_mismatch_config = -1; static int make_charts_obsolete = -1; - static char *mdstat_filename = NULL, *mismatch_cnt_filename = NULL; + static const char *mdstat_filename = NULL, *mismatch_cnt_filename = NULL; static struct raid *raids = NULL; static size_t raids_allocated = 0; size_t raids_num = 0, raid_idx = 0, redundant_num = 0; diff --git a/src/collectors/proc.plugin/proc_meminfo.c b/src/collectors/proc.plugin/proc_meminfo.c index 781329b59..de3f42329 100644 --- a/src/collectors/proc.plugin/proc_meminfo.c +++ b/src/collectors/proc.plugin/proc_meminfo.c @@ -347,8 +347,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_mem_hwcorrupt, RRDSET_FLAG_DETAIL); - rd_corrupted = rrddim_add(st_mem_hwcorrupt, "HardwareCorrupted", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } @@ -376,8 +374,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_AREA ); - rrdset_flag_set(st_mem_committed, RRDSET_FLAG_DETAIL); - rd_committed = rrddim_add(st_mem_committed, "Committed_AS", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); } @@ -404,7 +400,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_mem_writeback, RRDSET_FLAG_DETAIL); rd_dirty = rrddim_add(st_mem_writeback, "Dirty", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_writeback = rrddim_add(st_mem_writeback, "Writeback", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); @@ -444,8 +439,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); - rrdset_flag_set(st_mem_kernel, RRDSET_FLAG_DETAIL); - rd_slab = rrddim_add(st_mem_kernel, "Slab", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_kernelstack = rrddim_add(st_mem_kernel, "KernelStack", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_pagetables = rrddim_add(st_mem_kernel, "PageTables", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); @@ -484,8 +477,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); - rrdset_flag_set(st_mem_slab, RRDSET_FLAG_DETAIL); - 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); } @@ -518,8 +509,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); - rrdset_flag_set(st_mem_hugepages, RRDSET_FLAG_DETAIL); - rd_free = rrddim_add(st_mem_hugepages, "free", NULL, Hugepagesize, 1024, RRD_ALGORITHM_ABSOLUTE); rd_used = rrddim_add(st_mem_hugepages, "used", NULL, Hugepagesize, 1024, RRD_ALGORITHM_ABSOLUTE); rd_surp = rrddim_add(st_mem_hugepages, "surplus", NULL, Hugepagesize, 1024, RRD_ALGORITHM_ABSOLUTE); @@ -555,8 +544,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); - rrdset_flag_set(st_mem_transparent_hugepages, RRDSET_FLAG_DETAIL); - 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); } @@ -585,8 +572,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_mem_thp_details, RRDSET_FLAG_DETAIL); - rd_shmem_pmd_mapped = rrddim_add(st_mem_thp_details, "shmem_pmd", "ShmemPmdMapped", 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_file_huge_pages = rrddim_add(st_mem_thp_details, "file", "FileHugePages", 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_file_pmd_mapped = rrddim_add(st_mem_thp_details, "file_pmd", "FilePmdMapped", 1, 1024, RRD_ALGORITHM_ABSOLUTE); @@ -622,8 +607,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_mem_reclaiming, RRDSET_FLAG_DETAIL); - rd_active = rrddim_add(st_mem_reclaiming, "active", "Active", 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_inactive = rrddim_add(st_mem_reclaiming, "inactive", "Inactive", 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_active_anon = rrddim_add(st_mem_reclaiming, "active_anon", "Active(anon)", 1, 1024, RRD_ALGORITHM_ABSOLUTE); @@ -667,8 +650,6 @@ int do_proc_meminfo(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); - rrdset_flag_set(st_mem_high_low, RRDSET_FLAG_DETAIL); - rd_high_used = rrddim_add(st_mem_high_low, "high_used", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_low_used = rrddim_add(st_mem_high_low, "low_used", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); rd_high_free = rrddim_add(st_mem_high_low, "high_free", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); diff --git a/src/collectors/proc.plugin/proc_net_dev.c b/src/collectors/proc.plugin/proc_net_dev.c index 41c10ddbc..3af59aed1 100644 --- a/src/collectors/proc.plugin/proc_net_dev.c +++ b/src/collectors/proc.plugin/proc_net_dev.c @@ -251,6 +251,8 @@ static struct netdev { // ---------------------------------------------------------------------------- static void netdev_charts_release(struct netdev *d) { + rrdvar_chart_variable_release(d->st_bandwidth, d->chart_var_speed); + if(d->st_bandwidth) rrdset_is_obsolete___safe_from_collector_thread(d->st_bandwidth); if(d->st_packets) rrdset_is_obsolete___safe_from_collector_thread(d->st_packets); if(d->st_errors) rrdset_is_obsolete___safe_from_collector_thread(d->st_errors); @@ -472,7 +474,7 @@ static void netdev_rename_this_device(struct netdev *d) { // ---------------------------------------------------------------------------- -int netdev_function_net_interfaces(BUFFER *wb, const char *function __maybe_unused) { +static int netdev_function_net_interfaces(BUFFER *wb, const char *function __maybe_unused, BUFFER *payload __maybe_unused, const char *source __maybe_unused) { buffer_flush(wb); wb->content_type = CT_APPLICATION_JSON; buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT); @@ -1279,8 +1281,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_speed, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_speed, d->chart_labels); d->rd_speed = rrddim_add(d->st_speed, "speed", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -1319,8 +1319,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_duplex, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_duplex, d->chart_labels); d->rd_duplex_full = rrddim_add(d->st_duplex, "full", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -1351,8 +1349,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_operstate, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_operstate, d->chart_labels); d->rd_operstate_up = rrddim_add(d->st_operstate, "up", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -1391,8 +1387,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_carrier, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_carrier, d->chart_labels); d->rd_carrier_up = rrddim_add(d->st_carrier, "up", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -1421,8 +1415,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_mtu, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_mtu, d->chart_labels); d->rd_mtu = rrddim_add(d->st_mtu, "mtu", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -1450,8 +1442,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_packets, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_packets, d->chart_labels); d->rd_rpackets = rrddim_add(d->st_packets, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1491,8 +1481,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_errors, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_errors, d->chart_labels); d->rd_rerrors = rrddim_add(d->st_errors, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1530,8 +1518,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_drops, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_drops, d->chart_labels); d->rd_rdrops = rrddim_add(d->st_drops, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1569,8 +1555,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_fifo, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_fifo, d->chart_labels); d->rd_rfifo = rrddim_add(d->st_fifo, "receive", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1608,8 +1592,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_compressed, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_compressed, d->chart_labels); d->rd_rcompressed = rrddim_add(d->st_compressed, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1647,8 +1629,6 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(d->st_events, RRDSET_FLAG_DETAIL); - rrdset_update_rrdlabels(d->st_events, d->chart_labels); d->rd_rframe = rrddim_add(d->st_events, "frames", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1721,17 +1701,17 @@ void *netdev_main(void *ptr_is_null __maybe_unused) virtual_device_collect_delay_secs = 300; rrd_function_add_inline(localhost, NULL, "network-interfaces", 10, - RRDFUNCTIONS_PRIORITY_DEFAULT, RRDFUNCTIONS_NETDEV_HELP, + RRDFUNCTIONS_PRIORITY_DEFAULT, RRDFUNCTIONS_VERSION_DEFAULT, + RRDFUNCTIONS_NETDEV_HELP, "top", HTTP_ACCESS_ANONYMOUS_DATA, netdev_function_net_interfaces); - usec_t step = localhost->rrd_update_every * USEC_PER_SEC; heartbeat_t hb; - heartbeat_init(&hb); + heartbeat_init(&hb, localhost->rrd_update_every * USEC_PER_SEC); while (service_running(SERVICE_COLLECTORS)) { worker_is_idle(); - usec_t hb_dt = heartbeat_next(&hb, step); + usec_t hb_dt = heartbeat_next(&hb); if (unlikely(!service_running(SERVICE_COLLECTORS))) break; diff --git a/src/collectors/proc.plugin/proc_net_netstat.c b/src/collectors/proc.plugin/proc_net_netstat.c index da7a28fa7..6689a057f 100644 --- a/src/collectors/proc.plugin/proc_net_netstat.c +++ b/src/collectors/proc.plugin/proc_net_netstat.c @@ -465,7 +465,6 @@ static void do_proc_net_snmp6(int update_every) { , 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); @@ -501,7 +500,6 @@ static void do_proc_net_snmp6(int update_every) { , 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); @@ -544,7 +542,6 @@ static void do_proc_net_snmp6(int update_every) { , 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); @@ -624,7 +621,6 @@ static void do_proc_net_snmp6(int update_every) { , 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); @@ -697,7 +693,6 @@ static void do_proc_net_snmp6(int update_every) { , 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); @@ -735,7 +730,6 @@ static void do_proc_net_snmp6(int update_every) { , update_every , RRDSET_TYPE_AREA ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_Ip6InMcastOctets = rrddim_add(st, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rd_Ip6OutMcastOctets = rrddim_add(st, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); @@ -767,7 +761,6 @@ static void do_proc_net_snmp6(int update_every) { , update_every , RRDSET_TYPE_AREA ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_Ip6InBcastOctets = rrddim_add(st, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rd_Ip6OutBcastOctets = rrddim_add(st, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); @@ -799,7 +792,6 @@ static void do_proc_net_snmp6(int update_every) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_Ip6InMcastPkts = rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_Ip6OutMcastPkts = rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1781,8 +1773,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , RRDSET_TYPE_AREA ); - rrdset_flag_set(st_ip_mcast, RRDSET_FLAG_DETAIL); - rd_in = rrddim_add(st_ip_mcast, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_ip_mcast, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); } @@ -1817,8 +1807,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , RRDSET_TYPE_AREA ); - rrdset_flag_set(st_ip_bcast, RRDSET_FLAG_DETAIL); - rd_in = rrddim_add(st_ip_bcast, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_ip_bcast, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); } @@ -1853,8 +1841,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_ip_mcastpkts, RRDSET_FLAG_DETAIL); - rd_in = rrddim_add(st_ip_mcastpkts, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_ip_mcastpkts, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } @@ -1886,8 +1872,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_ip_bcastpkts, RRDSET_FLAG_DETAIL); - rd_in = rrddim_add(st_ip_bcastpkts, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_out = rrddim_add(st_ip_bcastpkts, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); } @@ -1919,8 +1903,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); @@ -2241,7 +2223,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); @@ -2277,7 +2258,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); @@ -2319,7 +2299,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); @@ -2596,7 +2575,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); @@ -2631,7 +2609,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); @@ -2666,7 +2643,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); @@ -2744,7 +2720,6 @@ int do_proc_net_netstat(int update_every, usec_t dt) { , 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); diff --git a/src/collectors/proc.plugin/proc_net_rpc_nfs.c b/src/collectors/proc.plugin/proc_net_rpc_nfs.c index d6547636e..da3243bad 100644 --- a/src/collectors/proc.plugin/proc_net_rpc_nfs.c +++ b/src/collectors/proc.plugin/proc_net_rpc_nfs.c @@ -296,8 +296,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { , RRDSET_TYPE_STACKED ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - rd_udp = rrddim_add(st, "udp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_tcp = rrddim_add(st, "tcp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } @@ -332,7 +330,6 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_calls = rrddim_add(st, "calls", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_retransmits = rrddim_add(st, "retransmits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); diff --git a/src/collectors/proc.plugin/proc_net_rpc_nfsd.c b/src/collectors/proc.plugin/proc_net_rpc_nfsd.c index 1d9127a03..82d74b6a9 100644 --- a/src/collectors/proc.plugin/proc_net_rpc_nfsd.c +++ b/src/collectors/proc.plugin/proc_net_rpc_nfsd.c @@ -501,7 +501,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_stale = rrddim_add(st, "stale", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); } @@ -587,7 +586,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_STACKED ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_udp = rrddim_add(st, "udp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_tcp = rrddim_add(st, "tcp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -623,7 +621,6 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_calls = rrddim_add(st, "calls", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_bad_format = rrddim_add(st, "bad_format", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); diff --git a/src/collectors/proc.plugin/proc_net_sctp_snmp.c b/src/collectors/proc.plugin/proc_net_sctp_snmp.c index 4a3d5c912..1987ff7a1 100644 --- a/src/collectors/proc.plugin/proc_net_sctp_snmp.c +++ b/src/collectors/proc.plugin/proc_net_sctp_snmp.c @@ -214,7 +214,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_received = rrddim_add(st, "SctpInSCTPPacks", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_sent = rrddim_add(st, "SctpOutSCTPPacks", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -248,7 +247,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_invalid = rrddim_add(st, "SctpOutOfBlues", "invalid", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_csum = rrddim_add(st, "SctpChecksumErrors", "checksum", 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -282,7 +280,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { , NETDATA_CHART_PRIO_SCTP + 40 , update_every , RRDSET_TYPE_LINE); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_reassembled = rrddim_add(st, "SctpReasmUsrMsgs", "reassembled", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_fragmented = rrddim_add(st, "SctpFragUsrMsgs", "fragmented", -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -321,7 +318,6 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_InCtrl = rrddim_add(st, "SctpInCtrlChunks", "InCtrl", 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_InOrder = rrddim_add(st, "SctpInOrderChunks", "InOrder", 1, 1, RRD_ALGORITHM_INCREMENTAL); diff --git a/src/collectors/proc.plugin/proc_net_sockstat.c b/src/collectors/proc.plugin/proc_net_sockstat.c index da8682b51..185eb4e5a 100644 --- a/src/collectors/proc.plugin/proc_net_sockstat.c +++ b/src/collectors/proc.plugin/proc_net_sockstat.c @@ -128,7 +128,7 @@ int do_proc_net_sockstat(int update_every, usec_t dt) { do_frag_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG sockets", CONFIG_BOOLEAN_AUTO); do_frag_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG memory", CONFIG_BOOLEAN_AUTO); - update_constants_every = config_get_number("plugin:proc:/proc/net/sockstat", "update constants every", update_constants_every); + update_constants_every = config_get_duration_seconds("plugin:proc:/proc/net/sockstat", "update constants every", update_constants_every); update_constants_count = update_constants_every; arl_sockets = arl_create("sockstat/sockets", arl_callback_str2kernel_uint_t, 60); diff --git a/src/collectors/proc.plugin/proc_net_stat_conntrack.c b/src/collectors/proc.plugin/proc_net_stat_conntrack.c index 6951cba79..cb1c8837d 100644 --- a/src/collectors/proc.plugin/proc_net_stat_conntrack.c +++ b/src/collectors/proc.plugin/proc_net_stat_conntrack.c @@ -11,7 +11,7 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { static int do_sockets = -1, do_new = -1, do_changes = -1, do_expect = -1, do_search = -1, do_errors = -1; 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 const char *nf_conntrack_filename, *nf_conntrack_count_filename, *nf_conntrack_max_filename; 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, @@ -217,7 +217,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_inserted = rrddim_add(st, "inserted", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_deleted = rrddim_add(st, "deleted", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -253,7 +252,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_created = rrddim_add(st, "created", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_deleted = rrddim_add(st, "deleted", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -289,7 +287,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_searched = rrddim_add(st, "searched", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_restarted = rrddim_add(st, "restarted", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -326,7 +323,6 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); rd_icmp_error = rrddim_add(st, "icmp_error", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_insert_failed = rrddim_add(st, "insert_failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); diff --git a/src/collectors/proc.plugin/proc_net_wireless.c b/src/collectors/proc.plugin/proc_net_wireless.c index c7efa3335..f5556a942 100644 --- a/src/collectors/proc.plugin/proc_net_wireless.c +++ b/src/collectors/proc.plugin/proc_net_wireless.c @@ -208,7 +208,7 @@ int do_proc_net_wireless(int update_every, usec_t dt) UNUSED(dt); static procfile *ff = NULL; static int do_status, do_quality = -1, do_discarded_packets, do_beacon; - static char *proc_net_wireless_filename = NULL; + static const char *proc_net_wireless_filename = NULL; if (unlikely(do_quality == -1)) { char filename[FILENAME_MAX + 1]; @@ -264,8 +264,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(wireless_dev->st_status, RRDSET_FLAG_DETAIL); - wireless_dev->rd_status = rrddim_add(wireless_dev->st_status, "status", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); add_labels_to_wireless(wireless_dev, wireless_dev->st_status); @@ -295,7 +293,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) NETDATA_CHART_PRIO_WIRELESS_IFACE + 1, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(wireless_dev->st_link, RRDSET_FLAG_DETAIL); wireless_dev->rd_link = rrddim_add(wireless_dev->st_link, "link_quality", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -316,7 +313,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) NETDATA_CHART_PRIO_WIRELESS_IFACE + 2, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(wireless_dev->st_level, RRDSET_FLAG_DETAIL); wireless_dev->rd_level = rrddim_add(wireless_dev->st_level, "signal_level", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -337,7 +333,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) NETDATA_CHART_PRIO_WIRELESS_IFACE + 3, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(wireless_dev->st_noise, RRDSET_FLAG_DETAIL); wireless_dev->rd_noise = rrddim_add(wireless_dev->st_noise, "noise_level", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); @@ -376,8 +371,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(wireless_dev->st_discarded_packets, RRDSET_FLAG_DETAIL); - wireless_dev->rd_nwid = rrddim_add(wireless_dev->st_discarded_packets, "nwid", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); wireless_dev->rd_crypt = rrddim_add(wireless_dev->st_discarded_packets, "crypt", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); wireless_dev->rd_frag = rrddim_add(wireless_dev->st_discarded_packets, "frag", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -414,8 +407,6 @@ int do_proc_net_wireless(int update_every, usec_t dt) update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(wireless_dev->st_missed_beacon, RRDSET_FLAG_DETAIL); - wireless_dev->rd_missed_beacon = rrddim_add(wireless_dev->st_missed_beacon, "missed_beacons", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); add_labels_to_wireless(wireless_dev, wireless_dev->st_missed_beacon); diff --git a/src/collectors/proc.plugin/proc_pressure.c b/src/collectors/proc.plugin/proc_pressure.c index 4037e60ac..c4d4bc2b1 100644 --- a/src/collectors/proc.plugin/proc_pressure.c +++ b/src/collectors/proc.plugin/proc_pressure.c @@ -158,7 +158,7 @@ int do_proc_pressure(int update_every, usec_t dt) { int i; static usec_t next_pressure_dt = 0; - static char *base_path = NULL; + static const char *base_path = NULL; update_every = (update_every < MIN_PRESSURE_UPDATE_EVERY) ? MIN_PRESSURE_UPDATE_EVERY : update_every; pressure_update_every = update_every; @@ -170,9 +170,8 @@ int do_proc_pressure(int update_every, usec_t dt) { return 0; } - if (unlikely(!base_path)) { + if (unlikely(!base_path)) base_path = config_get(CONFIG_SECTION_PLUGIN_PROC_PRESSURE, "base path of pressure metrics", "/proc/pressure"); - } for (i = 0; i < PRESSURE_NUM_RESOURCES; i++) { procfile *ff = resource_info[i].pf; diff --git a/src/collectors/proc.plugin/proc_spl_kstat_zfs.c b/src/collectors/proc.plugin/proc_spl_kstat_zfs.c index 5a0f90951..9286479c9 100644 --- a/src/collectors/proc.plugin/proc_spl_kstat_zfs.c +++ b/src/collectors/proc.plugin/proc_spl_kstat_zfs.c @@ -18,7 +18,7 @@ int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) { static int do_zfs_stats = 0; static procfile *ff = NULL; - static char *dirname = NULL; + static const char *dirname = NULL; static ARL_BASE *arl_base = NULL; arcstats.l2exist = -1; diff --git a/src/collectors/proc.plugin/proc_stat.c b/src/collectors/proc.plugin/proc_stat.c index c211ceee5..b36f6b867 100644 --- a/src/collectors/proc.plugin/proc_stat.c +++ b/src/collectors/proc.plugin/proc_stat.c @@ -293,7 +293,7 @@ static void* wake_cpu_thread(void* core) { return 0; } -static int read_schedstat(char *schedstat_filename, struct per_core_cpuidle_chart **cpuidle_charts_address, size_t *schedstat_cores_found) { +static int read_schedstat(const char *schedstat_filename, struct per_core_cpuidle_chart **cpuidle_charts_address, size_t *schedstat_cores_found) { static size_t cpuidle_charts_len = 0; static procfile *ff = NULL; struct per_core_cpuidle_chart *cpuidle_charts = *cpuidle_charts_address; @@ -373,7 +373,7 @@ static int read_one_state(char *buf, const char *filename, int *fd) { return 1; } -static int read_cpuidle_states(char *cpuidle_name_filename , char *cpuidle_time_filename, struct per_core_cpuidle_chart *cpuidle_charts, size_t core) { +static int read_cpuidle_states(const char *cpuidle_name_filename, const char *cpuidle_time_filename, struct per_core_cpuidle_chart *cpuidle_charts, size_t core) { char filename[FILENAME_MAX + 1]; static char next_state_filename[FILENAME_MAX + 1]; struct stat stbuf; @@ -484,7 +484,7 @@ int do_proc_stat(int update_every, usec_t dt) { static int do_cpu = -1, do_cpu_cores = -1, do_interrupts = -1, do_context = -1, do_forks = -1, do_processes = -1, do_core_throttle_count = -1, do_package_throttle_count = -1, do_cpu_freq = -1, do_cpuidle = -1; 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, + static const 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 const RRDVAR_ACQUIRED *cpus_var = NULL; static int accurate_freq_avail = 0, accurate_freq_is_used = 0; @@ -794,7 +794,6 @@ int do_proc_stat(int update_every, usec_t dt) { , update_every , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_forks, RRDSET_FLAG_DETAIL); rd_started = rrddim_add(st_forks, "started", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } diff --git a/src/collectors/proc.plugin/proc_uptime.c b/src/collectors/proc.plugin/proc_uptime.c index ddab7269b..7471171ed 100644 --- a/src/collectors/proc.plugin/proc_uptime.c +++ b/src/collectors/proc.plugin/proc_uptime.c @@ -5,7 +5,7 @@ int do_proc_uptime(int update_every, usec_t dt) { (void)dt; - static char *uptime_filename = NULL; + static const char *uptime_filename = NULL; if(!uptime_filename) { char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/uptime"); diff --git a/src/collectors/proc.plugin/proc_vmstat.c b/src/collectors/proc.plugin/proc_vmstat.c index 050086689..e38e9b678 100644 --- a/src/collectors/proc.plugin/proc_vmstat.c +++ b/src/collectors/proc.plugin/proc_vmstat.c @@ -355,8 +355,6 @@ int do_proc_vmstat(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_oom_kill, RRDSET_FLAG_DETAIL); - rd_oom_kill = rrddim_add(st_oom_kill, "kills", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } @@ -397,8 +395,6 @@ int do_proc_vmstat(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdset_flag_set(st_numa, RRDSET_FLAG_DETAIL); - // These depend on CONFIG_NUMA in the kernel. rd_local = rrddim_add(st_numa, "local", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); rd_foreign = rrddim_add(st_numa, "foreign", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); diff --git a/src/collectors/proc.plugin/sys_class_drm.c b/src/collectors/proc.plugin/sys_class_drm.c index ab4d98a72..0622274a0 100644 --- a/src/collectors/proc.plugin/sys_class_drm.c +++ b/src/collectors/proc.plugin/sys_class_drm.c @@ -837,7 +837,7 @@ int do_sys_class_drm(int update_every, usec_t dt) { if(unlikely(!drm_dir)) { char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/class/drm"); - char *drm_dir_name = config_get(CONFIG_SECTION_PLUGIN_PROC_DRM, "directory to monitor", filename); + const char *drm_dir_name = config_get(CONFIG_SECTION_PLUGIN_PROC_DRM, "directory to monitor", filename); if(unlikely(NULL == (drm_dir = opendir(drm_dir_name)))){ collector_error("Cannot read directory '%s'", drm_dir_name); return 1; diff --git a/src/collectors/proc.plugin/sys_class_infiniband.c b/src/collectors/proc.plugin/sys_class_infiniband.c index ff1652ddf..34a126c5e 100644 --- a/src/collectors/proc.plugin/sys_class_infiniband.c +++ b/src/collectors/proc.plugin/sys_class_infiniband.c @@ -302,7 +302,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) static int initialized = 0; static int enable_new_ports = -1, enable_only_active = CONFIG_BOOLEAN_YES; static int do_bytes = -1, do_packets = -1, do_errors = -1, do_hwpackets = -1, do_hwerrors = -1; - static char *sys_class_infiniband_dirname = NULL; + static const char *sys_class_infiniband_dirname = NULL; static long long int dt_to_refresh_ports = 0, last_refresh_ports_usec = 0; @@ -332,7 +332,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) SIMPLE_PATTERN_EXACT, true); dt_to_refresh_ports = - config_get_number(CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "refresh ports state every seconds", 30) * + config_get_duration_seconds(CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "refresh ports state every", 30) * USEC_PER_SEC; if (dt_to_refresh_ports < 0) dt_to_refresh_ports = 0; @@ -538,8 +538,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) port->priority + 1, update_every, RRDSET_TYPE_AREA); - // Create Dimensions - rrdset_flag_set(port->st_bytes, RRDSET_FLAG_DETAIL); + // On this chart, we want to have a KB/s so the dashboard will autoscale it // The reported values are also per-lane, so we must multiply it by the width // x4 lanes multiplier as per Documentation/ABI/stable/sysfs-class-infiniband @@ -576,8 +575,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) port->priority + 2, update_every, RRDSET_TYPE_AREA); - // Create Dimensions - rrdset_flag_set(port->st_packets, RRDSET_FLAG_DETAIL); + FOREACH_COUNTER_PACKETS(GEN_RRD_DIM_ADD, port) } @@ -605,8 +603,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) port->priority + 3, update_every, RRDSET_TYPE_LINE); - // Create Dimensions - rrdset_flag_set(port->st_errors, RRDSET_FLAG_DETAIL); + FOREACH_COUNTER_ERRORS(GEN_RRD_DIM_ADD, port) } @@ -641,8 +638,6 @@ int do_sys_class_infiniband(int update_every, usec_t dt) update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(port->st_hwerrors, RRDSET_FLAG_DETAIL); - // VENDORS: Set your selection // VENDOR: Mellanox @@ -677,8 +672,6 @@ int do_sys_class_infiniband(int update_every, usec_t dt) update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(port->st_hwpackets, RRDSET_FLAG_DETAIL); - // VENDORS: Set your selection // VENDOR: Mellanox diff --git a/src/collectors/proc.plugin/sys_class_power_supply.c b/src/collectors/proc.plugin/sys_class_power_supply.c index c6be72679..7e4dda777 100644 --- a/src/collectors/proc.plugin/sys_class_power_supply.c +++ b/src/collectors/proc.plugin/sys_class_power_supply.c @@ -199,7 +199,7 @@ int do_sys_class_power_supply(int update_every, usec_t dt) { (void)dt; static int do_capacity = -1, do_power = -1, do_property[3] = {-1}; static int keep_fds_open = CONFIG_BOOLEAN_NO, keep_fds_open_config = -1; - static char *dirname = NULL; + static const char *dirname = NULL; if(unlikely(do_capacity == -1)) { do_capacity = config_get_boolean("plugin:proc:/sys/class/power_supply", "battery capacity", CONFIG_BOOLEAN_YES); diff --git a/src/collectors/proc.plugin/sys_devices_pci_aer.c b/src/collectors/proc.plugin/sys_devices_pci_aer.c index 563ebf051..c39795ea1 100644 --- a/src/collectors/proc.plugin/sys_devices_pci_aer.c +++ b/src/collectors/proc.plugin/sys_devices_pci_aer.c @@ -2,7 +2,7 @@ #include "plugin_proc.h" -static char *pci_aer_dirname = NULL; +static const char *pci_aer_dirname = NULL; typedef enum __attribute__((packed)) { AER_DEV_NONFATAL = (1 << 0), diff --git a/src/collectors/proc.plugin/sys_devices_system_edac_mc.c b/src/collectors/proc.plugin/sys_devices_system_edac_mc.c index d3db8c044..93ee235cf 100644 --- a/src/collectors/proc.plugin/sys_devices_system_edac_mc.c +++ b/src/collectors/proc.plugin/sys_devices_system_edac_mc.c @@ -37,7 +37,7 @@ struct mc { }; static struct mc *mc_root = NULL; -static char *mc_dirname = NULL; +static const char *mc_dirname = NULL; static void find_all_mc() { char name[FILENAME_MAX + 1]; diff --git a/src/collectors/proc.plugin/sys_devices_system_node.c b/src/collectors/proc.plugin/sys_devices_system_node.c index 12f31a04e..9bc3703fa 100644 --- a/src/collectors/proc.plugin/sys_devices_system_node.c +++ b/src/collectors/proc.plugin/sys_devices_system_node.c @@ -4,22 +4,35 @@ struct node { char *name; - char *numastat_filename; - procfile *numastat_ff; - RRDSET *numastat_st; + + struct { + char *filename; + procfile *ff; + RRDSET *st; + } numastat; + + struct { + char *filename; + procfile *ff; + RRDSET *st_mem_usage; + RRDSET *st_mem_activity; + } meminfo; + struct node *next; }; static struct node *numa_root = NULL; +static int numa_node_count = 0; static int find_all_nodes() { int numa_node_count = 0; char name[FILENAME_MAX + 1]; snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/node"); - char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name); + const char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name); DIR *dir = opendir(dirname); if(!dir) { - collector_error("Cannot read NUMA node directory '%s'", dirname); + nd_log( + NDLS_COLLECTORS, errno == ENOENT ? NDLP_INFO : NDLP_ERR, "Cannot read NUMA node directory '%s'", dirname); return 0; } @@ -47,8 +60,16 @@ static int find_all_nodes() { freez(m); continue; } + m->numastat.filename = strdupz(name); - m->numastat_filename = strdupz(name); + snprintfz(name, FILENAME_MAX, "%s/%s/meminfo", dirname, de->d_name); + if(stat(name, &st) == -1) { + freez(m->numastat.filename); + freez(m->name); + freez(m); + continue; + } + m->meminfo.filename = strdupz(name); m->next = numa_root; numa_root = m; @@ -59,22 +80,12 @@ static int find_all_nodes() { return numa_node_count; } -int do_proc_sys_devices_system_node(int update_every, usec_t dt) { - (void)dt; - +static void do_muma_numastat(struct node *m, int update_every) { static uint32_t hash_local_node = 0, hash_numa_foreign = 0, hash_interleave_hit = 0, hash_other_node = 0, hash_numa_hit = 0, hash_numa_miss = 0; - static int do_numastat = -1, numa_node_count = 0; - struct node *m; - - if(unlikely(numa_root == NULL)) { - numa_node_count = find_all_nodes(); - if(unlikely(numa_root == NULL)) - return 1; - } - - if(unlikely(do_numastat == -1)) { - do_numastat = config_get_boolean_ondemand("plugin:proc:/sys/devices/system/node", "enable per-node numa metrics", CONFIG_BOOLEAN_AUTO); + static bool initialized = false; + if(unlikely(!initialized)) { + initialized = true; hash_local_node = simple_hash("local_node"); hash_numa_foreign = simple_hash("numa_foreign"); hash_interleave_hit = simple_hash("interleave_hit"); @@ -83,82 +94,205 @@ int do_proc_sys_devices_system_node(int update_every, usec_t dt) { hash_numa_miss = simple_hash("numa_miss"); } - if (do_numastat == CONFIG_BOOLEAN_YES || (do_numastat == CONFIG_BOOLEAN_AUTO && numa_node_count >= 2)) { - for(m = numa_root; m; m = m->next) { - if(m->numastat_filename) { - - if(unlikely(!m->numastat_ff)) { - m->numastat_ff = procfile_open(m->numastat_filename, " ", PROCFILE_FLAG_DEFAULT); - - if(unlikely(!m->numastat_ff)) - continue; - } - - m->numastat_ff = procfile_readall(m->numastat_ff); - if(unlikely(!m->numastat_ff || procfile_lines(m->numastat_ff) < 1 || procfile_linewords(m->numastat_ff, 0) < 1)) - continue; - - if(unlikely(!m->numastat_st)) { - m->numastat_st = rrdset_create_localhost( - "mem" - , m->name - , NULL - , "numa" - , "mem.numa_nodes" - , "NUMA events" - , "events/s" - , PLUGIN_PROC_NAME - , "/sys/devices/system/node" - , NETDATA_CHART_PRIO_MEM_NUMA_NODES - , update_every - , RRDSET_TYPE_LINE - ); - - rrdlabels_add(m->numastat_st->rrdlabels, "numa_node", m->name, RRDLABEL_SRC_AUTO); - - rrdset_flag_set(m->numastat_st, RRDSET_FLAG_DETAIL); - - rrddim_add(m->numastat_st, "numa_hit", "hit", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(m->numastat_st, "numa_miss", "miss", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(m->numastat_st, "local_node", "local", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(m->numastat_st, "numa_foreign", "foreign", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(m->numastat_st, "interleave_hit", "interleave", 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(m->numastat_st, "other_node", "other", 1, 1, RRD_ALGORITHM_INCREMENTAL); - - } - - size_t lines = procfile_lines(m->numastat_ff), l; - for(l = 0; l < lines; l++) { - size_t words = procfile_linewords(m->numastat_ff, l); - - if(unlikely(words < 2)) { - if(unlikely(words)) - collector_error("Cannot read %s numastat line %zu. Expected 2 params, read %zu.", m->name, l, words); - continue; - } - - char *name = procfile_lineword(m->numastat_ff, l, 0); - char *value = procfile_lineword(m->numastat_ff, l, 1); - - if (unlikely(!name || !*name || !value || !*value)) - continue; - - uint32_t hash = simple_hash(name); - if(likely( - (hash == hash_numa_hit && !strcmp(name, "numa_hit")) - || (hash == hash_numa_miss && !strcmp(name, "numa_miss")) - || (hash == hash_local_node && !strcmp(name, "local_node")) - || (hash == hash_numa_foreign && !strcmp(name, "numa_foreign")) - || (hash == hash_interleave_hit && !strcmp(name, "interleave_hit")) - || (hash == hash_other_node && !strcmp(name, "other_node")) - )) - rrddim_set(m->numastat_st, name, (collected_number)str2kernel_uint_t(value)); - } - - rrdset_done(m->numastat_st); + if (m->numastat.filename) { + if(unlikely(!m->numastat.ff)) { + m->numastat.ff = procfile_open(m->numastat.filename, " ", PROCFILE_FLAG_DEFAULT); + + if(unlikely(!m->numastat.ff)) + return; + } + + m->numastat.ff = procfile_readall(m->numastat.ff); + if(unlikely(!m->numastat.ff || procfile_lines(m->numastat.ff) < 1 || procfile_linewords(m->numastat.ff, 0) < 1)) + return; + + if(unlikely(!m->numastat.st)) { + m->numastat.st = rrdset_create_localhost( + "numa_node_stat" + , m->name + , NULL + , "numa" + , "mem.numa_node_stat" + , "NUMA Node Memory Allocation Events" + , "events/s" + , PLUGIN_PROC_NAME + , "/sys/devices/system/node" + , NETDATA_CHART_PRIO_MEM_NUMA_NODES_NUMASTAT + , update_every + , RRDSET_TYPE_LINE + ); + + rrdlabels_add(m->numastat.st->rrdlabels, "numa_node", m->name, RRDLABEL_SRC_AUTO); + + rrddim_add(m->numastat.st, "numa_hit", "hit", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rrddim_add(m->numastat.st, "numa_miss", "miss", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rrddim_add(m->numastat.st, "local_node", "local", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rrddim_add(m->numastat.st, "numa_foreign", "foreign", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rrddim_add(m->numastat.st, "interleave_hit", "interleave", 1, 1, RRD_ALGORITHM_INCREMENTAL); + rrddim_add(m->numastat.st, "other_node", "other", 1, 1, RRD_ALGORITHM_INCREMENTAL); + + } + + size_t lines = procfile_lines(m->numastat.ff), l; + for(l = 0; l < lines; l++) { + size_t words = procfile_linewords(m->numastat.ff, l); + + if(unlikely(words < 2)) { + if(unlikely(words)) + collector_error("Cannot read %s line %zu. Expected 2 params, read %zu.", m->numastat.filename, l, words); + continue; + } + + char *name = procfile_lineword(m->numastat.ff, l, 0); + char *value = procfile_lineword(m->numastat.ff, l, 1); + + if (unlikely(!name || !*name || !value || !*value)) + continue; + + uint32_t hash = simple_hash(name); + + if ((hash == hash_numa_hit && !strcmp(name, "numa_hit")) || + (hash == hash_numa_miss && !strcmp(name, "numa_miss")) || + (hash == hash_local_node && !strcmp(name, "local_node")) || + (hash == hash_numa_foreign && !strcmp(name, "numa_foreign")) || + (hash == hash_interleave_hit && !strcmp(name, "interleave_hit")) || + (hash == hash_other_node && !strcmp(name, "other_node"))) { + rrddim_set(m->numastat.st, name, (collected_number)str2kernel_uint_t(value)); + } + } + + rrdset_done(m->numastat.st); + } +} + +static void do_numa_meminfo(struct node *m, int update_every) { + static uint32_t hash_MemFree = 0, hash_MemUsed = 0, hash_ActiveAnon = 0, hash_InactiveAnon = 0, hash_ActiveFile = 0, + hash_InactiveFile = 0; + static bool initialized = false; + + if (unlikely(!initialized)) { + initialized = true; + hash_MemFree = simple_hash("MemFree"); + hash_MemUsed = simple_hash("MemUsed"); + hash_ActiveAnon = simple_hash("Active(anon)"); + hash_InactiveAnon = simple_hash("Inactive(anon)"); + hash_ActiveFile = simple_hash("Active(file)"); + hash_InactiveFile = simple_hash("Inactive(file)"); + } + + if (m->meminfo.filename) { + if (unlikely(!m->meminfo.ff)) { + m->meminfo.ff = procfile_open(m->meminfo.filename, " :", PROCFILE_FLAG_DEFAULT); + if (unlikely(!m->meminfo.ff)) + return; + } + + m->meminfo.ff = procfile_readall(m->meminfo.ff); + if (unlikely(!m->meminfo.ff || procfile_lines(m->meminfo.ff) < 1 || procfile_linewords(m->meminfo.ff, 0) < 1)) + return; + + if (unlikely(!m->meminfo.st_mem_usage)) { + m->meminfo.st_mem_usage = rrdset_create_localhost( + "numa_node_mem_usage", + m->name, + NULL, + "numa", + "mem.numa_node_mem_usage", + "NUMA Node Memory Usage", + "bytes", + PLUGIN_PROC_NAME, + "/sys/devices/system/node", + NETDATA_CHART_PRIO_MEM_NUMA_NODES_MEMINFO, + update_every, + RRDSET_TYPE_STACKED); + + rrdlabels_add(m->meminfo.st_mem_usage->rrdlabels, "numa_node", m->name, RRDLABEL_SRC_AUTO); + + rrddim_add(m->meminfo.st_mem_usage, "MemFree", "free", 1, 1, RRD_ALGORITHM_ABSOLUTE); + rrddim_add(m->meminfo.st_mem_usage, "MemUsed", "used", 1, 1, RRD_ALGORITHM_ABSOLUTE); + } + if (unlikely(!m->meminfo.st_mem_activity)) { + m->meminfo.st_mem_activity = rrdset_create_localhost( + "numa_node_mem_activity", + m->name, + NULL, + "numa", + "mem.numa_node_mem_activity", + "NUMA Node Memory Activity", + "bytes", + PLUGIN_PROC_NAME, + "/sys/devices/system/node", + NETDATA_CHART_PRIO_MEM_NUMA_NODES_ACTIVITY, + update_every, + RRDSET_TYPE_STACKED); + + rrdlabels_add(m->meminfo.st_mem_activity->rrdlabels, "numa_node", m->name, RRDLABEL_SRC_AUTO); + + rrddim_add(m->meminfo.st_mem_activity, "Active(anon)", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + rrddim_add(m->meminfo.st_mem_activity, "Inactive(anon)", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + rrddim_add(m->meminfo.st_mem_activity, "Active(file)", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + rrddim_add(m->meminfo.st_mem_activity, "Inactive(file)", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + } + + size_t lines = procfile_lines(m->meminfo.ff), l; + for (l = 0; l < lines; l++) { + size_t words = procfile_linewords(m->meminfo.ff, l); + + if (unlikely(words < 4)) { + if (words) + collector_error( + "Cannot read %s line %zu. Expected 4 params, read %zu.", m->meminfo.filename, l, words); + continue; } + + char *name = procfile_lineword(m->meminfo.ff, l, 2); + char *value = procfile_lineword(m->meminfo.ff, l, 3); + + if (unlikely(!name || !*name || !value || !*value)) + continue; + + uint32_t hash = simple_hash(name); + + if ((hash == hash_MemFree && !strcmp(name, "MemFree")) || + (hash == hash_MemUsed && !strcmp(name, "MemUsed"))) { + rrddim_set(m->meminfo.st_mem_usage, name, (collected_number)str2kernel_uint_t(value) * 1024); + } else if ( + (hash == hash_ActiveAnon && !strcmp(name, "Active(anon)")) || + (hash == hash_InactiveAnon && !strcmp(name, "Inactive(anon)")) || + (hash == hash_ActiveFile && !strcmp(name, "Active(file)")) || + (hash == hash_InactiveFile && !strcmp(name, "Inactive(file)"))) { + rrddim_set(m->meminfo.st_mem_activity, name, (collected_number)str2kernel_uint_t(value) * 1024); + } + } + rrdset_done(m->meminfo.st_mem_usage); + rrdset_done(m->meminfo.st_mem_activity); + } +} + +int do_proc_sys_devices_system_node(int update_every, usec_t dt) { + (void)dt; + struct node *m; + + static int do_numastat = -1; + + if(unlikely(do_numastat == -1)) { + do_numastat = config_get_boolean_ondemand( + "plugin:proc:/sys/devices/system/node", "enable per-node numa metrics", CONFIG_BOOLEAN_AUTO); + } + + if(unlikely(numa_root == NULL)) { + numa_node_count = find_all_nodes(); + if(unlikely(numa_root == NULL)) + return 1; + } + + if (do_numastat == CONFIG_BOOLEAN_YES || (do_numastat == CONFIG_BOOLEAN_AUTO && numa_node_count >= 2)) { + for (m = numa_root; m; m = m->next) { + do_muma_numastat(m, update_every); + do_numa_meminfo(m, update_every); } + return 0; } - return 0; + return 1; } diff --git a/src/collectors/proc.plugin/sys_fs_btrfs.c b/src/collectors/proc.plugin/sys_fs_btrfs.c index bf9b002bc..f51461146 100644 --- a/src/collectors/proc.plugin/sys_fs_btrfs.c +++ b/src/collectors/proc.plugin/sys_fs_btrfs.c @@ -270,8 +270,8 @@ static inline int find_btrfs_disks(BTRFS_NODE *node, const char *path) { DIR *dir = opendir(path); if (!dir) { - if(!node->logged_error) { - collector_error("BTRFS: Cannot open directory '%s'.", path); + if (!node->logged_error) { + nd_log(NDLS_COLLECTORS, errno == ENOENT ? NDLP_INFO : NDLP_ERR, "BTRFS: Cannot open directory '%s'.", path); node->logged_error = 1; } return 1; @@ -374,8 +374,8 @@ static inline int find_btrfs_devices(BTRFS_NODE *node, const char *path) { DIR *dir = opendir(path); if (!dir) { - if(!node->logged_error) { - collector_error("BTRFS: Cannot open directory '%s'.", path); + if (!node->logged_error) { + nd_log(NDLS_COLLECTORS, errno == ENOENT ? NDLP_INFO : NDLP_ERR, "BTRFS: Cannot open directory '%s'.", path); node->logged_error = 1; } return 1; @@ -474,8 +474,8 @@ static inline int find_all_btrfs_pools(const char *path, int update_every) { DIR *dir = opendir(path); if (!dir) { - if(!logged_error) { - collector_error("BTRFS: Cannot open directory '%s'.", path); + if (!logged_error) { + nd_log(NDLS_COLLECTORS, errno == ENOENT ? NDLP_INFO : NDLP_ERR, "BTRFS: Cannot open directory '%s'.", path); logged_error = 1; } return 1; @@ -678,7 +678,7 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) { , do_error_stats = CONFIG_BOOLEAN_AUTO; static usec_t refresh_delta = 0, refresh_every = 60 * USEC_PER_SEC; - static char *btrfs_path = NULL; + static const char *btrfs_path = NULL; (void)dt; @@ -689,7 +689,7 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) { snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/fs/btrfs"); btrfs_path = config_get("plugin:proc:/sys/fs/btrfs", "path to monitor", filename); - refresh_every = config_get_number("plugin:proc:/sys/fs/btrfs", "check for btrfs changes every", refresh_every / USEC_PER_SEC) * USEC_PER_SEC; + refresh_every = config_get_duration_seconds("plugin:proc:/sys/fs/btrfs", "check for btrfs changes every", refresh_every / USEC_PER_SEC) * USEC_PER_SEC; refresh_delta = refresh_every; do_allocation_disks = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "physical disks allocation", do_allocation_disks); |