fixes
Costa Tsaousis (ktsaou) committed
May 2, 2014 at 12:33 UTC
b9f41f0bc3ecd017dbe78f07ce9ac43f5fe53d0c
2 files changed
+33
-12
charts.d/example-chart.sh
renamed
+26
-8
@@ -19,10 +19,15 @@ test $update_every -eq 0 && update_every=1 # if it is zero, make it 1
19
20
# create the chart with 3 dimensions
21
cat <<EOF
22
-CHART example.random '' "Random Numbers Example Chart" "random numbers" random random stacked 500 $update_every
23
-DIMENSION number1 '' absolute 1 1
24
-DIMENSION number2 '' absolute 1 1
25
-DIMENSION number3 '' absolute 1 1 hidden
22
+CHART example.load '' "System Load Average" "load" load load line 500 $update_every
23
+DIMENSION load1 '1 min' absolute 1 100
24
+DIMENSION load5 '5 mins' absolute 1 100
25
+DIMENSION load15 '15 mins' absolute 1 100
26
+
27
+CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked 5000 $update_every
28
+DIMENSION random1 '' percentage-of-absolute-row 1 1
29
+DIMENSION random2 '' percentage-of-absolute-row 1 1
30
+DIMENSION random3 '' percentage-of-absolute-row 1 1
31
EOF
32
33
# You can create more charts if you like.
@@ -34,17 +39,30 @@ do
39
# do all the work to collect / calculate the values
40
# for each dimension
41
42
+ # here we parse the system average load
43
+ # it is decimal (with 2 decimal digits), so we remove the dot and
44
+ # at the definition we have divisor = 100, to have the graph show the right value
45
+ loadavg="`cat /proc/loadavg | sed -e "s/\.//g"`"
46
+ load1=`echo $loadavg | cut -d ' ' -f 1`
47
+ load5=`echo $loadavg | cut -d ' ' -f 2`
48
+ load15=`echo $loadavg | cut -d ' ' -f 3`
49
+
50
value1=$RANDOM
51
value2=$RANDOM
52
value3=$RANDOM
53
41
-
54
# write the result of the work.
55
cat <<VALUESEOF
56
+BEGIN example.load
57
+SET load1 = $load1
58
+SET load5 = $load5
59
+SET load15 = $load15
60
+END
61
+
62
BEGIN example.random
45
-SET number1 = $value1
46
-SET number2 = $value2
47
-SET number3 = $value3
63
+SET random1 = $value1
64
+SET random2 = $value2
65
+SET random3 = $value3
66
END
67
VALUESEOF
68
netdata.c
+7
-4
@@ -5589,7 +5589,8 @@ void *chartsd_worker_thread(void *arg)
5589
char *p = line;
5590
char *s = qstrsep(&p);
5591
5592
- if(!strcmp(s, "SET")) {
5592
+ if(!s || !*s) continue;
5593
+ else if(!strcmp(s, "SET")) {
5594
char *dimension = qstrsep(&p);
5595
char *equal = qstrsep(&p);
5596
char *value = qstrsep(&p);
@@ -5670,7 +5671,7 @@ void *chartsd_worker_thread(void *arg)
5671
if(!family || !*family) family = id;
5672
if(!category || !*category) category = type;
5673
5673
- st = rrd_stats_find(id);
5674
+ st = rrd_stats_find_bytype(type, id);
5675
if(!st) {
5676
debug(D_CHARTSD, "CHARTSD: Creating chart type='%s', id='%s', name='%s', family='%s', category='%s', chart='%s', priority=%d, update_every=%d"
5677
, type, id
@@ -5684,8 +5685,10 @@ void *chartsd_worker_thread(void *arg)
5685
5686
st = rrd_stats_create(type, id, name, family, title, units, priority, update_every, chart_type);
5687
cd->update_every = update_every;
5688
+
5689
+ if(strcmp(category, "none") == 0) st->isdetail = 1;
5690
}
5688
- else debug(D_CHARTSD, "CHARTSD: Chart '%s' already exists. Not adding it again.");
5691
+ else debug(D_CHARTSD, "CHARTSD: Chart '%s' already exists. Not adding it again.", st->id);
5692
}
5693
else if(!strcmp(s, "DIMENSION")) {
5694
char *id = qstrsep(&p);
@@ -5730,7 +5733,7 @@ void *chartsd_worker_thread(void *arg)
5733
rd = rrd_stats_dimension_add(st, id, name, multiplier, divisor, algorithm_id(algorithm));
5734
if(hidden && strcmp(hidden, "hidden") == 0) rd->hidden = 1;
5735
}
5733
- else if(st->debug) debug(D_CHARTSD, "CHARTSD: %s/%s already exists. Not adding it again.", st->id, id);
5736
+ else if(st->debug) debug(D_CHARTSD, "CHARTSD: dimension %s/%s already exists. Not adding it again.", st->id, id);
5737
}
5738
else if(!strcmp(s, "MYPID")) {
5739
char *pid = qstrsep(&p);