]> arthur.barton.de Git - netdata.git/commitdiff
fixes
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Fri, 2 May 2014 09:33:25 +0000 (12:33 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Fri, 2 May 2014 09:33:25 +0000 (12:33 +0300)
charts.d/example-chart.sh [new file with mode: 0755]
charts.d/skeleton-chart.sh [deleted file]
netdata.c

diff --git a/charts.d/example-chart.sh b/charts.d/example-chart.sh
new file mode 100755 (executable)
index 0000000..3ca64a0
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# report our PID back to netdata
+# this is required for netdata to kill this process 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"
+
+# netdata passes the requested update frequency as the first argument
+update_every=$1
+update_every=$(( update_every + 1 - 1))        # makes sure it is a number
+test $update_every -eq 0 && update_every=1 # if it is zero, make it 1
+
+# create the chart with 3 dimensions
+cat <<EOF
+CHART example.load '' "System Load Average" "load" load load line 500 $update_every
+DIMENSION load1 '1 min' absolute 1 100
+DIMENSION load5 '5 mins' absolute 1 100
+DIMENSION load15 '15 mins' absolute 1 100
+
+CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked 5000 $update_every
+DIMENSION random1 '' percentage-of-absolute-row 1 1
+DIMENSION random2 '' percentage-of-absolute-row 1 1
+DIMENSION random3 '' percentage-of-absolute-row 1 1
+EOF
+
+# You can create more charts if you like.
+# Just add more chart definitions.
+
+# work forever
+while [ 1 ]
+do
+       # do all the work to collect / calculate the values
+       # for each dimension
+
+       # here we parse the system average load
+       # it is decimal (with 2 decimal digits), so we remove the dot and
+       # at the definition we have divisor = 100, to have the graph show the right value
+       loadavg="`cat /proc/loadavg | sed -e "s/\.//g"`"
+       load1=`echo $loadavg | cut -d ' ' -f 1`
+       load5=`echo $loadavg | cut -d ' ' -f 2`
+       load15=`echo $loadavg | cut -d ' ' -f 3`
+
+       value1=$RANDOM
+       value2=$RANDOM
+       value3=$RANDOM
+
+       # write the result of the work.
+       cat <<VALUESEOF
+BEGIN example.load
+SET load1 = $load1
+SET load5 = $load5
+SET load15 = $load15
+END
+
+BEGIN example.random
+SET random1 = $value1
+SET random2 = $value2
+SET random3 = $value3
+END
+VALUESEOF
+
+       # if you have more charts, add BEGIN->END statements here
+
+       # wait the time you are required to
+       loopsleepms $update_every
+done
diff --git a/charts.d/skeleton-chart.sh b/charts.d/skeleton-chart.sh
deleted file mode 100755 (executable)
index 94a0f73..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-
-# report our PID back to netdata
-# this is required for netdata to kill this process 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"
-
-# netdata passes the requested update frequency as the first argument
-update_every=$1
-update_every=$(( update_every + 1 - 1))        # makes sure it is a number
-test $update_every -eq 0 && update_every=1 # if it is zero, make it 1
-
-# create the chart with 3 dimensions
-cat <<EOF
-CHART example.random '' "Random Numbers Example Chart" "random numbers" random random stacked 500 $update_every
-DIMENSION number1 '' absolute 1 1
-DIMENSION number2 '' absolute 1 1
-DIMENSION number3 '' absolute 1 1 hidden
-EOF
-
-# You can create more charts if you like.
-# Just add more chart definitions.
-
-# work forever
-while [ 1 ]
-do
-       # do all the work to collect / calculate the values
-       # for each dimension
-
-       value1=$RANDOM
-       value2=$RANDOM
-       value3=$RANDOM
-
-
-       # write the result of the work.
-       cat <<VALUESEOF
-BEGIN example.random
-SET number1 = $value1
-SET number2 = $value2
-SET number3 = $value3
-END
-VALUESEOF
-
-       # if you have more charts, add BEGIN->END statements here
-
-       # wait the time you are required to
-       loopsleepms $update_every
-done
index 123cc2de7fc3bcc78fa8413e2b164956a3860cdc..4a32e58d339c2c945830565e85f138bc1f8bbabc 100644 (file)
--- a/netdata.c
+++ b/netdata.c
@@ -5589,7 +5589,8 @@ void *chartsd_worker_thread(void *arg)
                        char *p = line;
                        char *s = qstrsep(&p);
 
-                       if(!strcmp(s, "SET")) {
+                       if(!s || !*s) continue;
+                       else if(!strcmp(s, "SET")) {
                                char *dimension = qstrsep(&p);
                                char *equal = qstrsep(&p);
                                char *value = qstrsep(&p);
@@ -5670,7 +5671,7 @@ void *chartsd_worker_thread(void *arg)
                                if(!family || !*family) family = id;
                                if(!category || !*category) category = type;
 
-                               st = rrd_stats_find(id);
+                               st = rrd_stats_find_bytype(type, id);
                                if(!st) {
                                        debug(D_CHARTSD, "CHARTSD: Creating chart type='%s', id='%s', name='%s', family='%s', category='%s', chart='%s', priority=%d, update_every=%d"
                                                , type, id
@@ -5684,8 +5685,10 @@ void *chartsd_worker_thread(void *arg)
 
                                        st = rrd_stats_create(type, id, name, family, title, units, priority, update_every, chart_type);
                                        cd->update_every = update_every;
+
+                                       if(strcmp(category, "none") == 0) st->isdetail = 1;
                                }
-                               else debug(D_CHARTSD, "CHARTSD: Chart '%s' already exists. Not adding it again.");
+                               else debug(D_CHARTSD, "CHARTSD: Chart '%s' already exists. Not adding it again.", st->id);
                        }
                        else if(!strcmp(s, "DIMENSION")) {
                                char *id = qstrsep(&p);
@@ -5730,7 +5733,7 @@ void *chartsd_worker_thread(void *arg)
                                        rd = rrd_stats_dimension_add(st, id, name, multiplier, divisor, algorithm_id(algorithm));
                                        if(hidden && strcmp(hidden, "hidden") == 0) rd->hidden = 1;
                                }
-                               else if(st->debug) debug(D_CHARTSD, "CHARTSD: %s/%s already exists. Not adding it again.", st->id, id);
+                               else if(st->debug) debug(D_CHARTSD, "CHARTSD: dimension %s/%s already exists. Not adding it again.", st->id, id);
                        }
                        else if(!strcmp(s, "MYPID")) {
                                char *pid = qstrsep(&p);