summaryrefslogtreecommitdiffstats
path: root/charts.d
diff options
context:
space:
mode:
Diffstat (limited to 'charts.d')
-rw-r--r--charts.d/Makefile.am4
-rw-r--r--charts.d/Makefile.in6
-rw-r--r--charts.d/README.md30
-rwxr-xr-xcharts.d/airsearches.chart.sh91
-rwxr-xr-xcharts.d/ap.chart.sh4
-rwxr-xr-xcharts.d/apache.chart.sh62
-rwxr-xr-xcharts.d/cpu_apps.chart.sh2
-rwxr-xr-xcharts.d/cpufreq.chart.sh4
-rwxr-xr-xcharts.d/crsproxy.chart.sh151
-rwxr-xr-xcharts.d/example.chart.sh94
-rw-r--r--charts.d/exim.chart.sh52
-rwxr-xr-xcharts.d/hddtemp.chart.sh66
-rwxr-xr-xcharts.d/load_average.chart.sh2
-rwxr-xr-xcharts.d/mem_apps.chart.sh2
-rwxr-xr-xcharts.d/mysql.chart.sh375
-rwxr-xr-xcharts.d/nginx.chart.sh21
-rwxr-xr-xcharts.d/nut.chart.sh2
-rwxr-xr-xcharts.d/opensips.chart.sh2
-rwxr-xr-xcharts.d/phpfpm.chart.sh37
-rwxr-xr-xcharts.d/postfix.chart.sh10
-rwxr-xr-xcharts.d/sensors.chart.sh15
-rwxr-xr-xcharts.d/squid.chart.sh20
-rwxr-xr-xcharts.d/tomcat.chart.sh38
23 files changed, 473 insertions, 617 deletions
diff --git a/charts.d/Makefile.am b/charts.d/Makefile.am
index ad11e972a..e131d508f 100644
--- a/charts.d/Makefile.am
+++ b/charts.d/Makefile.am
@@ -4,13 +4,13 @@
MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
dist_charts_SCRIPTS = \
- airsearches.chart.sh \
ap.chart.sh \
apache.chart.sh \
cpu_apps.chart.sh \
cpufreq.chart.sh \
- crsproxy.chart.sh \
example.chart.sh \
+ exim.chart.sh \
+ hddtemp.chart.sh \
load_average.chart.sh \
mem_apps.chart.sh \
mysql.chart.sh \
diff --git a/charts.d/Makefile.in b/charts.d/Makefile.in
index 3aff5a94c..5dfb3cc4b 100644
--- a/charts.d/Makefile.in
+++ b/charts.d/Makefile.in
@@ -263,6 +263,8 @@ pluginsdir = @pluginsdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+pythondir = @pythondir@
+registrydir = @registrydir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -279,13 +281,13 @@ webdir = @webdir@
#
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
dist_charts_SCRIPTS = \
- airsearches.chart.sh \
ap.chart.sh \
apache.chart.sh \
cpu_apps.chart.sh \
cpufreq.chart.sh \
- crsproxy.chart.sh \
example.chart.sh \
+ exim.chart.sh \
+ hddtemp.chart.sh \
load_average.chart.sh \
mem_apps.chart.sh \
mysql.chart.sh \
diff --git a/charts.d/README.md b/charts.d/README.md
index fd66c0d6a..37c9d22ec 100644
--- a/charts.d/README.md
+++ b/charts.d/README.md
@@ -181,6 +181,36 @@ 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=()
+```
+
+---
+
+# 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/airsearches.chart.sh b/charts.d/airsearches.chart.sh
deleted file mode 100755
index 449b14255..000000000
--- a/charts.d/airsearches.chart.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/sh
-
-airsearches_url=
-airsearches_cmds=
-airsearches_update_every=15
-
-airsearches_get() {
- wget 2>/dev/null -O - "$airsearches_url" |\
- sed -e "s|<br />|\n|g" -e "s|: |=|g" -e "s| \+|_|g" -e "s/^/airsearches_/g" |\
- tr "[A-Z]\.\!@#\$%^&*()_+\-" "[a-z]_____________" |\
- egrep "^airsearches_[a-z0-9_]+=[0-9]+$"
-}
-
-airsearches_check() {
- # make sure we have all the commands we need
- require_cmd wget || return 1
-
- # make sure we are configured
- if [ -z "$airsearches_url" ]
- then
- echo >&2 "$PROGRAM_NAME: airsearches: not configured. Please set airsearches_url='url' in $confd/airsearches.conf"
- return 1
- fi
-
- # check once if the url works
- wget 2>/dev/null -O /dev/null "$airsearches_url"
- if [ ! $? -eq 0 ]
- then
- echo >&2 "$PROGRAM_NAME: airsearches: cannot fetch the url: $airsearches_url. Please set airsearches_url='url' in $confd/airsearches.conf"
- return 1
- fi
-
- # if the admin did not give any commands
- # find the available ones
- if [ -z "$airsearches_cmds" ]
- then
- airsearches_cmds="$(airsearches_get | cut -d '=' -f 1 | sed "s/^airsearches_//g" | sort -u)"
- echo
- fi
-
- # did we find any commands?
- if [ -z "$airsearches_cmds" ]
- then
- echo >&2 "$PROGRAM_NAME: airsearches: cannot find command list automatically. Please set airsearches_cmds='...' in $confd/airsearches.conf"
- return 1
- fi
-
- # ok we can do it
- return 0
-}
-
-airsearches_create() {
- [ -z "$airsearches_cmds" ] && return 1
-
- # create the charts
- local x=
- echo "CHART airsearches.affiliates '' 'Air Searches per affiliate' 'requests / min' airsearches '' stacked 20000 $airsearches_update_every"
- for x in $airsearches_cmds
- do
- echo "DIMENSION $x '' incremental 60 1"
- done
-
- return 0
-}
-
-airsearches_update() {
- # the first argument to this function is the microseconds since last update
- # pass this parameter to the BEGIN statement (see bellow).
-
- # do all the work to collect / calculate the values
- # for each dimension
- # remember: KEEP IT SIMPLE AND SHORT
-
- # get the values from airsearches
- eval "$(airsearches_get)"
-
- # write the result of the work.
- local x=
-
- echo "BEGIN airsearches.affiliates $1"
- for x in $airsearches_cmds
- do
- eval "v=\$airsearches_$x"
- echo "SET $x = $v"
- done
- echo "END"
-
- airsearches_dt=0
-
- return 0
-}
diff --git a/charts.d/ap.chart.sh b/charts.d/ap.chart.sh
index aed51c1b6..7b4f690bb 100755
--- a/charts.d/ap.chart.sh
+++ b/charts.d/ap.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
@@ -11,6 +11,8 @@ export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
# _check is called once, to find out if this chart should be enabled or not
ap_check() {
+ require_cmd iw || return 1
+
local ev=$(iw dev | awk '
BEGIN {
i = "";
diff --git a/charts.d/apache.chart.sh b/charts.d/apache.chart.sh
index dbf14a432..2d68d43b2 100755
--- a/charts.d/apache.chart.sh
+++ b/charts.d/apache.chart.sh
@@ -1,7 +1,8 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# the URL to download apache status info
apache_url="http://127.0.0.1:80/server-status?auto"
+apache_curl_opts=
# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
@@ -66,19 +67,14 @@ apache_detect() {
# we will not check of the Conns*
# keys, since these are apache 2.4 specific
- if [ -z "${apache_key_accesses}" \
- -o -z "${apache_key_kbytes}" \
- -o -z "${apache_key_reqpersec}" \
- -o -z "${apache_key_bytespersec}" \
- -o -z "${apache_key_bytesperreq}" \
- -o -z "${apache_key_busyworkers}" \
- -o -z "${apache_key_idleworkers}" \
- -o -z "${apache_key_scoreboard}" \
- ]
- then
- echo >&2 "apache: Invalid response or missing keys from apache server: ${*}"
- return 1
- fi
+ [ -z "${apache_key_accesses}" ] && echo >&2 "apache: missing 'Total Accesses' from apache server: ${*}" && return 1
+ [ -z "${apache_key_kbytes}" ] && echo >&2 "apache: missing 'Total kBytes' from apache server: ${*}" && return 1
+ [ -z "${apache_key_reqpersec}" ] && echo >&2 "apache: missing 'ReqPerSec' from apache server: ${*}" && return 1
+ [ -z "${apache_key_bytespersec}" ] && echo >&2 "apache: missing 'BytesPerSec' from apache server: ${*}" && return 1
+ [ -z "${apache_key_bytesperreq}" ] && echo >&2 "apache: missing 'BytesPerReq' from apache server: ${*}" && return 1
+ [ -z "${apache_key_busyworkers}" ] && echo >&2 "apache: missing 'BusyWorkers' from apache server: ${*}" && return 1
+ [ -z "${apache_key_idleworkers}" ] && echo >&2 "apache: missing 'IdleWorkers' from apache server: ${*}" && return 1
+ [ -z "${apache_key_scoreboard}" ] && echo >&2 "apache: missing 'Scoreboard' from apache server: ${*}" && return 1
if [ ! -z "${apache_key_connstotal}" \
-a ! -z "${apache_key_connsasyncwriting}" \
@@ -87,6 +83,8 @@ apache_detect() {
]
then
apache_has_conns=1
+ else
+ apache_has_conns=0
fi
return 0
@@ -94,7 +92,7 @@ apache_detect() {
apache_get() {
local oIFS="${IFS}" ret
- IFS=$':\n' apache_response=($(curl -Ss "${apache_url}"))
+ IFS=$':\n' apache_response=($(curl -Ss ${apache_curl_opts} "${apache_url}"))
ret=$?
IFS="${oIFS}"
@@ -167,27 +165,27 @@ apache_check() {
# _create is called once, to create the charts
apache_create() {
cat <<EOF
-CHART apache.bytesperreq '' "apache Lifetime Avg. Response Size" "bytes/request" statistics apache.bytesperreq area $((apache_priority + 8)) $apache_update_every
+CHART apache_local.bytesperreq '' "apache Lifetime Avg. Response Size" "bytes/request" statistics apache.bytesperreq area $((apache_priority + 8)) $apache_update_every
DIMENSION size '' absolute 1 ${apache_decimal_detail}
-CHART apache.workers '' "apache Workers" "workers" workers apache.workers stacked $((apache_priority + 5)) $apache_update_every
+CHART apache_local.workers '' "apache Workers" "workers" workers apache.workers stacked $((apache_priority + 5)) $apache_update_every
DIMENSION idle '' absolute 1 1
DIMENSION busy '' absolute 1 1
-CHART apache.reqpersec '' "apache Lifetime Avg. Requests/s" "requests/s" statistics apache.reqpersec line $((apache_priority + 6)) $apache_update_every
+CHART apache_local.reqpersec '' "apache Lifetime Avg. Requests/s" "requests/s" statistics apache.reqpersec line $((apache_priority + 6)) $apache_update_every
DIMENSION requests '' absolute 1 ${apache_decimal_detail}
-CHART apache.bytespersec '' "apache Lifetime Avg. Bandwidth/s" "kilobits/s" statistics apache.bytespersec area $((apache_priority + 7)) $apache_update_every
+CHART apache_local.bytespersec '' "apache Lifetime Avg. Bandwidth/s" "kilobits/s" statistics apache.bytespersec area $((apache_priority + 7)) $apache_update_every
DIMENSION sent '' absolute 8 $((apache_decimal_detail * 1000))
-CHART apache.requests '' "apache Requests" "requests/s" requests apache.requests line $((apache_priority + 1)) $apache_update_every
+CHART apache_local.requests '' "apache Requests" "requests/s" requests apache.requests line $((apache_priority + 1)) $apache_update_every
DIMENSION requests '' incremental 1 1
-CHART apache.net '' "apache Bandwidth" "kilobits/s" bandwidth apache.net area $((apache_priority + 3)) $apache_update_every
+CHART apache_local.net '' "apache Bandwidth" "kilobits/s" bandwidth apache.net area $((apache_priority + 3)) $apache_update_every
DIMENSION sent '' incremental 8 1
EOF
if [ ${apache_has_conns} -eq 1 ]
then
cat <<EOF2
-CHART apache.connections '' "apache Connections" "connections" connections apache.connections line $((apache_priority + 2)) $apache_update_every
+CHART apache_local.connections '' "apache Connections" "connections" connections apache.connections line $((apache_priority + 2)) $apache_update_every
DIMENSION connections '' absolute 1 1
-CHART apache.conns_async '' "apache Async Connections" "connections" connections apache.conns_async stacked $((apache_priority + 4)) $apache_update_every
+CHART apache_local.conns_async '' "apache Async Connections" "connections" connections apache.conns_async stacked $((apache_priority + 4)) $apache_update_every
DIMENSION keepalive '' absolute 1 1
DIMENSION closing '' absolute 1 1
DIMENSION writing '' absolute 1 1
@@ -211,22 +209,22 @@ apache_update() {
# write the result of the work.
cat <<VALUESEOF
-BEGIN apache.requests $1
+BEGIN apache_local.requests $1
SET requests = $((apache_accesses))
END
-BEGIN apache.net $1
+BEGIN apache_local.net $1
SET sent = $((apache_kbytes))
END
-BEGIN apache.reqpersec $1
+BEGIN apache_local.reqpersec $1
SET requests = $((apache_reqpersec))
END
-BEGIN apache.bytespersec $1
+BEGIN apache_local.bytespersec $1
SET sent = $((apache_bytespersec))
END
-BEGIN apache.bytesperreq $1
+BEGIN apache_local.bytesperreq $1
SET size = $((apache_bytesperreq))
END
-BEGIN apache.workers $1
+BEGIN apache_local.workers $1
SET idle = $((apache_idleworkers))
SET busy = $((apache_busyworkers))
END
@@ -235,12 +233,12 @@ VALUESEOF
if [ ${apache_has_conns} -eq 1 ]
then
cat <<VALUESEOF2
-BEGIN apache.connections $1
+BEGIN apache_local.connections $1
SET connections = $((apache_connstotal))
END
-BEGIN apache.conns_async $1
+BEGIN apache_local.conns_async $1
SET keepalive = $((apache_connsasynckeepalive))
-SET closing = $((apache_connsasyncwriting))
+SET closing = $((apache_connsasyncclosing))
SET writing = $((apache_connsasyncwriting))
END
VALUESEOF2
diff --git a/charts.d/cpu_apps.chart.sh b/charts.d/cpu_apps.chart.sh
index 5a25163e1..6b2513dcf 100755
--- a/charts.d/cpu_apps.chart.sh
+++ b/charts.d/cpu_apps.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
# THIS PLUGIN IS OBSOLETE
# USE apps.plugin INSTEAD
diff --git a/charts.d/cpufreq.chart.sh b/charts.d/cpufreq.chart.sh
index 008ffe1d7..06f692fa6 100755
--- a/charts.d/cpufreq.chart.sh
+++ b/charts.d/cpufreq.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_
@@ -54,7 +54,7 @@ cpufreq_create() {
echo >&2 "charts.d: cpufreq: on file='$file', dir='$dir', cpu='$cpu', id='$id'"
echo "DIMENSION $id '$id' absolute 1 1000"
- echo >>$TMP_DIR/cpufreq.sh "printf \"SET $id = \"; cat $file "
+ echo >>$TMP_DIR/cpufreq.sh "echo \"SET $id = \"\$(< $file )"
done
echo >>$TMP_DIR/cpufreq.sh "echo END"
diff --git a/charts.d/crsproxy.chart.sh b/charts.d/crsproxy.chart.sh
deleted file mode 100755
index 9ad8b3382..000000000
--- a/charts.d/crsproxy.chart.sh
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/bin/sh
-
-crsproxy_url=
-crsproxy_cmds=
-crsproxy_update_every=15
-
-crsproxy_get() {
- wget 2>/dev/null -O - "$crsproxy_url" |\
- sed \
- -e "s/ \+/ /g" \
- -e "s/\./_/g" \
- -e "s/ =/=/g" \
- -e "s/= /=/g" \
- -e "s/^/crsproxy_/g" |\
- egrep "^crsproxy_[a-zA-Z][a-zA-Z0-9_]*=[0-9]+$"
-}
-
-crsproxy_check() {
- # make sure we have all the commands we need
- require_cmd wget || return 1
-
- if [ -z "$crsproxy_url" ]
- then
- echo >&2 "$PROGRAM_NAME: crsproxy: not configured. Please set crsproxy_url='url' in $confd/crsproxy.conf"
- return 1
- fi
-
- # check once if the url works
- wget 2>/dev/null -O /dev/null "$crsproxy_url"
- if [ ! $? -eq 0 ]
- then
- echo >&2 "$PROGRAM_NAME: crsproxy: cannot fetch the url: $crsproxy_url. Please set crsproxy_url='url' in $confd/crsproxy.conf"
- return 1
- fi
-
- # if the user did not request specific commands
- # find the commands available
- if [ -z "$crsproxy_cmds" ]
- then
- crsproxy_cmds="$(crsproxy_get | cut -d '=' -f 1 | sed "s/^crsproxy_cmd_//g" | sort -u)"
- fi
-
- # if no commands are available
- if [ -z "$crsproxy_cmds" ]
- then
- echo >&2 "$PROGRAM_NAME: crsproxy: cannot find command list automatically. Please set crsproxy_cmds='...' in $confd/crsproxy.conf"
- return 1
- fi
- return 0
-}
-
-crsproxy_create() {
- # create the charts
- cat <<EOF
-CHART crsproxy.connected '' "CRS Proxy Connected Clients" "clients" crsproxy '' line 20000 $crsproxy_update_every
-DIMENSION web '' absolute 1 1
-DIMENSION native '' absolute 1 1
-DIMENSION virtual '' absolute 1 1
-CHART crsproxy.requests '' "CRS Proxy Requests Rate" "requests / min" crsproxy '' area 20001 $crsproxy_update_every
-DIMENSION web '' incremental 60 1
-DIMENSION native '' incremental -60 1
-CHART crsproxy.clients '' "CRS Proxy Clients Rate" "clients / min" crsproxy '' area 20010 $crsproxy_update_every
-DIMENSION web '' incremental 60 1
-DIMENSION native '' incremental -60 1
-DIMENSION virtual '' incremental 60 1
-CHART crsproxy.replies '' "CRS Replies Rate" "replies / min" crsproxy '' area 20020 $crsproxy_update_every
-DIMENSION ok '' incremental 60 1
-DIMENSION failed '' incremental -60 1
-CHART crsproxy.bconnections '' "Back-End Connections Rate" "connections / min" crsproxy '' area 20030 $crsproxy_update_every
-DIMENSION ok '' incremental 60 1
-DIMENSION failed '' incremental -60 1
-EOF
-
- local x=
- echo "CHART crsproxy.commands '' 'CRS Commands Requests' 'requests / min' crsproxy '' stacked 20100 $crsproxy_update_every"
- for x in $crsproxy_cmds
- do
- echo "DIMENSION $x '' incremental 60 $crsproxy_update_every"
- done
-
- echo "CHART crsproxy.commands_failed '' 'CRS Failed Commands' 'replies / min' crsproxy '' stacked 20110 $crsproxy_update_every"
- for x in $crsproxy_cmds
- do
- echo "DIMENSION $x '' incremental 60 $crsproxy_update_every"
- done
-
- return 0
-}
-
-
-crsproxy_update() {
- # the first argument to this function is the microseconds since last update
- # pass this parameter to the BEGIN statement (see bellow).
-
- # do all the work to collect / calculate the values
- # for each dimension
- # remember: KEEP IT SIMPLE AND SHORT
-
- # get the values from crsproxy
- eval "$(crsproxy_get)"
-
-
- # write the result of the work.
- cat <<VALUESEOF
-BEGIN crsproxy.connected $1
-SET web = $((crsproxy_web_clients_opened - crsproxy_web_clients_closed))
-SET native = $((crsproxy_crs_clients_opened - crsproxy_crs_clients_closed))
-SET virtual = $((crsproxy_virtual_clients_opened - crsproxy_virtual_clients_closed))
-END
-BEGIN crsproxy.requests $1
-SET web = $crsproxy_web_requests
-SET native = $crsproxy_native_requests
-END
-BEGIN crsproxy.clients $1
-SET web = $crsproxy_web_clients_opened
-SET native = $crsproxy_crs_clients_opened
-SET virtual = $crsproxy_virtual_clients_opened
-END
-BEGIN crsproxy.replies $1
-SET ok = $crsproxy_replies_success
-SET failed = $crsproxy_replies_error
-END
-BEGIN crsproxy.bconnections $1
-SET ok = $crsproxy_connections_nonblocking_established
-SET failed = $crsproxy_connections_nonblocking_failed
-END
-VALUESEOF
-
- local native_requests="_native_requests"
- local web_requests="_web_requests"
- local replies_error="_replies_error"
- local x=
-
- echo "BEGIN crsproxy.commands $1"
- for x in $crsproxy_cmds
- do
- eval "v=\$(( crsproxy_cmd_$x$native_requests + crsproxy_cmd_$x$web_requests ))"
- echo "SET $x = $v"
- done
- echo "END"
-
- echo "BEGIN crsproxy.commands_failed $1"
- for x in $crsproxy_cmds
- do
- eval "v=\$crsproxy_cmd_$x$replies_error"
- echo "SET $x = $v"
- done
- echo "END"
-
- return 0
-}
diff --git a/charts.d/example.chart.sh b/charts.d/example.chart.sh
index ad2050462..1f020dee2 100755
--- a/charts.d/example.chart.sh
+++ b/charts.d/example.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_
@@ -7,14 +7,71 @@
# between the calls of the _update() function
example_update_every=
+# the priority is used to sort the charts on the dashboard
+# 1 = the first chart
example_priority=150000
+# to enable this chart, you have to set this to 12345
+# (just a demonstration for something that needs to be checked)
+example_magic_number=
+
+# global variables to store our collected data
+# remember: they need to start with the module name example_
+example_value1=
+example_value2=
+example_value3=
+example_value4=
+example_last=0
+example_count=0
+
+example_get() {
+ # do all the work to collect / calculate the values
+ # for each dimension
+ #
+ # Remember:
+ # 1. KEEP IT SIMPLE AND SHORT
+ # 2. AVOID FORKS (avoid piping commands)
+ # 3. AVOID CALLING TOO MANY EXTERNAL PROGRAMS
+ # 4. USE LOCAL VARIABLES (global variables may overlap with other modules)
+
+ example_value1=$RANDOM
+ example_value2=$RANDOM
+ example_value3=$RANDOM
+ example_value4=$((8192 + (RANDOM * 16383 / 32767) ))
+
+ if [ $example_count -gt 0 ]
+ then
+ example_count=$((example_count - 1))
+
+ [ $example_last -gt 16383 ] && example_value4=$((example_last + (RANDOM * ( (32767 - example_last) / 2) / 32767)))
+ [ $example_last -le 16383 ] && example_value4=$((example_last - (RANDOM * (example_last / 2) / 32767)))
+ else
+ example_count=$((1 + (RANDOM * 5 / 32767) ))
+
+ [ $example_last -gt 16383 -a $example_value4 -gt 16383 ] && example_value4=$((value4 - 16383))
+ [ $example_last -le 16383 -a $example_value4 -lt 16383 ] && example_value4=$((value4 + 16383))
+ fi
+ example_last=$example_value4
+
+ # this should return:
+ # - 0 to send the data to netdata
+ # - 1 to report a failure to collect the data
+
+ return 0
+}
+
# _check is called once, to find out if this chart should be enabled or not
example_check() {
# this should return:
# - 0 to enable the chart
# - 1 to disable the chart
+ # check something
+ [ "${example_magic_number}" != "12345" ] && echo >&2 "example: you have to set example_magic_number=$example_magic_number in example.conf to start example chart." && return 1
+
+ # check that we can collect data
+ example_get || return 1
+
return 0
}
@@ -34,46 +91,21 @@ EOF
}
# _update is called continiously, to collect the values
-example_last=0
-example_count=0
example_update() {
- local value1 value2 value3 value4 mode
-
# the first argument to this function is the microseconds since last update
# pass this parameter to the BEGIN statement (see bellow).
- # do all the work to collect / calculate the values
- # for each dimension
- # remember: KEEP IT SIMPLE AND SHORT
-
- value1=$RANDOM
- value2=$RANDOM
- value3=$RANDOM
- value4=$((8192 + (RANDOM * 16383 / 32767) ))
-
- if [ $example_count -gt 0 ]
- then
- example_count=$((example_count - 1))
-
- [ $example_last -gt 16383 ] && value4=$((example_last + (RANDOM * ( (32767 - example_last) / 2) / 32767)))
- [ $example_last -le 16383 ] && value4=$((example_last - (RANDOM * (example_last / 2) / 32767)))
- else
- example_count=$((1 + (RANDOM * 5 / 32767) ))
-
- [ $example_last -gt 16383 -a $value4 -gt 16383 ] && value4=$((value4 - 16383))
- [ $example_last -le 16383 -a $value4 -lt 16383 ] && value4=$((value4 + 16383))
- fi
- example_last=$value4
+ example_get || return 1
# write the result of the work.
cat <<VALUESEOF
BEGIN example.random $1
-SET random1 = $value1
-SET random2 = $value2
-SET random3 = $value3
+SET random1 = $example_value1
+SET random2 = $example_value2
+SET random3 = $example_value3
END
BEGIN example.random2 $1
-SET random = $value4
+SET random = $example_value4
END
VALUESEOF
# echo >&2 "example_count = $example_count value = $value4"
diff --git a/charts.d/exim.chart.sh b/charts.d/exim.chart.sh
new file mode 100644
index 000000000..c60ae9460
--- /dev/null
+++ b/charts.d/exim.chart.sh
@@ -0,0 +1,52 @@
+# no need for shebang - this file is loaded from charts.d.plugin
+
+exim_command=
+
+# how frequently to collect queue size
+exim_update_every=5
+
+exim_priority=60000
+
+exim_check() {
+ if [ -z "$exim_command" -o ! -x "$exim_command" ]
+ then
+ local d=
+ for d in /sbin /usr/sbin /usr/local/sbin
+ do
+ if [ -x "$d/exim" ]
+ then
+ exim_command="$d/exim"
+ break
+ fi
+ done
+ fi
+
+ if [ -z "$exim_command" -o ! -x "$exim_command" ]
+ then
+ echo >&2 "$PROGRAM_NAME: exim: cannot find exim executable. Please set 'exim_command=/path/to/exim' in $confd/exim.conf"
+ return 1
+ fi
+
+ if [ `$exim_command -bpc 2>&1 | grep -c denied` -ne 0 ]
+ then
+ echo >&2 "$PROGRAM_NAME: exim: permission denied. Please set 'queue_list_requires_admin = false' in your exim options file"
+ return 1
+ fi
+
+ return 0
+}
+
+exim_create() {
+cat <<EOF
+CHART exim_local.qemails '' "Exim Queue Emails" "emails" queue exim.queued.emails line $((exim_priority + 1)) $exim_update_every
+DIMENSION emails '' absolute 1 1
+EOF
+return 0
+}
+
+exim_update() {
+echo "BEGIN exim_local.qemails $1"
+echo "SET emails = " `$exim_command -bpc`
+echo "END"
+return 0
+}
diff --git a/charts.d/hddtemp.chart.sh b/charts.d/hddtemp.chart.sh
new file mode 100755
index 000000000..41c3e2478
--- /dev/null
+++ b/charts.d/hddtemp.chart.sh
@@ -0,0 +1,66 @@
+# no need for shebang - this file is loaded from charts.d.plugin
+
+# if this chart is called X.chart.sh, then all functions and global variables
+# must start with X_
+hddtemp_host="localhost"
+hddtemp_port="7634"
+declare -A hddtemp_disks=()
+
+# _update_every is a special variable - it holds the number of seconds
+# between the calls of the _update() function
+hddtemp_update_every=3
+hddtemp_priority=90000
+
+# _check is called once, to find out if this chart should be enabled or not
+hddtemp_check() {
+ nc $hddtemp_host $hddtemp_port &>/dev/null && return 0 || return 1
+}
+
+# _create is called once, to create the charts
+hddtemp_create() {
+ if [ ${#hddtemp_disks[@]} -eq 0 ]; then
+ local all
+ all=$(nc $hddtemp_host $hddtemp_port )
+ unset hddtemp_disks
+ 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
+# echo "DIMENSION ${hddtemp_disks[i]} ${disk_names[i]} absolute 1 1"
+ echo "DIMENSION ${hddtemp_disks[$i]} '' absolute 1 1"
+ done
+ return 0
+}
+
+# _update is called continiously, to collect the values
+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
+ IFS="|" all=( $(nc $hddtemp_host $hddtemp_port 2>/dev/null) )
+ set +f
+ IFS=$OLD_IFS
+
+ # check if there is some data
+ if [ -z "${all[3]}" ]; then
+ return 1
+ fi
+
+ # write the result of the work.
+ echo "BEGIN hddtemp.temperature $1"
+ end=${#hddtemp_disks[@]}
+ for ((i=0; i<end; i++)); do
+ # temperature - this will turn SLP to zero
+ t=$(( ${all[ $((i * 5 + 3)) ]} ))
+ echo "SET ${hddtemp_disks[$i]} = $t"
+ done
+ echo "END"
+
+ return 0
+}
diff --git a/charts.d/load_average.chart.sh b/charts.d/load_average.chart.sh
index 4d86a8f4c..e6790d807 100755
--- a/charts.d/load_average.chart.sh
+++ b/charts.d/load_average.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
load_average_update_every=5
load_priority=100
diff --git a/charts.d/mem_apps.chart.sh b/charts.d/mem_apps.chart.sh
index f537ada48..ab95b361c 100755
--- a/charts.d/mem_apps.chart.sh
+++ b/charts.d/mem_apps.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
mem_apps_apps=
diff --git a/charts.d/mysql.chart.sh b/charts.d/mysql.chart.sh
index 56dce42d7..120fec66e 100755
--- a/charts.d/mysql.chart.sh
+++ b/charts.d/mysql.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
#
@@ -7,139 +7,31 @@
# This statement does not require any privilege.
# It requires only the ability to connect to the server.
-mysql_update_every=5
+mysql_update_every=2
mysql_priority=60000
-declare -A mysql_cmds=() mysql_opts=() mysql_ids=()
+declare -A mysql_cmds=() mysql_opts=() mysql_ids=() mysql_data=()
-mysql_exec() {
- local ret
-
- "${@}" -s -e "show global status;"
- ret=$?
+mysql_get() {
+ local arr
+ local oIFS="${IFS}"
+ mysql_data=()
+ IFS=$'\t'$'\n'
+ #arr=($("${@}" -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=($("${@}" -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=($("${@}" -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]+" ))
+ IFS="${oIFS}"
+
+ [ "${#arr[@]}" -lt 3 ] && return 1
+ local end=${#arr[@]}
+ for ((i=2;i<end;i+=2)); do
+ mysql_data["${arr[$i]}"]=${arr[$i+1]}
+ done
- [ $ret -ne 0 ] && echo "plugin_command_failure $ret"
- return $ret
-}
+ [ -z "${mysql_data[Connections]}" ] && return 1
-mysql_get() {
- unset \
- mysql_Bytes_received \
- mysql_Bytes_sent \
- mysql_Queries \
- mysql_Questions \
- mysql_Slow_queries \
- mysql_Handler_commit \
- mysql_Handler_delete \
- mysql_Handler_prepare \
- mysql_Handler_read_first \
- mysql_Handler_read_key \
- mysql_Handler_read_next \
- mysql_Handler_read_prev \
- mysql_Handler_read_rnd \
- mysql_Handler_read_rnd_next \
- mysql_Handler_rollback \
- mysql_Handler_savepoint \
- mysql_Handler_savepoint_rollback \
- mysql_Handler_update \
- mysql_Handler_write \
- mysql_Table_locks_immediate \
- mysql_Table_locks_waited \
- mysql_Select_full_join \
- mysql_Select_full_range_join \
- mysql_Select_range \
- mysql_Select_range_check \
- mysql_Select_scan \
- mysql_Sort_merge_passes \
- mysql_Sort_range \
- mysql_Sort_scan \
- mysql_Created_tmp_disk_tables \
- mysql_Created_tmp_files \
- mysql_Created_tmp_tables \
- mysql_Connection_errors_accept \
- mysql_Connection_errors_internal \
- mysql_Connection_errors_max_connections \
- mysql_Connection_errors_peer_addr \
- mysql_Connection_errors_select \
- mysql_Connection_errors_tcpwrap \
- mysql_Connections \
- mysql_Aborted_connects \
- mysql_Binlog_cache_disk_use \
- mysql_Binlog_cache_use \
- mysql_Binlog_stmt_cache_disk_use \
- mysql_Binlog_stmt_cache_use \
- mysql_Threads_connected \
- mysql_Threads_created \
- mysql_Threads_cached \
- mysql_Threads_running \
- mysql_Innodb_data_read \
- mysql_Innodb_data_written \
- mysql_Innodb_data_reads \
- mysql_Innodb_data_writes \
- mysql_Innodb_data_fsyncs \
- mysql_Innodb_data_pending_reads \
- mysql_Innodb_data_pending_writes \
- mysql_Innodb_data_pending_fsyncs \
- mysql_Innodb_log_waits \
- mysql_Innodb_log_write_requests \
- mysql_Innodb_log_writes \
- mysql_Innodb_os_log_fsyncs \
- mysql_Innodb_os_log_pending_fsyncs \
- mysql_Innodb_os_log_pending_writes \
- mysql_Innodb_os_log_written \
- mysql_Innodb_row_lock_current_waits \
- mysql_Innodb_rows_inserted \
- mysql_Innodb_rows_read \
- mysql_Innodb_rows_updated \
- mysql_Innodb_rows_deleted \
- mysql_Innodb_buffer_pool_pages_data \
- mysql_Innodb_buffer_pool_pages_dirty \
- mysql_Innodb_buffer_pool_pages_flushed \
- mysql_Innodb_buffer_pool_pages_free \
- mysql_Innodb_buffer_pool_pages_misc \
- mysql_Innodb_buffer_pool_pages_total \
- mysql_Innodb_buffer_pool_bytes_data \
- mysql_Innodb_buffer_pool_bytes_dirty \
- mysql_Innodb_buffer_pool_read_ahead_rnd \
- mysql_Innodb_buffer_pool_read_ahead \
- mysql_Innodb_buffer_pool_read_ahead_evicted \
- mysql_Innodb_buffer_pool_read_requests \
- mysql_Innodb_buffer_pool_reads \
- mysql_Innodb_buffer_pool_wait_free \
- mysql_Innodb_buffer_pool_write_requests \
- mysql_Qcache_free_blocks \
- mysql_Qcache_free_memory \
- mysql_Qcache_hits \
- mysql_Qcache_inserts \
- mysql_Qcache_lowmem_prunes \
- mysql_Qcache_not_cached \
- mysql_Qcache_queries_in_cache \
- mysql_Qcache_total_blocks \
- mysql_Key_blocks_not_flushed \
- mysql_Key_blocks_unused \
- mysql_Key_blocks_used \
- mysql_Key_read_requests \
- mysql_Key_reads \
- mysql_Key_write_requests \
- mysql_Key_writes \
- mysql_Open_files \
- mysql_Opened_files
-
-
- mysql_plugin_command_failure=0
-
- eval "$(mysql_exec "${@}" |\
- sed \
- -e "s/[[:space:]]\+/ /g" \
- -e "s/\./_/g" \
- -e "s/^\([a-zA-Z0-9_]\+\)[[:space:]]\+\([0-9]\+\)$/mysql_\1=\2/g" |\
- egrep "^mysql_[a-zA-Z0-9_]+=[[:digit:]]+$")"
-
- [ $mysql_plugin_command_failure -eq 1 ] && return 1
- [ -z "$mysql_Connections" ] && return 1
-
- mysql_Thread_cache_misses=0
- [ $(( mysql_Connections + 1 - 1 )) -gt 0 ] && mysql_Thread_cache_misses=$(( mysql_Threads_created * 10000 / mysql_Connections ))
+ mysql_data[Thread_cache_misses]=0
+ [ $(( mysql_data[Connections] + 1 - 1 )) -gt 0 ] && mysql_data[Thread_cache_misses]=$(( mysql_data[Threads_created] * 10000 / mysql_data[Connections] ))
return 0
}
@@ -200,7 +92,7 @@ mysql_check() {
if [ ${#mysql_opts[@]} -eq 0 ]
then
- if [ ${unconfigured} -eq 1 && ${tryroot} -eq 0 ]
+ if [ ${unconfigured} -eq 1 -a ${tryroot} -eq 0 ]
then
mysql_check tryroot "${@}"
return $?
@@ -380,7 +272,7 @@ CHART mysql_$x.files_rate '' "mysql Opened Files Rate" "files/s" files mysql.fil
DIMENSION Opened_files files incremental 1 1
EOF
- if [ ! -z "$mysql_Binlog_stmt_cache_disk_use" ]
+ if [ ! -z "${mysql_data[Binlog_stmt_cache_disk_use]}" ]
then
cat <<EOF
CHART mysql_$x.binlog_stmt_cache '' "mysql Binlog Statement Cache" "statements/s" binlog mysql.binlog_stmt_cache line $((mysql_priority + 50)) $mysql_update_every
@@ -389,7 +281,7 @@ DIMENSION Binlog_stmt_cache_use all incremental 1 1
EOF
fi
- if [ ! -z "$mysql_Connection_errors_accept" ]
+ if [ ! -z "${mysql_data[Connection_errors_accept]}" ]
then
cat <<EOF
CHART mysql_$x.connection_errors '' "mysql Connection Errors" "connections/s" connections mysql.connection_errors line $((mysql_priority + 51)) $mysql_update_every
@@ -415,23 +307,12 @@ mysql_update() {
# for each dimension
# remember: KEEP IT SIMPLE AND SHORT
- # 1. get the counters page from mysql
- # 2. sed to remove spaces; replace . with _; remove spaces around =; prepend each line with: local mysql_
- # 3. egrep lines starting with:
- # local mysql_client_http_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
- # local mysql_server_all_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
- # 4. then execute this as a script with the eval
- #
- # be very carefull with eval:
- # 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
-
local m x
for m in "${!mysql_ids[@]}"
do
x="${mysql_ids[$m]}"
-
mysql_get "${mysql_cmds[$m]}" ${mysql_opts[$m]}
+
if [ $? -ne 0 ]
then
unset mysql_ids[$m]
@@ -444,186 +325,186 @@ mysql_update() {
# write the result of the work.
cat <<VALUESEOF
BEGIN mysql_$x.net $1
-SET Bytes_received = $mysql_Bytes_received
-SET Bytes_sent = $mysql_Bytes_sent
+SET Bytes_received = ${mysql_data[Bytes_received]}
+SET Bytes_sent = ${mysql_data[Bytes_sent]}
END
BEGIN mysql_$x.queries $1
-SET Queries = $mysql_Queries
-SET Questions = $mysql_Questions
-SET Slow_queries = $mysql_Slow_queries
+SET Queries = ${mysql_data[Queries]}
+SET Questions = ${mysql_data[Questions]}
+SET Slow_queries = ${mysql_data[Slow_queries]}
END
BEGIN mysql_$x.handlers $1
-SET Handler_commit = $mysql_Handler_commit
-SET Handler_delete = $mysql_Handler_delete
-SET Handler_prepare = $mysql_Handler_prepare
-SET Handler_read_first = $mysql_Handler_read_first
-SET Handler_read_key = $mysql_Handler_read_key
-SET Handler_read_next = $mysql_Handler_read_next
-SET Handler_read_prev = $mysql_Handler_read_prev
-SET Handler_read_rnd = $mysql_Handler_read_rnd
-SET Handler_read_rnd_next = $mysql_Handler_read_rnd_next
-SET Handler_rollback = $mysql_Handler_rollback
-SET Handler_savepoint = $mysql_Handler_savepoint
-SET Handler_savepoint_rollback = $mysql_Handler_savepoint_rollback
-SET Handler_update = $mysql_Handler_update
-SET Handler_write = $mysql_Handler_write
+SET Handler_commit = ${mysql_data[Handler_commit]}
+SET Handler_delete = ${mysql_data[Handler_delete]}
+SET Handler_prepare = ${mysql_data[Handler_prepare]}
+SET Handler_read_first = ${mysql_data[Handler_read_first]}
+SET Handler_read_key = ${mysql_data[Handler_read_key]}
+SET Handler_read_next = ${mysql_data[Handler_read_next]}
+SET Handler_read_prev = ${mysql_data[Handler_read_prev]}
+SET Handler_read_rnd = ${mysql_data[Handler_read_rnd]}
+SET Handler_read_rnd_next = ${mysql_data[Handler_read_rnd_next]}
+SET Handler_rollback = ${mysql_data[Handler_rollback]}
+SET Handler_savepoint = ${mysql_data[Handler_savepoint]}
+SET Handler_savepoint_rollback = ${mysql_data[Handler_savepoint_rollback]}
+SET Handler_update = ${mysql_data[Handler_update]}
+SET Handler_write = ${mysql_data[Handler_write]}
END
BEGIN mysql_$x.table_locks $1
-SET Table_locks_immediate = $mysql_Table_locks_immediate
-SET Table_locks_waited = $mysql_Table_locks_waited
+SET Table_locks_immediate = ${mysql_data[Table_locks_immediate]}
+SET Table_locks_waited = ${mysql_data[Table_locks_waited]}
END
BEGIN mysql_$x.join_issues $1
-SET Select_full_join = $mysql_Select_full_join
-SET Select_full_range_join = $mysql_Select_full_range_join
-SET Select_range = $mysql_Select_range
-SET Select_range_check = $mysql_Select_range_check
-SET Select_scan = $mysql_Select_scan
+SET Select_full_join = ${mysql_data[Select_full_join]}
+SET Select_full_range_join = ${mysql_data[Select_full_range_join]}
+SET Select_range = ${mysql_data[Select_range]}
+SET Select_range_check = ${mysql_data[Select_range_check]}
+SET Select_scan = ${mysql_data[Select_scan]}
END
BEGIN mysql_$x.sort_issues $1
-SET Sort_merge_passes = $mysql_Sort_merge_passes
-SET Sort_range = $mysql_Sort_range
-SET Sort_scan = $mysql_Sort_scan
+SET Sort_merge_passes = ${mysql_data[Sort_merge_passes]}
+SET Sort_range = ${mysql_data[Sort_range]}
+SET Sort_scan = ${mysql_data[Sort_scan]}
END
BEGIN mysql_$x.tmp $1
-SET Created_tmp_disk_tables = $mysql_Created_tmp_disk_tables
-SET Created_tmp_files = $mysql_Created_tmp_files
-SET Created_tmp_tables = $mysql_Created_tmp_tables
+SET Created_tmp_disk_tables = ${mysql_data[Created_tmp_disk_tables]}
+SET Created_tmp_files = ${mysql_data[Created_tmp_files]}
+SET Created_tmp_tables = ${mysql_data[Created_tmp_tables]}
END
BEGIN mysql_$x.connections $1
-SET Connections = $mysql_Connections
-SET Aborted_connects = $mysql_Aborted_connects
+SET Connections = ${mysql_data[Connections]}
+SET Aborted_connects = ${mysql_data[Aborted_connects]}
END
BEGIN mysql_$x.binlog_cache $1
-SET Binlog_cache_disk_use = $mysql_Binlog_cache_disk_use
-SET Binlog_cache_use = $mysql_Binlog_cache_use
+SET Binlog_cache_disk_use = ${mysql_data[Binlog_cache_disk_use]}
+SET Binlog_cache_use = ${mysql_data[Binlog_cache_use]}
END
BEGIN mysql_$x.threads $1
-SET Threads_connected = $mysql_Threads_connected
-SET Threads_created = $mysql_Threads_created
-SET Threads_cached = $mysql_Threads_cached
-SET Threads_running = $mysql_Threads_running
+SET Threads_connected = ${mysql_data[Threads_connected]}
+SET Threads_created = ${mysql_data[Threads_created]}
+SET Threads_cached = ${mysql_data[Threads_cached]}
+SET Threads_running = ${mysql_data[Threads_running]}
END
BEGIN mysql_$x.thread_cache_misses $1
-SET misses = $mysql_Thread_cache_misses
+SET misses = ${mysql_data[Thread_cache_misses]}
END
BEGIN mysql_$x.innodb_io $1
-SET Innodb_data_read = $mysql_Innodb_data_read
-SET Innodb_data_written = $mysql_Innodb_data_written
+SET Innodb_data_read = ${mysql_data[Innodb_data_read]}
+SET Innodb_data_written = ${mysql_data[Innodb_data_written]}
END
BEGIN mysql_$x.innodb_io_ops $1
-SET Innodb_data_reads = $mysql_Innodb_data_reads
-SET Innodb_data_writes = $mysql_Innodb_data_writes
-SET Innodb_data_fsyncs = $mysql_Innodb_data_fsyncs
+SET Innodb_data_reads = ${mysql_data[Innodb_data_reads]}
+SET Innodb_data_writes = ${mysql_data[Innodb_data_writes]}
+SET Innodb_data_fsyncs = ${mysql_data[Innodb_data_fsyncs]}
END
BEGIN mysql_$x.innodb_io_pending_ops $1
-SET Innodb_data_pending_reads = $mysql_Innodb_data_pending_reads
-SET Innodb_data_pending_writes = $mysql_Innodb_data_pending_writes
-SET Innodb_data_pending_fsyncs = $mysql_Innodb_data_pending_fsyncs
+SET Innodb_data_pending_reads = ${mysql_data[Innodb_data_pending_reads]}
+SET Innodb_data_pending_writes = ${mysql_data[Innodb_data_pending_writes]}
+SET Innodb_data_pending_fsyncs = ${mysql_data[Innodb_data_pending_fsyncs]}
END
BEGIN mysql_$x.innodb_log $1
-SET Innodb_log_waits = $mysql_Innodb_log_waits
-SET Innodb_log_write_requests = $mysql_Innodb_log_write_requests
-SET Innodb_log_writes = $mysql_Innodb_log_writes
+SET Innodb_log_waits = ${mysql_data[Innodb_log_waits]}
+SET Innodb_log_write_requests = ${mysql_data[Innodb_log_write_requests]}
+SET Innodb_log_writes = ${mysql_data[Innodb_log_writes]}
END
BEGIN mysql_$x.innodb_os_log $1
-SET Innodb_os_log_fsyncs = $mysql_Innodb_os_log_fsyncs
-SET Innodb_os_log_pending_fsyncs = $mysql_Innodb_os_log_pending_fsyncs
-SET Innodb_os_log_pending_writes = $mysql_Innodb_os_log_pending_writes
+SET Innodb_os_log_fsyncs = ${mysql_data[Innodb_os_log_fsyncs]}
+SET Innodb_os_log_pending_fsyncs = ${mysql_data[Innodb_os_log_pending_fsyncs]}
+SET Innodb_os_log_pending_writes = ${mysql_data[Innodb_os_log_pending_writes]}
END
BEGIN mysql_$x.innodb_os_log_io $1
-SET Innodb_os_log_written = $mysql_Innodb_os_log_written
+SET Innodb_os_log_written = ${mysql_data[Innodb_os_log_written]}
END
BEGIN mysql_$x.innodb_cur_row_lock $1
-SET Innodb_row_lock_current_waits = $mysql_Innodb_row_lock_current_waits
+SET Innodb_row_lock_current_waits = ${mysql_data[Innodb_row_lock_current_waits]}
END
BEGIN mysql_$x.innodb_rows $1
-SET Innodb_rows_inserted = $mysql_Innodb_rows_inserted
-SET Innodb_rows_read = $mysql_Innodb_rows_read
-SET Innodb_rows_updated = $mysql_Innodb_rows_updated
-SET Innodb_rows_deleted = $mysql_Innodb_rows_deleted
+SET Innodb_rows_inserted = ${mysql_data[Innodb_rows_inserted]}
+SET Innodb_rows_read = ${mysql_data[Innodb_rows_read]}
+SET Innodb_rows_updated = ${mysql_data[Innodb_rows_updated]}
+SET Innodb_rows_deleted = ${mysql_data[Innodb_rows_deleted]}
END
BEGIN mysql_$x.innodb_buffer_pool_pages $1
-SET Innodb_buffer_pool_pages_data = $mysql_Innodb_buffer_pool_pages_data
-SET Innodb_buffer_pool_pages_dirty = $mysql_Innodb_buffer_pool_pages_dirty
-SET Innodb_buffer_pool_pages_free = $mysql_Innodb_buffer_pool_pages_free
-SET Innodb_buffer_pool_pages_flushed = $mysql_Innodb_buffer_pool_pages_flushed
-SET Innodb_buffer_pool_pages_misc = $mysql_Innodb_buffer_pool_pages_misc
-SET Innodb_buffer_pool_pages_total = $mysql_Innodb_buffer_pool_pages_total
+SET Innodb_buffer_pool_pages_data = ${mysql_data[Innodb_buffer_pool_pages_data]}
+SET Innodb_buffer_pool_pages_dirty = ${mysql_data[Innodb_buffer_pool_pages_dirty]}
+SET Innodb_buffer_pool_pages_free = ${mysql_data[Innodb_buffer_pool_pages_free]}
+SET Innodb_buffer_pool_pages_flushed = ${mysql_data[Innodb_buffer_pool_pages_flushed]}
+SET Innodb_buffer_pool_pages_misc = ${mysql_data[Innodb_buffer_pool_pages_misc]}
+SET Innodb_buffer_pool_pages_total = ${mysql_data[Innodb_buffer_pool_pages_total]}
END
BEGIN mysql_$x.innodb_buffer_pool_bytes $1
-SET Innodb_buffer_pool_bytes_data = $mysql_Innodb_buffer_pool_bytes_data
-SET Innodb_buffer_pool_bytes_dirty = $mysql_Innodb_buffer_pool_bytes_dirty
+SET Innodb_buffer_pool_bytes_data = ${mysql_data[Innodb_buffer_pool_bytes_data]}
+SET Innodb_buffer_pool_bytes_dirty = ${mysql_data[Innodb_buffer_pool_bytes_dirty]}
END
BEGIN mysql_$x.innodb_buffer_pool_read_ahead $1
-SET Innodb_buffer_pool_read_ahead = $mysql_Innodb_buffer_pool_read_ahead
-SET Innodb_buffer_pool_read_ahead_evicted = $mysql_Innodb_buffer_pool_read_ahead_evicted
-SET Innodb_buffer_pool_read_ahead_rnd = $mysql_Innodb_buffer_pool_read_ahead_rnd
+SET Innodb_buffer_pool_read_ahead = ${mysql_data[Innodb_buffer_pool_read_ahead]}
+SET Innodb_buffer_pool_read_ahead_evicted = ${mysql_data[Innodb_buffer_pool_read_ahead_evicted]}
+SET Innodb_buffer_pool_read_ahead_rnd = ${mysql_data[Innodb_buffer_pool_read_ahead_rnd]}
END
BEGIN mysql_$x.innodb_buffer_pool_reqs $1
-SET Innodb_buffer_pool_read_requests = $mysql_Innodb_buffer_pool_read_requests
-SET Innodb_buffer_pool_write_requests = $mysql_Innodb_buffer_pool_write_requests
+SET Innodb_buffer_pool_read_requests = ${mysql_data[Innodb_buffer_pool_read_requests]}
+SET Innodb_buffer_pool_write_requests = ${mysql_data[Innodb_buffer_pool_write_requests]}
END
BEGIN mysql_$x.innodb_buffer_pool_ops $1
-SET Innodb_buffer_pool_reads = $mysql_Innodb_buffer_pool_reads
-SET Innodb_buffer_pool_wait_free = $mysql_Innodb_buffer_pool_wait_free
+SET Innodb_buffer_pool_reads = ${mysql_data[Innodb_buffer_pool_reads]}
+SET Innodb_buffer_pool_wait_free = ${mysql_data[Innodb_buffer_pool_wait_free]}
END
BEGIN mysql_$x.qcache_ops $1
-SET Qcache_hits hits = $mysql_Qcache_hits
-SET Qcache_lowmem_prunes = $mysql_Qcache_lowmem_prunes
-SET Qcache_inserts inserts = $mysql_Qcache_inserts inserts
-SET Qcache_not_cached = $mysql_Qcache_not_cached
+SET Qcache_hits hits = ${mysql_data[Qcache_hits]}
+SET Qcache_lowmem_prunes = ${mysql_data[Qcache_lowmem_prunes]}
+SET Qcache_inserts = ${mysql_data[Qcache_inserts]}
+SET Qcache_not_cached = ${mysql_data[Qcache_not_cached]}
END
BEGIN mysql_$x.qcache $1
-SET Qcache_queries_in_cache = $mysql_Qcache_queries_in_cache
+SET Qcache_queries_in_cache = ${mysql_data[Qcache_queries_in_cache]}
END
BEGIN mysql_$x.qcache_freemem $1
-SET Qcache_free_memory = $mysql_Qcache_free_memory
+SET Qcache_free_memory = ${mysql_data[Qcache_free_memory]}
END
BEGIN mysql_$x.qcache_memblocks $1
-SET Qcache_free_blocks = $mysql_Qcache_free_blocks
-SET Qcache_total_blocks = $mysql_Qcache_total_blocks
+SET Qcache_free_blocks = ${mysql_data[Qcache_free_blocks]}
+SET Qcache_total_blocks = ${mysql_data[Qcache_total_blocks]}
END
BEGIN mysql_$x.key_blocks $1
-SET Key_blocks_unused = $mysql_Key_blocks_unused
-SET Key_blocks_used = $mysql_Key_blocks_used
-SET Key_blocks_not_flushed = $mysql_Key_blocks_not_flushed
+SET Key_blocks_unused = ${mysql_data[Key_blocks_unused]}
+SET Key_blocks_used = ${mysql_data[Key_blocks_used]}
+SET Key_blocks_not_flushed = ${mysql_data[Key_blocks_not_flushed]}
END
BEGIN mysql_$x.key_requests $1
-SET Key_read_requests = $mysql_Key_read_requests
-SET Key_write_requests = $mysql_Key_write_requests
+SET Key_read_requests = ${mysql_data[Key_read_requests]}
+SET Key_write_requests = ${mysql_data[Key_write_requests]}
END
BEGIN mysql_$x.key_disk_ops $1
-SET Key_reads = $mysql_Key_reads
-SET Key_writes = $mysql_Key_writes
+SET Key_reads = ${mysql_data[Key_reads]}
+SET Key_writes = ${mysql_data[Key_writes]}
END
BEGIN mysql_$x.files $1
-SET Open_files = $mysql_Open_files
+SET Open_files = ${mysql_data[Open_files]}
END
BEGIN mysql_$x.files_rate $1
-SET Opened_files = $mysql_Opened_files
+SET Opened_files = ${mysql_data[Opened_files]}
END
VALUESEOF
- if [ ! -z "$mysql_Binlog_stmt_cache_disk_use" ]
+ if [ ! -z "${mysql_data[Binlog_stmt_cache_disk_use]}" ]
then
cat <<VALUESEOF
BEGIN mysql_$x.binlog_stmt_cache $1
-SET Binlog_stmt_cache_disk_use = $mysql_Binlog_stmt_cache_disk_use
-SET Binlog_stmt_cache_use = $mysql_Binlog_stmt_cache_use
+SET Binlog_stmt_cache_disk_use = ${mysql_data[Binlog_stmt_cache_disk_use]}
+SET Binlog_stmt_cache_use = ${mysql_data[Binlog_stmt_cache_use]}
END
VALUESEOF
fi
- if [ ! -z "$mysql_Connection_errors_accept" ]
+ if [ ! -z "${mysql_data[Connection_errors_accept]}" ]
then
cat <<VALUESEOF
BEGIN mysql_$x.connection_errors $1
-SET Connection_errors_accept = $mysql_Connection_errors_accept
-SET Connection_errors_internal = $mysql_Connection_errors_internal
-SET Connection_errors_max_connections = $mysql_Connection_errors_max_connections
-SET Connection_errors_peer_addr = $mysql_Connection_errors_peer_addr
-SET Connection_errors_select = $mysql_Connection_errors_select
-SET Connection_errors_tcpwrap = $mysql_Connection_errors_tcpwrap
+SET Connection_errors_accept = ${mysql_data[Connection_errors_accept]}
+SET Connection_errors_internal = ${mysql_data[Connection_errors_internal]}
+SET Connection_errors_max_connections = ${mysql_data[Connection_errors_max_connections]}
+SET Connection_errors_peer_addr = ${mysql_data[Connection_errors_peer_addr]}
+SET Connection_errors_select = ${mysql_data[Connection_errors_select]}
+SET Connection_errors_tcpwrap = ${mysql_data[Connection_errors_tcpwrap]}
END
VALUESEOF
fi
diff --git a/charts.d/nginx.chart.sh b/charts.d/nginx.chart.sh
index 450aa94b3..a2a9b320f 100755
--- a/charts.d/nginx.chart.sh
+++ b/charts.d/nginx.chart.sh
@@ -1,9 +1,10 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_
nginx_url="http://127.0.0.1:80/stub_status"
+nginx_curl_opts=""
# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
@@ -19,7 +20,7 @@ nginx_reading=0
nginx_writing=0
nginx_waiting=0
nginx_get() {
- nginx_response=($(curl -Ss "${nginx_url}"))
+ nginx_response=($(curl -Ss ${nginx_curl_opts} "${nginx_url}"))
[ $? -ne 0 -o "${#nginx_response[@]}" -eq 0 ] && return 1
if [ "${nginx_response[0]}" != "Active" \
@@ -81,18 +82,18 @@ nginx_check() {
# _create is called once, to create the charts
nginx_create() {
cat <<EOF
-CHART nginx.connections '' "nginx Active Connections" "connections" nginx nginx.connections line $((nginx_priority + 1)) $nginx_update_every
+CHART nginx_local.connections '' "nginx Active Connections" "connections" nginx nginx.connections line $((nginx_priority + 1)) $nginx_update_every
DIMENSION active '' absolute 1 1
-CHART nginx.requests '' "nginx Requests" "requests/s" nginx nginx.requests line $((nginx_priority + 2)) $nginx_update_every
+CHART nginx_local.requests '' "nginx Requests" "requests/s" nginx nginx.requests line $((nginx_priority + 2)) $nginx_update_every
DIMENSION requests '' incremental 1 1
-CHART nginx.connections_status '' "nginx Active Connections by Status" "connections" nginx nginx.connections.status line $((nginx_priority + 3)) $nginx_update_every
+CHART nginx_local.connections_status '' "nginx Active Connections by Status" "connections" nginx nginx.connections.status line $((nginx_priority + 3)) $nginx_update_every
DIMENSION reading '' absolute 1 1
DIMENSION writing '' absolute 1 1
DIMENSION waiting idle absolute 1 1
-CHART nginx.connect_rate '' "nginx Connections Rate" "connections/s" nginx nginx.connections.rate line $((nginx_priority + 4)) $nginx_update_every
+CHART nginx_local.connect_rate '' "nginx Connections Rate" "connections/s" nginx nginx.connections.rate line $((nginx_priority + 4)) $nginx_update_every
DIMENSION accepts accepted incremental 1 1
DIMENSION handled '' incremental 1 1
EOF
@@ -113,18 +114,18 @@ nginx_update() {
# write the result of the work.
cat <<VALUESEOF
-BEGIN nginx.connections $1
+BEGIN nginx_local.connections $1
SET active = $((nginx_active_connections))
END
-BEGIN nginx.requests $1
+BEGIN nginx_local.requests $1
SET requests = $((nginx_requests))
END
-BEGIN nginx.connections_status $1
+BEGIN nginx_local.connections_status $1
SET reading = $((nginx_reading))
SET writing = $((nginx_writing))
SET waiting = $((nginx_waiting))
END
-BEGIN nginx.connect_rate $1
+BEGIN nginx_local.connect_rate $1
SET accepts = $((nginx_accepts))
SET handled = $((nginx_handled))
END
diff --git a/charts.d/nut.chart.sh b/charts.d/nut.chart.sh
index a47208451..3c8e1c9d0 100755
--- a/charts.d/nut.chart.sh
+++ b/charts.d/nut.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# a space separated list of UPS names
# if empty, the list returned by 'upsc -l' will be used
diff --git a/charts.d/opensips.chart.sh b/charts.d/opensips.chart.sh
index c7066ec05..ce42ccdd7 100755
--- a/charts.d/opensips.chart.sh
+++ b/charts.d/opensips.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
opensips_opts="fifo get_statistics all"
opensips_cmd=
diff --git a/charts.d/phpfpm.chart.sh b/charts.d/phpfpm.chart.sh
index c0532fab1..976ce91b1 100755
--- a/charts.d/phpfpm.chart.sh
+++ b/charts.d/phpfpm.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_
@@ -8,6 +8,7 @@
# you can see, https://easyengine.io/tutorials/php/fpm-status-page/
declare -A phpfpm_urls=()
+declare -A phpfpm_curl_opts=()
# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
@@ -29,8 +30,9 @@ phpfpm_max_active_processes=0
phpfpm_max_children_reached=0
phpfpm_slow_requests=0
phpfpm_get() {
- url=$1
- phpfpm_response=($(curl -Ss "${url}"))
+ local opts="${1}" url="${2}"
+
+ phpfpm_response=($(curl -Ss ${opts} "${url}"))
[ $? -ne 0 -o "${#phpfpm_response[@]}" -eq 0 ] && return 1
if [[ "${phpfpm_response[0]}" != "pool:" \
@@ -42,7 +44,6 @@ phpfpm_get() {
|| "${phpfpm_response[26]}" != "idle" \
|| "${phpfpm_response[29]}" != "active" \
|| "${phpfpm_response[32]}" != "total" \
- || "${phpfpm_response[43]}" != "slow" \
]]
then
echo >&2 "phpfpm: invalid response from phpfpm status server: ${phpfpm_response[*]}"
@@ -61,7 +62,12 @@ phpfpm_get() {
phpfpm_total_processes="${phpfpm_response[34]}"
phpfpm_max_active_processes="${phpfpm_response[38]}"
phpfpm_max_children_reached="${phpfpm_response[42]}"
- phpfpm_slow_requests="${phpfpm_response[45]}"
+ if [ "${phpfpm_response[43]}" == "slow" ]
+ then
+ phpfpm_slow_requests="${phpfpm_response[45]}"
+ else
+ phpfpm_slow_requests="-1"
+ fi
if [[ -z "${phpfpm_pool}" \
|| -z "${phpfpm_start_time}" \
@@ -75,7 +81,6 @@ phpfpm_get() {
|| -z "${phpfpm_total_processes}" \
|| -z "${phpfpm_max_active_processes}" \
|| -z "${phpfpm_max_children_reached}" \
- || -z "${phpfpm_slow_requests}" \
]]
then
echo >&2 "phpfpm: empty values got from phpfpm status server: ${phpfpm_response[*]}"
@@ -94,7 +99,7 @@ phpfpm_check() {
local m
for m in "${!phpfpm_urls[@]}"
do
- phpfpm_get "${phpfpm_urls[$m]}"
+ phpfpm_get "${phpfpm_curl_opts[$m]}" "${phpfpm_urls[$m]}"
if [ $? -ne 0 ]; then
echo >&2 "phpfpm: cannot find status on URL '${phpfpm_url[$m]}'. Please set phpfpm_urls[$m]='http://localhost/status' in $confd/phpfpm.conf"
unset phpfpm_urls[$m]
@@ -130,8 +135,11 @@ DIMENSION requests '' incremental 1 1
CHART phpfpm_$m.performance '' "PHP-FPM Performance" "status" phpfpm phpfpm.performance line $((phpfpm_priority + 3)) $phpfpm_update_every
DIMENSION reached 'max children reached' absolute 1 1
-DIMENSION slow 'slow requests' absolute 1 1
EOF
+ if [ $((phpfpm_slow_requests)) -ne -1 ]
+ then
+ echo "DIMENSION slow 'slow requests' absolute 1 1"
+ fi
done
return 0
@@ -149,7 +157,7 @@ phpfpm_update() {
local m
for m in "${!phpfpm_urls[@]}"
do
- phpfpm_get "${phpfpm_urls[$m]}"
+ phpfpm_get "${phpfpm_curl_opts[$m]}" "${phpfpm_urls[$m]}"
if [ $? -ne 0 ]; then
continue
fi
@@ -166,10 +174,17 @@ SET requests = $((phpfpm_accepted_conn))
END
BEGIN phpfpm_$m.performance $1
SET reached = $((phpfpm_max_children_reached))
-SET slow = $((phpfpm_slow_requests))
-END
EOF
+ if [ $((phpfpm_slow_requests)) -ne -1 ]
+ then
+ echo "SET slow = $((phpfpm_slow_requests))"
+ fi
+ echo "END"
done
return 0
}
+
+phpfpm_check
+phpfpm_create
+phpfpm_update
diff --git a/charts.d/postfix.chart.sh b/charts.d/postfix.chart.sh
index f4f710275..7f07a1868 100755
--- a/charts.d/postfix.chart.sh
+++ b/charts.d/postfix.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
# the postqueue command
# if empty, it will use the one found in the system path
@@ -43,9 +43,9 @@ postfix_check() {
postfix_create() {
cat <<EOF
-CHART postfix.qemails '' "Postfix Queue Emails" "emails" queue postfix.queued.emails line $((postfix_priority + 1)) $postfix_update_every
+CHART postfix_local.qemails '' "Postfix Queue Emails" "emails" queue postfix.queued.emails line $((postfix_priority + 1)) $postfix_update_every
DIMENSION emails '' absolute 1 1
-CHART postfix.qsize '' "Postfix Queue Emails Size" "emails size in KB" queue postfix.queued.size area $((postfix_priority + 2)) $postfix_update_every
+CHART postfix_local.qsize '' "Postfix Queue Emails Size" "emails size in KB" queue postfix.queued.size area $((postfix_priority + 2)) $postfix_update_every
DIMENSION size '' absolute 1 1
EOF
@@ -80,10 +80,10 @@ postfix_update() {
# write the result of the work.
cat <<VALUESEOF
-BEGIN postfix.qemails $1
+BEGIN postfix_local.qemails $1
SET emails = $postfix_q_emails
END
-BEGIN postfix.qsize $1
+BEGIN postfix_local.qsize $1
SET size = $postfix_q_size
END
VALUESEOF
diff --git a/charts.d/sensors.chart.sh b/charts.d/sensors.chart.sh
index 19e938586..9652f896a 100755
--- a/charts.d/sensors.chart.sh
+++ b/charts.d/sensors.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
# sensors docs
# https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
@@ -23,6 +23,8 @@ sensors_update_every=
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
}
@@ -47,15 +49,20 @@ sensors_check() {
sensors_check_files() {
# we only need sensors that report a non-zero value
+ # also remove not needed sensors
- local f= v=
+ local f= v= excluded=
for f in $*
do
[ ! -f "$f" ] && continue
+ for ex in ${sensors_excluded[@]}; do
+ [[ $f =~ .*$ex$ ]] && excluded='1' && break
+ done
- v="$( cat $f )"
+ [ "$excluded" != "1" ] && v="$( cat $f )" || v=0
v=$(( v + 1 - 1 ))
[ $v -ne 0 ] && echo "$f" && continue
+ excluded=
echo >&2 "$PROGRAM_NAME: sensors: $f gives zero values"
done
@@ -206,7 +213,7 @@ sensors_create() {
fi
echo "DIMENSION $fid '$labelname' $algorithm $multiplier $divisor"
- echo >>$TMP_DIR/sensors.sh "printf \"SET $fid = \"; cat $file "
+ echo >>$TMP_DIR/sensors.sh "echo \"SET $fid = \"\$(< $file )"
done
echo >>$TMP_DIR/sensors.sh "echo END"
diff --git a/charts.d/squid.chart.sh b/charts.d/squid.chart.sh
index f6154b256..3e72ba6df 100755
--- a/charts.d/squid.chart.sh
+++ b/charts.d/squid.chart.sh
@@ -1,10 +1,10 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
squid_host=
squid_port=
squid_url=
squid_timeout=2
-squid_update_every=5
+squid_update_every=2
squid_priority=60000
squid_get_stats_internal() {
@@ -63,21 +63,21 @@ squid_check() {
squid_create() {
# create the charts
cat <<EOF
-CHART squid.clients_net '' "Squid Client Bandwidth" "kilobits / sec" clients squid.clients.net area $((squid_priority + 1)) $squid_update_every
+CHART squid_local.clients_net '' "Squid Client Bandwidth" "kilobits / sec" clients squid.clients.net area $((squid_priority + 1)) $squid_update_every
DIMENSION client_http_kbytes_in in incremental 8 1
DIMENSION client_http_kbytes_out out incremental -8 1
DIMENSION client_http_hit_kbytes_out hits incremental -8 1
-CHART squid.clients_requests '' "Squid Client Requests" "requests / sec" clients squid.clients.requests line $((squid_priority + 3)) $squid_update_every
+CHART squid_local.clients_requests '' "Squid Client Requests" "requests / sec" clients squid.clients.requests line $((squid_priority + 3)) $squid_update_every
DIMENSION client_http_requests requests incremental 1 1
DIMENSION client_http_hits hits incremental 1 1
DIMENSION client_http_errors errors incremental -1 1
-CHART squid.servers_net '' "Squid Server Bandwidth" "kilobits / sec" servers squid.servers.net area $((squid_priority + 2)) $squid_update_every
+CHART squid_local.servers_net '' "Squid Server Bandwidth" "kilobits / sec" servers squid.servers.net area $((squid_priority + 2)) $squid_update_every
DIMENSION server_all_kbytes_in in incremental 8 1
DIMENSION server_all_kbytes_out out incremental -8 1
-CHART squid.servers_requests '' "Squid Server Requests" "requests / sec" servers squid.servers.requests line $((squid_priority + 4)) $squid_update_every
+CHART squid_local.servers_requests '' "Squid Server Requests" "requests / sec" servers squid.servers.requests line $((squid_priority + 4)) $squid_update_every
DIMENSION server_all_requests requests incremental 1 1
DIMENSION server_all_errors errors incremental -1 1
EOF
@@ -111,24 +111,24 @@ squid_update() {
# write the result of the work.
cat <<VALUESEOF
-BEGIN squid.clients_net $1
+BEGIN squid_local.clients_net $1
SET client_http_kbytes_in = $squid_client_http_kbytes_in
SET client_http_kbytes_out = $squid_client_http_kbytes_out
SET client_http_hit_kbytes_out = $squid_client_http_hit_kbytes_out
END
-BEGIN squid.clients_requests $1
+BEGIN squid_local.clients_requests $1
SET client_http_requests = $squid_client_http_requests
SET client_http_hits = $squid_client_http_hits
SET client_http_errors = $squid_client_http_errors
END
-BEGIN squid.servers_net $1
+BEGIN squid_local.servers_net $1
SET server_all_kbytes_in = $squid_server_all_kbytes_in
SET server_all_kbytes_out = $squid_server_all_kbytes_out
END
-BEGIN squid.servers_requests $1
+BEGIN squid_local.servers_requests $1
SET server_all_requests = $squid_server_all_requests
SET server_all_errors = $squid_server_all_errors
END
diff --git a/charts.d/tomcat.chart.sh b/charts.d/tomcat.chart.sh
index 4e10a9183..cc6baea1a 100755
--- a/charts.d/tomcat.chart.sh
+++ b/charts.d/tomcat.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
# Description: Tomcat netdata charts.d plugin
# Author: Jorge Romero
@@ -6,10 +6,11 @@
# the URL to download tomcat status info
# usually http://localhost:8080/manager/status?XML=true
tomcat_url=""
+tomcat_curl_opts=""
# set tomcat username/password here
-tomcatUser=""
-tomcatPassword=""
+tomcat_user=""
+tomcat_password=""
# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
@@ -36,13 +37,23 @@ tomcat_check() {
echo >&2 "tomcat url is unset or set to the empty string"
return 1
fi
- if [ -z "${tomcatUser}" ]; then
- echo >&2 "tomcat user is unset or set to the empty string"
- return 1
+ if [ -z "${tomcat_user}" ]; then
+ # check backwards compatibility
+ if [ -z "${tomcatUser}" ]; then
+ echo >&2 "tomcat user is unset or set to the empty string"
+ return 1
+ else
+ tomcat_user="${tomcatUser}"
+ fi
fi
- if [ -z "${tomcatPassword}" ]; then
- echo >&2 "tomcat password is unset or set to the empty string"
- return 1
+ if [ -z "${tomcat_password}" ]; then
+ # check backwards compatibility
+ if [ -z "${tomcatPassword}" ]; then
+ echo >&2 "tomcat password is unset or set to the empty string"
+ return 1
+ else
+ tomcat_password="${tomcatPassword}"
+ fi
fi
# check if we can get to tomcat's status page
@@ -62,13 +73,14 @@ tomcat_check() {
}
tomcat_get() {
- # Collect tomcat values
- mapfile -t lines < <(curl -u "$tomcatUser":"$tomcatPassword" -Ss "$tomcat_url" |\
+ # collect tomcat values
+ tomcat_port="$(IFS=/ read -ra a <<< "$tomcat_url"; hostport=${a[2]}; echo "${hostport#*:}")"
+ mapfile -t lines < <(curl -u "$tomcat_user":"$tomcat_password" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
xmlstarlet sel \
-t -m "/status/jvm/memory" -v @free \
- -n -m "/status/connector[@name='\"http-bio-8080\"']/threadInfo" -v @currentThreadCount \
+ -n -m "/status/connector[@name='\"http-bio-$tomcat_port\"']/threadInfo" -v @currentThreadCount \
-n -v @currentThreadsBusy \
- -n -m "/status/connector[@name='\"http-bio-8080\"']/requestInfo" -v @requestCount \
+ -n -m "/status/connector[@name='\"http-bio-$tomcat_port\"']/requestInfo" -v @requestCount \
-n -v @bytesSent -n -)
tomcat_jvm_freememory="${lines[0]}"