]> arthur.barton.de Git - netdata.git/commitdiff
Renamed charts.d to plugins.d
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 3 May 2014 13:59:38 +0000 (16:59 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 3 May 2014 13:59:38 +0000 (16:59 +0300)
Moved stuff around to accomplish it.

charts.d will remain for simple scripts
plugins.d will get a new thread each

charts.d/README [deleted file]
charts.d/loopsleepms.sh.inc [deleted file]
charts.d/tc-qos-collector.sh [deleted file]
plugins.d/README [new file with mode: 0644]
plugins.d/loopsleepms.sh.inc [new file with mode: 0755]
plugins.d/tc-qos-helper.sh [new file with mode: 0755]

diff --git a/charts.d/README b/charts.d/README
deleted file mode 100644 (file)
index 6491dcb..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-
--------------------------------------------------------------------------------
-NETDATA CUSTOM PLUGINS
-
-custom chart plugins can be any program that can print a few values on its
-standard output.
-
-There are 5 lines netdata parses. lines starting with:
-
-CHART - create a new chart
-DIMENSION - add a dimension to the chart just created
-
-BEGIN - initialize data collection for a chart
-SET - set the value of a dimension for the initialized chart
-END - complete data collection for the initialized chart
-
-a single script can produce any number of charts with any number of dimensions
-each. charts can also be added any time (not just the beginning).
-
-The script should accept just one parameter: the number of seconds it is
-expected to update the values for its charts. The value passed by netdata
-to the script is controlled via the configuration file.
-
-The script can overwrite the update frequency. For example, the server may
-request per second updates, but the script may overwrite this to one update
-every 5 seconds.
-
-
--------------------------------------------------------------------------------
-CREATE NEW CHART
-
- > CHART type.id name title units family[=id] category[=type] charttype[=line]
-                                   priority[=1000] update_every[=user default]
-
- where:
- - type.id
-   uniquely identifies the chart
-   this is what will be needed to add values to the chart
-
- - name
-   is the name that will be presented to the used for this chart
-
- - title
-   the text above the chart
-
- - units
-   the label of the vertical axis of the chart
-
- - family
-   is used to group charts together.
-   (for example all eth0 charts should say: eth0)
-
- - category
-   is not used currently.
-   it will be used to set the section under which the chart will appear
-   (for example mem.ram should appear in the 'system' section)
-   the special word 'none' means: do not show this chart on the home page
-
- - charttype
-   line, area or stacked
-
- - priority
-   is the relative priority of the charts as rendered on the web page
-   lower numbers make the charts appear before the ones with higher numbers
-
- - update_every
-   overwrite the update frequency set by the server
-
-
--------------------------------------------------------------------------------
-ADD DIMENSIONS
-
- > DIMENSION id name[=id] algorithm[=absolute] multiplier[=1] divisor[=1]
-                                                              hidden[=not set]
-
- where:
-
- - id
-   the id of this dimension (it is a text value, not numeric)
-   this will be needed to add values to the dimension
-
- - name
-   the name of the dimension as it will appear at the legend of the chart
-
- - algorithms
-   one of:
-
-   * absolute
-     the value is to drawn as-is
-
-   * incremental
-     the value increases over time.
-     the difference from the last value is presented in the chart.
-     the server stretches the difference to produce 1 second increments.
-     it does this at the microsecond level.
-
-   * percentage-of-absolute-row
-     the % of this value compared to the total of all dimensions.
-
-   * percentage-of-incremental-row
-     the % of this value compared to the differential total of
-     each dimension.
-
- - multiplier
-   a value to multiply the collected value.
-
- - divisor
-   a value to divide the collected value.
-
- - hidden
-   giving the keyword 'hidden' will make this dimension hidden.
-   it will take part in the calculation but will not be presented in the chart
-
-
--------------------------------------------------------------------------------
-DATA COLLECTION
-
- data collection is defined as a series of BEGIN -> SET -> END lines.
-
- > BEGIN type.id
-
- - type.id
-   is the unique identification of the chart (created with CHART)
-
- > SET id = value
-
-  - id
-    is the unique identification of the dimension (of the chart just began)
-
-  - value
-    is the collected value
-
-  more SET lines may appear to update all the dimensions of the chart.
-  all of them in one BEGIN -> END block.
-  All SET lines within a single BEGIN -> END block have to refer to the
-  same chart. If more charts need to be updated, each chart should have
-  its own BEGIN -> SET -> END block.
-
- > END
-
- END does not take any parameters.
- it commits the collected values to the chart.
-
--------------------------------------------------------------------------------
-A NOTE ABOUT VALUES
-
- NetData will collect any signed value in the 64bit range:
-
-    -9.223.372.036.854.775.808   to   +9.223.372.036.854.775.807
-
- However, to lower its memory requirements, it stores all values in the
- signed 32bit range, divided by 10, that is:
-
-                  -214.748.364   to   +214.748.364
-
- This division by 10, is used to give a decimal point in the charts.
- In memory, every number is 4 bytes (32bits).
-
- algorithm, multiplier and divisor help maintain all the detail required.
-
- The algorithm is applied in the wider 64bit numbers. Once the calculation
- is complete the value is multiplied by the multiplier, by 10, and then
- divided by the divider (all of these at the 64bit level).
- The 64bit result is then stored in a 32 bit signed int.
-
- So, at the chart level:
-
-  - the finest number is 0.1
-  - the smallest -214.748.364,8
-  - the highest   214.748.364,7
-
- You should choose a multiplier and divisor to stay within these limits.
-
- Example:
-
- eth0 bytes-in is a 64bit number that is incremented every time.
- let say it is              1.000.000.000.000.000.000
- and one second later it is 1.000.000.000.999.000.000
-
- the dimension is 'incremental' with multiplier 8 (bytes to bits)
- and divider 1024 (bits to kilobits).
-
- netdata will store this value:
-
- value = (1.000.000.000.000.000.000 - 1.000.000.000.999.000.000)
-                 * 10
-                  * 8
-               / 1024
-         = 78.046.875
-
- or 7.804.687,5 kilobits/second (a little less than 8 gigabits/second)
-
-
diff --git a/charts.d/loopsleepms.sh.inc b/charts.d/loopsleepms.sh.inc
deleted file mode 100755 (executable)
index 3c12d5d..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/sh
-
-# this function is used to sleep a fraction of a second
-# it calculates the difference between every time is called
-# and tries to align the sleep time to give you exactly the
-# loop you need.
-
-LOOPSLEEPMS_HIGHRES=2
-LOOPSLEEPMS_LASTRUN=0
-LOOPSLEEPMS_LASTSLEEP=0
-loopsleepms() {
-       # the time in seconds to wait, as the first argument
-       local t=$1
-
-       # check if high resolution timer is supported
-       if [ $LOOPSLEEPMS_HIGHRES -eq 2 ]
-       then
-               LOOPSLEEPMS_HIGHRES=1
-               test `date +%N` = "%N" && LOOPSLEEPMS_HIGHRES=0
-       fi
-
-       # if high resolution is not supported
-       # just sleep the time requested, in seconds
-       if [ $LOOPSLEEPMS_HIGHRES -eq 0 ]
-       then
-               sleep $t
-               return
-       fi
-
-       # get the current time
-       local d=`date +'%s.%N'`
-       local s=`echo $d | cut -d '.' -f 1`
-       local m=`echo $d | cut -d '.' -f 2 | cut -b 1-3`
-       local now="$s$m" # milliseconds since epoch (1-1-1970)
-
-       # calculate required sleep in ms
-       t=$((t * 1000))
-
-       # this is our first run
-       # just wait the requested time
-       test $LOOPSLEEPMS_LASTRUN -eq 0 && LOOPSLEEPMS_LASTRUN=$now
-
-       # calculate ms since last run
-       local workms=$((now - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP))
-       # echo "# last loop's work took $workms ms"
-
-       # calculate ms to sleep
-       local mstosleep=$((t - workms))
-       # echo "# mstosleep is $mstosleep ms"
-       
-       # if we are too slow, sleep some time
-       test $mstosleep -lt 100 && mstosleep=100
-
-       local s=$((mstosleep / 1000))
-       local m=$((mstosleep - (s * 1000)))
-
-       # echo "# sleeping $s.$m"
-       # echo
-       sleep $s.$m
-
-       # keep the values we need
-       # for our next run
-       LOOPSLEEPMS_LASTRUN=$now
-       LOOPSLEEPMS_LASTSLEEP=$mstosleep
-}
diff --git a/charts.d/tc-qos-collector.sh b/charts.d/tc-qos-collector.sh
deleted file mode 100755 (executable)
index 3398c68..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-
-# let netdata know our PID
-# this is required to kill us when it exits
-echo "MYPID $$"
-
-# default sleep function
-loopsleepms() {
-       sleep $1
-}
-# if found and included, this file overwrites loopsleepms()
-# with a high resolution timer function for precise looping.
-. "`dirname $0`/loopsleepms.sh.inc"
-
-# check if we have a valid number for interval
-t=$1
-sleep_time=$(( t + 1 - 1 ))
-if [ "$sleep_time" -eq 0 ]
-       then
-       sleep_time=1
-fi
-
-devices=
-fix_names=
-
-setclassname() {
-       echo "SETCLASSNAME $3 $2"
-}
-
-show_tc() {
-       local x="$1"
-
-       echo "BEGIN $x"
-       
-       /sbin/tc -s class show dev $x
-       
-       # check FireQOS names for classes
-       if [ ! -z "$fix_names" -a -f /var/run/fireqos/ifaces/$x ]
-       then
-               name="`cat /var/run/fireqos/ifaces/$x`"
-               echo "SETDEVICENAME $name"
-
-               interface_classes=
-               . /var/run/fireqos/$name.conf
-               for n in $interface_classes_monitor
-               do
-                               setclassname `echo $n | tr '|' ' '`
-               done
-               
-               echo "SETDEVICEGROUP $interface_dev"
-       fi
-       echo "END $x"
-}
-
-all_devices() {
-       cat /proc/net/dev | grep ":" | cut -d ':' -f 1 | while read dev
-       do
-               l=`/sbin/tc class show dev $dev | wc -l`
-               [ $l -ne 0 ] && echo $dev
-       done
-}
-
-# update devices and class names
-# once every 2 minutes
-names_every=$((120 / sleep_time))
-
-# exit this script every hour
-# it will be restarted automatically
-exit_after=$((3600 / sleep_time))
-
-c=0
-gc=0
-while [ 1 ]
-do
-       fix_names=
-       c=$((c + 1))
-       gc=$((gc + 1))
-
-       if [ $c -le 1 -o $c -ge $names_every ]
-       then
-               c=1
-               fix_names="YES"
-               devices="`all_devices`"
-       fi
-
-       for d in $devices
-       do
-               show_tc $d
-       done
-
-       [ $gc -gt $exit_after ] && exit 0
-       
-       loopsleepms $sleep_time
-done
diff --git a/plugins.d/README b/plugins.d/README
new file mode 100644 (file)
index 0000000..6491dcb
--- /dev/null
@@ -0,0 +1,195 @@
+
+-------------------------------------------------------------------------------
+NETDATA CUSTOM PLUGINS
+
+custom chart plugins can be any program that can print a few values on its
+standard output.
+
+There are 5 lines netdata parses. lines starting with:
+
+CHART - create a new chart
+DIMENSION - add a dimension to the chart just created
+
+BEGIN - initialize data collection for a chart
+SET - set the value of a dimension for the initialized chart
+END - complete data collection for the initialized chart
+
+a single script can produce any number of charts with any number of dimensions
+each. charts can also be added any time (not just the beginning).
+
+The script should accept just one parameter: the number of seconds it is
+expected to update the values for its charts. The value passed by netdata
+to the script is controlled via the configuration file.
+
+The script can overwrite the update frequency. For example, the server may
+request per second updates, but the script may overwrite this to one update
+every 5 seconds.
+
+
+-------------------------------------------------------------------------------
+CREATE NEW CHART
+
+ > CHART type.id name title units family[=id] category[=type] charttype[=line]
+                                   priority[=1000] update_every[=user default]
+
+ where:
+ - type.id
+   uniquely identifies the chart
+   this is what will be needed to add values to the chart
+
+ - name
+   is the name that will be presented to the used for this chart
+
+ - title
+   the text above the chart
+
+ - units
+   the label of the vertical axis of the chart
+
+ - family
+   is used to group charts together.
+   (for example all eth0 charts should say: eth0)
+
+ - category
+   is not used currently.
+   it will be used to set the section under which the chart will appear
+   (for example mem.ram should appear in the 'system' section)
+   the special word 'none' means: do not show this chart on the home page
+
+ - charttype
+   line, area or stacked
+
+ - priority
+   is the relative priority of the charts as rendered on the web page
+   lower numbers make the charts appear before the ones with higher numbers
+
+ - update_every
+   overwrite the update frequency set by the server
+
+
+-------------------------------------------------------------------------------
+ADD DIMENSIONS
+
+ > DIMENSION id name[=id] algorithm[=absolute] multiplier[=1] divisor[=1]
+                                                              hidden[=not set]
+
+ where:
+
+ - id
+   the id of this dimension (it is a text value, not numeric)
+   this will be needed to add values to the dimension
+
+ - name
+   the name of the dimension as it will appear at the legend of the chart
+
+ - algorithms
+   one of:
+
+   * absolute
+     the value is to drawn as-is
+
+   * incremental
+     the value increases over time.
+     the difference from the last value is presented in the chart.
+     the server stretches the difference to produce 1 second increments.
+     it does this at the microsecond level.
+
+   * percentage-of-absolute-row
+     the % of this value compared to the total of all dimensions.
+
+   * percentage-of-incremental-row
+     the % of this value compared to the differential total of
+     each dimension.
+
+ - multiplier
+   a value to multiply the collected value.
+
+ - divisor
+   a value to divide the collected value.
+
+ - hidden
+   giving the keyword 'hidden' will make this dimension hidden.
+   it will take part in the calculation but will not be presented in the chart
+
+
+-------------------------------------------------------------------------------
+DATA COLLECTION
+
+ data collection is defined as a series of BEGIN -> SET -> END lines.
+
+ > BEGIN type.id
+
+ - type.id
+   is the unique identification of the chart (created with CHART)
+
+ > SET id = value
+
+  - id
+    is the unique identification of the dimension (of the chart just began)
+
+  - value
+    is the collected value
+
+  more SET lines may appear to update all the dimensions of the chart.
+  all of them in one BEGIN -> END block.
+  All SET lines within a single BEGIN -> END block have to refer to the
+  same chart. If more charts need to be updated, each chart should have
+  its own BEGIN -> SET -> END block.
+
+ > END
+
+ END does not take any parameters.
+ it commits the collected values to the chart.
+
+-------------------------------------------------------------------------------
+A NOTE ABOUT VALUES
+
+ NetData will collect any signed value in the 64bit range:
+
+    -9.223.372.036.854.775.808   to   +9.223.372.036.854.775.807
+
+ However, to lower its memory requirements, it stores all values in the
+ signed 32bit range, divided by 10, that is:
+
+                  -214.748.364   to   +214.748.364
+
+ This division by 10, is used to give a decimal point in the charts.
+ In memory, every number is 4 bytes (32bits).
+
+ algorithm, multiplier and divisor help maintain all the detail required.
+
+ The algorithm is applied in the wider 64bit numbers. Once the calculation
+ is complete the value is multiplied by the multiplier, by 10, and then
+ divided by the divider (all of these at the 64bit level).
+ The 64bit result is then stored in a 32 bit signed int.
+
+ So, at the chart level:
+
+  - the finest number is 0.1
+  - the smallest -214.748.364,8
+  - the highest   214.748.364,7
+
+ You should choose a multiplier and divisor to stay within these limits.
+
+ Example:
+
+ eth0 bytes-in is a 64bit number that is incremented every time.
+ let say it is              1.000.000.000.000.000.000
+ and one second later it is 1.000.000.000.999.000.000
+
+ the dimension is 'incremental' with multiplier 8 (bytes to bits)
+ and divider 1024 (bits to kilobits).
+
+ netdata will store this value:
+
+ value = (1.000.000.000.000.000.000 - 1.000.000.000.999.000.000)
+                 * 10
+                  * 8
+               / 1024
+         = 78.046.875
+
+ or 7.804.687,5 kilobits/second (a little less than 8 gigabits/second)
+
+
diff --git a/plugins.d/loopsleepms.sh.inc b/plugins.d/loopsleepms.sh.inc
new file mode 100755 (executable)
index 0000000..3c12d5d
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# this function is used to sleep a fraction of a second
+# it calculates the difference between every time is called
+# and tries to align the sleep time to give you exactly the
+# loop you need.
+
+LOOPSLEEPMS_HIGHRES=2
+LOOPSLEEPMS_LASTRUN=0
+LOOPSLEEPMS_LASTSLEEP=0
+loopsleepms() {
+       # the time in seconds to wait, as the first argument
+       local t=$1
+
+       # check if high resolution timer is supported
+       if [ $LOOPSLEEPMS_HIGHRES -eq 2 ]
+       then
+               LOOPSLEEPMS_HIGHRES=1
+               test `date +%N` = "%N" && LOOPSLEEPMS_HIGHRES=0
+       fi
+
+       # if high resolution is not supported
+       # just sleep the time requested, in seconds
+       if [ $LOOPSLEEPMS_HIGHRES -eq 0 ]
+       then
+               sleep $t
+               return
+       fi
+
+       # get the current time
+       local d=`date +'%s.%N'`
+       local s=`echo $d | cut -d '.' -f 1`
+       local m=`echo $d | cut -d '.' -f 2 | cut -b 1-3`
+       local now="$s$m" # milliseconds since epoch (1-1-1970)
+
+       # calculate required sleep in ms
+       t=$((t * 1000))
+
+       # this is our first run
+       # just wait the requested time
+       test $LOOPSLEEPMS_LASTRUN -eq 0 && LOOPSLEEPMS_LASTRUN=$now
+
+       # calculate ms since last run
+       local workms=$((now - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP))
+       # echo "# last loop's work took $workms ms"
+
+       # calculate ms to sleep
+       local mstosleep=$((t - workms))
+       # echo "# mstosleep is $mstosleep ms"
+       
+       # if we are too slow, sleep some time
+       test $mstosleep -lt 100 && mstosleep=100
+
+       local s=$((mstosleep / 1000))
+       local m=$((mstosleep - (s * 1000)))
+
+       # echo "# sleeping $s.$m"
+       # echo
+       sleep $s.$m
+
+       # keep the values we need
+       # for our next run
+       LOOPSLEEPMS_LASTRUN=$now
+       LOOPSLEEPMS_LASTSLEEP=$mstosleep
+}
diff --git a/plugins.d/tc-qos-helper.sh b/plugins.d/tc-qos-helper.sh
new file mode 100755 (executable)
index 0000000..3398c68
--- /dev/null
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+# let netdata know our PID
+# this is required to kill us when it exits
+echo "MYPID $$"
+
+# default sleep function
+loopsleepms() {
+       sleep $1
+}
+# if found and included, this file overwrites loopsleepms()
+# with a high resolution timer function for precise looping.
+. "`dirname $0`/loopsleepms.sh.inc"
+
+# check if we have a valid number for interval
+t=$1
+sleep_time=$(( t + 1 - 1 ))
+if [ "$sleep_time" -eq 0 ]
+       then
+       sleep_time=1
+fi
+
+devices=
+fix_names=
+
+setclassname() {
+       echo "SETCLASSNAME $3 $2"
+}
+
+show_tc() {
+       local x="$1"
+
+       echo "BEGIN $x"
+       
+       /sbin/tc -s class show dev $x
+       
+       # check FireQOS names for classes
+       if [ ! -z "$fix_names" -a -f /var/run/fireqos/ifaces/$x ]
+       then
+               name="`cat /var/run/fireqos/ifaces/$x`"
+               echo "SETDEVICENAME $name"
+
+               interface_classes=
+               . /var/run/fireqos/$name.conf
+               for n in $interface_classes_monitor
+               do
+                               setclassname `echo $n | tr '|' ' '`
+               done
+               
+               echo "SETDEVICEGROUP $interface_dev"
+       fi
+       echo "END $x"
+}
+
+all_devices() {
+       cat /proc/net/dev | grep ":" | cut -d ':' -f 1 | while read dev
+       do
+               l=`/sbin/tc class show dev $dev | wc -l`
+               [ $l -ne 0 ] && echo $dev
+       done
+}
+
+# update devices and class names
+# once every 2 minutes
+names_every=$((120 / sleep_time))
+
+# exit this script every hour
+# it will be restarted automatically
+exit_after=$((3600 / sleep_time))
+
+c=0
+gc=0
+while [ 1 ]
+do
+       fix_names=
+       c=$((c + 1))
+       gc=$((gc + 1))
+
+       if [ $c -le 1 -o $c -ge $names_every ]
+       then
+               c=1
+               fix_names="YES"
+               devices="`all_devices`"
+       fi
+
+       for d in $devices
+       do
+               show_tc $d
+       done
+
+       [ $gc -gt $exit_after ] && exit 0
+       
+       loopsleepms $sleep_time
+done