10 # default sleep function
14 # if found and included, this file overwrites loopsleepms()
15 # with a high resolution timer function for precise looping.
16 . "`dirname $0`/loopsleepms.sh.inc"
18 # netdata passes the requested update frequency as the first argument
20 update_every=$(( update_every + 1 - 1)) # makes sure it is a number
21 test $update_every -eq 0 && update_every=1 # if it is zero, make it 1
26 myconfig="$confd/charts.d.conf"
27 minimum_update_frequency=1
29 # load the configuration
35 echo >&2 "charts.d: cannot load $myconfig"
41 if [ ! -d "$chartsd" ]
43 echo >&2 "charts.d: cannot find charts directory '$chartsd'"
49 ls *.chart.sh | sed "s/\.chart\.sh$//g"
52 all_enabled_charts() {
55 # find all enabled charts
60 if [ "$enabled" = "yes" ]
62 local charts="$charts $x"
64 echo >&2 "charts.d: chart '$x' is NOT enabled. Add a line with $x=yes in $myconfig to enable it."
71 # check the enabled charts
72 local check=`cat "$chartsd/$x.chart.sh" | sed "s/^ \+//g" | grep "^${x}_check()"`
75 echo >&2 "charts.d: chart '$x' does not seem to have a ${x}_check() function. Disabling it."
79 local create=`cat "$chartsd/$x.chart.sh" | sed "s/^ \+//g" | grep "^${x}_create()"`
82 echo >&2 "charts.d: chart '$x' does not seem to have a ${x}_create() function. Disabling it."
86 local update=`cat "$chartsd/$x.chart.sh" | sed "s/^ \+//g" | grep "^${x}_update()"`
89 echo >&2 "charts.d: chart '$x' does not seem to have a ${x}_update() function. Disabling it."
94 if [ -f "$confd/$x.conf" ]
96 if [ ! -z "`cat "$confd/$x.conf" | sed "s/^ \+//g" | grep -v "^$" | grep -v "^#" | grep -v "^${x}_"`" ]
98 echo >&2 "charts.d: chart's $x config $confd/$x.conf should only have lines starting with ${x}_ . Disabling it."
103 "$pluginsd/charts.d.dryrun-helper.sh" "$x" "$chartsd/$x.chart.sh" "$confd/$x.conf" >/dev/null
106 echo >&2 "charts.d: chart's $x did not pass the dry run check. This means it uses global variables not starting with $x. Disabling it."
110 local charts2="$charts2 $x"
118 for x in `all_enabled_charts`
120 . "$chartsd/$x.chart.sh"
122 if [ -f "$confd/$x.conf" ]
130 active_charts="$active_charts $x"
132 echo >&2 "charts.d: chart '$x' check() function reports failure."
139 echo "Will run the charts: $active_charts"
144 for x in $active_charts
149 run_charts="$run_charts $x"
151 echo >&2 "charts.d: chart '$x' create() function reports failure."
158 now_charts=$run_charts
166 run_charts="$run_charts $x"
168 echo >&2 "charts.d: chart '$x' update() function reports failure. Disabling it."
172 # wait the time you are required to
173 loopsleepms $update_every