diff options
author | Fotis Voutsas <fjvoutsas@gmail.com> | 2020-12-03 17:33:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 17:33:04 +0200 |
commit | 04dbf7039e16a174983917f2d01e45d9b0daf98f (patch) | |
tree | ec739db3578bb4ac52b5ac29ac007794151d6e25 | |
parent | fae19246df3c8768c8207372d46828a9afe788d4 (diff) |
File descr alarm v01 (#10192)
-rw-r--r-- | collectors/apps.plugin/apps_plugin.c | 12 | ||||
-rw-r--r-- | health/Makefile.am | 1 | ||||
-rw-r--r-- | health/health.d/apps_plugin.conf | 13 | ||||
-rw-r--r-- | libnetdata/os.c | 1 |
4 files changed, 26 insertions, 1 deletions
diff --git a/collectors/apps.plugin/apps_plugin.c b/collectors/apps.plugin/apps_plugin.c index b440bcd5ec..21146bb341 100644 --- a/collectors/apps.plugin/apps_plugin.c +++ b/collectors/apps.plugin/apps_plugin.c @@ -508,6 +508,7 @@ struct file_descriptor { static int all_files_len = 0, all_files_size = 0; + long double currentmaxfds = 0; // ---------------------------------------------------------------------------- // read users and groups from files @@ -2998,6 +2999,7 @@ static inline void aggregate_pid_fds_on_targets(struct pid_stat *p) { reallocate_target_fds(u); reallocate_target_fds(g); + long double currentfds = 0; size_t c, size = p->fds_size; struct pid_fd *fds = p->fds; for(c = 0; c < size ;c++) { @@ -3006,10 +3008,15 @@ static inline void aggregate_pid_fds_on_targets(struct pid_stat *p) { if(likely(fd <= 0 || fd >= all_files_size)) continue; + currentfds++; + aggregate_fd_on_target(fd, w); aggregate_fd_on_target(fd, u); aggregate_fd_on_target(fd, g); } + + if (currentfds >= currentmaxfds) + currentmaxfds = currentfds; } static inline void aggregate_pid_on_target(struct target *w, struct pid_stat *p, struct target *o) { @@ -3607,6 +3614,10 @@ static void send_collected_data_to_netdata(struct target *root, const char *type if (unlikely(w->exposed && w->processes)) send_SET(w->name, w->openfiles); } + if (!strcmp("apps", type)){ + kernel_uint_t usedfdpercentage = (kernel_uint_t) ((currentmaxfds * 100) / sysconf(_SC_OPEN_MAX)); + fprintf(stdout, "VARIABLE fdperc = " KERNEL_UINT_FORMAT "\n", usedfdpercentage); + } send_END(); send_BEGIN(type, "sockets", dt); @@ -4184,6 +4195,7 @@ int main(int argc, char **argv) { exit(1); } + currentmaxfds = 0; calculate_netdata_statistics(); normalize_utilization(apps_groups_root_target); diff --git a/health/Makefile.am b/health/Makefile.am index 0802dc750f..399d6df5ab 100644 --- a/health/Makefile.am +++ b/health/Makefile.am @@ -29,6 +29,7 @@ dist_healthconfig_DATA = \ health.d/anomalies.conf \ health.d/apache.conf \ health.d/apcupsd.conf \ + health.d/apps_plugin.conf \ health.d/backend.conf \ health.d/bcache.conf \ health.d/beanstalkd.conf \ diff --git a/health/health.d/apps_plugin.conf b/health/health.d/apps_plugin.conf new file mode 100644 index 0000000000..d3670f1c9d --- /dev/null +++ b/health/health.d/apps_plugin.conf @@ -0,0 +1,13 @@ +# you can disable an alarm notification by setting the 'to' line to: silent + + alarm: used_file_descriptors + on: apps.files + hosts: * + calc: $fdperc + units: % + every: 5s + warn: $this > (($status >= $WARNING) ? (75) : (80)) + crit: $this > (($status == $CRITICAL) ? (85) : (90)) + delay: down 5m multiplier 1.5 max 1h + info: Peak percentage of file descriptors used + to: sysadmin diff --git a/libnetdata/os.c b/libnetdata/os.c index 0248eb627c..4271a917cd 100644 --- a/libnetdata/os.c +++ b/libnetdata/os.c @@ -215,4 +215,3 @@ int getsysctl_by_name(const char *name, void *ptr, size_t len) { } #endif // (TARGET_OS == OS_MACOS) - |