summaryrefslogtreecommitdiffstats
path: root/collectors/diskspace.plugin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
commitd079b656b4719739b2247dcd9d46e9bec793095a (patch)
treed2c950c70a776bcf697c963151c5bd959f8a9f03 /collectors/diskspace.plugin
parentReleasing debian version 1.37.1-2. (diff)
downloadnetdata-d079b656b4719739b2247dcd9d46e9bec793095a.tar.xz
netdata-d079b656b4719739b2247dcd9d46e9bec793095a.zip
Merging upstream version 1.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/diskspace.plugin')
-rw-r--r--collectors/diskspace.plugin/README.md10
-rw-r--r--collectors/diskspace.plugin/plugin_diskspace.c77
2 files changed, 45 insertions, 42 deletions
diff --git a/collectors/diskspace.plugin/README.md b/collectors/diskspace.plugin/README.md
index c037a0b16..6d1ec7ca2 100644
--- a/collectors/diskspace.plugin/README.md
+++ b/collectors/diskspace.plugin/README.md
@@ -1,7 +1,11 @@
<!--
-title: "diskspace.plugin"
+title: "Monitor disk (diskspace.plugin)"
description: "Monitor the disk usage space of mounted disks in real-time with the Netdata Agent, plus preconfigured alarms for disks at risk of filling up."
-custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/diskspace.plugin/README.md
+custom_edit_url: "https://github.com/netdata/netdata/edit/master/collectors/diskspace.plugin/README.md"
+sidebar_label: "Disks"
+learn_status: "Published"
+learn_topic_type: "References"
+learn_rel_path: "References/Collectors references/System metrics"
-->
# diskspace.plugin
@@ -38,6 +42,6 @@ Charts can be enabled/disabled for every mount separately:
# inodes usage = auto
```
-> for disks performance monitoring, see the `proc` plugin, [here](/collectors/proc.plugin/README.md#monitoring-disks)
+> for disks performance monitoring, see the `proc` plugin, [here](https://github.com/netdata/netdata/blob/master/collectors/proc.plugin/README.md#monitoring-disks)
diff --git a/collectors/diskspace.plugin/plugin_diskspace.c b/collectors/diskspace.plugin/plugin_diskspace.c
index e806a3360..743612ffb 100644
--- a/collectors/diskspace.plugin/plugin_diskspace.c
+++ b/collectors/diskspace.plugin/plugin_diskspace.c
@@ -3,7 +3,6 @@
#include "../proc.plugin/plugin_proc.h"
#define PLUGIN_DISKSPACE_NAME "diskspace.plugin"
-#define THREAD_DISKSPACE_SLOW_NAME "PLUGIN[diskspace slow]"
#define DEFAULT_EXCLUDED_PATHS "/proc/* /sys/* /var/run/user/* /run/user/* /snap/* /var/lib/docker/*"
#define DEFAULT_EXCLUDED_FILESYSTEMS "*gvfs *gluster* *s3fs *ipfs *davfs2 *httpfs *sshfs *gdfs *moosefs fusectl autofs"
@@ -182,7 +181,7 @@ static void calculate_values_and_show_charts(
#ifdef NETDATA_INTERNAL_CHECKS
if(unlikely(btotal != bavail + breserved_root + bused))
- error("DISKSPACE: disk block statistics for '%s' (disk '%s') do not sum up: total = %llu, available = %llu, reserved = %llu, used = %llu", mi->mount_point, disk, (unsigned long long)btotal, (unsigned long long)bavail, (unsigned long long)breserved_root, (unsigned long long)bused);
+ collector_error("DISKSPACE: disk block statistics for '%s' (disk '%s') do not sum up: total = %llu, available = %llu, reserved = %llu, used = %llu", mi->mount_point, disk, (unsigned long long)btotal, (unsigned long long)bavail, (unsigned long long)breserved_root, (unsigned long long)bused);
#endif
// --------------------------------------------------------------------------
@@ -201,7 +200,7 @@ static void calculate_values_and_show_charts(
#ifdef NETDATA_INTERNAL_CHECKS
if(unlikely(btotal != bavail + breserved_root + bused))
- error("DISKSPACE: disk inode statistics for '%s' (disk '%s') do not sum up: total = %llu, available = %llu, reserved = %llu, used = %llu", mi->mount_point, disk, (unsigned long long)ftotal, (unsigned long long)favail, (unsigned long long)freserved_root, (unsigned long long)fused);
+ collector_error("DISKSPACE: disk inode statistics for '%s' (disk '%s') do not sum up: total = %llu, available = %llu, reserved = %llu, used = %llu", mi->mount_point, disk, (unsigned long long)ftotal, (unsigned long long)favail, (unsigned long long)freserved_root, (unsigned long long)fused);
#endif
int rendered = 0;
@@ -320,7 +319,7 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
, SIMPLE_PATTERN_EXACT
);
- dict_mountpoints = dictionary_create(DICT_OPTION_NONE);
+ dict_mountpoints = dictionary_create_advanced(DICT_OPTION_NONE, &dictionary_stats_category_collectors, 0);
}
struct mount_point_metadata *m = dictionary_get(dict_mountpoints, mi->mount_point);
@@ -349,23 +348,23 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
struct stat bs;
if(stat(mi->mount_point, &bs) == -1) {
- error("DISKSPACE: Cannot stat() mount point '%s' (disk '%s', filesystem '%s', root '%s')."
- , mi->mount_point
- , disk
- , mi->filesystem?mi->filesystem:""
- , mi->root?mi->root:""
- );
+ collector_error("DISKSPACE: Cannot stat() mount point '%s' (disk '%s', filesystem '%s', root '%s')."
+ , mi->mount_point
+ , disk
+ , mi->filesystem?mi->filesystem:""
+ , mi->root?mi->root:""
+ );
def_space = CONFIG_BOOLEAN_NO;
def_inodes = CONFIG_BOOLEAN_NO;
}
else {
if((bs.st_mode & S_IFMT) != S_IFDIR) {
- error("DISKSPACE: Mount point '%s' (disk '%s', filesystem '%s', root '%s') is not a directory."
- , mi->mount_point
- , disk
- , mi->filesystem?mi->filesystem:""
- , mi->root?mi->root:""
- );
+ collector_error("DISKSPACE: Mount point '%s' (disk '%s', filesystem '%s', root '%s') is not a directory."
+ , mi->mount_point
+ , disk
+ , mi->filesystem?mi->filesystem:""
+ , mi->root?mi->root:""
+ );
def_space = CONFIG_BOOLEAN_NO;
def_inodes = CONFIG_BOOLEAN_NO;
}
@@ -431,12 +430,12 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
if (statvfs(mi->mount_point, &buff_statvfs) < 0) {
if(!m->shown_error) {
- error("DISKSPACE: failed to statvfs() mount point '%s' (disk '%s', filesystem '%s', root '%s')"
- , mi->mount_point
- , disk
- , mi->filesystem?mi->filesystem:""
- , mi->root?mi->root:""
- );
+ collector_error("DISKSPACE: failed to statvfs() mount point '%s' (disk '%s', filesystem '%s', root '%s')"
+ , mi->mount_point
+ , disk
+ , mi->filesystem?mi->filesystem:""
+ , mi->root?mi->root:""
+ );
m->shown_error = 1;
}
return;
@@ -464,12 +463,12 @@ static inline void do_slow_disk_space_stats(struct basic_mountinfo *mi, int upda
struct statvfs buff_statvfs;
if (statvfs(mi->mount_point, &buff_statvfs) < 0) {
if(!m->shown_error) {
- error("DISKSPACE: failed to statvfs() mount point '%s' (disk '%s', filesystem '%s', root '%s')"
- , mi->mount_point
- , mi->persistent_id
- , mi->filesystem?mi->filesystem:""
- , mi->root?mi->root:""
- );
+ collector_error("DISKSPACE: failed to statvfs() mount point '%s' (disk '%s', filesystem '%s', root '%s')"
+ , mi->mount_point
+ , mi->persistent_id
+ , mi->filesystem?mi->filesystem:""
+ , mi->root?mi->root:""
+ );
m->shown_error = 1;
}
return;
@@ -483,7 +482,7 @@ static void diskspace_slow_worker_cleanup(void *ptr)
{
UNUSED(ptr);
- info("cleaning up...");
+ collector_info("cleaning up...");
worker_unregister();
}
@@ -515,7 +514,7 @@ void *diskspace_slow_worker(void *ptr)
heartbeat_t hb;
heartbeat_init(&hb);
- while(!netdata_exit) {
+ while(service_running(SERVICE_COLLECTORS)) {
worker_is_idle();
heartbeat_next(&hb, USEC_PER_SEC);
@@ -530,7 +529,7 @@ void *diskspace_slow_worker(void *ptr)
if (!dict_mountpoints)
continue;
- if(unlikely(netdata_exit)) break;
+ if(unlikely(!service_running(SERVICE_COLLECTORS))) break;
// --------------------------------------------------------------------------
// disk space metrics
@@ -547,10 +546,10 @@ void *diskspace_slow_worker(void *ptr)
for(bmi = slow_mountinfo_root; bmi; bmi = bmi->next) {
do_slow_disk_space_stats(bmi, slow_update_every);
- if(unlikely(netdata_exit)) break;
+ if(unlikely(!service_running(SERVICE_COLLECTORS))) break;
}
- if(unlikely(netdata_exit)) break;
+ if(unlikely(!service_running(SERVICE_COLLECTORS))) break;
worker_is_busy(WORKER_JOB_SLOW_CLEANUP);
@@ -584,7 +583,7 @@ static void diskspace_main_cleanup(void *ptr) {
struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
- info("cleaning up...");
+ collector_info("cleaning up...");
if (diskspace_slow_thread) {
netdata_thread_join(*diskspace_slow_thread, NULL);
@@ -632,7 +631,7 @@ void *diskspace_main(void *ptr) {
netdata_thread_create(
diskspace_slow_thread,
- THREAD_DISKSPACE_SLOW_NAME,
+ "P[diskspace slow]",
NETDATA_THREAD_OPTION_JOINABLE,
diskspace_slow_worker,
&slow_worker_data);
@@ -640,11 +639,11 @@ void *diskspace_main(void *ptr) {
usec_t step = update_every * USEC_PER_SEC;
heartbeat_t hb;
heartbeat_init(&hb);
- while(!netdata_exit) {
+ while(service_running(SERVICE_COLLECTORS)) {
worker_is_idle();
/* usec_t hb_dt = */ heartbeat_next(&hb, step);
- if(unlikely(netdata_exit)) break;
+ if(unlikely(!service_running(SERVICE_COLLECTORS))) break;
// --------------------------------------------------------------------------
// this is smart enough not to reload it every time
@@ -671,11 +670,11 @@ void *diskspace_main(void *ptr) {
worker_is_busy(WORKER_JOB_MOUNTPOINT);
do_disk_space_stats(mi, update_every);
- if(unlikely(netdata_exit)) break;
+ if(unlikely(!service_running(SERVICE_COLLECTORS))) break;
}
netdata_mutex_unlock(&slow_mountinfo_mutex);
- if(unlikely(netdata_exit)) break;
+ if(unlikely(!service_running(SERVICE_COLLECTORS))) break;
if(dict_mountpoints) {
worker_is_busy(WORKER_JOB_CLEANUP);