summaryrefslogtreecommitdiffstats
path: root/charts.d
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:19:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:20:17 +0000
commita64a253794ac64cb40befee54db53bde17dd0d49 (patch)
treec1024acc5f6e508814b944d99f112259bb28b1be /charts.d
parentNew upstream version 1.10.0+dfsg (diff)
downloadnetdata-upstream/1.11.0+dfsg.tar.xz
netdata-upstream/1.11.0+dfsg.zip
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--charts.d/Makefile.am31
-rw-r--r--charts.d/README.md344
-rw-r--r--collectors/cgroups.plugin/Makefile.in (renamed from charts.d/Makefile.in)160
-rw-r--r--collectors/charts.d.plugin/ap/ap.chart.sh (renamed from charts.d/ap.chart.sh)9
-rw-r--r--collectors/charts.d.plugin/apache/apache.chart.sh (renamed from charts.d/apache.chart.sh)52
-rw-r--r--collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh (renamed from charts.d/apcupsd.chart.sh)7
-rw-r--r--collectors/charts.d.plugin/cpu_apps/cpu_apps.chart.sh (renamed from charts.d/cpu_apps.chart.sh)3
-rw-r--r--collectors/charts.d.plugin/cpufreq/cpufreq.chart.sh (renamed from charts.d/cpufreq.chart.sh)32
-rw-r--r--collectors/charts.d.plugin/example/example.chart.sh (renamed from charts.d/example.chart.sh)15
-rw-r--r--collectors/charts.d.plugin/exim/exim.chart.sh (renamed from charts.d/exim.chart.sh)7
-rw-r--r--collectors/charts.d.plugin/hddtemp/hddtemp.chart.sh (renamed from charts.d/hddtemp.chart.sh)13
-rw-r--r--collectors/charts.d.plugin/libreswan/libreswan.chart.sh (renamed from charts.d/libreswan.chart.sh)9
-rw-r--r--collectors/charts.d.plugin/load_average/load_average.chart.sh (renamed from charts.d/load_average.chart.sh)3
-rw-r--r--collectors/charts.d.plugin/mem_apps/mem_apps.chart.sh (renamed from charts.d/mem_apps.chart.sh)3
-rw-r--r--collectors/charts.d.plugin/mysql/mysql.chart.sh (renamed from charts.d/mysql.chart.sh)28
-rw-r--r--collectors/charts.d.plugin/nginx/nginx.chart.sh (renamed from charts.d/nginx.chart.sh)51
-rw-r--r--collectors/charts.d.plugin/nut/nut.chart.sh (renamed from charts.d/nut.chart.sh)41
-rw-r--r--collectors/charts.d.plugin/opensips/opensips.chart.sh (renamed from charts.d/opensips.chart.sh)10
-rw-r--r--collectors/charts.d.plugin/phpfpm/phpfpm.chart.sh (renamed from charts.d/phpfpm.chart.sh)20
-rw-r--r--collectors/charts.d.plugin/postfix/postfix.chart.sh (renamed from charts.d/postfix.chart.sh)13
-rw-r--r--collectors/charts.d.plugin/sensors/sensors.chart.sh (renamed from charts.d/sensors.chart.sh)113
-rw-r--r--collectors/charts.d.plugin/squid/squid.chart.sh (renamed from charts.d/squid.chart.sh)21
-rw-r--r--collectors/charts.d.plugin/tomcat/tomcat.chart.sh (renamed from charts.d/tomcat.chart.sh)7
23 files changed, 341 insertions, 651 deletions
diff --git a/charts.d/Makefile.am b/charts.d/Makefile.am
deleted file mode 100644
index 104ba86af..000000000
--- a/charts.d/Makefile.am
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
-#
-MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
-
-dist_charts_SCRIPTS = \
- $(NULL)
-
-dist_charts_DATA = \
- README.md \
- ap.chart.sh \
- apcupsd.chart.sh \
- apache.chart.sh \
- cpu_apps.chart.sh \
- cpufreq.chart.sh \
- example.chart.sh \
- exim.chart.sh \
- hddtemp.chart.sh \
- libreswan.chart.sh \
- load_average.chart.sh \
- mem_apps.chart.sh \
- mysql.chart.sh \
- nginx.chart.sh \
- nut.chart.sh \
- opensips.chart.sh \
- phpfpm.chart.sh \
- postfix.chart.sh \
- sensors.chart.sh \
- squid.chart.sh \
- tomcat.chart.sh \
- $(NULL)
diff --git a/charts.d/README.md b/charts.d/README.md
deleted file mode 100644
index 748af08a1..000000000
--- a/charts.d/README.md
+++ /dev/null
@@ -1,344 +0,0 @@
-The following charts.d plugins are supported:
-
----
-
-# 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=()
-```
-
----
-
-# 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).
-
----
-
-# 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.
-
-
----
-
-# 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
-```
-
----
-
-# 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
-```
-
----
-
-# 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=()
-```
-
----
-
-# 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/Makefile.in b/collectors/cgroups.plugin/Makefile.in
index ebd1af2be..49c3c9834 100644
--- a/charts.d/Makefile.in
+++ b/collectors/cgroups.plugin/Makefile.in
@@ -14,6 +14,8 @@
@SET_MAKE@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
@@ -79,18 +81,21 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-subdir = charts.d
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
- $(dist_charts_SCRIPTS) $(dist_charts_DATA)
+DIST_COMMON = $(top_srcdir)/build/subst.inc $(srcdir)/Makefile.in \
+ $(srcdir)/Makefile.am $(dist_plugins_SCRIPTS) \
+ $(dist_noinst_DATA)
+subdir = collectors/cgroups.plugin
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___atomic.m4 \
- $(top_srcdir)/m4/ax_c__generic.m4 $(top_srcdir)/m4/ax_c_lto.m4 \
- $(top_srcdir)/m4/ax_c_mallinfo.m4 \
- $(top_srcdir)/m4/ax_c_mallopt.m4 \
- $(top_srcdir)/m4/ax_check_compile_flag.m4 \
- $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
- $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/jemalloc.m4 \
- $(top_srcdir)/m4/tcmalloc.m4 $(top_srcdir)/configure.ac
+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
@@ -124,8 +129,8 @@ am__uninstall_files_from_dir = { \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
-am__installdirs = "$(DESTDIR)$(chartsdir)" "$(DESTDIR)$(chartsdir)"
-SCRIPTS = $(dist_charts_SCRIPTS)
+am__installdirs = "$(DESTDIR)$(pluginsdir)"
+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
@@ -145,7 +150,7 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
-DATA = $(dist_charts_DATA)
+DATA = $(dist_noinst_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@@ -245,6 +250,7 @@ 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@
@@ -266,6 +272,7 @@ htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+libconfigdir = @libconfigdir@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
@@ -292,42 +299,28 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
varlibdir = @varlibdir@
webdir = @webdir@
-
-#
-# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
-#
+AUTOMAKE_OPTIONS = subdir-objects
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
-dist_charts_SCRIPTS = \
+CLEANFILES = \
+ cgroup-name.sh \
+ $(NULL)
+
+SUFFIXES = .in
+dist_plugins_SCRIPTS = \
+ cgroup-name.sh \
+ cgroup-network-helper.sh \
$(NULL)
-dist_charts_DATA = \
+dist_noinst_DATA = \
+ cgroup-name.sh.in \
README.md \
- ap.chart.sh \
- apcupsd.chart.sh \
- apache.chart.sh \
- cpu_apps.chart.sh \
- cpufreq.chart.sh \
- example.chart.sh \
- exim.chart.sh \
- hddtemp.chart.sh \
- libreswan.chart.sh \
- load_average.chart.sh \
- mem_apps.chart.sh \
- mysql.chart.sh \
- nginx.chart.sh \
- nut.chart.sh \
- opensips.chart.sh \
- phpfpm.chart.sh \
- postfix.chart.sh \
- sensors.chart.sh \
- squid.chart.sh \
- tomcat.chart.sh \
$(NULL)
all: all-am
.SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+.SUFFIXES: .in
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build/subst.inc $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -336,9 +329,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu charts.d/Makefile'; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu collectors/cgroups.plugin/Makefile'; \
$(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --gnu charts.d/Makefile
+ $(AUTOMAKE) --gnu collectors/cgroups.plugin/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -348,6 +341,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
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:
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -357,12 +351,12 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(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)
+install-dist_pluginsSCRIPTS: $(dist_plugins_SCRIPTS)
@$(NORMAL_INSTALL)
- @list='$(dist_charts_SCRIPTS)'; test -n "$(chartsdir)" || list=; \
+ @list='$(dist_plugins_SCRIPTS)'; test -n "$(pluginsdir)" || list=; \
if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(chartsdir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(chartsdir)" || exit 1; \
+ 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; \
@@ -381,38 +375,17 @@ install-dist_chartsSCRIPTS: $(dist_charts_SCRIPTS)
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 $$?; \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(pluginsdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(pluginsdir)$$dir" || exit $$?; \
} \
; done
-uninstall-dist_chartsSCRIPTS:
+uninstall-dist_pluginsSCRIPTS:
@$(NORMAL_UNINSTALL)
- @list='$(dist_charts_SCRIPTS)'; test -n "$(chartsdir)" || exit 0; \
+ @list='$(dist_plugins_SCRIPTS)'; test -n "$(pluginsdir)" || 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_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)
+ dir='$(DESTDIR)$(pluginsdir)'; $(am__uninstall_files_from_dir)
tags TAGS:
ctags CTAGS:
@@ -454,7 +427,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(SCRIPTS) $(DATA)
installdirs:
- for dir in "$(DESTDIR)$(chartsdir)" "$(DESTDIR)$(chartsdir)"; do \
+ for dir in "$(DESTDIR)$(pluginsdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -479,6 +452,7 @@ install-strip:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
@@ -508,7 +482,7 @@ info: info-am
info-am:
-install-data-am: install-dist_chartsDATA install-dist_chartsSCRIPTS
+install-data-am: install-dist_pluginsSCRIPTS
install-dvi: install-dvi-am
@@ -552,23 +526,37 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-dist_chartsDATA uninstall-dist_chartsSCRIPTS
+uninstall-am: uninstall-dist_pluginsSCRIPTS
.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-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
-
+ install-data-am install-dist_pluginsSCRIPTS 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_pluginsSCRIPTS
+
+.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.
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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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).