improvements in configuration generation
Costa Tsaousis (ktsaou) committed
Apr 27, 2014 at 19:09 UTC
24a4ae344a393281726544bb87c04120bd7b6c10
1 file changed
+26
-2
netdata.c
+26
-2
@@ -1700,19 +1700,43 @@ void generate_config(struct web_buffer *wb)
1700
struct config_value *cv;
1701
1702
for(i = 0; i < 3 ;i++) {
1703
+ web_buffer_increase(wb, 500);
1704
+ switch(i) {
1705
+ case 0:
1706
+ web_buffer_printf(wb, "\n\n# global netdata configuration\n");
1707
+ break;
1708
+
1709
+ case 1:
1710
+ web_buffer_printf(wb, "\n\n# per plugin configuration\n");
1711
+ break;
1712
+
1713
+ case 2:
1714
+ web_buffer_printf(wb, "\n\n# per chart configuration\n");
1715
+ break;
1716
+ }
1717
+
1718
for(co = config_root; co ; co = co->next) {
1719
if(strcmp(co->name, "global") == 0 || strcmp(co->name, "debug") == 0 || strcmp(co->name, "plugins") == 0) pri = 0;
1720
else if(strncmp(co->name, "plugin:", 7) == 0) pri = 1;
1721
else pri = 2;
1722
1723
if(i == pri) {
1724
+ int used = 0;
1725
+ for(cv = co->values; cv ; cv = cv->next)
1726
+ used += cv->used;
1727
+
1728
+ if(!used) {
1729
+ web_buffer_increase(wb, 500);
1730
+ web_buffer_printf(wb, "\n# node '%s' is not used.", co->name);
1731
+ }
1732
+
1733
web_buffer_increase(wb, CONFIG_MAX_NAME + 4);
1734
web_buffer_printf(wb, "\n[%s]\n", co->name);
1735
1736
for(cv = co->values; cv ; cv = cv->next) {
1713
- if(!cv->used) {
1737
+ if(used && !cv->used) {
1738
web_buffer_increase(wb, CONFIG_MAX_NAME + 200);
1715
- web_buffer_printf(wb, "\t# the option '%s' is not used, you can remove it\n", cv->name);
1739
+ web_buffer_printf(wb, "\n\t# option '%s' is not used.\n", cv->name);
1740
}
1741
web_buffer_increase(wb, CONFIG_MAX_NAME + CONFIG_MAX_VALUE + 5);
1742
web_buffer_printf(wb, "\t%s = %s\n", cv->name, cv->value);