diff options
Diffstat (limited to '')
88 files changed, 3182 insertions, 223 deletions
diff --git a/collectors/charts.d.plugin/Makefile.am b/collectors/charts.d.plugin/Makefile.am new file mode 100644 index 000000000..e2e00258f --- /dev/null +++ b/collectors/charts.d.plugin/Makefile.am @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +MAINTAINERCLEANFILES = $(srcdir)/Makefile.in + +CLEANFILES = \ + charts.d.plugin \ + $(NULL) + +include $(top_srcdir)/build/subst.inc +SUFFIXES = .in + +dist_libconfig_DATA = \ + charts.d.conf \ + $(NULL) + +dist_plugins_SCRIPTS = \ + charts.d.dryrun-helper.sh \ + charts.d.plugin \ + loopsleepms.sh.inc \ + $(NULL) + +dist_noinst_DATA = \ + charts.d.plugin.in \ + README.md \ + $(NULL) + +dist_charts_SCRIPTS = \ + $(NULL) + +dist_charts_DATA = \ + $(NULL) + +userchartsconfigdir=$(configdir)/charts.d +dist_userchartsconfig_DATA = \ + $(top_srcdir)/installer/.keep \ + $(NULL) + +chartsconfigdir=$(libconfigdir)/charts.d +dist_chartsconfig_DATA = \ + $(top_srcdir)/installer/.keep \ + $(NULL) + +include ap/Makefile.inc +include apache/Makefile.inc +include apcupsd/Makefile.inc +include cpu_apps/Makefile.inc +include cpufreq/Makefile.inc +include example/Makefile.inc +include exim/Makefile.inc +include hddtemp/Makefile.inc +include libreswan/Makefile.inc +include load_average/Makefile.inc +include mem_apps/Makefile.inc +include mysql/Makefile.inc +include nginx/Makefile.inc +include nut/Makefile.inc +include opensips/Makefile.inc +include phpfpm/Makefile.inc +include postfix/Makefile.inc +include sensors/Makefile.inc +include squid/Makefile.inc +include tomcat/Makefile.inc diff --git a/collectors/charts.d.plugin/Makefile.in b/collectors/charts.d.plugin/Makefile.in new file mode 100644 index 000000000..23e2edebb --- /dev/null +++ b/collectors/charts.d.plugin/Makefile.in @@ -0,0 +1,953 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# SPDX-License-Identifier: GPL-3.0-or-later + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(top_srcdir)/build/subst.inc $(srcdir)/ap/Makefile.inc \ + $(srcdir)/apache/Makefile.inc $(srcdir)/apcupsd/Makefile.inc \ + $(srcdir)/cpu_apps/Makefile.inc $(srcdir)/cpufreq/Makefile.inc \ + $(srcdir)/example/Makefile.inc $(srcdir)/exim/Makefile.inc \ + $(srcdir)/hddtemp/Makefile.inc \ + $(srcdir)/libreswan/Makefile.inc \ + $(srcdir)/load_average/Makefile.inc \ + $(srcdir)/mem_apps/Makefile.inc $(srcdir)/mysql/Makefile.inc \ + $(srcdir)/nginx/Makefile.inc $(srcdir)/nut/Makefile.inc \ + $(srcdir)/opensips/Makefile.inc $(srcdir)/phpfpm/Makefile.inc \ + $(srcdir)/postfix/Makefile.inc $(srcdir)/sensors/Makefile.inc \ + $(srcdir)/squid/Makefile.inc $(srcdir)/tomcat/Makefile.inc \ + $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(dist_charts_SCRIPTS) $(dist_plugins_SCRIPTS) \ + $(dist_charts_DATA) $(dist_chartsconfig_DATA) \ + $(dist_libconfig_DATA) $(dist_noinst_DATA) \ + $(dist_userchartsconfig_DATA) +subdir = collectors/charts.d.plugin +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/build/m4/ax_c___atomic.m4 \ + $(top_srcdir)/build/m4/ax_c__generic.m4 \ + $(top_srcdir)/build/m4/ax_c_lto.m4 \ + $(top_srcdir)/build/m4/ax_c_mallinfo.m4 \ + $(top_srcdir)/build/m4/ax_c_mallopt.m4 \ + $(top_srcdir)/build/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/build/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/build/m4/ax_pthread.m4 \ + $(top_srcdir)/build/m4/jemalloc.m4 \ + $(top_srcdir)/build/m4/tcmalloc.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(chartsdir)" "$(DESTDIR)$(pluginsdir)" \ + "$(DESTDIR)$(chartsdir)" "$(DESTDIR)$(chartsconfigdir)" \ + "$(DESTDIR)$(libconfigdir)" "$(DESTDIR)$(userchartsconfigdir)" +SCRIPTS = $(dist_charts_SCRIPTS) $(dist_plugins_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +DATA = $(dist_charts_DATA) $(dist_chartsconfig_DATA) \ + $(dist_libconfig_DATA) $(dist_noinst_DATA) \ + $(dist_userchartsconfig_DATA) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPMIMONITORING_CFLAGS = @IPMIMONITORING_CFLAGS@ +IPMIMONITORING_LIBS = @IPMIMONITORING_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBCAP_CFLAGS = @LIBCAP_CFLAGS@ +LIBCAP_LIBS = @LIBCAP_LIBS@ +LIBMNL_CFLAGS = @LIBMNL_CFLAGS@ +LIBMNL_LIBS = @LIBMNL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MATH_CFLAGS = @MATH_CFLAGS@ +MATH_LIBS = @MATH_LIBS@ +MKDIR_P = @MKDIR_P@ +NFACCT_CFLAGS = @NFACCT_CFLAGS@ +NFACCT_LIBS = @NFACCT_LIBS@ +OBJEXT = @OBJEXT@ +OPTIONAL_IPMIMONITORING_CFLAGS = @OPTIONAL_IPMIMONITORING_CFLAGS@ +OPTIONAL_IPMIMONITORING_LIBS = @OPTIONAL_IPMIMONITORING_LIBS@ +OPTIONAL_LIBCAP_CFLAGS = @OPTIONAL_LIBCAP_CFLAGS@ +OPTIONAL_LIBCAP_LIBS = @OPTIONAL_LIBCAP_LIBS@ +OPTIONAL_MATH_CLFAGS = @OPTIONAL_MATH_CLFAGS@ +OPTIONAL_MATH_LIBS = @OPTIONAL_MATH_LIBS@ +OPTIONAL_NFACCT_CLFAGS = @OPTIONAL_NFACCT_CLFAGS@ +OPTIONAL_NFACCT_LIBS = @OPTIONAL_NFACCT_LIBS@ +OPTIONAL_UUID_CLFAGS = @OPTIONAL_UUID_CLFAGS@ +OPTIONAL_UUID_LIBS = @OPTIONAL_UUID_LIBS@ +OPTIONAL_ZLIB_CLFAGS = @OPTIONAL_ZLIB_CLFAGS@ +OPTIONAL_ZLIB_LIBS = @OPTIONAL_ZLIB_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_RPM_RELEASE = @PACKAGE_RPM_RELEASE@ +PACKAGE_RPM_VERSION = @PACKAGE_RPM_VERSION@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PTHREAD_CC = @PTHREAD_CC@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SSE_CANDIDATE = @SSE_CANDIDATE@ +STRIP = @STRIP@ +UUID_CFLAGS = @UUID_CFLAGS@ +UUID_LIBS = @UUID_LIBS@ +VERSION = @VERSION@ +ZLIB_CFLAGS = @ZLIB_CFLAGS@ +ZLIB_LIBS = @ZLIB_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +ax_pthread_config = @ax_pthread_config@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_target = @build_target@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cachedir = @cachedir@ +chartsdir = @chartsdir@ +configdir = @configdir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +has_jemalloc = @has_jemalloc@ +has_tcmalloc = @has_tcmalloc@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libconfigdir = @libconfigdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nodedir = @nodedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pluginsdir = @pluginsdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pythondir = @pythondir@ +registrydir = @registrydir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +varlibdir = @varlibdir@ +webdir = @webdir@ +MAINTAINERCLEANFILES = $(srcdir)/Makefile.in +CLEANFILES = \ + charts.d.plugin \ + $(NULL) + +SUFFIXES = .in +dist_libconfig_DATA = \ + charts.d.conf \ + $(NULL) + +dist_plugins_SCRIPTS = \ + charts.d.dryrun-helper.sh \ + charts.d.plugin \ + loopsleepms.sh.inc \ + $(NULL) + + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution + +# do not install these files, but include them in the distribution +dist_noinst_DATA = charts.d.plugin.in README.md $(NULL) ap/README.md \ + ap/Makefile.inc apache/README.md apache/Makefile.inc \ + apcupsd/README.md apcupsd/Makefile.inc cpu_apps/README.md \ + cpu_apps/Makefile.inc cpufreq/README.md cpufreq/Makefile.inc \ + example/README.md example/Makefile.inc exim/README.md \ + exim/Makefile.inc hddtemp/README.md hddtemp/Makefile.inc \ + libreswan/README.md libreswan/Makefile.inc \ + load_average/README.md load_average/Makefile.inc \ + mem_apps/README.md mem_apps/Makefile.inc mysql/README.md \ + mysql/Makefile.inc nginx/README.md nginx/Makefile.inc \ + nut/README.md nut/Makefile.inc opensips/README.md \ + opensips/Makefile.inc phpfpm/README.md phpfpm/Makefile.inc \ + postfix/README.md postfix/Makefile.inc sensors/README.md \ + sensors/Makefile.inc squid/README.md squid/Makefile.inc \ + tomcat/README.md tomcat/Makefile.inc +dist_charts_SCRIPTS = \ + $(NULL) + + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files + +# install these files +dist_charts_DATA = $(NULL) ap/ap.chart.sh apache/apache.chart.sh \ + apcupsd/apcupsd.chart.sh cpu_apps/cpu_apps.chart.sh \ + cpufreq/cpufreq.chart.sh example/example.chart.sh \ + exim/exim.chart.sh hddtemp/hddtemp.chart.sh \ + libreswan/libreswan.chart.sh \ + load_average/load_average.chart.sh mem_apps/mem_apps.chart.sh \ + mysql/mysql.chart.sh nginx/nginx.chart.sh nut/nut.chart.sh \ + opensips/opensips.chart.sh phpfpm/phpfpm.chart.sh \ + postfix/postfix.chart.sh sensors/sensors.chart.sh \ + squid/squid.chart.sh tomcat/tomcat.chart.sh +userchartsconfigdir = $(configdir)/charts.d +dist_userchartsconfig_DATA = \ + $(top_srcdir)/installer/.keep \ + $(NULL) + +chartsconfigdir = $(libconfigdir)/charts.d +dist_chartsconfig_DATA = $(top_srcdir)/installer/.keep $(NULL) \ + ap/ap.conf apache/apache.conf apcupsd/apcupsd.conf \ + cpu_apps/cpu_apps.conf cpufreq/cpufreq.conf \ + example/example.conf exim/exim.conf hddtemp/hddtemp.conf \ + libreswan/libreswan.conf load_average/load_average.conf \ + mem_apps/mem_apps.conf mysql/mysql.conf nginx/nginx.conf \ + nut/nut.conf opensips/opensips.conf phpfpm/phpfpm.conf \ + postfix/postfix.conf sensors/sensors.conf squid/squid.conf \ + tomcat/tomcat.conf +all: all-am + +.SUFFIXES: +.SUFFIXES: .in +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build/subst.inc $(srcdir)/ap/Makefile.inc $(srcdir)/apache/Makefile.inc $(srcdir)/apcupsd/Makefile.inc $(srcdir)/cpu_apps/Makefile.inc $(srcdir)/cpufreq/Makefile.inc $(srcdir)/example/Makefile.inc $(srcdir)/exim/Makefile.inc $(srcdir)/hddtemp/Makefile.inc $(srcdir)/libreswan/Makefile.inc $(srcdir)/load_average/Makefile.inc $(srcdir)/mem_apps/Makefile.inc $(srcdir)/mysql/Makefile.inc $(srcdir)/nginx/Makefile.inc $(srcdir)/nut/Makefile.inc $(srcdir)/opensips/Makefile.inc $(srcdir)/phpfpm/Makefile.inc $(srcdir)/postfix/Makefile.inc $(srcdir)/sensors/Makefile.inc $(srcdir)/squid/Makefile.inc $(srcdir)/tomcat/Makefile.inc $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu collectors/charts.d.plugin/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu collectors/charts.d.plugin/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; +$(top_srcdir)/build/subst.inc $(srcdir)/ap/Makefile.inc $(srcdir)/apache/Makefile.inc $(srcdir)/apcupsd/Makefile.inc $(srcdir)/cpu_apps/Makefile.inc $(srcdir)/cpufreq/Makefile.inc $(srcdir)/example/Makefile.inc $(srcdir)/exim/Makefile.inc $(srcdir)/hddtemp/Makefile.inc $(srcdir)/libreswan/Makefile.inc $(srcdir)/load_average/Makefile.inc $(srcdir)/mem_apps/Makefile.inc $(srcdir)/mysql/Makefile.inc $(srcdir)/nginx/Makefile.inc $(srcdir)/nut/Makefile.inc $(srcdir)/opensips/Makefile.inc $(srcdir)/phpfpm/Makefile.inc $(srcdir)/postfix/Makefile.inc $(srcdir)/sensors/Makefile.inc $(srcdir)/squid/Makefile.inc $(srcdir)/tomcat/Makefile.inc: + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-dist_chartsSCRIPTS: $(dist_charts_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(dist_charts_SCRIPTS)'; test -n "$(chartsdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(chartsdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(chartsdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(chartsdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(chartsdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-dist_chartsSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(dist_charts_SCRIPTS)'; test -n "$(chartsdir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(chartsdir)'; $(am__uninstall_files_from_dir) +install-dist_pluginsSCRIPTS: $(dist_plugins_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(dist_plugins_SCRIPTS)'; test -n "$(pluginsdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pluginsdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pluginsdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(pluginsdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(pluginsdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-dist_pluginsSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(dist_plugins_SCRIPTS)'; test -n "$(pluginsdir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(pluginsdir)'; $(am__uninstall_files_from_dir) +install-dist_chartsDATA: $(dist_charts_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_charts_DATA)'; test -n "$(chartsdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(chartsdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(chartsdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(chartsdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(chartsdir)" || exit $$?; \ + done + +uninstall-dist_chartsDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_charts_DATA)'; test -n "$(chartsdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(chartsdir)'; $(am__uninstall_files_from_dir) +install-dist_chartsconfigDATA: $(dist_chartsconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_chartsconfig_DATA)'; test -n "$(chartsconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(chartsconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(chartsconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(chartsconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(chartsconfigdir)" || exit $$?; \ + done + +uninstall-dist_chartsconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_chartsconfig_DATA)'; test -n "$(chartsconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(chartsconfigdir)'; $(am__uninstall_files_from_dir) +install-dist_libconfigDATA: $(dist_libconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_libconfig_DATA)'; test -n "$(libconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(libconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(libconfigdir)" || exit $$?; \ + done + +uninstall-dist_libconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_libconfig_DATA)'; test -n "$(libconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(libconfigdir)'; $(am__uninstall_files_from_dir) +install-dist_userchartsconfigDATA: $(dist_userchartsconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_userchartsconfig_DATA)'; test -n "$(userchartsconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(userchartsconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(userchartsconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(userchartsconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(userchartsconfigdir)" || exit $$?; \ + done + +uninstall-dist_userchartsconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_userchartsconfig_DATA)'; test -n "$(userchartsconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(userchartsconfigdir)'; $(am__uninstall_files_from_dir) +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(chartsdir)" "$(DESTDIR)$(pluginsdir)" "$(DESTDIR)$(chartsdir)" "$(DESTDIR)$(chartsconfigdir)" "$(DESTDIR)$(libconfigdir)" "$(DESTDIR)$(userchartsconfigdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-dist_chartsDATA install-dist_chartsSCRIPTS \ + install-dist_chartsconfigDATA install-dist_libconfigDATA \ + install-dist_pluginsSCRIPTS install-dist_userchartsconfigDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dist_chartsDATA uninstall-dist_chartsSCRIPTS \ + uninstall-dist_chartsconfigDATA uninstall-dist_libconfigDATA \ + uninstall-dist_pluginsSCRIPTS \ + uninstall-dist_userchartsconfigDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic cscopelist-am \ + ctags-am distclean distclean-generic distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dist_chartsDATA \ + install-dist_chartsSCRIPTS install-dist_chartsconfigDATA \ + install-dist_libconfigDATA install-dist_pluginsSCRIPTS \ + install-dist_userchartsconfigDATA install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags-am uninstall uninstall-am \ + uninstall-dist_chartsDATA uninstall-dist_chartsSCRIPTS \ + uninstall-dist_chartsconfigDATA uninstall-dist_libconfigDATA \ + uninstall-dist_pluginsSCRIPTS \ + uninstall-dist_userchartsconfigDATA + +.in: + if sed \ + -e 's#[@]localstatedir_POST@#$(localstatedir)#g' \ + -e 's#[@]sbindir_POST@#$(sbindir)#g' \ + -e 's#[@]sysconfdir_POST@#$(sysconfdir)#g' \ + -e 's#[@]pythondir_POST@#$(pythondir)#g' \ + -e 's#[@]configdir_POST@#$(configdir)#g' \ + -e 's#[@]libconfigdir_POST@#$(libconfigdir)#g' \ + -e 's#[@]cachedir_POST@#$(cachedir)#g' \ + $< > $@.tmp; then \ + mv "$@.tmp" "$@"; \ + else \ + rm -f "$@.tmp"; \ + false; \ + fi + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/collectors/charts.d.plugin/README.md b/collectors/charts.d.plugin/README.md new file mode 100644 index 000000000..b224bffe3 --- /dev/null +++ b/collectors/charts.d.plugin/README.md @@ -0,0 +1,193 @@ +# charts.d.plugin + +`charts.d.plugin` is a netdata external plugin. It is an **orchestrator** for data collection modules written in `BASH` v4+. + +1. It runs as an independent process `ps fax` shows it +2. It is started and stopped automatically by netdata +3. It communicates with netdata via a unidirectional pipe (sending data to the netdata daemon) +4. Supports any number of data collection **modules** + +`charts.d.plugin` has been designed so that the actual script that will do data collection will be permanently in +memory, collecting data with as little overheads as possible +(i.e. initialize once, repeatedly collect values with minimal overhead). + +`charts.d.plugin` looks for scripts in `/usr/lib/netdata/charts.d`. +The scripts should have the filename suffix: `.chart.sh`. + +## Configuration + +`charts.d.plugin` itself can be configured using the configuration file `/etc/netdata/charts.d.conf` +(to edit it on your system run `/etc/netdata/edit-config charts.d.conf`). This file is also a BASH script. + +In this file, you can place statements like this: + +``` +enable_all_charts="yes" +X="yes" +Y="no" +``` + +where `X` and `Y` are the names of individual charts.d collector scripts. +When set to `yes`, charts.d will evaluate the collector script (see below). +When set to `no`, charts.d will ignore the collector script. + +The variable `enable_all_charts` sets the default enable/disable state for all charts. + +## A charts.d module + +A `charts.d.plugin` module is a BASH script defining a few functions. + +For a module called `X`, the following criteria must be met: + +1. The module script must be called `X.chart.sh` and placed in `/usr/libexec/netdata/charts.d`. + +2. If the module needs a configuration, it should be called `X.conf` and placed in `/etc/netdata/charts.d`. + The configuration file `X.conf` is also a BASH script itself. + To edit the default files supplied by netdata run `/etc/netdata/edit-config charts.d/X.conf`, + where `X` is the name of the module. + +3. All functions and global variables defined in the script and its configuration, must begin with `X_`. + +4. The following functions must be defined: + + - `X_check()` - returns 0 or 1 depending on whether the module is able to run or not + (following the standard Linux command line return codes: 0 = OK, the collector can operate and 1 = FAILED, + the collector cannot be used). + + - `X_create()` - creates the netdata charts, following the standard netdata plugin guides as described in + **[External Plugins](../plugins.d/)** (commands `CHART` and `DIMENSION`). + The return value does matter: 0 = OK, 1 = FAILED. + + - `X_update()` - collects the values for the defined charts, following the standard netdata plugin guides + as described in **[External Plugins](../plugins.d/)** (commands `BEGIN`, `SET`, `END`). + The return value also matters: 0 = OK, 1 = FAILED. + +5. The following global variables are available to be set: + - `X_update_every` - is the data collection frequency for the module script, in seconds. + +The module script may use more functions or variables. But all of them must begin with `X_`. + +The standard netdata plugin variables are also available (check **[External Plugins](../plugins.d/)**). + +### X_check() + +The purpose of the BASH function `X_check()` is to check if the module can collect data (or check its config). + +For example, if the module is about monitoring a local mysql database, the `X_check()` function may attempt to +connect to a local mysql database to find out if it can read the values it needs. + +`X_check()` is run only once for the lifetime of the module. + +### X_create() + +The purpose of the BASH function `X_create()` is to create the charts and dimensions using the standard netdata +plugin guides (**[External Plugins](../plugins.d/)**). + +`X_create()` will be called just once and only after `X_check()` was successful. +You can however call it yourself when there is need for it (for example to add a new dimension to an existing chart). + +A non-zero return value will disable the collector. + +### X_update() + +`X_update()` will be called repeatedly every `X_update_every` seconds, to collect new values and send them to netdata, +following the netdata plugin guides (**[External Plugins](../plugins.d/)**). + +The function will be called with one parameter: microseconds since the last time it was run. This value should be +appended to the `BEGIN` statement of every chart updated by the collector script. + +A non-zero return value will disable the collector. + +### Useful functions charts.d provides + +Module scripts can use the following charts.d functions: + +#### require_cmd command + +`require_cmd()` will check if a command is available in the running system. + +For example, your `X_check()` function may use it like this: + +```sh +mysql_check() { + require_cmd mysql || return 1 + return 0 +} +``` + +Using the above, if the command `mysql` is not available in the system, the `mysql` module will be disabled. + +#### fixid "string" + +`fixid()` will get a string and return a properly formatted id for a chart or dimension. + +This is an expensive function that should not be used in `X_update()`. +You can keep the generated id in a BASH associative array to have the values availables in `X_update()`, like this: + +```sh +declare -A X_ids=() +X_create() { + local name="a very bad name for id" + + X_ids[$name]="$(fixid "$name")" +} + +X_update() { + local microseconds="$1" + + ... + local name="a very bad name for id" + ... + + echo "BEGIN ${X_ids[$name]} $microseconds" + ... +} +``` + +### Debugging your collectors + +You can run `charts.d.plugin` by hand with something like this: + +```sh +# become user netdata +sudo su -s /bin/sh netdata + +# run the plugin in debug mode +/usr/libexec/netdata/plugins.d/charts.d.plugin debug 1 X Y Z +``` + +Charts.d will run in `debug` mode, with an update frequency of `1`, evaluating only the collector scripts +`X`, `Y` and `Z`. You can define zero or more module scripts. If none is defined, charts.d will evaluate all +module scripts available. + +Keep in mind that if your configs are not in `/etc/netdata`, you should do the following before running +`charts.d.plugin`: + +```sh +export NETDATA_USER_CONFIG_DIR="/path/to/etc/netdata" +``` + +Also, remember that netdata runs `chart.d.plugin` as user `netdata` (or any other user netdata is configured to run as). + + +## Running multiple instances of charts.d.plugin + +`charts.d.plugin` will call the `X_update()` function one after another. This means that a delay in collector `X` +will also delay the collection of `Y` and `Z`. + +You can have multiple `charts.d.plugin` running to overcome this problem. + +This is what you need to do: + +1. Decide a new name for the new charts.d instance: example `charts2.d`. + +2. Create/edit the files `/etc/netdata/charts.d.conf` and `/etc/netdata/charts2.d.conf` and enable / disable the + module you want each to run. Remember to set `enable_all_charts="no"` to both of them, and enable the individual + modules for each. + +3. link `/usr/libexec/netdata/plugins.d/charts.d.plugin` to `/usr/libexec/netdata/plugins.d/charts2.d.plugin`. + Netdata will spawn a new charts.d process. + +Execute the above in this order, since netdata will (by default) attempt to start new plugins soon after they are +created in `/usr/libexec/netdata/plugins.d/`. + diff --git a/collectors/charts.d.plugin/ap/Makefile.inc b/collectors/charts.d.plugin/ap/Makefile.inc new file mode 100644 index 000000000..a2dd375ac --- /dev/null +++ b/collectors/charts.d.plugin/ap/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += ap/ap.chart.sh +dist_chartsconfig_DATA += ap/ap.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += ap/README.md ap/Makefile.inc + diff --git a/collectors/charts.d.plugin/ap/README.md b/collectors/charts.d.plugin/ap/README.md new file mode 100644 index 000000000..eb4e80707 --- /dev/null +++ b/collectors/charts.d.plugin/ap/README.md @@ -0,0 +1,84 @@ +# Access Point Plugin (ap) + +The `ap` collector visualizes data related to access points. + +## Example netdata charts + +![image](https://cloud.githubusercontent.com/assets/2662304/12377654/9f566e88-bd2d-11e5-855a-e0ba96b8fd98.png) + +## How it works + +It does the following: + +1. Runs `iw dev` searching for interfaces that have `type AP`. + + From the same output it collects the SSIDs each AP supports by looking for lines `ssid NAME`. + + Example: +```sh +# iw dev +phy#0 + Interface wlan0 + ifindex 3 + wdev 0x1 + addr 7c:dd:90:77:34:2a + ssid TSAOUSIS + type AP + channel 7 (2442 MHz), width: 20 MHz, center1: 2442 MHz +``` + + +2. For each interface found, it runs `iw INTERFACE station dump`. + + From the output is collects: + + - rx/tx bytes + - rx/tx packets + - tx retries + - tx failed + - signal strength + - rx/tx bitrate + - expected throughput + + Example: + +```sh +# iw wlan0 station dump +Station 40:b8:37:5a:ed:5e (on wlan0) + inactive time: 910 ms + rx bytes: 15588897 + rx packets: 127772 + tx bytes: 52257763 + tx packets: 95802 + tx retries: 2162 + tx failed: 28 + signal: -43 dBm + signal avg: -43 dBm + tx bitrate: 65.0 MBit/s MCS 7 + rx bitrate: 1.0 MBit/s + expected throughput: 32.125Mbps + authorized: yes + authenticated: yes + preamble: long + WMM/WME: yes + MFP: no + TDLS peer: no +``` + +3. For each interface found, it creates 6 charts: + + - Number of Connected clients + - Bandwidth for all clients + - Packets for all clients + - Transmit Issues for all clients + - Average Signal among all clients + - Average Bitrate (including average expected throughput) among all clients + +## Configuration + +You can only set `ap_update_every=NUMBER` to `/etc/netdata/charts.d/ap.conf`, to give the data collection frequency. +To edit this file on your system run `/etc/netdata/edit-config charts.d/ap.conf`. + +## Auto-detection + +The plugin is able to auto-detect if you are running access points on your linux box. diff --git a/charts.d/ap.chart.sh b/collectors/charts.d.plugin/ap/ap.chart.sh index ce2eefc9f..ccc36120c 100644 --- a/charts.d/ap.chart.sh +++ b/collectors/charts.d.plugin/ap/ap.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # _update_every is a special variable - it holds the number of seconds @@ -16,8 +17,8 @@ declare -A ap_devs=() # _check is called once, to find out if this chart should be enabled or not ap_check() { require_cmd iw || return 1 - - local ev=$(run iw dev | awk ' + local ev + ev=$(run iw dev | awk ' BEGIN { i = ""; ssid = ""; @@ -102,7 +103,7 @@ ap_update() { do echo echo "DEVICE ${dev}" - iw ${dev} station dump + iw "${dev}" station dump done | awk " function zero_data() { dev = \"\"; diff --git a/conf.d/charts.d/ap.conf b/collectors/charts.d.plugin/ap/ap.conf index 38fc157ce..38fc157ce 100644 --- a/conf.d/charts.d/ap.conf +++ b/collectors/charts.d.plugin/ap/ap.conf diff --git a/collectors/charts.d.plugin/apache/Makefile.inc b/collectors/charts.d.plugin/apache/Makefile.inc new file mode 100644 index 000000000..4b360eae0 --- /dev/null +++ b/collectors/charts.d.plugin/apache/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += apache/apache.chart.sh +dist_chartsconfig_DATA += apache/apache.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += apache/README.md apache/Makefile.inc + diff --git a/collectors/charts.d.plugin/apache/README.md b/collectors/charts.d.plugin/apache/README.md new file mode 100644 index 000000000..890cee984 --- /dev/null +++ b/collectors/charts.d.plugin/apache/README.md @@ -0,0 +1,127 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT + +--- + +# Apache Plugin (apache) + +The `apache` collector visualizes key performance data for an apache web server. + +## Example netdata charts + +For apache 2.2: + +![image](https://cloud.githubusercontent.com/assets/2662304/12530273/421c4d14-c1e2-11e5-9fb6-ca6d6dd3b1dd.png) + +For apache 2.4: + +![image](https://cloud.githubusercontent.com/assets/2662304/12530376/29ec26de-c1e6-11e5-9af1-e48aaf781795.png) + +## How it works + +It runs `curl "http://apache.host/server-status?auto` to fetch the current status of apache. + +It has been tested with apache 2.2 and apache 2.4. The latter also provides connections information (total and break down by status). + +Apache 2.2 response: + +```sh +$ curl "http://127.0.0.1/server-status?auto" +Total Accesses: 80057 +Total kBytes: 223017 +CPULoad: .018287 +Uptime: 64472 +ReqPerSec: 1.24173 +BytesPerSec: 3542.15 +BytesPerReq: 2852.59 +BusyWorkers: 1 +IdleWorkers: 49 +Scoreboard: _________________________......................................._W_______________________....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... +``` + +Apache 2.4 response: + +```sh +$ curl "http://127.0.0.1/server-status?auto" +127.0.0.1 +ServerVersion: Apache/2.4.18 (Unix) +ServerMPM: event +Server Built: Dec 14 2015 08:05:54 +CurrentTime: Saturday, 23-Jan-2016 14:42:06 EET +RestartTime: Saturday, 23-Jan-2016 04:57:13 EET +ParentServerConfigGeneration: 2 +ParentServerMPMGeneration: 1 +ServerUptimeSeconds: 35092 +ServerUptime: 9 hours 44 minutes 52 seconds +Load1: 0.32 +Load5: 0.32 +Load15: 0.27 +Total Accesses: 32403 +Total kBytes: 34464 +CPUUser: 30.37 +CPUSystem: 29.55 +CPUChildrenUser: 0 +CPUChildrenSystem: 0 +CPULoad: .170751 +Uptime: 35092 +ReqPerSec: .923373 +BytesPerSec: 1005.67 +BytesPerReq: 1089.13 +BusyWorkers: 1 +IdleWorkers: 99 +ConnsTotal: 0 +ConnsAsyncWriting: 0 +ConnsAsyncKeepAlive: 0 +ConnsAsyncClosing: 0 +Scoreboard: __________________________________________________________________________________________W_________............................................................................................................................................................................................................................................................................................................ +``` + +From the apache status output it collects: + + - total accesses (incremental value, rendered as requests/s) + - total bandwidth (incremental value, rendered as bandwidth/s) + - requests per second (this appears to be calculated by apache as an average for its lifetime, while the one calculated by netdata using the total accesses counter is real-time) + - bytes per second (average for the lifetime of the apache server) + - bytes per request (average for the lifetime of the apache server) + - workers by status (`busy` and `idle`) + - total connections (currently active connections - offered by apache 2.4+) + - async connections per status (`keepalive`, `writing`, `closing` - offered by apache 2.4+) + +## Configuration + +The configuration is stored in `/etc/netdata/charts.d/apache.conf`. +To edit this file on your system run `/etc/netdata/edit-config charts.d/apache.conf`. + +The internal default is: + +```sh +# the URL your apache server is responding with mod_status information. +apache_url="http://127.0.0.1:80/server-status?auto" + +# use this to set custom curl options you may need +apache_curl_opts= + +# set this to a NUMBER to overwrite the update frequency +# it is in seconds +apache_update_every= +``` + +The default `apache_update_every` is configured in netdata. + +## Auto-detection + +If you have configured your apache server to offer server-status information on localhost clients, the defaults should work fine. + +## Apache Configuration + +Apache configuration differs between distributions. Please check your distribution's documentation for information on enabling apache's `mod_status` module. + +If you are able to run successfully, by hand this command: + +```sh +curl "http://127.0.0.1:80/server-status?auto" +``` + +netdata will be able to do it too. + +Notice: You may need to have the default `000-default.conf ` website enabled in order for the status mod to work. diff --git a/charts.d/apache.chart.sh b/collectors/charts.d.plugin/apache/apache.chart.sh index a8ac08014..95876432f 100644 --- a/charts.d/apache.chart.sh +++ b/collectors/charts.d.plugin/apache/apache.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # the URL to download apache status info @@ -82,12 +83,11 @@ apache_detect() { [ -z "${apache_key_idleworkers}" ] && error "missing 'IdleWorkers' from apache server: ${*}" && return 1 [ -z "${apache_key_scoreboard}" ] && error "missing 'Scoreboard' from apache server: ${*}" && return 1 - if [ ! -z "${apache_key_connstotal}" \ - -a ! -z "${apache_key_connsasyncwriting}" \ - -a ! -z "${apache_key_connsasynckeepalive}" \ - -a ! -z "${apache_key_connsasyncclosing}" \ - ] - then + if [ ! -z "${apache_key_connstotal}" ] && \ + [ ! -z "${apache_key_connsasyncwriting}" ] && \ + [ ! -z "${apache_key_connsasynckeepalive}" ] && \ + [ ! -z "${apache_key_connsasyncclosing}" ] + then apache_has_conns=1 else apache_has_conns=0 @@ -98,16 +98,20 @@ apache_detect() { apache_get() { local oIFS="${IFS}" ret + # shellcheck disable=2207 IFS=$':\n' apache_response=($(run curl -Ss ${apache_curl_opts} "${apache_url}")) ret=$? IFS="${oIFS}" - [ $ret -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1 + if [ $ret -ne 0 ] || [ "${#apache_response[@]}" -eq 0 ] + then + return 1 + fi # the last line on the apache output is "Scoreboard" # we use this label to detect that the output has a new word count - if [ ${apache_keys_detected} -eq 0 -o "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ] - then + if [ ${apache_keys_detected} -eq 0 ] || [ "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ] + then apache_detect "${apache_response[@]}" || return 1 apache_keys_detected=1 fi @@ -127,21 +131,20 @@ apache_get() { apache_busyworkers="${apache_response[${apache_key_busyworkers}]}" apache_idleworkers="${apache_response[${apache_key_idleworkers}]}" - if [ -z "${apache_accesses}" \ - -o -z "${apache_kbytes}" \ - -o -z "${apache_reqpersec}" \ - -o -z "${apache_bytespersec}" \ - -o -z "${apache_bytesperreq}" \ - -o -z "${apache_busyworkers}" \ - -o -z "${apache_idleworkers}" \ - ] - then + if [ -z "${apache_accesses}" ] || \ + [ -z "${apache_kbytes}" ] || \ + [ -z "${apache_reqpersec}" ] || \ + [ -z "${apache_bytespersec}" ] || \ + [ -z "${apache_bytesperreq}" ] || \ + [ -z "${apache_busyworkers}" ] + [ -z "${apache_idleworkers}" ] + then error "empty values got from apache server: ${apache_response[*]}" return 1 fi if [ ${apache_has_conns} -eq 1 ] - then + then apache_connstotal="${apache_response[${apache_key_connstotal}]}" apache_connsasyncwriting="${apache_response[${apache_key_connsasyncwriting}]}" apache_connsasynckeepalive="${apache_response[${apache_key_connsasynckeepalive}]}" @@ -155,8 +158,10 @@ apache_get() { apache_check() { apache_get + # shellcheck disable=2181 if [ $? -ne 0 ] - then + then + # shellcheck disable=2154 error "cannot find stub_status on URL '${apache_url}'. Please set apache_url='http://apache.server:80/server-status?auto' in $confd/apache.conf" return 1 fi @@ -187,7 +192,7 @@ DIMENSION sent '' incremental 8 1 EOF if [ ${apache_has_conns} -eq 1 ] - then + then cat <<EOF2 CHART apache_local.connections '' "apache Connections" "connections" connections apache.connections line $((apache_priority + 2)) $apache_update_every DIMENSION connections '' absolute 1 1 @@ -203,7 +208,6 @@ EOF2 # _update is called continuously, to collect the values apache_update() { - local reqs net # the first argument to this function is the microseconds since last update # pass this parameter to the BEGIN statement (see bellow). @@ -237,7 +241,7 @@ END VALUESEOF if [ ${apache_has_conns} -eq 1 ] - then + then cat <<VALUESEOF2 BEGIN apache_local.connections $1 SET connections = $((apache_connstotal)) diff --git a/conf.d/charts.d/apache.conf b/collectors/charts.d.plugin/apache/apache.conf index 50914cf32..50914cf32 100644 --- a/conf.d/charts.d/apache.conf +++ b/collectors/charts.d.plugin/apache/apache.conf diff --git a/collectors/charts.d.plugin/apcupsd/Makefile.inc b/collectors/charts.d.plugin/apcupsd/Makefile.inc new file mode 100644 index 000000000..19cb9cad7 --- /dev/null +++ b/collectors/charts.d.plugin/apcupsd/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += apcupsd/apcupsd.chart.sh +dist_chartsconfig_DATA += apcupsd/apcupsd.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += apcupsd/README.md apcupsd/Makefile.inc + diff --git a/python.d/python_modules/bases/FrameworkServices/__init__.py b/collectors/charts.d.plugin/apcupsd/README.md index e69de29bb..e69de29bb 100644 --- a/python.d/python_modules/bases/FrameworkServices/__init__.py +++ b/collectors/charts.d.plugin/apcupsd/README.md diff --git a/charts.d/apcupsd.chart.sh b/collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh index 9878fd36c..e26ef566a 100644 --- a/charts.d/apcupsd.chart.sh +++ b/collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # apcupsd_ip= @@ -43,11 +44,12 @@ apcupsd_check() { for host in "${!apcupsd_sources[@]}" do run apcupsd_get "${apcupsd_sources[${host}]}" >/dev/null + # shellcheck disable=2181 if [ $? -ne 0 ] then error "cannot get information for apcupsd server ${host} on ${apcupsd_sources[${host}]}." failed=$((failed + 1)) - elif [ $(apcupsd_get "${apcupsd_sources[${host}]}" | awk '/^STATUS.*/{ print $3 }') != "ONLINE" ] + elif [ "$(apcupsd_get "${apcupsd_sources[${host}]}" | awk '/^STATUS.*/{ print $3 }')" != "ONLINE" ] then error "APC UPS ${host} on ${apcupsd_sources[${host}]} is not online." failed=$((failed + 1)) @@ -183,6 +185,7 @@ END { print \"SET time = \" time; print \"END\" }" + # shellcheck disable=SC2181 if [ $? -ne 0 ] then failed=$((failed + 1)) diff --git a/conf.d/charts.d/apcupsd.conf b/collectors/charts.d.plugin/apcupsd/apcupsd.conf index 679c0d61b..679c0d61b 100644 --- a/conf.d/charts.d/apcupsd.conf +++ b/collectors/charts.d.plugin/apcupsd/apcupsd.conf diff --git a/conf.d/charts.d.conf b/collectors/charts.d.plugin/charts.d.conf index acb2a6fae..acb2a6fae 100644 --- a/conf.d/charts.d.conf +++ b/collectors/charts.d.plugin/charts.d.conf diff --git a/plugins.d/charts.d.dryrun-helper.sh b/collectors/charts.d.plugin/charts.d.dryrun-helper.sh index 8142f9882..67496c1bd 100755 --- a/plugins.d/charts.d.dryrun-helper.sh +++ b/collectors/charts.d.plugin/charts.d.dryrun-helper.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck disable=SC2181 # will stop the script for any error set -e @@ -10,8 +13,8 @@ conf="$3" can_diff=1 -tmp1="`mktemp`" -tmp2="`mktemp`" +tmp1="$(mktemp)" +tmp2="$(mktemp)" myset() { set | grep -v "^_=" | grep -v "^PIPESTATUS=" | grep -v "^BASH_LINENO=" @@ -36,6 +39,7 @@ myset >"$tmp1" # include the plugin and its config if [ -f "$conf" ] then + # shellcheck source=/dev/null . "$conf" if [ $? -ne 0 ] then @@ -45,6 +49,7 @@ then fi fi +# shellcheck source=/dev/null . "$chart" if [ $? -ne 0 ] then diff --git a/plugins.d/charts.d.plugin b/collectors/charts.d.plugin/charts.d.plugin index 9bd03fd47..1c6e8c5c9 100755..100644 --- a/plugins.d/charts.d.plugin +++ b/collectors/charts.d.plugin/charts.d.plugin @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! @@ -116,14 +117,15 @@ info "started from '$PROGRAM_FILE' with options: $*" # netdata exposes a few environment variables for us [ -z "${NETDATA_PLUGINS_DIR}" ] && NETDATA_PLUGINS_DIR="$(dirname "${0}")" -[ -z "${NETDATA_CONFIG_DIR}" ] && NETDATA_CONFIG_DIR="$(dirname "${0}")/../../../../etc/netdata" +[ -z "${NETDATA_USER_CONFIG_DIR}" ] && NETDATA_USER_CONFIG_DIR="/usr/local/etc/netdata" +[ -z "${NETDATA_STOCK_CONFIG_DIR}" ] && NETDATA_STOCK_CONFIG_DIR="/usr/local/lib/netdata/conf.d" pluginsd="${NETDATA_PLUGINS_DIR}" -confd="${NETDATA_CONFIG_DIR}" +stockconfd="${NETDATA_STOCK_CONFIG_DIR}/${PROGRAM_NAME}" +userconfd="${NETDATA_USER_CONFIG_DIR}/${PROGRAM_NAME}" +olduserconfd="${NETDATA_USER_CONFIG_DIR}" chartsd="$pluginsd/../charts.d" -myconfig="$confd/$PROGRAM_NAME.conf" - minimum_update_frequency="${NETDATA_UPDATE_EVERY-1}" update_every=${minimum_update_frequency} # this will be overwritten by the command line @@ -230,22 +232,33 @@ mysleep="sleep" # if found and included, this file overwrites loopsleepms() # and current_time_ms() with a high resolution timer function # for precise looping. -. "$pluginsd/loopsleepms.sh.inc" +source "$pluginsd/loopsleepms.sh.inc" +[ $? -ne 0 ] && error "Failed to load '$pluginsd/loopsleepms.sh.inc'." # ----------------------------------------------------------------------------- # load my configuration -if [ -f "$myconfig" ] +for myconfig in "${NETDATA_STOCK_CONFIG_DIR}/${PROGRAM_NAME}.conf" "${NETDATA_USER_CONFIG_DIR}/${PROGRAM_NAME}.conf" +do + if [ -f "$myconfig" ] then - . "$myconfig" - [ $? -ne 0 ] && fatal "cannot load $myconfig" + source "$myconfig" + if [ $? -ne 0 ] + then + error "Config file '$myconfig' loaded with errors." + else + info "Configuration file '$myconfig' loaded." + fi + else + warning "Configuration file '$myconfig' not found." + fi +done + +# make sure time_divisor is right +time_divisor=$((time_divisor)) +[ $time_divisor -lt 10 ] && time_divisor=10 +[ $time_divisor -gt 100 ] && time_divisor=100 - time_divisor=$((time_divisor)) - [ $time_divisor -lt 10 ] && time_divisor=10 - [ $time_divisor -gt 100 ] && time_divisor=100 -else - info "configuration file '$myconfig' not found. Using defaults." -fi # we check for the timeout command, after we load our # configuration, so that the user may overwrite the @@ -296,7 +309,7 @@ run() { { printf "$(logdate): ${PROGRAM_NAME}: ${status}: ${MODULE_NAME}: command '" printf "%q " "${@}" - printf "' failed:\n --- BEGIN TRACE ---\n" + printf "' failed with code ${ret}:\n --- BEGIN TRACE ---\n" cat "${TMP_DIR}/run.${pid}" printf " --- END TRACE ---\n" } >&2 @@ -411,7 +424,7 @@ all_enabled_charts() { if [ ! "${enabled}" = "${required}" ] then - info "is disabled. Add a line with $chart=$required in $myconfig to enable it (or remove the line that disables it)." + info "is disabled. Add a line with $chart=$required in '${NETDATA_USER_CONFIG_DIR}/${PROGRAM_NAME}.conf' to enable it (or remove the line that disables it)." else debug "is enabled for auto-detection." local charts="$charts $chart" @@ -447,18 +460,18 @@ all_enabled_charts() { fi # check its config - #if [ -f "$confd/$chart.conf" ] + #if [ -f "$userconfd/$chart.conf" ] #then - # if [ ! -z "$( cat "$confd/$chart.conf" | sed "s/^ \+//g" | grep -v "^$" | grep -v "^#" | grep -v "^$chart$charts_undescore" )" ] + # if [ ! -z "$( cat "$userconfd/$chart.conf" | sed "s/^ \+//g" | grep -v "^$" | grep -v "^#" | grep -v "^$chart$charts_undescore" )" ] # then - # error "module's $chart config $confd/$chart.conf should only have lines starting with $chart$charts_undescore . Disabling it." + # error "module's $chart config $userconfd/$chart.conf should only have lines starting with $chart$charts_undescore . Disabling it." # continue # fi #fi #if [ $dryrunner -eq 1 ] # then - # "$pluginsd/charts.d.dryrun-helper.sh" "$chart" "$chartsd/$chart.chart.sh" "$confd/$chart.conf" >/dev/null + # "$pluginsd/charts.d.dryrun-helper.sh" "$chart" "$chartsd/$chart.chart.sh" "$userconfd/$chart.conf" >/dev/null # if [ $? -ne 0 ] # then # error "module's $chart did not pass the dry run check. This means it uses global variables not starting with $chart. Disabling it." @@ -486,18 +499,35 @@ do debug "loading module: '$chartsd/$chart.chart.sh'" - . "$chartsd/$chart.chart.sh" + source "$chartsd/$chart.chart.sh" + [ $? -ne 0 ] && warning "Module '$chartsd/$chart.chart.sh' loaded with errors." - if [ -f "$confd/$PROGRAM_NAME/$chart.conf" ] + # first load the stock config + if [ -f "$stockconfd/$chart.conf" ] then - debug "loading module configuration: '$confd/$PROGRAM_NAME/$chart.conf'" - . "$confd/$PROGRAM_NAME/$chart.conf" - elif [ -f "$confd/$chart.conf" ] + debug "loading module configuration: '$stockconfd/$chart.conf'" + source "$stockconfd/$chart.conf" + [ $? -ne 0 ] && warning "Config file '$stockconfd/$chart.conf' loaded with errors." + else + debug "not found module configuration: '$stockconfd/$chart.conf'" + fi + + # then load the user config (it overwrites the stock) + if [ -f "$userconfd/$chart.conf" ] then - debug "loading module configuration: '$confd/$chart.conf'" - . "$confd/$chart.conf" + debug "loading module configuration: '$userconfd/$chart.conf'" + source "$userconfd/$chart.conf" + [ $? -ne 0 ] && warning "Config file '$userconfd/$chart.conf' loaded with errors." else - warning "configuration file '$confd/$PROGRAM_NAME/$chart.conf' not found. Using defaults." + debug "not found module configuration: '$userconfd/$chart.conf'" + + if [ -f "$olduserconfd/$chart.conf" ] + then + # support for very old netdata that had the charts.d module configs in /etc/netdata + info "loading module configuration from obsolete location: '$olduserconfd/$chart.conf'" + source "$olduserconfd/$chart.conf" + [ $? -ne 0 ] && warning "Config file '$olduserconfd/$chart.conf' loaded with errors." + fi fi eval "dt=\$$chart$suffix_update_every" diff --git a/collectors/charts.d.plugin/charts.d.plugin.in b/collectors/charts.d.plugin/charts.d.plugin.in new file mode 100755 index 000000000..3477894d8 --- /dev/null +++ b/collectors/charts.d.plugin/charts.d.plugin.in @@ -0,0 +1,743 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later + +# netdata +# real-time performance and health monitoring, done right! +# (C) 2017 Costa Tsaousis <costa@tsaousis.gr> +# GPL v3+ +# +# charts.d.plugin allows easy development of BASH plugins +# +# if you need to run parallel charts.d processes, link this file to a different name +# in the same directory, with a .plugin suffix and netdata will start both of them, +# each will have a different config file and modules configuration directory. +# + +export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" + +PROGRAM_FILE="$0" +PROGRAM_NAME="$(basename $0)" +PROGRAM_NAME="${PROGRAM_NAME/.plugin}" +MODULE_NAME="main" + +# ----------------------------------------------------------------------------- +# create temp dir + +debug=0 +TMP_DIR= +chartsd_cleanup() { + trap '' EXIT QUIT HUP INT TERM + + if [ ! -z "$TMP_DIR" -a -d "$TMP_DIR" ] + then + [ $debug -eq 1 ] && echo >&2 "$PROGRAM_NAME: cleaning up temporary directory $TMP_DIR ..." + rm -rf "$TMP_DIR" + fi + exit 0 +} +trap chartsd_cleanup EXIT QUIT HUP INT TERM + +if [ $UID = "0" ] +then + TMP_DIR="$( mktemp -d /var/run/netdata-${PROGRAM_NAME}-XXXXXXXXXX )" +else + TMP_DIR="$( mktemp -d /tmp/.netdata-${PROGRAM_NAME}-XXXXXXXXXX )" +fi + +logdate() { + date "+%Y-%m-%d %H:%M:%S" +} + +log() { + local status="${1}" + shift + + echo >&2 "$(logdate): ${PROGRAM_NAME}: ${status}: ${MODULE_NAME}: ${*}" + +} + +warning() { + log WARNING "${@}" +} + +error() { + log ERROR "${@}" +} + +info() { + log INFO "${@}" +} + +fatal() { + log FATAL "${@}" + echo "DISABLE" + exit 1 +} + +debug() { + [ $debug -eq 1 ] && log DEBUG "${@}" +} + +# ----------------------------------------------------------------------------- +# check a few commands + +require_cmd() { + local x=$(which "${1}" 2>/dev/null || command -v "${1}" 2>/dev/null) + if [ -z "${x}" -o ! -x "${x}" ] + then + warning "command '${1}' is not found in ${PATH}." + eval "${1^^}_CMD=\"\"" + return 1 + fi + + eval "${1^^}_CMD=\"${x}\"" + return 0 +} + +require_cmd date || exit 1 +require_cmd sed || exit 1 +require_cmd basename || exit 1 +require_cmd dirname || exit 1 +require_cmd cat || exit 1 +require_cmd grep || exit 1 +require_cmd egrep || exit 1 +require_cmd mktemp || exit 1 +require_cmd awk || exit 1 +require_cmd timeout || exit 1 +require_cmd curl || exit 1 + +# ----------------------------------------------------------------------------- + +[ $(( ${BASH_VERSINFO[0]} )) -lt 4 ] && fatal "BASH version 4 or later is required, but found version: ${BASH_VERSION}. Please upgrade." + +info "started from '$PROGRAM_FILE' with options: $*" + +# ----------------------------------------------------------------------------- +# internal defaults +# netdata exposes a few environment variables for us + +[ -z "${NETDATA_PLUGINS_DIR}" ] && NETDATA_PLUGINS_DIR="$(dirname "${0}")" +[ -z "${NETDATA_USER_CONFIG_DIR}" ] && NETDATA_USER_CONFIG_DIR="@configdir_POST@" +[ -z "${NETDATA_STOCK_CONFIG_DIR}" ] && NETDATA_STOCK_CONFIG_DIR="@libconfigdir_POST@" + +pluginsd="${NETDATA_PLUGINS_DIR}" +stockconfd="${NETDATA_STOCK_CONFIG_DIR}/${PROGRAM_NAME}" +userconfd="${NETDATA_USER_CONFIG_DIR}/${PROGRAM_NAME}" +olduserconfd="${NETDATA_USER_CONFIG_DIR}" +chartsd="$pluginsd/../charts.d" + +minimum_update_frequency="${NETDATA_UPDATE_EVERY-1}" +update_every=${minimum_update_frequency} # this will be overwritten by the command line + +# work around for non BASH shells +charts_create="_create" +charts_update="_update" +charts_check="_check" +charts_undescore="_" + +# when making iterations, charts.d can loop more frequently +# to prevent plugins missing iterations. +# this is a percentage relative to update_every to align its +# iterations. +# The minimum is 10%, the maximum 100%. +# So, if update_every is 1 second and time_divisor is 50, +# charts.d will iterate every 500ms. +# Charts will be called to collect data only if the time +# passed since the last time the collected data is equal or +# above their update_every. +time_divisor=50 + +# number of seconds to run without restart +# after this time, charts.d.plugin will exit +# netdata will restart it +restart_timeout=$((3600 * 4)) + +# check if the charts.d plugins are using global variables +# they should not. +# It does not currently support BASH v4 arrays, so it is +# disabled +dryrunner=0 + +# check for timeout command +check_for_timeout=1 + +# the default enable/disable value for all charts +enable_all_charts="yes" + +# ----------------------------------------------------------------------------- +# parse parameters + +check=0 +chart_only= +while [ ! -z "$1" ] +do + if [ "$1" = "check" ] + then + check=1 + shift + continue + fi + + if [ "$1" = "debug" -o "$1" = "all" ] + then + debug=1 + shift + continue + fi + + if [ -f "$chartsd/$1.chart.sh" ] + then + debug=1 + chart_only="$( echo $1.chart.sh | sed "s/\.chart\.sh$//g" )" + shift + continue + fi + + if [ -f "$chartsd/$1" ] + then + debug=1 + chart_only="$( echo $1 | sed "s/\.chart\.sh$//g" )" + shift + continue + fi + + # number check + n="$1" + x=$(( n )) + if [ "$x" = "$n" ] + then + shift + update_every=$x + [ $update_every -lt $minimum_update_frequency ] && update_every=$minimum_update_frequency + continue + fi + + fatal "Cannot understand parameter $1. Aborting." +done + + +# ----------------------------------------------------------------------------- +# loop control + +# default sleep function +LOOPSLEEPMS_HIGHRES=0 +now_ms= +current_time_ms_default() { + now_ms="$(date +'%s')000" +} +current_time_ms="current_time_ms_default" +current_time_ms_accuracy=1 +mysleep="sleep" + +# if found and included, this file overwrites loopsleepms() +# and current_time_ms() with a high resolution timer function +# for precise looping. +source "$pluginsd/loopsleepms.sh.inc" +[ $? -ne 0 ] && error "Failed to load '$pluginsd/loopsleepms.sh.inc'." + +# ----------------------------------------------------------------------------- +# load my configuration + +for myconfig in "${NETDATA_STOCK_CONFIG_DIR}/${PROGRAM_NAME}.conf" "${NETDATA_USER_CONFIG_DIR}/${PROGRAM_NAME}.conf" +do + if [ -f "$myconfig" ] + then + source "$myconfig" + if [ $? -ne 0 ] + then + error "Config file '$myconfig' loaded with errors." + else + info "Configuration file '$myconfig' loaded." + fi + else + warning "Configuration file '$myconfig' not found." + fi +done + +# make sure time_divisor is right +time_divisor=$((time_divisor)) +[ $time_divisor -lt 10 ] && time_divisor=10 +[ $time_divisor -gt 100 ] && time_divisor=100 + + +# we check for the timeout command, after we load our +# configuration, so that the user may overwrite the +# timeout command we use, providing a function that +# can emulate the timeout command we need: +# > timeout SECONDS command ... +if [ $check_for_timeout -eq 1 ] + then + require_cmd timeout || exit 1 +fi + +# ----------------------------------------------------------------------------- +# internal checks + +# netdata passes the requested update frequency as the first argument +update_every=$(( update_every + 1 - 1)) # makes sure it is a number +test $update_every -eq 0 && update_every=1 # if it is zero, make it 1 + +# check the charts.d directory +[ ! -d "$chartsd" ] && fatal "cannot find charts directory '$chartsd'" + +# ----------------------------------------------------------------------------- +# library functions + +fixid() { + echo "$*" |\ + tr -c "[A-Z][a-z][0-9]" "_" |\ + sed -e "s|^_\+||g" -e "s|_\+$||g" -e "s|_\+|_|g" |\ + tr "[A-Z]" "[a-z]" +} + +run() { + local ret pid="${BASHPID}" t + + if [ "z${1}" = "z-t" -a "${2}" != "0" ] + then + t="${2}" + shift 2 + timeout ${t} "${@}" 2>"${TMP_DIR}/run.${pid}" + ret=$? + else + "${@}" 2>"${TMP_DIR}/run.${pid}" + ret=$? + fi + + if [ ${ret} -ne 0 ] + then + { + printf "$(logdate): ${PROGRAM_NAME}: ${status}: ${MODULE_NAME}: command '" + printf "%q " "${@}" + printf "' failed with code ${ret}:\n --- BEGIN TRACE ---\n" + cat "${TMP_DIR}/run.${pid}" + printf " --- END TRACE ---\n" + } >&2 + fi + rm "${TMP_DIR}/run.${pid}" + + return ${ret} +} + +# convert any floating point number +# to integer, give a multiplier +# the result is stored in ${FLOAT2INT_RESULT} +# so that no fork is necessary +# the multiplier must be a power of 10 +float2int() { + local f m="$2" a b l v=($1) + f=${v[0]} + + # the length of the multiplier - 1 + l=$(( ${#m} - 1 )) + + # check if the number is in scientific notation + if [[ ${f} =~ ^[[:space:]]*(-)?[0-9.]+(e|E)(\+|-)[0-9]+ ]] + then + # convert it to decimal + # unfortunately, this fork cannot be avoided + # if you know of a way to avoid it, please let me know + f=$(printf "%0.${l}f" ${f}) + fi + + # split the floating point number + # in integer (a) and decimal (b) + a=${f/.*/} + b=${f/*./} + + # if the integer part is missing + # set it to zero + [ -z "${a}" ] && a="0" + + # strip leading zeros from the integer part + # base 10 convertion + a=$((10#$a)) + + # check the length of the decimal part + # against the length of the multiplier + if [ ${#b} -gt ${l} ] + then + # too many digits - take the most significant + b=${b:0:${l}} + + elif [ ${#b} -lt ${l} ] + then + # too few digits - pad with zero on the right + local z="00000000000000000000000" r=$((l - ${#b})) + b="${b}${z:0:${r}}" + fi + + # strip leading zeros from the decimal part + # base 10 convertion + b=$((10#$b)) + + # store the result + FLOAT2INT_RESULT=$(( (a * m) + b )) +} + + +# ----------------------------------------------------------------------------- +# charts check functions + +all_charts() { + cd "$chartsd" + [ $? -ne 0 ] && error "cannot cd to $chartsd" && return 1 + + ls *.chart.sh | sed "s/\.chart\.sh$//g" +} + +declare -A charts_enable_keyword=( + ['apache']="force" + ['cpu_apps']="force" + ['cpufreq']="force" + ['example']="force" + ['exim']="force" + ['hddtemp']="force" + ['load_average']="force" + ['mem_apps']="force" + ['mysql']="force" + ['nginx']="force" + ['phpfpm']="force" + ['postfix']="force" + ['sensors']="force" + ['squid']="force" + ['tomcat']="force" + ) + +all_enabled_charts() { + local charts= enabled= required= + + # find all enabled charts + + for chart in $( all_charts ) + do + MODULE_NAME="${chart}" + + eval "enabled=\$$chart" + if [ -z "${enabled}" ] + then + enabled="${enable_all_charts}" + fi + + required="${charts_enable_keyword[${chart}]}" + [ -z "${required}" ] && required="yes" + + if [ ! "${enabled}" = "${required}" ] + then + info "is disabled. Add a line with $chart=$required in '${NETDATA_USER_CONFIG_DIR}/${PROGRAM_NAME}.conf' to enable it (or remove the line that disables it)." + else + debug "is enabled for auto-detection." + local charts="$charts $chart" + fi + done + MODULE_NAME="main" + + local charts2= + for chart in $charts + do + MODULE_NAME="${chart}" + + # check the enabled charts + local check="$( cat "$chartsd/$chart.chart.sh" | sed "s/^ \+//g" | grep "^$chart$charts_check()" )" + if [ -z "$check" ] + then + error "module '$chart' does not seem to have a $chart$charts_check() function. Disabling it." + continue + fi + + local create="$( cat "$chartsd/$chart.chart.sh" | sed "s/^ \+//g" | grep "^$chart$charts_create()" )" + if [ -z "$create" ] + then + error "module '$chart' does not seem to have a $chart$charts_create() function. Disabling it." + continue + fi + + local update="$( cat "$chartsd/$chart.chart.sh" | sed "s/^ \+//g" | grep "^$chart$charts_update()" )" + if [ -z "$update" ] + then + error "module '$chart' does not seem to have a $chart$charts_update() function. Disabling it." + continue + fi + + # check its config + #if [ -f "$userconfd/$chart.conf" ] + #then + # if [ ! -z "$( cat "$userconfd/$chart.conf" | sed "s/^ \+//g" | grep -v "^$" | grep -v "^#" | grep -v "^$chart$charts_undescore" )" ] + # then + # error "module's $chart config $userconfd/$chart.conf should only have lines starting with $chart$charts_undescore . Disabling it." + # continue + # fi + #fi + + #if [ $dryrunner -eq 1 ] + # then + # "$pluginsd/charts.d.dryrun-helper.sh" "$chart" "$chartsd/$chart.chart.sh" "$userconfd/$chart.conf" >/dev/null + # if [ $? -ne 0 ] + # then + # error "module's $chart did not pass the dry run check. This means it uses global variables not starting with $chart. Disabling it." + # continue + # fi + #fi + + local charts2="$charts2 $chart" + done + MODULE_NAME="main" + + echo $charts2 + debug "enabled charts: $charts2" +} + +# ----------------------------------------------------------------------------- +# load the charts + +suffix_retries="_retries" +suffix_update_every="_update_every" +active_charts= +for chart in $( all_enabled_charts ) +do + MODULE_NAME="${chart}" + + debug "loading module: '$chartsd/$chart.chart.sh'" + + source "$chartsd/$chart.chart.sh" + [ $? -ne 0 ] && warning "Module '$chartsd/$chart.chart.sh' loaded with errors." + + # first load the stock config + if [ -f "$stockconfd/$chart.conf" ] + then + debug "loading module configuration: '$stockconfd/$chart.conf'" + source "$stockconfd/$chart.conf" + [ $? -ne 0 ] && warning "Config file '$stockconfd/$chart.conf' loaded with errors." + else + debug "not found module configuration: '$stockconfd/$chart.conf'" + fi + + # then load the user config (it overwrites the stock) + if [ -f "$userconfd/$chart.conf" ] + then + debug "loading module configuration: '$userconfd/$chart.conf'" + source "$userconfd/$chart.conf" + [ $? -ne 0 ] && warning "Config file '$userconfd/$chart.conf' loaded with errors." + else + debug "not found module configuration: '$userconfd/$chart.conf'" + + if [ -f "$olduserconfd/$chart.conf" ] + then + # support for very old netdata that had the charts.d module configs in /etc/netdata + info "loading module configuration from obsolete location: '$olduserconfd/$chart.conf'" + source "$olduserconfd/$chart.conf" + [ $? -ne 0 ] && warning "Config file '$olduserconfd/$chart.conf' loaded with errors." + fi + fi + + eval "dt=\$$chart$suffix_update_every" + dt=$(( dt + 1 - 1 )) # make sure it is a number + if [ $dt -lt $update_every ] + then + eval "$chart$suffix_update_every=$update_every" + fi + + $chart$charts_check + if [ $? -eq 0 ] + then + debug "module '$chart' activated" + active_charts="$active_charts $chart" + else + error "module's '$chart' check() function reports failure." + fi +done +MODULE_NAME="main" +debug "activated modules: $active_charts" + + +# ----------------------------------------------------------------------------- +# check overwrites + +# enable work time reporting +debug_time= +test $debug -eq 1 && debug_time=tellwork + +# if we only need a specific chart, remove all the others +if [ ! -z "${chart_only}" ] +then + debug "requested to run only for: '${chart_only}'" + check_charts= + for chart in $active_charts + do + if [ "$chart" = "$chart_only" ] + then + check_charts="$chart" + break + fi + done + active_charts="$check_charts" +fi +debug "activated charts: $active_charts" + +# stop if we just need a pre-check +if [ $check -eq 1 ] +then + info "CHECK RESULT" + info "Will run the charts: $active_charts" + exit 0 +fi + +# ----------------------------------------------------------------------------- + +cd "${TMP_DIR}" || exit 1 + +# ----------------------------------------------------------------------------- +# create charts + +run_charts= +for chart in $active_charts +do + MODULE_NAME="${chart}" + + debug "calling '$chart$charts_create()'..." + $chart$charts_create + if [ $? -eq 0 ] + then + run_charts="$run_charts $chart" + debug "'$chart' initialized." + else + error "module's '$chart' function '$chart$charts_create()' reports failure." + fi +done +MODULE_NAME="main" +debug "run_charts='$run_charts'" + + +# ----------------------------------------------------------------------------- +# update dimensions + +[ -z "$run_charts" ] && fatal "No charts to collect data from." + +declare -A charts_last_update=() charts_update_every=() charts_retries=() charts_next_update=() charts_run_counter=() charts_serial_failures=() +global_update() { + local exit_at \ + c=0 dt ret last_ms exec_start_ms exec_end_ms \ + chart now_charts=() next_charts=($run_charts) \ + next_ms x seconds millis + + # return the current time in ms in $now_ms + ${current_time_ms} + + exit_at=$(( now_ms + (restart_timeout * 1000) )) + + for chart in $run_charts + do + eval "charts_update_every[$chart]=\$$chart$suffix_update_every" + test -z "${charts_update_every[$chart]}" && charts_update_every[$chart]=$update_every + + eval "charts_retries[$chart]=\$$chart$suffix_retries" + test -z "${charts_retries[$chart]}" && charts_retries[$chart]=10 + + charts_last_update[$chart]=$((now_ms - (now_ms % (charts_update_every[$chart] * 1000) ) )) + charts_next_update[$chart]=$(( charts_last_update[$chart] + (charts_update_every[$chart] * 1000) )) + charts_run_counter[$chart]=0 + charts_serial_failures[$chart]=0 + + echo "CHART netdata.plugin_chartsd_$chart '' 'Execution time for $chart plugin' 'milliseconds / run' charts.d netdata.plugin_charts area 145000 ${charts_update_every[$chart]}" + echo "DIMENSION run_time 'run time' absolute 1 1" + done + + # the main loop + while [ "${#next_charts[@]}" -gt 0 ] + do + c=$((c + 1)) + now_charts=("${next_charts[@]}") + next_charts=() + + # return the current time in ms in $now_ms + ${current_time_ms} + + for chart in "${now_charts[@]}" + do + MODULE_NAME="${chart}" + + if [ ${now_ms} -ge ${charts_next_update[$chart]} ] + then + last_ms=${charts_last_update[$chart]} + dt=$(( (now_ms - last_ms) )) + + charts_last_update[$chart]=${now_ms} + + while [ ${charts_next_update[$chart]} -lt ${now_ms} ] + do + charts_next_update[$chart]=$(( charts_next_update[$chart] + (charts_update_every[$chart] * 1000) )) + done + + # the first call should not give a duration + # so that netdata calibrates to current time + dt=$(( dt * 1000 )) + charts_run_counter[$chart]=$(( charts_run_counter[$chart] + 1 )) + if [ ${charts_run_counter[$chart]} -eq 1 ] + then + dt= + fi + + exec_start_ms=$now_ms + $chart$charts_update $dt + ret=$? + + # return the current time in ms in $now_ms + ${current_time_ms}; exec_end_ms=$now_ms + + echo "BEGIN netdata.plugin_chartsd_$chart $dt" + echo "SET run_time = $(( exec_end_ms - exec_start_ms ))" + echo "END" + + if [ $ret -eq 0 ] + then + charts_serial_failures[$chart]=0 + next_charts+=($chart) + else + charts_serial_failures[$chart]=$(( charts_serial_failures[$chart] + 1 )) + + if [ ${charts_serial_failures[$chart]} -gt ${charts_retries[$chart]} ] + then + error "module's '$chart' update() function reported failure ${charts_serial_failures[$chart]} times. Disabling it." + else + error "module's '$chart' update() function reports failure. Will keep trying for a while." + next_charts+=($chart) + fi + fi + else + next_charts+=($chart) + fi + done + MODULE_NAME="${chart}" + + # wait the time you are required to + next_ms=$((now_ms + (update_every * 1000 * 100) )) + for x in "${charts_next_update[@]}"; do [ ${x} -lt ${next_ms} ] && next_ms=${x}; done + next_ms=$((next_ms - now_ms)) + + if [ ${LOOPSLEEPMS_HIGHRES} -eq 1 -a ${next_ms} -gt 0 ] + then + next_ms=$(( next_ms + current_time_ms_accuracy )) + seconds=$(( next_ms / 1000 )) + millis=$(( next_ms % 1000 )) + if [ ${millis} -lt 10 ] + then + millis="00${millis}" + elif [ ${millis} -lt 100 ] + then + millis="0${millis}" + fi + + debug "sleeping for ${seconds}.${millis} seconds." + ${mysleep} ${seconds}.${millis} + else + debug "sleeping for ${update_every} seconds." + ${mysleep} $update_every + fi + + test ${now_ms} -ge ${exit_at} && exit 0 + done + + fatal "nothing left to do, exiting..." +} + +global_update diff --git a/collectors/charts.d.plugin/cpu_apps/Makefile.inc b/collectors/charts.d.plugin/cpu_apps/Makefile.inc new file mode 100644 index 000000000..a35f82837 --- /dev/null +++ b/collectors/charts.d.plugin/cpu_apps/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += cpu_apps/cpu_apps.chart.sh +dist_chartsconfig_DATA += cpu_apps/cpu_apps.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += cpu_apps/README.md cpu_apps/Makefile.inc + diff --git a/collectors/charts.d.plugin/cpu_apps/README.md b/collectors/charts.d.plugin/cpu_apps/README.md new file mode 100644 index 000000000..cd8adf0a2 --- /dev/null +++ b/collectors/charts.d.plugin/cpu_apps/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> USE APPS.PLUGIN. diff --git a/charts.d/cpu_apps.chart.sh b/collectors/charts.d.plugin/cpu_apps/cpu_apps.chart.sh index 8e075831a..869464afe 100644 --- a/charts.d/cpu_apps.chart.sh +++ b/collectors/charts.d.plugin/cpu_apps/cpu_apps.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash disable=SC2154,SC1072,SC1073,SC2009,SC2162,SC2006,SC2002,SC2086,SC1117 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # THIS PLUGIN IS OBSOLETE # USE apps.plugin INSTEAD diff --git a/conf.d/charts.d/cpu_apps.conf b/collectors/charts.d.plugin/cpu_apps/cpu_apps.conf index 850cd0c6f..850cd0c6f 100644 --- a/conf.d/charts.d/cpu_apps.conf +++ b/collectors/charts.d.plugin/cpu_apps/cpu_apps.conf diff --git a/collectors/charts.d.plugin/cpufreq/Makefile.inc b/collectors/charts.d.plugin/cpufreq/Makefile.inc new file mode 100644 index 000000000..682379133 --- /dev/null +++ b/collectors/charts.d.plugin/cpufreq/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += cpufreq/cpufreq.chart.sh +dist_chartsconfig_DATA += cpufreq/cpufreq.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += cpufreq/README.md cpufreq/Makefile.inc + diff --git a/collectors/charts.d.plugin/cpufreq/README.md b/collectors/charts.d.plugin/cpufreq/README.md new file mode 100644 index 000000000..d82951aac --- /dev/null +++ b/collectors/charts.d.plugin/cpufreq/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT diff --git a/charts.d/cpufreq.chart.sh b/collectors/charts.d.plugin/cpufreq/cpufreq.chart.sh index 1c41c38f2..1fc6caabf 100644 --- a/charts.d/cpufreq.chart.sh +++ b/collectors/charts.d.plugin/cpufreq/cpufreq.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # if this chart is called X.chart.sh, then all functions and global variables @@ -19,7 +20,7 @@ cpufreq_update_every= cpufreq_priority=10000 cpufreq_find_all_files() { - find $1 -maxdepth $cpufreq_sys_depth -name scaling_cur_freq 2>/dev/null + find "$1" -maxdepth $cpufreq_sys_depth -name scaling_cur_freq 2>/dev/null } # _check is called once, to find out if this chart should be enabled or not @@ -29,30 +30,30 @@ cpufreq_check() { # - 0 to enable the chart # - 1 to disable the chart - [ -z "$( cpufreq_find_all_files $cpufreq_sys_dir )" ] && return 1 + [ -z "$( cpufreq_find_all_files "$cpufreq_sys_dir" )" ] && return 1 return 0 } # _create is called once, to create the charts cpufreq_create() { - local dir= file= id= i= + local dir file id i # we create a script with the source of the # cpufreq_update() function # - the highest speed we can achieve - - [ $cpufreq_source_update -eq 1 ] && echo >$TMP_DIR/cpufreq.sh "cpufreq_update() {" + [ $cpufreq_source_update -eq 1 ] && echo >"$TMP_DIR/cpufreq.sh" "cpufreq_update() {" echo "CHART cpu.cpufreq '' 'CPU Clock' 'MHz' 'cpufreq' '' line $((cpufreq_priority + 1)) $cpufreq_update_every" - echo >>$TMP_DIR/cpufreq.sh "echo \"BEGIN cpu.cpufreq \$1\"" + echo >>"$TMP_DIR/cpufreq.sh" "echo \"BEGIN cpu.cpufreq \$1\"" i=0 - for file in $( cpufreq_find_all_files $cpufreq_sys_dir | sort -u ) + for file in $( cpufreq_find_all_files "$cpufreq_sys_dir" | sort -u ) do i=$(( i + 1 )) - dir=$( dirname $file ) + dir=$( dirname "$file" ) cpu= - [ -f $dir/affected_cpus ] && cpu=$( cat $dir/affected_cpus ) + [ -f "$dir/affected_cpus" ] && cpu=$( cat "$dir/affected_cpus" ) [ -z "$cpu" ] && cpu="$i.a" id="$( fixid "cpu$cpu" )" @@ -60,14 +61,15 @@ cpufreq_create() { debug "file='$file', dir='$dir', cpu='$cpu', id='$id'" echo "DIMENSION $id '$id' absolute 1 1000" - echo >>$TMP_DIR/cpufreq.sh "echo \"SET $id = \"\$(< $file )" + echo >>"$TMP_DIR/cpufreq.sh" "echo \"SET $id = \"\$(< $file )" done - echo >>$TMP_DIR/cpufreq.sh "echo END" + echo >>"$TMP_DIR/cpufreq.sh" "echo END" - [ $cpufreq_source_update -eq 1 ] && echo >>$TMP_DIR/cpufreq.sh "}" + [ $cpufreq_source_update -eq 1 ] && echo >>"$TMP_DIR/cpufreq.sh" "}" # ok, load the function cpufreq_update() we created - [ $cpufreq_source_update -eq 1 ] && . $TMP_DIR/cpufreq.sh + # shellcheck disable=SC1090 + [ $cpufreq_source_update -eq 1 ] && . "$TMP_DIR/cpufreq.sh" return 0 } @@ -80,8 +82,8 @@ cpufreq_update() { # do all the work to collect / calculate the values # for each dimension # remember: KEEP IT SIMPLE AND SHORT - - [ $cpufreq_source_update -eq 0 ] && . $TMP_DIR/cpufreq.sh $1 + # shellcheck disable=SC1090 + [ $cpufreq_source_update -eq 0 ] && . "$TMP_DIR/cpufreq.sh" "$1" return 0 } diff --git a/conf.d/charts.d/cpufreq.conf b/collectors/charts.d.plugin/cpufreq/cpufreq.conf index 7130555af..7130555af 100644 --- a/conf.d/charts.d/cpufreq.conf +++ b/collectors/charts.d.plugin/cpufreq/cpufreq.conf diff --git a/collectors/charts.d.plugin/example/Makefile.inc b/collectors/charts.d.plugin/example/Makefile.inc new file mode 100644 index 000000000..e6838fbbe --- /dev/null +++ b/collectors/charts.d.plugin/example/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += example/example.chart.sh +dist_chartsconfig_DATA += example/example.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += example/README.md example/Makefile.inc + diff --git a/collectors/charts.d.plugin/example/README.md b/collectors/charts.d.plugin/example/README.md new file mode 100644 index 000000000..bfd5e210a --- /dev/null +++ b/collectors/charts.d.plugin/example/README.md @@ -0,0 +1,2 @@ +This is just an example charts.d data collector. + diff --git a/charts.d/example.chart.sh b/collectors/charts.d.plugin/example/example.chart.sh index ffc98712f..1562c597a 100644 --- a/charts.d/example.chart.sh +++ b/collectors/charts.d.plugin/example/example.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # if this chart is called X.chart.sh, then all functions and global variables @@ -46,7 +47,7 @@ example_get() { example_value4=$((8192 + (RANDOM * 16383 / 32767) )) if [ $example_count -gt 0 ] - then + then example_count=$((example_count - 1)) [ $example_last -gt 16383 ] && example_value4=$((example_last + (RANDOM * ( (32767 - example_last) / 2) / 32767))) @@ -54,8 +55,14 @@ example_get() { else example_count=$((1 + (RANDOM * 5 / 32767) )) - [ $example_last -gt 16383 -a $example_value4 -gt 16383 ] && example_value4=$((example_value4 - 16383)) - [ $example_last -le 16383 -a $example_value4 -lt 16383 ] && example_value4=$((example_value4 + 16383)) + if [ $example_last -gt 16383 ] && [ $example_value4 -gt 16383 ] + then + example_value4=$((example_value4 - 16383)) + fi + if [ $example_last -le 16383 ] && [ $example_value4 -lt 16383 ] + then + example_value4=$((example_value4 + 16383)) + fi fi example_last=$example_value4 diff --git a/conf.d/charts.d/example.conf b/collectors/charts.d.plugin/example/example.conf index 6232ca584..6232ca584 100644 --- a/conf.d/charts.d/example.conf +++ b/collectors/charts.d.plugin/example/example.conf diff --git a/collectors/charts.d.plugin/exim/Makefile.inc b/collectors/charts.d.plugin/exim/Makefile.inc new file mode 100644 index 000000000..ca2112a80 --- /dev/null +++ b/collectors/charts.d.plugin/exim/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += exim/exim.chart.sh +dist_chartsconfig_DATA += exim/exim.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += exim/README.md exim/Makefile.inc + diff --git a/collectors/charts.d.plugin/exim/README.md b/collectors/charts.d.plugin/exim/README.md new file mode 100644 index 000000000..d82951aac --- /dev/null +++ b/collectors/charts.d.plugin/exim/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT diff --git a/charts.d/exim.chart.sh b/collectors/charts.d.plugin/exim/exim.chart.sh index 4c70f2c19..8099a7249 100644 --- a/charts.d/exim.chart.sh +++ b/collectors/charts.d.plugin/exim/exim.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # Contributed by @jsveiga with PR #480 @@ -22,7 +23,7 @@ exim_check() { exim_command="${EXIM_CMD}" fi - if [ $(${exim_command} -bpc 2>&1 | grep -c denied) -ne 0 ] + if [ "$(${exim_command} -bpc 2>&1 | grep -c denied)" -ne 0 ] then error "permission denied - please set 'queue_list_requires_admin = false' in your exim options file" return 1 @@ -41,7 +42,7 @@ EOF exim_update() { echo "BEGIN exim_local.qemails $1" - echo "SET emails = " $(run ${exim_command} -bpc) + echo "SET emails = $(run "${exim_command}" -bpc)" echo "END" return 0 } diff --git a/conf.d/charts.d/exim.conf b/collectors/charts.d.plugin/exim/exim.conf index f96ac4dbb..f96ac4dbb 100644 --- a/conf.d/charts.d/exim.conf +++ b/collectors/charts.d.plugin/exim/exim.conf diff --git a/collectors/charts.d.plugin/hddtemp/Makefile.inc b/collectors/charts.d.plugin/hddtemp/Makefile.inc new file mode 100644 index 000000000..2bd29e5b1 --- /dev/null +++ b/collectors/charts.d.plugin/hddtemp/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += hddtemp/hddtemp.chart.sh +dist_chartsconfig_DATA += hddtemp/hddtemp.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += hddtemp/README.md hddtemp/Makefile.inc + diff --git a/collectors/charts.d.plugin/hddtemp/README.md b/collectors/charts.d.plugin/hddtemp/README.md new file mode 100644 index 000000000..98f18900c --- /dev/null +++ b/collectors/charts.d.plugin/hddtemp/README.md @@ -0,0 +1,28 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT + +# hddtemp + +The plugin will collect temperatures from disks + +It will create one chart with all active disks + +1. **temperature in Celsius** + +### configuration + +hddtemp needs to be running in daemonized mode + +```sh +# host with daemonized hddtemp +hddtemp_host="localhost" + +# port on which hddtemp is showing data +hddtemp_port="7634" + +# array of included disks +# the default is to include all +hddtemp_disks=() +``` + +--- diff --git a/charts.d/hddtemp.chart.sh b/collectors/charts.d.plugin/hddtemp/hddtemp.chart.sh index 3aada1751..e90310981 100644 --- a/charts.d/hddtemp.chart.sh +++ b/collectors/charts.d.plugin/hddtemp/hddtemp.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # contributed by @paulfantom with PR #511 @@ -30,13 +31,14 @@ hddtemp_create() { local all all=$(nc $hddtemp_host $hddtemp_port ) unset hddtemp_disks - hddtemp_disks=( `grep -Po '/dev/[^|]+' <<< "$all" | cut -c 6-` ) + # shellcheck disable=SC2190,SC2207 + hddtemp_disks=( $(grep -Po '/dev/[^|]+' <<< "$all" | cut -c 6-) ) fi # local disk_names # disk_names=(`sed -e 's/||/\n/g;s/^|//' <<< "$all" | cut -d '|' -f2 | tr ' ' '_'`) echo "CHART hddtemp.temperature 'disks_temp' 'temperature' 'Celsius' 'Disks temperature' 'hddtemp.temp' line $((hddtemp_priority)) $hddtemp_update_every" - for i in `seq 0 $((${#hddtemp_disks[@]}-1))`; do + for i in $(seq 0 $((${#hddtemp_disks[@]}-1))); do # echo "DIMENSION ${hddtemp_disks[i]} ${disk_names[i]} absolute 1 1" echo "DIMENSION ${hddtemp_disks[$i]} '' absolute 1 1" done @@ -44,13 +46,14 @@ hddtemp_create() { } # _update is called continuously, to collect the values -hddtemp_last=0 -hddtemp_count=0 +#hddtemp_last=0 +#hddtemp_count=0 hddtemp_update() { # local all=( `nc $hddtemp_host $hddtemp_port | sed -e 's/||/\n/g;s/^|//' | cut -d '|' -f3` ) # local all=( `nc $hddtemp_host $hddtemp_port | awk 'BEGIN { FS="|" };{i=4; while (i <= NF) {print $i+0;i+=5;};}'` ) OLD_IFS=$IFS set -f + # shellcheck disable=SC2207 IFS="|" all=( $(nc $hddtemp_host $hddtemp_port 2>/dev/null) ) set +f IFS=$OLD_IFS diff --git a/conf.d/charts.d/hddtemp.conf b/collectors/charts.d.plugin/hddtemp/hddtemp.conf index b6037b40e..b6037b40e 100644 --- a/conf.d/charts.d/hddtemp.conf +++ b/collectors/charts.d.plugin/hddtemp/hddtemp.conf diff --git a/collectors/charts.d.plugin/libreswan/Makefile.inc b/collectors/charts.d.plugin/libreswan/Makefile.inc new file mode 100644 index 000000000..af767d0dd --- /dev/null +++ b/collectors/charts.d.plugin/libreswan/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += libreswan/libreswan.chart.sh +dist_chartsconfig_DATA += libreswan/libreswan.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += libreswan/README.md libreswan/Makefile.inc + diff --git a/collectors/charts.d.plugin/libreswan/README.md b/collectors/charts.d.plugin/libreswan/README.md new file mode 100644 index 000000000..41026cf72 --- /dev/null +++ b/collectors/charts.d.plugin/libreswan/README.md @@ -0,0 +1,42 @@ +# libreswan + +The plugin will collects bytes-in, bytes-out and uptime for all established libreswan IPSEC tunnels. + +The following charts are created, **per tunnel**: + +1. **Uptime** + + * the uptime of the tunnel + +2. **Traffic** + + * bytes in + * bytes out + +### configuration + +Its config file is `/etc/netdata/charts.d/libreswan.conf`. + +The plugin executes 2 commands to collect all the information it needs: + +```sh +ipsec whack --status +ipsec whack --trafficstatus +``` + +The first command is used to extract the currently established tunnels, their IDs and their names. +The second command is used to extract the current uptime and traffic. + +Most probably user `netdata` will not be able to query libreswan, so the `ipsec` commands will be denied. +The plugin attempts to run `ipsec` as `sudo ipsec ...`, to get access to libreswan statistics. + +To allow user `netdata` execute `sudo ipsec ...`, create the file `/etc/sudoers.d/netdata` with this content: + +``` +netdata ALL = (root) NOPASSWD: /sbin/ipsec whack --status +netdata ALL = (root) NOPASSWD: /sbin/ipsec whack --trafficstatus +``` + +Make sure the path `/sbin/ipsec` matches your setup (execute `which ipsec` to find the right path). + +--- diff --git a/charts.d/libreswan.chart.sh b/collectors/charts.d.plugin/libreswan/libreswan.chart.sh index 30632e9ce..6e29f8473 100644 --- a/charts.d/libreswan.chart.sh +++ b/collectors/charts.d.plugin/libreswan/libreswan.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash disable=SC1117 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2018 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # _update_every is a special variable - it holds the number of seconds @@ -60,7 +61,8 @@ libreswan_get() { libreswan_connected_tunnels=() # convert the ipsec command output to a shell script - # and source it to get the values + # and source it to get the values + # shellcheck disable=SC1090 source <( { libreswan_ipsec whack --status; @@ -85,6 +87,7 @@ libreswan_check() { require_cmd ipsec || return 1 # make sure it is libreswan + # shellcheck disable=SC2143 if [ -z "$(ipsec --version | grep -i libreswan)" ] then error "ipsec command is not Libreswan. Disabling Libreswan plugin." @@ -140,7 +143,7 @@ libreswan_update_one() { [ -z "${id}" ] && libreswan_create_one "${name}" - uptime=$(( ${libreswan_now} - ${libreswan_established_add_time[${n}]} )) + uptime=$(( libreswan_now - libreswan_established_add_time[${n}] )) [ ${uptime} -lt 0 ] && uptime=0 # write the result of the work. diff --git a/conf.d/charts.d/libreswan.conf b/collectors/charts.d.plugin/libreswan/libreswan.conf index 9b3ee77b7..9b3ee77b7 100644 --- a/conf.d/charts.d/libreswan.conf +++ b/collectors/charts.d.plugin/libreswan/libreswan.conf diff --git a/collectors/charts.d.plugin/load_average/Makefile.inc b/collectors/charts.d.plugin/load_average/Makefile.inc new file mode 100644 index 000000000..e5a481bf4 --- /dev/null +++ b/collectors/charts.d.plugin/load_average/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += load_average/load_average.chart.sh +dist_chartsconfig_DATA += load_average/load_average.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += load_average/README.md load_average/Makefile.inc + diff --git a/collectors/charts.d.plugin/load_average/README.md b/collectors/charts.d.plugin/load_average/README.md new file mode 100644 index 000000000..39d3b8189 --- /dev/null +++ b/collectors/charts.d.plugin/load_average/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> THE NETDATA DAEMON COLLECTS LOAD AVERAGE BY ITSELF diff --git a/charts.d/load_average.chart.sh b/collectors/charts.d.plugin/load_average/load_average.chart.sh index 70d3aec7a..b30cb850f 100644 --- a/charts.d/load_average.chart.sh +++ b/collectors/charts.d.plugin/load_average/load_average.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash disable=SC2154,SC1072,SC1073,SC2009,SC2162,SC2006,SC2002,SC2086,SC1117 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # load_average_update_every=5 diff --git a/conf.d/charts.d/load_average.conf b/collectors/charts.d.plugin/load_average/load_average.conf index 68979275f..68979275f 100644 --- a/conf.d/charts.d/load_average.conf +++ b/collectors/charts.d.plugin/load_average/load_average.conf diff --git a/plugins.d/loopsleepms.sh.inc b/collectors/charts.d.plugin/loopsleepms.sh.inc index ef3db192d..bdc032b99 100644 --- a/plugins.d/loopsleepms.sh.inc +++ b/collectors/charts.d.plugin/loopsleepms.sh.inc @@ -1,4 +1,5 @@ # no need for shebang - this file is included from other scripts +# SPDX-License-Identifier: GPL-3.0-or-later LOOPSLEEP_DATE="$(which date 2>/dev/null || command -v date 2>/dev/null)" if [ -z "$LOOPSLEEP_DATE" ] @@ -85,11 +86,12 @@ fi # ----------------------------------------------------------------------------- # use read with timeout for sleep -mysleep="mysleep_read" +mysleep="" mysleep_fifo="${NETDATA_CACHE_DIR-/tmp}/.netdata_bash_sleep_timer_fifo" -[ ! -e "${mysleep_fifo}" ] && mkfifo "${mysleep_fifo}" -[ ! -e "${mysleep_fifo}" ] && mysleep="sleep" +[ -f "${mysleep_fifo}" ] && rm "${mysleep_fifo}" +[ ! -p "${mysleep_fifo}" ] && mkfifo "${mysleep_fifo}" +[ -p "${mysleep_fifo}" ] && mysleep="mysleep_read" mysleep_read() { read -t "${1}" <>"${mysleep_fifo}" @@ -102,6 +104,52 @@ mysleep_read() { fi } +# ----------------------------------------------------------------------------- +# use bash loadable module for sleep + +mysleep_builtin() { + builtin sleep "${1}" + ret=$? + if [ $ret -ne 0 ] + then + echo >&2 "$0: Cannot use builtin sleep for sleeping (return code ${ret})." + mysleep="sleep" + ${mysleep} "${1}" + fi +} + +if [ -z "${mysleep}" -a "$((BASH_VERSINFO[0] +0))" -ge 3 -a "${NETDATA_BASH_LOADABLES}" != "DISABLE" ] + then + # enable modules only for bash version 3+ + + for bash_modules_path in ${BASH_LOADABLES_PATH//:/ } "$(pkg-config bash --variable=loadablesdir 2>/dev/null)" "/usr/lib/bash" "/lib/bash" "/lib64/bash" "/usr/local/lib/bash" "/usr/local/lib64/bash" + do + [ -z "${bash_modules_path}" -o ! -d "${bash_modules_path}" ] && continue + + # check for sleep + for bash_module_sleep in "sleep" "sleep.so" + do + if [ -f "${bash_modules_path}/${bash_module_sleep}" ] + then + if enable -f "${bash_modules_path}/${bash_module_sleep}" sleep 2>/dev/null + then + mysleep="mysleep_builtin" + # echo >&2 "$0: Using bash loadable ${bash_modules_path}/${bash_module_sleep} for sleep" + break + fi + fi + + done + + [ ! -z "${mysleep}" ] && break + done +fi + +# ----------------------------------------------------------------------------- +# fallback to external sleep + +[ -z "${mysleep}" ] && mysleep="sleep" + # ----------------------------------------------------------------------------- # this function is used to sleep a fraction of a second diff --git a/collectors/charts.d.plugin/mem_apps/Makefile.inc b/collectors/charts.d.plugin/mem_apps/Makefile.inc new file mode 100644 index 000000000..ea546fb69 --- /dev/null +++ b/collectors/charts.d.plugin/mem_apps/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += mem_apps/mem_apps.chart.sh +dist_chartsconfig_DATA += mem_apps/mem_apps.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += mem_apps/README.md mem_apps/Makefile.inc + diff --git a/collectors/charts.d.plugin/mem_apps/README.md b/collectors/charts.d.plugin/mem_apps/README.md new file mode 100644 index 000000000..cd8adf0a2 --- /dev/null +++ b/collectors/charts.d.plugin/mem_apps/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> USE APPS.PLUGIN. diff --git a/charts.d/mem_apps.chart.sh b/collectors/charts.d.plugin/mem_apps/mem_apps.chart.sh index 3bc65fe24..a13dc71f1 100644 --- a/charts.d/mem_apps.chart.sh +++ b/collectors/charts.d.plugin/mem_apps/mem_apps.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash disable=SC2154,SC1072,SC1073,SC2009,SC2162,SC2006,SC2002,SC2086,SC1117 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # mem_apps_apps= diff --git a/conf.d/charts.d/mem_apps.conf b/collectors/charts.d.plugin/mem_apps/mem_apps.conf index 75d24dc3e..75d24dc3e 100644 --- a/conf.d/charts.d/mem_apps.conf +++ b/collectors/charts.d.plugin/mem_apps/mem_apps.conf diff --git a/collectors/charts.d.plugin/mysql/Makefile.inc b/collectors/charts.d.plugin/mysql/Makefile.inc new file mode 100644 index 000000000..ca02fd078 --- /dev/null +++ b/collectors/charts.d.plugin/mysql/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += mysql/mysql.chart.sh +dist_chartsconfig_DATA += mysql/mysql.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += mysql/README.md mysql/Makefile.inc + diff --git a/collectors/charts.d.plugin/mysql/README.md b/collectors/charts.d.plugin/mysql/README.md new file mode 100644 index 000000000..6765b53ab --- /dev/null +++ b/collectors/charts.d.plugin/mysql/README.md @@ -0,0 +1,81 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT + +# mysql + +The plugin will monitor one or more mysql servers + +It will produce the following charts: + +1. **Bandwidth** in kbps + * in + * out + +2. **Queries** in queries/sec + * queries + * questions + * slow queries + +3. **Operations** in operations/sec + * opened tables + * flush + * commit + * delete + * prepare + * read first + * read key + * read next + * read prev + * read random + * read random next + * rollback + * save point + * update + * write + +4. **Table Locks** in locks/sec + * immediate + * waited + +5. **Select Issues** in issues/sec + * full join + * full range join + * range + * range check + * scan + +6. **Sort Issues** in issues/sec + * merge passes + * range + * scan + +### configuration + +You can configure many database servers, like this: + +You can provide, per server, the following: + +1. a name, anything you like, but keep it short +2. the mysql command to connect to the server +3. the mysql command line options to be used for connecting to the server + +Here is an example for 2 servers: + +```sh +mysql_opts[server1]="-h server1.example.com" +mysql_opts[server2]="-h server2.example.com --connect_timeout 2" +``` + +The above will use the `mysql` command found in the system path. +You can also provide a custom mysql command per server, like this: + +```sh +mysql_cmds[server2]="/opt/mysql/bin/mysql" +``` + +The above sets the mysql command only for server2. server1 will use the system default. + +If no configuration is given, the plugin will attempt to connect to mysql server at localhost. + + +--- diff --git a/charts.d/mysql.chart.sh b/collectors/charts.d.plugin/mysql/mysql.chart.sh index 1363d01f4..37e8e2a7c 100644 --- a/charts.d/mysql.chart.sh +++ b/collectors/charts.d.plugin/mysql/mysql.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html @@ -25,7 +26,8 @@ mysql_get() { IFS=$'\t'$'\n' #arr=($(run "${@}" -e "SHOW GLOBAL STATUS WHERE value REGEXP '^[0-9]';" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)" )) #arr=($(run "${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^ ]+\s[0-9]" )) - arr=($(run "${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^[:space:]]+[[:space:]]+[0-9]+" )) + # shellcheck disable=SC2207 + arr=($(run "${@}" -N -e "SHOW GLOBAL STATUS;" | grep -E "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^[:space:]]+[[:space:]]+[0-9]+" )) IFS="${oIFS}" [ "${#arr[@]}" -lt 3 ] && return 1 @@ -55,6 +57,7 @@ mysql_check() { shift fi + # shellcheck disable=SC2230 [ -z "${mysql_cmd}" ] && mysql_cmd="$(which mysql 2>/dev/null || command -v mysql 2>/dev/null)" if [ ${#mysql_opts[@]} -eq 0 ] @@ -80,16 +83,18 @@ mysql_check() { [ -z "${mysql_cmds[$m]}" ] && mysql_cmds[$m]="$mysql_cmd" if [ -z "${mysql_cmds[$m]}" ] then - error "cannot get mysql command for '$m'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf" + # shellcheck disable=SC2154 + error "cannot get mysql command for '${m}'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf" fi mysql_get "${mysql_cmds[$m]}" ${mysql_opts[$m]} + # shellcheck disable=SC2181 if [ ! $? -eq 0 ] then error "cannot get global status for '$m'. Please set mysql_opts[$m]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf" - unset mysql_cmds[$m] - unset mysql_opts[$m] - unset mysql_ids[$m] + unset "mysql_cmds[$m]" + unset "mysql_opts[$m]" + unset "mysql_ids[$m]" continue fi @@ -98,7 +103,7 @@ mysql_check() { if [ ${#mysql_opts[@]} -eq 0 ] then - if [ ${unconfigured} -eq 1 -a ${tryroot} -eq 0 ] + if [ ${unconfigured} -eq 1 ] && [ ${tryroot} -eq 0 ] then mysql_check tryroot "${@}" return $? @@ -319,12 +324,13 @@ mysql_update() { x="${mysql_ids[$m]}" mysql_get "${mysql_cmds[$m]}" ${mysql_opts[$m]} + # shellcheck disable=SC2181 if [ $? -ne 0 ] then - unset mysql_ids[$m] - unset mysql_opts[$m] - unset mysql_cmds[$m] - error "failed to get values for '$m', disabling it." + unset "mysql_ids[$m]" + unset "mysql_opts[$m]" + unset "mysql_cmds[$m]" + error "failed to get values for '${m}', disabling it." continue fi diff --git a/conf.d/charts.d/mysql.conf b/collectors/charts.d.plugin/mysql/mysql.conf index 683e4af35..683e4af35 100644 --- a/conf.d/charts.d/mysql.conf +++ b/collectors/charts.d.plugin/mysql/mysql.conf diff --git a/collectors/charts.d.plugin/nginx/Makefile.inc b/collectors/charts.d.plugin/nginx/Makefile.inc new file mode 100644 index 000000000..c9d31aada --- /dev/null +++ b/collectors/charts.d.plugin/nginx/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += nginx/nginx.chart.sh +dist_chartsconfig_DATA += nginx/nginx.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += nginx/README.md nginx/Makefile.inc + diff --git a/collectors/charts.d.plugin/nginx/README.md b/collectors/charts.d.plugin/nginx/README.md new file mode 100644 index 000000000..d82951aac --- /dev/null +++ b/collectors/charts.d.plugin/nginx/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT diff --git a/charts.d/nginx.chart.sh b/collectors/charts.d.plugin/nginx/nginx.chart.sh index d0df460ac..14dda0832 100644 --- a/charts.d/nginx.chart.sh +++ b/collectors/charts.d.plugin/nginx/nginx.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # if this chart is called X.chart.sh, then all functions and global variables @@ -26,20 +27,21 @@ nginx_reading=0 nginx_writing=0 nginx_waiting=0 nginx_get() { + # shellcheck disable=SC2207 nginx_response=($(run curl -Ss ${nginx_curl_opts} "${nginx_url}")) - [ $? -ne 0 -o "${#nginx_response[@]}" -eq 0 ] && return 1 - - if [ "${nginx_response[0]}" != "Active" \ - -o "${nginx_response[1]}" != "connections:" \ - -o "${nginx_response[3]}" != "server" \ - -o "${nginx_response[4]}" != "accepts" \ - -o "${nginx_response[5]}" != "handled" \ - -o "${nginx_response[6]}" != "requests" \ - -o "${nginx_response[10]}" != "Reading:" \ - -o "${nginx_response[12]}" != "Writing:" \ - -o "${nginx_response[14]}" != "Waiting:" \ - ] - then + # shellcheck disable=SC2181 + if [ $? -ne 0 ] || [ "${#nginx_response[@]}" -eq 0 ]; then return 1; fi + + if [ "${nginx_response[0]}" != "Active" ] ||\ + [ "${nginx_response[1]}" != "connections:" ] ||\ + [ "${nginx_response[3]}" != "server" ] ||\ + [ "${nginx_response[4]}" != "accepts" ] ||\ + [ "${nginx_response[5]}" != "handled" ] ||\ + [ "${nginx_response[6]}" != "requests" ] ||\ + [ "${nginx_response[10]}" != "Reading:" ] ||\ + [ "${nginx_response[12]}" != "Writing:" ] ||\ + [ "${nginx_response[14]}" != "Waiting:" ] + then error "Invalid response from nginx server: ${nginx_response[*]}" return 1 fi @@ -52,15 +54,14 @@ nginx_get() { nginx_writing="${nginx_response[13]}" nginx_waiting="${nginx_response[15]}" - if [ -z "${nginx_active_connections}" \ - -o -z "${nginx_accepts}" \ - -o -z "${nginx_handled}" \ - -o -z "${nginx_requests}" \ - -o -z "${nginx_reading}" \ - -o -z "${nginx_writing}" \ - -o -z "${nginx_waiting}" \ - ] - then + if [ -z "${nginx_active_connections}" ] ||\ + [ -z "${nginx_accepts}" ] ||\ + [ -z "${nginx_handled}" ] ||\ + [ -z "${nginx_requests}" ] ||\ + [ -z "${nginx_reading}" ] ||\ + [ -z "${nginx_writing}" ] ||\ + [ -z "${nginx_waiting}" ] + then error "empty values got from nginx server: ${nginx_response[*]}" return 1 fi @@ -72,8 +73,10 @@ nginx_get() { nginx_check() { nginx_get + # shellcheck disable=2181 if [ $? -ne 0 ] - then + then + # shellcheck disable=SC2154 error "cannot find stub_status on URL '${nginx_url}'. Please set nginx_url='http://nginx.server/stub_status' in $confd/nginx.conf" return 1 fi diff --git a/conf.d/charts.d/nginx.conf b/collectors/charts.d.plugin/nginx/nginx.conf index c46100a58..c46100a58 100644 --- a/conf.d/charts.d/nginx.conf +++ b/collectors/charts.d.plugin/nginx/nginx.conf diff --git a/collectors/charts.d.plugin/nut/Makefile.inc b/collectors/charts.d.plugin/nut/Makefile.inc new file mode 100644 index 000000000..4fb47145d --- /dev/null +++ b/collectors/charts.d.plugin/nut/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += nut/nut.chart.sh +dist_chartsconfig_DATA += nut/nut.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += nut/README.md nut/Makefile.inc + diff --git a/collectors/charts.d.plugin/nut/README.md b/collectors/charts.d.plugin/nut/README.md new file mode 100644 index 000000000..71906f55a --- /dev/null +++ b/collectors/charts.d.plugin/nut/README.md @@ -0,0 +1,59 @@ +# nut + +The plugin will collect UPS data for all UPSes configured in the system. + +The following charts will be created: + +1. **UPS Charge** + + * percentage changed + +2. **UPS Battery Voltage** + + * current voltage + * high voltage + * low voltage + * nominal voltage + +3. **UPS Input Voltage** + + * current voltage + * fault voltage + * nominal voltage + +4. **UPS Input Current** + + * nominal current + +5. **UPS Input Frequency** + + * current frequency + * nominal frequency + +6. **UPS Output Voltage** + + * current voltage + +7. **UPS Load** + + * current load + +8. **UPS Temperature** + + * current temperature + + +### configuration + +This is the internal default for `/etc/netdata/nut.conf` + +```sh +# a space separated list of UPS names +# if empty, the list returned by 'upsc -l' will be used +nut_ups= + +# how frequently to collect UPS data +nut_update_every=2 +``` + +--- diff --git a/charts.d/nut.chart.sh b/collectors/charts.d.plugin/nut/nut.chart.sh index 6137639f9..7e252f325 100644 --- a/charts.d/nut.chart.sh +++ b/collectors/charts.d.plugin/nut/nut.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # a space separated list of UPS names @@ -24,6 +25,7 @@ nut_clients_chart=0 nut_priority=90000 declare -A nut_ids=() +declare -A nut_names=() nut_get_all() { run -t $nut_timeout upsc -l @@ -54,16 +56,23 @@ nut_check() { for x in $nut_ups do nut_get "$x" >/dev/null + # shellcheck disable=SC2181 if [ $? -eq 0 ] + then + if [ ! -z "${nut_names[${x}]}" ] then - nut_ids[$x]="$( fixid "$x" )" + nut_ids[$x]="$( fixid "${nut_names[${x}]}" )" + else + nut_ids[$x]="$( fixid "$x" )" + fi continue fi error "cannot get information for NUT UPS '$x'." done if [ ${#nut_ids[@]} -eq 0 ] - then + then + # shellcheck disable=SC2154 error "Cannot find UPSes - please set nut_ups='ups_name' in $confd/nut.conf" return 1 fi @@ -81,38 +90,41 @@ nut_create() { CHART nut_$x.charge '' "UPS Charge" "percentage" ups nut.charge area $((nut_priority + 1)) $nut_update_every DIMENSION battery_charge charge absolute 1 100 -CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" ups nut.battery.voltage line $((nut_priority + 2)) $nut_update_every +CHART nut_$x.runtime '' "UPS Runtime" "seconds" ups nut.runtime area $((nut_priority + 2)) $nut_update_every +DIMENSION battery_runtime runtime absolute 1 100 + +CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" ups nut.battery.voltage line $((nut_priority + 3)) $nut_update_every DIMENSION battery_voltage voltage absolute 1 100 DIMENSION battery_voltage_high high absolute 1 100 DIMENSION battery_voltage_low low absolute 1 100 DIMENSION battery_voltage_nominal nominal absolute 1 100 -CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" input nut.input.voltage line $((nut_priority + 3)) $nut_update_every +CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" input nut.input.voltage line $((nut_priority + 4)) $nut_update_every DIMENSION input_voltage voltage absolute 1 100 DIMENSION input_voltage_fault fault absolute 1 100 DIMENSION input_voltage_nominal nominal absolute 1 100 -CHART nut_$x.input_current '' "UPS Input Current" "Ampere" input nut.input.current line $((nut_priority + 4)) $nut_update_every +CHART nut_$x.input_current '' "UPS Input Current" "Ampere" input nut.input.current line $((nut_priority + 5)) $nut_update_every DIMENSION input_current_nominal nominal absolute 1 100 -CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" input nut.input.frequency line $((nut_priority + 5)) $nut_update_every +CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" input nut.input.frequency line $((nut_priority + 6)) $nut_update_every DIMENSION input_frequency frequency absolute 1 100 DIMENSION input_frequency_nominal nominal absolute 1 100 -CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" output nut.output.voltage line $((nut_priority + 6)) $nut_update_every +CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" output nut.output.voltage line $((nut_priority + 7)) $nut_update_every DIMENSION output_voltage voltage absolute 1 100 CHART nut_$x.load '' "UPS Load" "percentage" ups nut.load area $((nut_priority)) $nut_update_every DIMENSION load load absolute 1 100 -CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 7)) $nut_update_every +CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 8)) $nut_update_every DIMENSION temp temp absolute 1 100 EOF if [ "${nut_clients_chart}" = "1" ] then cat <<EOF2 -CHART nut_$x.clients '' "UPS Connected Clients" "clients" ups nut.clients area $((nut_priority + 8)) $nut_update_every +CHART nut_$x.clients '' "UPS Connected Clients" "clients" ups nut.clients area $((nut_priority + 9)) $nut_update_every DIMENSION clients '' absolute 1 1 EOF2 fi @@ -138,6 +150,7 @@ nut_update() { nut_get "$i" | awk " BEGIN { battery_charge = 0; + battery_runtime = 0; battery_voltage = 0; battery_voltage_high = 0; battery_voltage_low = 0; @@ -155,6 +168,7 @@ BEGIN { do_clients = ${nut_clients_chart}; } /^battery.charge: .*/ { battery_charge = \$2 * 100 }; +/^battery.runtime: .*/ { battery_runtime = \$2 * 100 }; /^battery.voltage: .*/ { battery_voltage = \$2 * 100 }; /^battery.voltage.high: .*/ { battery_voltage_high = \$2 * 100 }; /^battery.voltage.low: .*/ { battery_voltage_low = \$2 * 100 }; @@ -174,6 +188,10 @@ END { print \"SET battery_charge = \" battery_charge; print \"END\" + print \"BEGIN nut_$x.runtime $1\"; + print \"SET battery_runtime = \" battery_runtime; + print \"END\" + print \"BEGIN nut_$x.battery_voltage $1\"; print \"SET battery_voltage = \" battery_voltage; print \"SET battery_voltage_high = \" battery_voltage_high; @@ -214,7 +232,8 @@ END { print \"END\" } }" - [ $? -ne 0 ] && unset nut_ids[$i] && error "failed to get values for '$i', disabling it." + # shellcheck disable=2181 + [ $? -ne 0 ] && unset "nut_ids[$i]" && error "failed to get values for '$i', disabling it." done [ ${#nut_ids[@]} -eq 0 ] && error "no UPSes left active." && return 1 diff --git a/conf.d/charts.d/nut.conf b/collectors/charts.d.plugin/nut/nut.conf index d477ddd34..b95ad9048 100644 --- a/conf.d/charts.d/nut.conf +++ b/collectors/charts.d.plugin/nut/nut.conf @@ -9,6 +9,11 @@ # if empty, the list returned by 'upsc -l' will be used #nut_ups= +# each line represents an alias for one UPS +# if empty, the FQDN will be used +#nut_names["FQDN1"]="alias" +#nut_names["FQDN2"]="alias" + # how much time in seconds, to wait for nut to respond #nut_timeout=2 diff --git a/collectors/charts.d.plugin/opensips/Makefile.inc b/collectors/charts.d.plugin/opensips/Makefile.inc new file mode 100644 index 000000000..a7b5d3a92 --- /dev/null +++ b/collectors/charts.d.plugin/opensips/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += opensips/opensips.chart.sh +dist_chartsconfig_DATA += opensips/opensips.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += opensips/README.md opensips/Makefile.inc + diff --git a/python.d/python_modules/bases/__init__.py b/collectors/charts.d.plugin/opensips/README.md index e69de29bb..e69de29bb 100644 --- a/python.d/python_modules/bases/__init__.py +++ b/collectors/charts.d.plugin/opensips/README.md diff --git a/charts.d/opensips.chart.sh b/collectors/charts.d.plugin/opensips/opensips.chart.sh index 2a0249dae..c227bd4f2 100644 --- a/charts.d/opensips.chart.sh +++ b/collectors/charts.d.plugin/opensips/opensips.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash disable=SC1117,SC2154,SC2086 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # opensips_opts="fifo get_statistics all" @@ -34,8 +35,10 @@ opensips_check() { fi # check once if the command works - local x="$(opensips_get_stats | grep "^opensips_core_")" - if [ ! $? -eq 0 -o -z "$x" ] + local x + x="$(opensips_get_stats | grep "^opensips_core_")" + # shellcheck disable=SC2181 + if [ ! $? -eq 0 ] || [ -z "$x" ] then error "cannot get global status. Please set opensips_opts='options' whatever needed to get connected to opensips server, in $confd/opensips.conf" return 1 @@ -218,6 +221,7 @@ opensips_update() { opensips_command_failed=0 eval "local $(opensips_get_stats)" + # shellcheck disable=SC2181 [ $? -ne 0 ] && return 1 [ $opensips_command_failed -eq 1 ] && error "failed to get values, disabling." && return 1 diff --git a/conf.d/charts.d/opensips.conf b/collectors/charts.d.plugin/opensips/opensips.conf index e25111dce..e25111dce 100644 --- a/conf.d/charts.d/opensips.conf +++ b/collectors/charts.d.plugin/opensips/opensips.conf diff --git a/collectors/charts.d.plugin/phpfpm/Makefile.inc b/collectors/charts.d.plugin/phpfpm/Makefile.inc new file mode 100644 index 000000000..56bff6102 --- /dev/null +++ b/collectors/charts.d.plugin/phpfpm/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += phpfpm/phpfpm.chart.sh +dist_chartsconfig_DATA += phpfpm/phpfpm.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += phpfpm/README.md phpfpm/Makefile.inc + diff --git a/collectors/charts.d.plugin/phpfpm/README.md b/collectors/charts.d.plugin/phpfpm/README.md new file mode 100644 index 000000000..d82951aac --- /dev/null +++ b/collectors/charts.d.plugin/phpfpm/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT diff --git a/charts.d/phpfpm.chart.sh b/collectors/charts.d.plugin/phpfpm/phpfpm.chart.sh index a3c69b6f0..1af7910bc 100644 --- a/charts.d/phpfpm.chart.sh +++ b/collectors/charts.d.plugin/phpfpm/phpfpm.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # Contributed by @safeie with PR #276 @@ -36,8 +37,12 @@ phpfpm_slow_requests=0 phpfpm_get() { local opts="${1}" url="${2}" + # shellcheck disable=SC2207,2086 phpfpm_response=($(run curl -Ss ${opts} "${url}")) - [ $? -ne 0 -o "${#phpfpm_response[@]}" -eq 0 ] && return 1 + # shellcheck disable=SC2181 + if [ $? -ne 0 ] || [ "${#phpfpm_response[@]}" -eq 0 ]; then + return 1 + fi if [[ "${phpfpm_response[0]}" != "pool:" \ || "${phpfpm_response[2]}" != "process" \ @@ -104,9 +109,11 @@ phpfpm_check() { for m in "${!phpfpm_urls[@]}" do phpfpm_get "${phpfpm_curl_opts[$m]}" "${phpfpm_urls[$m]}" + # shellcheck disable=SC2181 if [ $? -ne 0 ]; then - error "cannot find status on URL '${phpfpm_url[$m]}'. Please set phpfpm_urls[$m]='http://localhost/status' in $confd/phpfpm.conf" - unset phpfpm_urls[$m] + # shellcheck disable=SC2154 + error "cannot find status on URL '${phpfpm_urls[$m]}'. Please set phpfpm_urls[$m]='http://localhost/status' in $confd/phpfpm.conf" + unset "phpfpm_urls[$m]" continue fi done @@ -162,6 +169,7 @@ phpfpm_update() { for m in "${!phpfpm_urls[@]}" do phpfpm_get "${phpfpm_curl_opts[$m]}" "${phpfpm_urls[$m]}" + # shellcheck disable=SC2181 if [ $? -ne 0 ]; then continue fi @@ -188,7 +196,3 @@ EOF return 0 } - -phpfpm_check -phpfpm_create -phpfpm_update diff --git a/conf.d/charts.d/phpfpm.conf b/collectors/charts.d.plugin/phpfpm/phpfpm.conf index e4dd0231b..e4dd0231b 100644 --- a/conf.d/charts.d/phpfpm.conf +++ b/collectors/charts.d.plugin/phpfpm/phpfpm.conf diff --git a/collectors/charts.d.plugin/postfix/Makefile.inc b/collectors/charts.d.plugin/postfix/Makefile.inc new file mode 100644 index 000000000..6e148352d --- /dev/null +++ b/collectors/charts.d.plugin/postfix/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += postfix/postfix.chart.sh +dist_chartsconfig_DATA += postfix/postfix.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += postfix/README.md postfix/Makefile.inc + diff --git a/collectors/charts.d.plugin/postfix/README.md b/collectors/charts.d.plugin/postfix/README.md new file mode 100644 index 000000000..5fc265d56 --- /dev/null +++ b/collectors/charts.d.plugin/postfix/README.md @@ -0,0 +1,26 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT + +# postfix + +The plugin will collect the postfix queue size. + +It will create two charts: + +1. **queue size in emails** +2. **queue size in KB** + +### configuration + +This is the internal default for `/etc/netdata/postfix.conf` + +```sh +# the postqueue command +# if empty, it will use the one found in the system path +postfix_postqueue= + +# how frequently to collect queue size +postfix_update_every=15 +``` + +--- diff --git a/charts.d/postfix.chart.sh b/collectors/charts.d.plugin/postfix/postfix.chart.sh index 85604fcbe..8cb938ce1 100644 --- a/charts.d/postfix.chart.sh +++ b/collectors/charts.d.plugin/postfix/postfix.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash disable=SC1117 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # the postqueue command @@ -21,13 +22,15 @@ postfix_check() { # - 1 to disable the chart # try to find the postqueue executable - if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ] + if [ -z "$postfix_postqueue" ] || [ ! -x "$postfix_postqueue" ] then + # shellcheck disable=SC2230 postfix_postqueue="$(which postqueue 2>/dev/null || command -v postqueue 2>/dev/null)" fi - if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ] + if [ -z "$postfix_postqueue" ] || [ ! -x "$postfix_postqueue" ] then + # shellcheck disable=SC2154 error "cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf" return 1 fi @@ -67,10 +70,10 @@ postfix_update() { postfix_q_emails=0 postfix_q_size=0 - eval "$(run $postfix_postqueue -p |\ + eval "$(run "$postfix_postqueue" -p |\ grep "^--" |\ sed -e "s/-- \([0-9]\+\) Kbytes in \([0-9]\+\) Requests.$/local postfix_q_size=\1\nlocal postfix_q_emails=\2/g" |\ - egrep "^local postfix_q_(emails|size)=[0-9]+$")" + grep -E "^local postfix_q_(emails|size)=[0-9]+$")" # write the result of the work. cat <<VALUESEOF diff --git a/conf.d/charts.d/postfix.conf b/collectors/charts.d.plugin/postfix/postfix.conf index b77817bd6..b77817bd6 100644 --- a/conf.d/charts.d/postfix.conf +++ b/collectors/charts.d.plugin/postfix/postfix.conf diff --git a/collectors/charts.d.plugin/sensors/Makefile.inc b/collectors/charts.d.plugin/sensors/Makefile.inc new file mode 100644 index 000000000..f466a1b62 --- /dev/null +++ b/collectors/charts.d.plugin/sensors/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += sensors/sensors.chart.sh +dist_chartsconfig_DATA += sensors/sensors.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += sensors/README.md sensors/Makefile.inc + diff --git a/collectors/charts.d.plugin/sensors/README.md b/collectors/charts.d.plugin/sensors/README.md new file mode 100644 index 000000000..ddc3650d6 --- /dev/null +++ b/collectors/charts.d.plugin/sensors/README.md @@ -0,0 +1,52 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT + +> Unlike the python one, this module can collect temperature on RPi. + +# sensors + +The plugin will provide charts for all configured system sensors + +> This plugin is reading sensors directly from the kernel. +> The `lm-sensors` package is able to perform calculations on the +> kernel provided values, this plugin will not perform. +> So, the values graphed, are the raw hardware values of the sensors. + +The plugin will create netdata charts for: + +1. **Temperature** +2. **Voltage** +3. **Current** +4. **Power** +5. **Fans Speed** +6. **Energy** +7. **Humidity** + +One chart for every sensor chip found and each of the above will be created. + +### configuration + +This is the internal default for `/etc/netdata/sensors.conf` + +```sh +# the directory the kernel keeps sensor data +sensors_sys_dir="${NETDATA_HOST_PREFIX}/sys/devices" + +# how deep in the tree to check for sensor data +sensors_sys_depth=10 + +# if set to 1, the script will overwrite internal +# script functions with code generated ones +# leave to 1, is faster +sensors_source_update=1 + +# how frequently to collect sensor data +# the default is to collect it at every iteration of charts.d +sensors_update_every= + +# array of sensors which are excluded +# the default is to include all +sensors_excluded=() +``` + +--- diff --git a/charts.d/sensors.chart.sh b/collectors/charts.d.plugin/sensors/sensors.chart.sh index f21248da1..54368f1e0 100644 --- a/charts.d/sensors.chart.sh +++ b/collectors/charts.d.plugin/sensors/sensors.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # sensors docs @@ -32,13 +33,14 @@ sensors_priority=90000 declare -A sensors_excluded=() sensors_find_all_files() { - find $1 -maxdepth $sensors_sys_depth -name \*_input -o -name temp 2>/dev/null + find "$1" -maxdepth $sensors_sys_depth -name \*_input -o -name temp 2>/dev/null } sensors_find_all_dirs() { - sensors_find_all_files $1 | while read + # shellcheck disable=SC2162 + sensors_find_all_files "$1" | while read do - dirname $REPLY + dirname "$REPLY" done | sort -u } @@ -49,7 +51,7 @@ sensors_check() { # - 0 to enable the chart # - 1 to disable the chart - [ -z "$( sensors_find_all_files $sensors_sys_dir )" ] && error "no sensors found in '$sensors_sys_dir'." && return 1 + [ -z "$( sensors_find_all_files "$sensors_sys_dir" )" ] && error "no sensors found in '$sensors_sys_dir'." && return 1 return 0 } @@ -57,15 +59,15 @@ sensors_check_files() { # we only need sensors that report a non-zero value # also remove not needed sensors - local f= v= excluded= - for f in $* + local f v excluded + for f in "$@" do [ ! -f "$f" ] && continue - for ex in ${sensors_excluded[@]}; do + for ex in "${sensors_excluded[@]}"; do [[ $f =~ .*$ex$ ]] && excluded='1' && break done - [ "$excluded" != "1" ] && v="$( cat $f )" || v=0 + [ "$excluded" != "1" ] && v="$( cat "$f" )" || v=0 v=$(( v + 1 - 1 )) [ $v -ne 0 ] && echo "$f" && continue excluded= @@ -78,14 +80,15 @@ sensors_check_temp_type() { # valid temp types are 1 to 6 # disabled sensors have the value 0 - local f= t= v= - for f in $* + local f t v + for f in "$@" do - t=$( echo $f | sed "s|_input$|_type|g" ) + # shellcheck disable=SC2001 + t=$( echo "$f" | sed "s|_input$|_type|g" ) [ "$f" = "$t" ] && echo "$f" && continue [ ! -f "$t" ] && echo "$f" && continue - v="$( cat $t )" + v="$( cat "$t" )" v=$(( v + 1 - 1 )) [ $v -ne 0 ] && echo "$f" && continue @@ -95,34 +98,34 @@ sensors_check_temp_type() { # _create is called once, to create the charts sensors_create() { - local path= dir= name= x= file= lfile= labelname= labelid= device= subsystem= id= type= mode= files= multiplier= divisor= + local path dir name x file lfile labelname device subsystem id type mode files multiplier divisor # we create a script with the source of the # sensors_update() function # - the highest speed we can achieve - - [ $sensors_source_update -eq 1 ] && echo >$TMP_DIR/sensors.sh "sensors_update() {" + [ $sensors_source_update -eq 1 ] && echo >"$TMP_DIR/sensors.sh" "sensors_update() {" - for path in $( sensors_find_all_dirs $sensors_sys_dir | sort -u ) + for path in $( sensors_find_all_dirs "$sensors_sys_dir" | sort -u ) do - dir=$( basename $path ) + dir=$( basename "$path" ) device= subsystem= id= type= name= - [ -h $path/device ] && device=$( readlink -f $path/device ) - [ ! -z "$device" ] && device=$( basename $device ) + [ -h "$path/device" ] && device=$( readlink -f "$path/device" ) + [ ! -z "$device" ] && device=$( basename "$device" ) [ -z "$device" ] && device="$dir" - [ -h $path/subsystem ] && subsystem=$( readlink -f $path/subsystem ) - [ ! -z "$subsystem" ] && subsystem=$( basename $subsystem ) + [ -h "$path/subsystem" ] && subsystem=$( readlink -f "$path/subsystem" ) + [ ! -z "$subsystem" ] && subsystem=$( basename "$subsystem" ) [ -z "$subsystem" ] && subsystem="$dir" - [ -f $path/name ] && name=$( cat $path/name ) + [ -f "$path/name" ] && name=$( cat "$path/name" ) [ -z "$name" ] && name="$dir" - [ -f $path/type ] && type=$( cat $path/type ) + [ -f "$path/type" ] && type=$( cat "$path/type" ) [ -z "$type" ] && type="$dir" id="$( fixid "$device.$subsystem.$dir" )" @@ -138,66 +141,66 @@ sensors_create() { case $mode in temperature) - files="$( ls $path/temp*_input 2>/dev/null; ls $path/temp 2>/dev/null )" - files="$( sensors_check_files $files )" - files="$( sensors_check_temp_type $files )" + files="$( ls "$path"/temp*_input 2>/dev/null; ls "$path/temp" 2>/dev/null )" + files="$( sensors_check_files "$files" )" + files="$( sensors_check_temp_type "$files" )" [ -z "$files" ] && continue echo "CHART sensors.temp_$id '' '$name Temperature' 'Celsius' 'temperature' 'sensors.temp' line $((sensors_priority + 1)) $sensors_update_every" - echo >>$TMP_DIR/sensors.sh "echo \"BEGIN sensors.temp_$id \$1\"" + echo >>"$TMP_DIR/sensors.sh" "echo \"BEGIN sensors.temp_$id \$1\"" divisor=1000 ;; voltage) - files="$( ls $path/in*_input 2>/dev/null )" - files="$( sensors_check_files $files )" + files="$( ls "$path"/in*_input 2>/dev/null )" + files="$( sensors_check_files "$files" )" [ -z "$files" ] && continue echo "CHART sensors.volt_$id '' '$name Voltage' 'Volts' 'voltage' 'sensors.volt' line $((sensors_priority + 2)) $sensors_update_every" - echo >>$TMP_DIR/sensors.sh "echo \"BEGIN sensors.volt_$id \$1\"" + echo >>"$TMP_DIR/sensors.sh" "echo \"BEGIN sensors.volt_$id \$1\"" divisor=1000 ;; current) - files="$( ls $path/curr*_input 2>/dev/null )" - files="$( sensors_check_files $files )" + files="$( ls "$path"/curr*_input 2>/dev/null )" + files="$( sensors_check_files "$files" )" [ -z "$files" ] && continue echo "CHART sensors.curr_$id '' '$name Current' 'Ampere' 'current' 'sensors.curr' line $((sensors_priority + 3)) $sensors_update_every" - echo >>$TMP_DIR/sensors.sh "echo \"BEGIN sensors.curr_$id \$1\"" + echo >>"$TMP_DIR/sensors.sh" "echo \"BEGIN sensors.curr_$id \$1\"" divisor=1000 ;; power) - files="$( ls $path/power*_input 2>/dev/null )" - files="$( sensors_check_files $files )" + files="$( ls "$path"/power*_input 2>/dev/null )" + files="$( sensors_check_files "$files" )" [ -z "$files" ] && continue echo "CHART sensors.power_$id '' '$name Power' 'Watt' 'power' 'sensors.power' line $((sensors_priority + 4)) $sensors_update_every" - echo >>$TMP_DIR/sensors.sh "echo \"BEGIN sensors.power_$id \$1\"" + echo >>"$TMP_DIR/sensors.sh" "echo \"BEGIN sensors.power_$id \$1\"" divisor=1000000 ;; fans) - files="$( ls $path/fan*_input 2>/dev/null )" - files="$( sensors_check_files $files )" + files="$( ls "$path"/fan*_input 2>/dev/null )" + files="$( sensors_check_files "$files" )" [ -z "$files" ] && continue echo "CHART sensors.fan_$id '' '$name Fans Speed' 'Rotations / Minute' 'fans' 'sensors.fans' line $((sensors_priority + 5)) $sensors_update_every" - echo >>$TMP_DIR/sensors.sh "echo \"BEGIN sensors.fan_$id \$1\"" + echo >>"$TMP_DIR/sensors.sh" "echo \"BEGIN sensors.fan_$id \$1\"" ;; energy) - files="$( ls $path/energy*_input 2>/dev/null )" - files="$( sensors_check_files $files )" + files="$( ls "$path"/energy*_input 2>/dev/null )" + files="$( sensors_check_files "$files" )" [ -z "$files" ] && continue echo "CHART sensors.energy_$id '' '$name Energy' 'Joule' 'energy' 'sensors.energy' areastack $((sensors_priority + 6)) $sensors_update_every" - echo >>$TMP_DIR/sensors.sh "echo \"BEGIN sensors.energy_$id \$1\"" + echo >>"$TMP_DIR/sensors.sh" "echo \"BEGIN sensors.energy_$id \$1\"" algorithm="incremental" divisor=1000000 ;; humidity) - files="$( ls $path/humidity*_input 2>/dev/null )" - files="$( sensors_check_files $files )" + files="$( ls "$path"/humidity*_input 2>/dev/null )" + files="$( sensors_check_files "$files" )" [ -z "$files" ] && continue echo "CHART sensors.humidity_$id '' '$name Humidity' 'Percent' 'humidity' 'sensors.humidity' line $((sensors_priority + 7)) $sensors_update_every" - echo >>$TMP_DIR/sensors.sh "echo \"BEGIN sensors.humidity_$id \$1\"" + echo >>"$TMP_DIR/sensors.sh" "echo \"BEGIN sensors.humidity_$id \$1\"" divisor=1000 ;; @@ -210,26 +213,27 @@ sensors_create() { do file="$x" fid="$( fixid "$file" )" - lfile="$( basename $file | sed "s|_input$|_label|g" )" - labelname="$( basename $file | sed "s|_input$||g" )" + lfile="$( basename "$file" | sed "s|_input$|_label|g" )" + labelname="$( basename "$file" | sed "s|_input$||g" )" - if [ ! "$path/$lfile" = "$file" -a -f "$path/$lfile" ] - then + if [ ! "$path/$lfile" = "$file" ] && [ -f "$path/$lfile" ] + then labelname="$( cat "$path/$lfile" )" fi echo "DIMENSION $fid '$labelname' $algorithm $multiplier $divisor" - echo >>$TMP_DIR/sensors.sh "echo \"SET $fid = \"\$(< $file )" + echo >>"$TMP_DIR/sensors.sh" "echo \"SET $fid = \"\$(< $file )" done - echo >>$TMP_DIR/sensors.sh "echo END" + echo >>"$TMP_DIR/sensors.sh" "echo END" done done - [ $sensors_source_update -eq 1 ] && echo >>$TMP_DIR/sensors.sh "}" + [ $sensors_source_update -eq 1 ] && echo >>"$TMP_DIR/sensors.sh" "}" # ok, load the function sensors_update() we created - [ $sensors_source_update -eq 1 ] && . $TMP_DIR/sensors.sh + # shellcheck source=/dev/null + [ $sensors_source_update -eq 1 ] && . "$TMP_DIR/sensors.sh" return 0 } @@ -243,7 +247,8 @@ sensors_update() { # for each dimension # remember: KEEP IT SIMPLE AND SHORT - [ $sensors_source_update -eq 0 ] && . $TMP_DIR/sensors.sh $1 + # shellcheck source=/dev/null + [ $sensors_source_update -eq 0 ] && . "$TMP_DIR/sensors.sh" "$1" return 0 } diff --git a/conf.d/charts.d/sensors.conf b/collectors/charts.d.plugin/sensors/sensors.conf index bcb28807d..bcb28807d 100644 --- a/conf.d/charts.d/sensors.conf +++ b/collectors/charts.d.plugin/sensors/sensors.conf diff --git a/collectors/charts.d.plugin/squid/Makefile.inc b/collectors/charts.d.plugin/squid/Makefile.inc new file mode 100644 index 000000000..ad470d88c --- /dev/null +++ b/collectors/charts.d.plugin/squid/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += squid/squid.chart.sh +dist_chartsconfig_DATA += squid/squid.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += squid/README.md squid/Makefile.inc + diff --git a/collectors/charts.d.plugin/squid/README.md b/collectors/charts.d.plugin/squid/README.md new file mode 100644 index 000000000..0934ccfcf --- /dev/null +++ b/collectors/charts.d.plugin/squid/README.md @@ -0,0 +1,66 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT + + +# squid + +The plugin will monitor a squid server. + +It will produce 4 charts: + +1. **Squid Client Bandwidth** in kbps + + * in + * out + * hits + +2. **Squid Client Requests** in requests/sec + + * requests + * hits + * errors + +3. **Squid Server Bandwidth** in kbps + + * in + * out + +4. **Squid Server Requests** in requests/sec + + * requests + * errors + +### autoconfig + +The plugin will by itself detect squid servers running on +localhost, on ports 3128 or 8080. + +It will attempt to download URLs in the form: + +- `cache_object://HOST:PORT/counters` +- `/squid-internal-mgr/counters` + +If any succeeds, it will use this. + +### configuration + +If you need to configure it by hand, create the file +`/etc/netdata/squid.conf` with the following variables: + +- `squid_host=IP` the IP of the squid host +- `squid_port=PORT` the port the squid is listening +- `squid_url="URL"` the URL with the statistics to be fetched from squid +- `squid_timeout=SECONDS` how much time we should wait for squid to respond +- `squid_update_every=SECONDS` the frequency of the data collection + +Example `/etc/netdata/squid.conf`: + +```sh +squid_host=127.0.0.1 +squid_port=3128 +squid_url="cache_object://127.0.0.1:3128/counters" +squid_timeout=2 +squid_update_every=5 +``` + +--- diff --git a/charts.d/squid.chart.sh b/collectors/charts.d.plugin/squid/squid.chart.sh index 2c19c35d5..cf5d1d78a 100644 --- a/charts.d/squid.chart.sh +++ b/collectors/charts.d.plugin/squid/squid.chart.sh @@ -1,21 +1,21 @@ +# shellcheck shell=bash disable=SC2154 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # squid_host= squid_port= squid_url= -squid_timeout=2 squid_update_every=2 squid_priority=60000 squid_get_stats_internal() { local host="$1" port="$2" url="$3" - run squidclient -h $host -p $port $url + run squidclient -h "$host" -p "$port" "$url" } squid_get_stats() { @@ -31,7 +31,7 @@ squid_autodetect() { do x=$(squid_get_stats_internal "$host" "$port" "$url" | grep client_http.requests) if [ ! -z "$x" ] - then + then squid_host="$host" squid_port="$port" squid_url="$url" @@ -50,14 +50,16 @@ squid_check() { require_cmd sed || return 1 require_cmd egrep || return 1 - if [ -z "$squid_host" -o -z "$squid_port" -o -z "$squid_url" ] - then + if [ -z "$squid_host" ] || [ -z "$squid_port" ] || [ -z "$squid_url" ] + then squid_autodetect || return 1 fi # check once if the url works - local x="$(squid_get_stats | grep client_http.requests)" - if [ ! $? -eq 0 -o -z "$x" ] + local x + x="$(squid_get_stats | grep client_http.requests)" + # shellcheck disable=SC2181 + if [ ! $? -eq 0 ] || [ -z "$x" ] then error "cannot fetch URL '$squid_url' by connecting to $squid_host:$squid_port. Please set squid_url='url' and squid_host='host' and squid_port='port' in $confd/squid.conf" return 1 @@ -111,9 +113,10 @@ squid_update() { # prepare the script and always grep at the end the lines that are usefull, so that # even if something goes wrong, no other code can be executed + # shellcheck disable=SC1117 eval "$(squid_get_stats |\ sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/^\([a-z0-9_]\+\) *= *\([0-9]\+\)$/local squid_\1=\2/g" |\ - egrep "^local squid_(client_http|server_all)_[a-z0-9_]+=[0-9]+$")" + grep -E "^local squid_(client_http|server_all)_[a-z0-9_]+=[0-9]+$")" # write the result of the work. cat <<VALUESEOF diff --git a/conf.d/charts.d/squid.conf b/collectors/charts.d.plugin/squid/squid.conf index 19e928f25..19e928f25 100644 --- a/conf.d/charts.d/squid.conf +++ b/collectors/charts.d.plugin/squid/squid.conf diff --git a/collectors/charts.d.plugin/tomcat/Makefile.inc b/collectors/charts.d.plugin/tomcat/Makefile.inc new file mode 100644 index 000000000..ef05b1953 --- /dev/null +++ b/collectors/charts.d.plugin/tomcat/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += tomcat/tomcat.chart.sh +dist_chartsconfig_DATA += tomcat/tomcat.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += tomcat/README.md tomcat/Makefile.inc + diff --git a/collectors/charts.d.plugin/tomcat/README.md b/collectors/charts.d.plugin/tomcat/README.md new file mode 100644 index 000000000..d82951aac --- /dev/null +++ b/collectors/charts.d.plugin/tomcat/README.md @@ -0,0 +1,2 @@ +> THIS MODULE IS OBSOLETE. +> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT diff --git a/charts.d/tomcat.chart.sh b/collectors/charts.d.plugin/tomcat/tomcat.chart.sh index 4ea6ae683..294487b8b 100644 --- a/charts.d/tomcat.chart.sh +++ b/collectors/charts.d.plugin/tomcat/tomcat.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # Contributed by @jgeromero with PR #277 @@ -46,6 +47,7 @@ tomcat_check() { fi if [ -z "${tomcat_user}" ]; then # check backwards compatibility + # shellcheck disable=SC2154 if [ -z "${tomcatUser}" ]; then error "tomcat user is unset or set to the empty string" return 1 @@ -55,6 +57,7 @@ tomcat_check() { fi if [ -z "${tomcat_password}" ]; then # check backwards compatibility + # shellcheck disable=SC2154 if [ -z "${tomcatPassword}" ]; then error "tomcat password is unset or set to the empty string" return 1 @@ -65,6 +68,7 @@ tomcat_check() { # check if we can get to tomcat's status page tomcat_get + # shellcheck disable=2181 if [ $? -ne 0 ] then error "cannot get to status page on URL '${tomcat_url}'. Please make sure tomcat url, username and password are correct." @@ -116,7 +120,6 @@ EOF # _update is called continuously, to collect the values tomcat_update() { - local reqs net # the first argument to this function is the microseconds since last update # pass this parameter to the BEGIN statement (see bellow). diff --git a/conf.d/charts.d/tomcat.conf b/collectors/charts.d.plugin/tomcat/tomcat.conf index e9f3eefa9..e9f3eefa9 100644 --- a/conf.d/charts.d/tomcat.conf +++ b/collectors/charts.d.plugin/tomcat/tomcat.conf |