@cryptotaxi247 / netdata-1 / commits / 9a35dea70

added options for tc per interface

Costa Tsaousis (ktsaou) committed Apr 27, 2014 at 18:18 UTC 9a35dea7075468a52db4a8db7c3c75bb26d0759b
1 file changed +31 -27
netdata.c
+31 -27
@@ -4843,42 +4843,46 @@ void tc_device_commit(struct tc_device *d)
4843 return;
4844 }
4845
4846 - RRD_STATS *st = rrd_stats_find_bytype(RRD_TYPE_TC, d->id);
4847 - if(!st) {
4848 - debug(D_TC_LOOP, "TC: Committing new TC device '%s'", d->name);
4846 + char var_name[4096 + 1];
4847 + snprintf(var_name, 4096, "qos for %s", d->id);
4848 + if(config_get_boolean("plugin:tc", var_name, 1)) {
4849 + RRD_STATS *st = rrd_stats_find_bytype(RRD_TYPE_TC, d->id);
4850 + if(!st) {
4851 + debug(D_TC_LOOP, "TC: Committing new TC device '%s'", d->name);
4852
4850 - st = rrd_stats_create(RRD_TYPE_TC, d->id, d->name, d->group, "Class Usage", "kilobits/s", 1000);
4853 + st = rrd_stats_create(RRD_TYPE_TC, d->id, d->name, d->group, "Class Usage", "kilobits/s", 1000);
4854
4852 - for ( c = d->classes ; c ; c = c->next) {
4853 - if(c->isleaf && c->hasparent)
4854 - rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
4855 + for ( c = d->classes ; c ; c = c->next) {
4856 + if(c->isleaf && c->hasparent)
4857 + rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
4858 + }
4859 + }
4860 + else {
4861 + unsigned long long usec = rrd_stats_next(st);
4862 + debug(D_TC_LOOP, "TC: Committing TC device '%s' after %llu usec", d->name, usec);
4863 }
4856 - }
4857 - else {
4858 - unsigned long long usec = rrd_stats_next(st);
4859 - debug(D_TC_LOOP, "TC: Committing TC device '%s' after %llu usec", d->name, usec);
4860 - }
4864
4862 - for ( c = d->classes ; c ; c = c->next) {
4863 - if(c->isleaf && c->hasparent) {
4864 - if(rrd_stats_dimension_set(st, c->id, &c->bytes, NULL) != 0) {
4865 -
4866 - // new class, we have to add it
4867 - rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
4868 - rrd_stats_dimension_set(st, c->id, &c->bytes, NULL);
4869 - }
4865 + for ( c = d->classes ; c ; c = c->next) {
4866 + if(c->isleaf && c->hasparent) {
4867 + if(rrd_stats_dimension_set(st, c->id, &c->bytes, NULL) != 0) {
4868 +
4869 + // new class, we have to add it
4870 + rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 0, 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL);
4871 + rrd_stats_dimension_set(st, c->id, &c->bytes, NULL);
4872 + }
4873
4871 - // if it has a name, different to the id
4872 - if(strcmp(c->id, c->name) != 0) {
4873 - // update the rrd dimension with the new name
4874 - RRD_DIMENSION *rd;
4875 - for(rd = st->dimensions ; rd ; rd = rd->next) {
4876 - if(strcmp(rd->id, c->id) == 0) { strcpy(rd->name, c->name); break; }
4874 + // if it has a name, different to the id
4875 + if(strcmp(c->id, c->name) != 0) {
4876 + // update the rrd dimension with the new name
4877 + RRD_DIMENSION *rd;
4878 + for(rd = st->dimensions ; rd ; rd = rd->next) {
4879 + if(strcmp(rd->id, c->id) == 0) { strcpy(rd->name, c->name); break; }
4880 + }
4881 }
4882 }
4883 }
4884 + rrd_stats_done(st);
4885 }
4881 - rrd_stats_done(st);
4886 }
4887
4888 void tc_device_set_class_name(struct tc_device *d, char *id, char *name)