@cryptotaxi247 / netdata-1 / commits / 51f269a91

made it work without complain in older kernel where not all data are available in /proc/stat and /proc/net/stat/nf_conntrack; also increased the maximum JSON line to 4096 bytes

Costa Tsaousis (ktsaou) committed Apr 7, 2014 at 16:11 UTC 51f269a91d69203d8d8849bfc3828b1cb3c596ca
1 file changed +5 -5
netdata.c
+5 -5
@@ -974,7 +974,7 @@ size_t rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_sh
974 if(!st->times[lt].tv_sec) continue;
975
976 // check if we may exceed the buffer provided
977 - web_buffer_increase(wb, 1024);
977 + web_buffer_increase(wb, 4096);
978
979 // prefer the most recent last entries
980 if(((count-pad) / group_count) > entries_to_show) continue;
@@ -2516,13 +2516,13 @@ int do_proc_net_stat_conntrack() {
2516 p = fgets(buffer, MAX_PROC_NET_STAT_CONNTRACK_LINE, fp);
2517 if(!p) break;
2518
2519 - unsigned long long tentries, tsearched, tfound, tnew, tinvalid, tignore, tdelete, tdelete_list, tinsert, tinsert_failed, tdrop, tearly_drop, ticmp_error, texpect_new, texpect_create, texpect_delete, tsearch_restart;
2519 + unsigned long long tentries = 0, tsearched = 0, tfound = 0, tnew = 0, tinvalid = 0, tignore = 0, tdelete = 0, tdelete_list = 0, tinsert = 0, tinsert_failed = 0, tdrop = 0, tearly_drop = 0, ticmp_error = 0, texpect_new = 0, texpect_create = 0, texpect_delete = 0, tsearch_restart = 0;
2520
2521 int r = sscanf(buffer, "%llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx\n",
2522 &tentries, &tsearched, &tfound, &tnew, &tinvalid, &tignore, &tdelete, &tdelete_list, &tinsert, &tinsert_failed, &tdrop, &tearly_drop, &ticmp_error, &texpect_new, &texpect_create, &texpect_delete, &tsearch_restart);
2523
2524 if(r == EOF) break;
2525 - if(r != 17) error("Cannot read /proc/net/stat/nf_conntrack. Expected 17 params, read %d.", r);
2525 + if(r < 16) error("Cannot read /proc/net/stat/nf_conntrack. Expected 17 params, read %d.", r);
2526
2527 if(!aentries) aentries = tentries;
2528
@@ -2722,14 +2722,14 @@ int do_proc_stat() {
2722
2723 if(strncmp(p, "cpu", 3) == 0) {
2724 char id[MAX_PROC_STAT_NAME + 1] = RRD_TYPE_STAT ".";
2725 - unsigned long long user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice;
2725 + unsigned long long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0;
2726 char *name = &id[RRD_TYPE_STAT_LEN + 1];
2727
2728 int r = sscanf(buffer, "%s %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
2729 name, &user, &nice, &system, &idle, &iowait, &irq, &softirq, &steal, &guest, &guest_nice);
2730
2731 if(r == EOF) break;
2732 - if(r != 11) error("Cannot read /proc/stat cpu line. Expected 11 params, read %d.", r);
2732 + if(r < 10) error("Cannot read /proc/stat cpu line. Expected 11 params, read %d.", r);
2733
2734 RRD_STATS *st = rrd_stats_find(id);
2735 if(!st) {