@cryptotaxi247 / netdata-1 / commits / c2d224ef5

made SETCLASSNAME generic

Costa Tsaousis (ktsaou) committed Apr 12, 2014 at 03:25 UTC c2d224ef586354152f9f59a5769a2253b076b9a6
2 files changed +18 -14
netdata.c
+11 -12
@@ -3246,7 +3246,7 @@ void tc_device_commit(struct tc_device *d)
3246 else rrd_stats_next(st);
3247
3248 for ( c = d->classes ; c ; c = c->next) {
3249 - if(c->isleaf && c->hasparent)
3249 + if(c->isleaf && c->hasparent) {
3250 if(rrd_stats_dimension_set(st, c->id, &c->bytes, NULL) != 0) {
3251
3252 // new class, we have to add it
@@ -3255,11 +3255,16 @@ void tc_device_commit(struct tc_device *d)
3255 else rrd_stats_dimension_set(st, c->id, &c->bytes, NULL);
3256 }
3257
3258 - // check if the class changed name
3259 - RRD_DIMENSION *rd;
3260 - for(rd = st->dimensions ; rd ; rd = rd->next) {
3261 - if(strcmp(rd->id, c->id) == 0) { strcpy(rd->name, c->name); break; }
3258 + // if it has a name, different to the id
3259 + if(strcmp(c->id, c->name) != 0) {
3260 +
3261 + // update the rrd dimension with the new name
3262 + RRD_DIMENSION *rd;
3263 + for(rd = st->dimensions ; rd ; rd = rd->next) {
3264 + if(strcmp(rd->id, c->id) == 0) { strcpy(rd->name, c->name); break; }
3265 + }
3266 }
3267 + }
3268 }
3269 rrd_stats_done(st);
3270 }
@@ -3410,15 +3415,9 @@ void *tc_main(void *ptr)
3415 if(name && *name) tc_device_set_device_name(device, name);
3416 }
3417 else if(device && (strcmp(p, "SETCLASSNAME") == 0)) {
3413 - char *name = strsep(&b, " |\n");
3414 - char *path = strsep(&b, " |\n");
3418 char *id = strsep(&b, " |\n");
3416 - char *qdisc = strsep(&b, " |\n");
3419 + char *path = strsep(&b, " |\n");
3420 if(id && *id && path && *path) tc_device_set_class_name(device, id, path);
3418 -
3419 - // prevent unused variables warning
3420 - if(qdisc) qdisc = NULL;
3421 - if(name) name = NULL;
3421 }
3422 else if((strcmp(p, "MYPID") == 0)) {
3423 char *id = strsep(&b, " \n");
tc-all.sh
+7 -2
@@ -12,6 +12,11 @@ fi
12
13 devices=
14 fix_names=
15 +
16 +setclassname() {
17 + echo "SETCLASSNAME $3 $2"
18 +}
19 +
20 show_tc() {
21 local x="$1"
22
@@ -27,9 +32,9 @@ show_tc() {
32
33 interface_classes=
34 . /var/run/fireqos/$name.conf
30 - for x in $interface_classes_monitor
35 + for n in $interface_classes_monitor
36 do
32 - echo "SETCLASSNAME $x"
37 + setclassname `echo $n | tr '|' ' '`
38 done
39 fi
40 echo "END $x"