summaryrefslogtreecommitdiffstats
path: root/charts.d
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2016-07-15 01:48:15 +0300
committerGitHub <noreply@github.com>2016-07-15 01:48:15 +0300
commite3f8f3d35e7bb0cae15e5bca864dc11f503a6928 (patch)
treeff2d7bfd058dffe90039a456276422da2ee5321e /charts.d
parentc3443ec92d76557b4d1413f1af0407ebb4e318ee (diff)
parent6619ea212e28c463dfc6a7480c2efa36476f3641 (diff)
Merge pull request #687 from ktsaou/master
new python.d config files
Diffstat (limited to 'charts.d')
-rwxr-xr-xcharts.d/ap.chart.sh4
-rwxr-xr-xcharts.d/apache.chart.sh2
-rwxr-xr-xcharts.d/cpu_apps.chart.sh2
-rwxr-xr-xcharts.d/cpufreq.chart.sh2
-rwxr-xr-xcharts.d/example.chart.sh89
-rw-r--r--charts.d/exim.chart.sh2
-rwxr-xr-xcharts.d/hddtemp.chart.sh2
-rwxr-xr-xcharts.d/load_average.chart.sh2
-rwxr-xr-xcharts.d/mem_apps.chart.sh2
-rwxr-xr-xcharts.d/mysql.chart.sh2
-rwxr-xr-xcharts.d/nginx.chart.sh2
-rwxr-xr-xcharts.d/nut.chart.sh2
-rwxr-xr-xcharts.d/opensips.chart.sh2
-rwxr-xr-xcharts.d/phpfpm.chart.sh2
-rwxr-xr-xcharts.d/postfix.chart.sh2
-rwxr-xr-xcharts.d/sensors.chart.sh2
-rwxr-xr-xcharts.d/squid.chart.sh2
-rwxr-xr-xcharts.d/tomcat.chart.sh2
18 files changed, 76 insertions, 49 deletions
diff --git a/charts.d/ap.chart.sh b/charts.d/ap.chart.sh
index aed51c1b67..7b4f690bb4 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 14af66b89f..2d68d43b27 100755
--- a/charts.d/apache.chart.sh
+++ b/charts.d/apache.chart.sh
@@ -1,4 +1,4 @@
-#!/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"
diff --git a/charts.d/cpu_apps.chart.sh b/charts.d/cpu_apps.chart.sh
index 5a25163e13..6b2513dcf0 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 7dd994e252..06f692fa69 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_
diff --git a/charts.d/example.chart.sh b/charts.d/example.chart.sh
index b20740e862..1f020dee27 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_
@@ -15,13 +15,63 @@ example_priority=150000
# (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
- [ "${example_magic_number}" != "12345" ] && return 1
+ # 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
}
@@ -41,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
index e436ce8f20..c60ae9460d 100644
--- a/charts.d/exim.chart.sh
+++ b/charts.d/exim.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
exim_command=
diff --git a/charts.d/hddtemp.chart.sh b/charts.d/hddtemp.chart.sh
index fea9f8018c..41c3e24780 100755
--- a/charts.d/hddtemp.chart.sh
+++ b/charts.d/hddtemp.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_
diff --git a/charts.d/load_average.chart.sh b/charts.d/load_average.chart.sh
index 4d86a8f4c0..e6790d8077 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 f537ada488..ab95b361c8 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 e2392c23dc..120fec66e3 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
#
diff --git a/charts.d/nginx.chart.sh b/charts.d/nginx.chart.sh
index a082c574e4..a2a9b320fa 100755
--- a/charts.d/nginx.chart.sh
+++ b/charts.d/nginx.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_
diff --git a/charts.d/nut.chart.sh b/charts.d/nut.chart.sh
index a47208451b..3c8e1c9d05 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 c7066ec054..ce42ccdd70 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 7cd77269e7..976ce91b19 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_
diff --git a/charts.d/postfix.chart.sh b/charts.d/postfix.chart.sh
index e705733cb7..7f07a18682 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
diff --git a/charts.d/sensors.chart.sh b/charts.d/sensors.chart.sh
index 06a35af2d9..9652f896a0 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
diff --git a/charts.d/squid.chart.sh b/charts.d/squid.chart.sh
index cc9ddfef20..3e72ba6df5 100755
--- a/charts.d/squid.chart.sh
+++ b/charts.d/squid.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
squid_host=
squid_port=
diff --git a/charts.d/tomcat.chart.sh b/charts.d/tomcat.chart.sh
index 50a17e2b3f..cc6baea1ae 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