cleanup: remove trailing spaces
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Alon Bar-Lev committed
Nov 30, 2015 at 00:34 UTC
9d260bde5a4dc3aebdd5d0ed04af669326456f7f
48 files changed
+261
-261
README.md
+7
-7
@@ -32,7 +32,7 @@ Here is a screenshot:
32
- **extremely lightweight**
33
34
It only needs a few megabytes of memory to store all its round robin database.
35
-
35
+
36
Although `netdata` does all its calculation using `long double` (128 bit) arithmetics, it stores all values using a **custom-made 32-bit number**. This custom-made number can store in 29 bits values from -167772150000000.0 to 167772150000000.0 with a precision of 0.00001 (yes, it is a floating point number, meaning that higher integer values have less decimal precision) and 3 bits for flags (2 are currently used and 1 is reserved for future use). This provides an extremely optimized memory footprint with just 0.0001% max accuracy loss (run: `./netdata --unittest` to see it in action).
37
38
- **per second data collection**
@@ -112,7 +112,7 @@ Here is a screenshot:
112
113
1. You run a daemon on your linux: netdata.
114
This deamon is written in C and is extremely lightweight.
115
-
115
+
116
netdata:
117
118
- Spawns threads to collect all the data for all sources
@@ -121,18 +121,18 @@ Here is a screenshot:
121
- Is a standalone web server.
122
123
For example, you can access JSON data by using:
124
-
124
+
125
```
126
http://127.0.0.1:19999/data/net.eth0
127
```
128
-
128
+
129
This will give you the JSON file for traffic on eth0.
130
The above is equivalent to:
131
-
131
+
132
```
133
http://127.0.0.1:19999/data/net.eth0/3600/1/average/0/0
134
```
135
-
135
+
136
where:
137
138
- 3600 is the number of entries to generate.
@@ -182,7 +182,7 @@ You can edit this file to set options. To apply the changes you made, you have t
182
183
- You can stop netdata by killing it with `killall netdata`.
184
You can stop and start netdata at any point. Netdata saves on exit its round robbin
185
- database to `/var/cache/netdata` so that it will continue from where it stopped the last time.
185
+ database to `/var/cache/netdata` so that it will continue from where it stopped the last time.
186
187
To access the web site for all graphs, go to:
188
charts.d/mysql.chart.sh
+1
-1
@@ -13,7 +13,7 @@ declare -A mysql_cmds=() mysql_opts=() mysql_ids=()
13
14
mysql_exec() {
15
local ret
16
-
16
+
17
"${@}" -s -e "show global status;"
18
ret=$?
19
charts.d/opensips.chart.sh
+1
-1
@@ -136,7 +136,7 @@ DIMENSION shmem_free_size free absolute 1 1024
136
CHART opensips.shmem_fragments '' "OpenSIPS Shared Memory Fragmentation" "fragments" opensips '' line 20019 $opensips_update_every
137
DIMENSION shmem_fragments fragments absolute 1 1
138
EOF
139
-
139
+
140
return 0
141
}
142
charts.d/postfix.chart.sh
+1
-1
@@ -70,7 +70,7 @@ postfix_update() {
70
# even if something goes wrong, no other code can be executed
71
postfix_q_emails=0
72
postfix_q_size=0
73
-
73
+
74
eval "`$postfix_postqueue -p |\
75
grep "^--" |\
76
sed -e "s/-- \([0-9]\+\) Kbytes in \([0-9]\+\) Requests.$/local postfix_q_size=\1\nlocal postfix_q_emails=\2/g" |\
charts.d/sensors.chart.sh
+1
-1
@@ -54,7 +54,7 @@ sensors_check_files() {
54
v="$( cat $f )"
55
v=$(( v + 1 - 1 ))
56
[ $v -ne 0 ] && echo "$f" && continue
57
-
57
+
58
echo >&2 "$PROGRAM_NAME: sensors: $f gives zero values"
59
done
60
}
charts.d/squid.chart.sh
+1
-1
@@ -87,7 +87,7 @@ CHART squid.servers_requests '' "Squid Server Requests" "requests / sec" squid '
87
DIMENSION server_all_requests requests incremental 1 1
88
DIMENSION server_all_errors errors incremental -1 1
89
EOF
90
-
90
+
91
return 0
92
}
93
conf.d/apps_groups.conf
+2
-2
@@ -1,6 +1,6 @@
1
#
2
# apps.plugin process grouping
3
-#
3
+#
4
# The apps.plugin displays charts with information about the processes running.
5
# This config allows grouping processes together, so that several processes
6
# will be reported together.
@@ -41,7 +41,7 @@ samba: smbd nmbd winbindd
41
nfs: rpcbind rpc.statd rpc.idmapd rpc.mountd nfsd4 nfsd4_callbacks nfsd nfsiod
42
ssh: ssh sshd scp
43
X: X lightdm xdm pulseaudio gkrellm
44
-xfce: xfwm4 xfdesktop xfce4-appfinder Thunar xfsettingsd xfce4-panel
44
+xfce: xfwm4 xfdesktop xfce4-appfinder Thunar xfsettingsd xfce4-panel
45
gnome: gnome-session gdm gconfd-2 gnome-terminal gnome-screensaver gnome-settings-daemon
46
named: named rncd
47
clam: clamd freshclam
plugins.d/README.md
+1
-1
@@ -59,7 +59,7 @@ the template is:
59
60
where:
61
- `type.id`
62
-
62
+
63
uniquely identifies the chart,
64
this is what will be needed to add values to the chart
65
plugins.d/charts.d.plugin
+2
-2
@@ -14,12 +14,12 @@ echo >&2 "$PROGRAM_NAME: started from '$PROGRAM_FILE' with options: $*"
14
15
if [ $(( ${BASH_VERSINFO[0]} )) -lt 4 ]
16
then
17
- echo >&2
17
+ echo >&2
18
echo >&2 "$PROGRAM_NAME: ERROR"
19
echo >&2 "BASH version 4 or later is required."
20
echo >&2 "You are running version: ${BASH_VERSION}"
21
echo >&2 "Please upgrade."
22
- echo >&2
22
+ echo >&2
23
exit 1
24
fi
25
plugins.d/loopsleepms.sh.inc
+1
-1
@@ -70,7 +70,7 @@ loopsleepms() {
70
# calculate ms to sleep
71
mstosleep=$(( t - LOOPSLEEPMS_LASTWORK ))
72
# echo "# mstosleep is $mstosleep ms"
73
-
73
+
74
# if we are too slow, sleep some time
75
test $mstosleep -lt 200 && mstosleep=200
76
plugins.d/tc-qos-helper.sh
+3
-3
@@ -41,9 +41,9 @@ show_tc() {
41
local x="$1"
42
43
echo "BEGIN $x"
44
-
44
+
45
$tc_cmd -s class show dev $x
46
-
46
+
47
# check FireQOS names for classes
48
if [ ! -z "$fix_names" -a -f /var/run/fireqos/ifaces/$x ]
49
then
@@ -56,7 +56,7 @@ show_tc() {
56
do
57
setclassname $(echo $n | tr '|' ' ')
58
done
59
-
59
+
60
echo "SETDEVICEGROUP $interface_dev"
61
fi
62
echo "END $x"
src/apps_plugin.c
+5
-5
@@ -354,7 +354,7 @@ struct target *get_target(const char *id, struct target *target)
354
struct target *w;
355
for(w = target_root ; w ; w = w->next)
356
if(strncmp(nid, w->id, MAX_NAME) == 0) return w;
357
-
357
+
358
w = calloc(sizeof(struct target), 1);
359
if(!w) {
360
error("Cannot allocate %lu bytes of memory", (unsigned long)sizeof(struct target));
@@ -1206,7 +1206,7 @@ void update_statistics(void)
1206
for(p = root_of_pids; p ; p = p->next) {
1207
if(p->ppid > 0 && p->ppid <= pid_max && all_pids[p->ppid]) {
1208
if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: \tparent of %d %s is %d %s\n", p->pid, p->comm, p->ppid, all_pids[p->ppid]->comm);
1209
-
1209
+
1210
p->parent = all_pids[p->ppid];
1211
p->parent->childs++;
1212
}
@@ -1336,7 +1336,7 @@ void update_statistics(void)
1336
w->fds = calloc(sizeof(int), all_files_size);
1337
if(!w->fds)
1338
error("Cannot allocate memory for fds in %s", w->name);
1339
-
1339
+
1340
w->minflt = 0;
1341
w->majflt = 0;
1342
w->utime = 0;
@@ -1477,7 +1477,7 @@ void update_statistics(void)
1477
for(p = root_of_pids; p ;) {
1478
if(!p->updated) {
1479
// fprintf(stderr, "\tEXITED %d %s [parent %d %s, target %s] utime=%llu, stime=%llu, cutime=%llu, cstime=%llu, minflt=%llu, majflt=%llu, cminflt=%llu, cmajflt=%llu\n", p->pid, p->comm, p->parent->pid, p->parent->comm, p->target->name, p->utime, p->stime, p->cutime, p->cstime, p->minflt, p->majflt, p->cminflt, p->cmajflt);
1480
-
1480
+
1481
for(c = 0 ; c < p->fds_size ; c++) if(p->fds[c] > 0) {
1482
file_descriptor_not_used(p->fds[c]);
1483
p->fds[c] = 0;
@@ -1955,7 +1955,7 @@ int main(int argc, char **argv)
1955
1956
usleep(susec);
1957
bcopy(&now, &last, sizeof(struct timeval));
1958
-
1958
+
1959
current_t = time(NULL);
1960
if(current_t - started_t > 3600) exit(0);
1961
}
src/avl.h
+1
-1
@@ -43,7 +43,7 @@ int avl_insert(avl_tree* t, avl* a);
43
44
/* Remove an element a from the AVL tree t
45
* returns -1 if the depth of the tree has shrunk
46
- * Warning: if the element is not present in the tree,
46
+ * Warning: if the element is not present in the tree,
47
* returns 0 as if it had been removed succesfully.
48
*/
49
int avl_remove(avl_tree* t, avl* a);
src/daemon.c
+4
-4
@@ -100,7 +100,7 @@ void prepare_rundir() {
100
mkdir(rundir, 0775);
101
snprintf(rundir, FILENAME_MAX, "/run/user/%d/netdata", getuid());
102
}
103
-
103
+
104
snprintf(pidfile, FILENAME_MAX, "%s/netdata.pid", rundir);
105
106
if(mkdir(rundir, 0775) != 0) {
@@ -204,7 +204,7 @@ int become_daemon(int dont_fork, int close_all_files, const char *user, const ch
204
}
205
}
206
}
207
-
207
+
208
if((dev_null = open("/dev/null", O_RDWR, 0666)) == -1) {
209
perror("Cannot open /dev/null");
210
if(input_fd != -1) close(input_fd);
@@ -264,7 +264,7 @@ int become_daemon(int dont_fork, int close_all_files, const char *user, const ch
264
if(close_all_files) {
265
int i;
266
for(i = sysconf(_SC_OPEN_MAX); i > 0; i--)
267
- if(
267
+ if(
268
((access_fd && i != *access_fd) || !access_fd)
269
&& i != dev_null
270
&& i != input_fd
@@ -289,7 +289,7 @@ int become_daemon(int dont_fork, int close_all_files, const char *user, const ch
289
input_fd = -1;
290
}
291
else dup2(dev_null, STDIN_FILENO);
292
-
292
+
293
if(output_fd != -1) {
294
if(output_fd != STDOUT_FILENO) {
295
dup2(output_fd, STDOUT_FILENO);
src/main.c
+6
-6
@@ -74,7 +74,7 @@ int killpid(pid_t pid, int sig)
74
errno = 0;
75
if(kill(pid, 0) == -1) {
76
switch(errno) {
77
- case ESRCH:
77
+ case ESRCH:
78
error("Request to kill pid %d, but it is not running.", pid);
79
break;
80
@@ -89,8 +89,8 @@ int killpid(pid_t pid, int sig)
89
}
90
else {
91
errno = 0;
92
-
93
- void (*old)(int);
92
+
93
+ void (*old)(int);
94
old = signal(sig, SIG_IGN);
95
if(old == SIG_ERR) {
96
error("Cannot overwrite signal handler for signal %d", sig);
@@ -104,7 +104,7 @@ int killpid(pid_t pid, int sig)
104
105
if(ret == -1) {
106
switch(errno) {
107
- case ESRCH:
107
+ case ESRCH:
108
error("Cannot kill pid %d, but it is not running.", pid);
109
break;
110
@@ -133,7 +133,7 @@ void kill_childs()
133
pthread_join(w->thread, NULL);
134
}
135
136
- int i;
136
+ int i;
137
for (i = 0; static_threads[i].name != NULL ; i++) {
138
if(static_threads[i].thread) {
139
debug(D_EXIT, "Stopping %s thread", static_threads[i].name);
@@ -357,7 +357,7 @@ int main(int argc, char **argv)
357
}
358
359
// --------------------------------------------------------------------
360
-
360
+
361
for (i = 0; static_threads[i].name != NULL ; i++) {
362
struct netdata_static_thread *st = &static_threads[i];
363
src/old-and-tests/benchmark.c
+1
-1
@@ -91,7 +91,7 @@ char *fastfile_getline(fastfile *ff) {
91
92
char *start = &ff->buffer[ff->cursor];
93
char *s = start;
94
-
94
+
95
while(*s != '\n' && *s != '\0') s++;
96
*s = '\0';
97
ff->cursor += ( s - start + 1 );
src/old-and-tests/benchmark2.c
+2
-2
@@ -19,7 +19,7 @@
19
20
/*
21
* This is a library for reading kernel files from /proc
22
- *
22
+ *
23
* The idea is this:
24
*
25
* - every file is opened once.
@@ -201,7 +201,7 @@ fastfile *fastfile_parser(fastfile *ff) {
201
char *s = ff->data, *e = ff->data, *t = ff->data;
202
uint32_t l = 0, w = 0;
203
e += ff->len;
204
-
204
+
205
ff->lines = fflines_add(ff->lines, w);
206
if(!ff->lines) goto cleanup;
207
src/old-and-tests/netdata.c
+111
-111
@@ -405,7 +405,7 @@ FILE *mypopen(const char *command, pid_t *pidptr)
405
fprintf(stdout, "MYPID %d\n", getpid());
406
fflush(NULL);
407
#endif
408
-
408
+
409
// ignore all signals
410
for (i = 1 ; i < 65 ;i++) if(i != SIGSEGV) signal(i, SIG_DFL);
411
@@ -485,12 +485,12 @@ char *url_decode(char *str) {
485
486
else
487
*pbuf++ = *pstr;
488
-
488
+
489
pstr++;
490
}
491
-
491
+
492
*pbuf = '\0';
493
-
493
+
494
return buf;
495
}
496
@@ -1163,7 +1163,7 @@ struct rrd_dimension {
1163
char id[RRD_STATS_NAME_MAX + 1]; // the id of this dimension (for internal identification)
1164
char *name; // the name of this dimension (as presented to user)
1165
char cache_file[FILENAME_MAX+1];
1166
-
1166
+
1167
unsigned long hash; // a simple hash on the id, to speed up searching
1168
// we first compare hashes, and only if the hashes are equal we do string comparisons
1169
@@ -1230,7 +1230,7 @@ struct rrd_stats {
1230
int update_every; // every how many seconds is this updated?
1231
unsigned long long first_entry_t; // the timestamp (in microseconds) of the oldest entry in the db
1232
struct timeval last_updated; // when this data set was last updated (updated every time the rrd_stats_done() function)
1233
- struct timeval last_collected_time; //
1233
+ struct timeval last_collected_time; //
1234
unsigned long long usec_since_last_update;
1235
1236
total_number collected_total;
@@ -1410,7 +1410,7 @@ RRD_STATS *rrd_stats_create(const char *type, const char *id, const char *name,
1410
1411
st->priority = config_get_number(st->id, "priority", priority);
1412
st->enabled = enabled;
1413
-
1413
+
1414
st->isdetail = 0;
1415
st->debug = 0;
1416
@@ -1530,7 +1530,7 @@ RRD_DIMENSION *rrd_stats_dimension_add(RRD_STATS *st, const char *id, const char
1530
1531
rd->entries = st->entries;
1532
rd->update_every = st->update_every;
1533
-
1533
+
1534
// append this dimension
1535
if(!st->dimensions)
1536
st->dimensions = rd;
@@ -1705,7 +1705,7 @@ int rrd_stats_dimension_hide(RRD_STATS *st, const char *id)
1705
void rrd_stats_dimension_set_by_pointer(RRD_STATS *st, RRD_DIMENSION *rd, collected_number value)
1706
{
1707
if(st) {;}
1708
-
1708
+
1709
gettimeofday(&rd->last_collected_time, NULL);
1710
rd->collected_value = value;
1711
}
@@ -2015,7 +2015,7 @@ unsigned long long rrd_stats_done(RRD_STATS *st)
2015
// add the value we will overwrite
2016
st->first_entry_t += st->update_every * 1000000ULL;
2017
}
2018
-
2018
+
2019
st->counter++;
2020
st->current_entry = ((st->current_entry + 1) >= st->entries) ? 0 : st->current_entry + 1;
2021
if(!st->first_entry_t) st->first_entry_t = next_ut;
@@ -2240,7 +2240,7 @@ void web_buffer_increase(struct web_buffer *b, long free_size_required)
2240
2241
b->buffer = realloc(b->buffer, b->size + increase);
2242
if(!b->buffer) fatal("Failed to increase data buffer from size %d to %d.", b->size, b->size + increase);
2243
-
2243
+
2244
b->size += increase;
2245
}
2246
@@ -2291,7 +2291,7 @@ struct web_client *web_client_create(int listener)
2291
{
2292
struct web_client *w;
2293
socklen_t addrlen;
2294
-
2294
+
2295
w = calloc(1, sizeof(struct web_client));
2296
if(!w) {
2297
error("Cannot allocate new web_client memory.");
@@ -2316,7 +2316,7 @@ struct web_client *web_client_create(int listener)
2316
debug(D_WEB_CLIENT_ACCESS, "%llu: New web client from %s on socket %d.", w->id, w->client_ip, w->ifd);
2317
2318
{
2319
- int flag = 1;
2319
+ int flag = 1;
2320
if(setsockopt(w->ifd, SOL_SOCKET, SO_KEEPALIVE, (char *) &flag, sizeof(int)) != 0) error("%llu: Cannot set SO_KEEPALIVE on socket.", w->id);
2321
}
2322
@@ -2367,7 +2367,7 @@ struct web_client *web_client_free(struct web_client *w)
2367
time_t rrd_stats_first_entry_t(RRD_STATS *st)
2368
{
2369
if(!st->first_entry_t) return st->last_updated.tv_sec;
2370
-
2370
+
2371
return st->first_entry_t / 1000000;
2372
}
2373
@@ -2506,7 +2506,7 @@ void rrd_stats_all_json(struct web_buffer *wb)
2506
}
2507
}
2508
pthread_rwlock_unlock(&root_rwlock);
2509
-
2509
+
2510
web_buffer_printf(wb, "\n\t],\n"
2511
"\t\"hostname\": \"%s\",\n"
2512
"\t\"update_every\": %d,\n"
@@ -2528,7 +2528,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2528
2529
// -------------------------------------------------------------------------
2530
// switch from JSON to google JSON
2531
-
2531
+
2532
char kq[2] = "\"";
2533
char sq[2] = "\"";
2534
switch(type) {
@@ -2546,20 +2546,20 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2546
2547
// -------------------------------------------------------------------------
2548
// validate the parameters
2549
-
2549
+
2550
if(entries_to_show < 1) entries_to_show = 1;
2551
if(group < 1) group = 1;
2552
-
2552
+
2553
// make sure current_entry is within limits
2554
long current_entry = (long)st->current_entry - (long)1;
2555
if(current_entry < 0) current_entry = 0;
2556
else if(current_entry >= st->entries) current_entry = st->entries - 1;
2557
-
2557
+
2558
// find the oldest entry of the round-robin
2559
long max_entries_init = (st->counter < (unsigned long)st->entries) ? st->counter : (unsigned long)st->entries;
2560
-
2560
+
2561
time_t time_init = st->last_updated.tv_sec;
2562
-
2562
+
2563
if(before == 0 || before > time_init) before = time_init;
2564
if(after == 0) after = rrd_stats_first_entry_t(st);
2565
@@ -2568,12 +2568,12 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2568
2569
// our return value (the last timestamp printed)
2570
// this is required to detect re-transmit in google JSONP
2571
- time_t last_timestamp = 0;
2571
+ time_t last_timestamp = 0;
2572
2573
2574
// -------------------------------------------------------------------------
2575
// find how many dimensions we have
2576
-
2576
+
2577
int dimensions = 0;
2578
RRD_DIMENSION *rd;
2579
for( rd = st->dimensions ; rd ; rd = rd->next) dimensions++;
@@ -2583,10 +2583,10 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2583
return 0;
2584
}
2585
2586
-
2586
+
2587
// -------------------------------------------------------------------------
2588
// prepare various strings, to speed up the loop
2589
-
2589
+
2590
char overflow_annotation[201]; snprintf(overflow_annotation, 200, ",{%sv%s:%sRESET OR OVERFLOW%s},{%sv%s:%sThe counters have been wrapped.%s}", kq, kq, sq, sq, kq, kq, sq, sq);
2591
char normal_annotation[201]; snprintf(normal_annotation, 200, ",{%sv%s:null},{%sv%s:null}", kq, kq, kq, kq);
2592
char pre_date[51]; snprintf(pre_date, 50, " {%sc%s:[{%sv%s:%s", kq, kq, kq, kq, sq);
@@ -2597,7 +2597,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2597
2598
// -------------------------------------------------------------------------
2599
// checks for debuging
2600
-
2600
+
2601
if(st->debug) {
2602
debug(D_RRD_STATS, "%s first_entry_t = %lu, last_entry_t = %lu, duration = %lu, after = %lu, before = %lu, duration = %lu, entries_to_show = %lu, group = %lu, max_entries = %ld"
2603
, st->id
@@ -2622,7 +2622,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2622
2623
// -------------------------------------------------------------------------
2624
// temp arrays for keeping values per dimension
2625
-
2625
+
2626
calculated_number group_values[dimensions]; // keep sums when grouping
2627
calculated_number print_values[dimensions]; // keep the final value to be printed
2628
int print_hidden[dimensions]; // keep hidden flags
@@ -2645,7 +2645,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2645
2646
// -------------------------------------------------------------------------
2647
// print the JSON header
2648
-
2648
+
2649
web_buffer_printf(wb, "{\n %scols%s:\n [\n", kq, kq);
2650
web_buffer_printf(wb, " {%sid%s:%s%s,%slabel%s:%stime%s,%spattern%s:%s%s,%stype%s:%sdatetime%s},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq);
2651
web_buffer_printf(wb, " {%sid%s:%s%s,%slabel%s:%s%s,%spattern%s:%s%s,%stype%s:%sstring%s,%sp%s:{%srole%s:%sannotation%s}},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, kq, kq, sq, sq);
@@ -2673,7 +2673,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2673
2674
int annotate_reset = 0;
2675
int annotation_count = 0;
2676
-
2676
+
2677
// to allow grouping on the same values, we need a pad
2678
long pad = before % group;
2679
@@ -2716,12 +2716,12 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2716
// debug(D_RRD_STATS, "Already printed all rows. Stopping.");
2717
break;
2718
}
2719
-
2719
+
2720
if(group_count != group) {
2721
// this is an incomplete group, skip it.
2722
for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++)
2723
group_values[c] = 0;
2724
-
2724
+
2725
group_count = 0;
2726
continue;
2727
}
@@ -2744,7 +2744,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2744
2745
for(rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
2746
calculated_number value = unpack_storage_number(rd->values[t]);
2747
-
2747
+
2748
switch(group_method) {
2749
case GROUP_MAX:
2750
if(abs(value) > abs(group_values[c])) group_values[c] = value;
@@ -2769,7 +2769,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2769
2770
if(print_this) {
2771
group_count = 0;
2772
-
2772
+
2773
if(annotate_reset) {
2774
annotation_count++;
2775
web_buffer_strcpy(wb, overflow_annotation);
@@ -2817,7 +2817,7 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, int
2817
else break;
2818
}
2819
else break;
2820
-
2820
+
2821
} // max_loop
2822
2823
debug(D_RRD_STATS, "RRD_STATS_JSON: %s total %ld bytes", st->name, wb->bytes);
@@ -2836,7 +2836,7 @@ void generate_config(struct web_buffer *wb, int only_changed)
2836
web_buffer_increase(wb, 500);
2837
switch(i) {
2838
case 0:
2839
- web_buffer_printf(wb,
2839
+ web_buffer_printf(wb,
2840
"# NetData Configuration\n"
2841
"# You can uncomment and change any of the options bellow.\n"
2842
"# The value shown in the commented settings, is the default value.\n"
@@ -2951,7 +2951,7 @@ int mysendfile(struct web_client *w, char *filename)
2951
return 404;
2952
}
2953
}
2954
-
2954
+
2955
// pick a Content-Type for the file
2956
if(strstr(filename, ".html") != NULL) w->data->contenttype = CT_TEXT_HTML;
2957
else if(strstr(filename, ".js") != NULL) w->data->contenttype = CT_APPLICATION_X_JAVASCRIPT;
@@ -2993,7 +2993,7 @@ void web_client_reset(struct web_client *w)
2993
2994
long sent = w->zoutput?(long)w->zstream.total_out:((w->mode == WEB_CLIENT_MODE_FILECOPY)?w->data->rbytes:w->data->bytes);
2995
long size = (w->mode == WEB_CLIENT_MODE_FILECOPY)?w->data->rbytes:w->data->bytes;
2996
-
2996
+
2997
if(w->last_url[0]) log_access("%llu: (sent/all = %ld/%ld bytes %0.0f%%, prep/sent/total = %0.2f/%0.2f/%0.2f ms) %s: '%s'",
2998
w->id,
2999
sent, size, -((size>0)?((float)(size-sent)/(float)size * 100.0):0.0),
@@ -3188,13 +3188,13 @@ int web_client_data_request(struct web_client *w, char *url, int datasource_type
3188
3189
else if(strcmp(key, "sig") == 0)
3190
google_sig = value;
3191
-
3191
+
3192
else if(strcmp(key, "out") == 0)
3193
google_out = value;
3194
-
3194
+
3195
else if(strcmp(key, "responseHandler") == 0)
3196
google_responseHandler = value;
3197
-
3197
+
3198
else if(strcmp(key, "outFileName") == 0)
3199
google_outFileName = value;
3200
}
@@ -3211,7 +3211,7 @@ int web_client_data_request(struct web_client *w, char *url, int datasource_type
3211
3212
// check the client wants json
3213
if(strcmp(google_out, "json") != 0) {
3214
- w->data->bytes = snprintf(w->data->buffer, w->data->size,
3214
+ w->data->bytes = snprintf(w->data->buffer, w->data->size,
3215
"%s({version:'%s',reqId:'%s',status:'error',errors:[{reason:'invalid_query',message:'output format is not supported',detailed_message:'the format %s requested is not supported by netdata.'}]});",
3216
google_responseHandler, google_version, google_reqId, google_out);
3217
return 200;
@@ -3220,11 +3220,11 @@ int web_client_data_request(struct web_client *w, char *url, int datasource_type
3220
}
3221
3222
if(datasource_type == DATASOURCE_GOOGLE_JSONP) {
3223
- w->data->bytes = snprintf(w->data->buffer, w->data->size,
3223
+ w->data->bytes = snprintf(w->data->buffer, w->data->size,
3224
"%s({version:'%s',reqId:'%s',status:'ok',sig:'%lu',table:",
3225
google_responseHandler, google_version, google_reqId, st->last_updated.tv_sec);
3226
}
3227
-
3227
+
3228
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending RRD data '%s' (id %s, %d lines, %d group, %d group_method, %lu after, %lu before).", w->id, st->name, st->id, lines, group_count, group_method, after, before);
3229
unsigned long timestamp_in_data = rrd_stats_json(datasource_type, st, w->data, lines, group_count, group_method, after, before, nonzero);
3230
@@ -3234,7 +3234,7 @@ int web_client_data_request(struct web_client *w, char *url, int datasource_type
3234
3235
else {
3236
// the client already has the latest data
3237
- w->data->bytes = snprintf(w->data->buffer, w->data->size,
3237
+ w->data->bytes = snprintf(w->data->buffer, w->data->size,
3238
"%s({version:'%s',reqId:'%s',status:'error',errors:[{reason:'not_modified',message:'Data not modified'}]});",
3239
google_responseHandler, google_version, google_reqId);
3240
}
@@ -3422,7 +3422,7 @@ void web_client_process(struct web_client *w)
3422
strcpy(w->data->buffer, "I don't understand you...\r\n");
3423
w->data->bytes = strlen(w->data->buffer);
3424
}
3425
-
3425
+
3426
// free url_decode() buffer
3427
if(pointer_to_free) free(pointer_to_free);
3428
}
@@ -3545,7 +3545,7 @@ void web_client_process(struct web_client *w)
3545
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %Z", &tm);
3546
3547
char custom_header[MAX_HTTP_HEADER_SIZE + 1] = "";
3548
- if(w->response_header[0])
3548
+ if(w->response_header[0])
3549
strcpy(custom_header, w->response_header);
3550
3551
int headerlen = 0;
@@ -3655,7 +3655,7 @@ void web_client_process(struct web_client *w)
3655
long web_client_send_chunk_header(struct web_client *w, int len)
3656
{
3657
debug(D_DEFLATE, "%llu: OPEN CHUNK of %d bytes (hex: %x).", w->id, len, len);
3658
- char buf[1024];
3658
+ char buf[1024];
3659
sprintf(buf, "%X\r\n", len);
3660
int bytes = send(w->ofd, buf, strlen(buf), MSG_DONTWAIT);
3661
@@ -4075,7 +4075,7 @@ void *socket_listen_main(void *ptr)
4075
error("%llu: Cannot request detach of newly created web client thread.", w->id);
4076
w->obsolete = 1;
4077
}
4078
-
4078
+
4079
log_access("%llu: %s connected", w->id, w->client_ip);
4080
}
4081
else debug(D_WEB_CLIENT, "LISTENER: select() didn't do anything.");
@@ -4128,10 +4128,10 @@ int do_proc_net_dev() {
4128
char iface[MAX_PROC_NET_DEV_IFACE_NAME + 1] = "";
4129
unsigned long long rbytes, rpackets, rerrors, rdrops, rfifo, rframe, rcompressed, rmulticast;
4130
unsigned long long tbytes, tpackets, terrors, tdrops, tfifo, tcollisions, tcarrier, tcompressed;
4131
-
4131
+
4132
int r;
4133
char *p;
4134
-
4134
+
4135
if(fp) {
4136
if(fseek(fp, 0, SEEK_SET) == -1) {
4137
error("Re-opening file /proc/net/dev.");
@@ -4147,20 +4147,20 @@ int do_proc_net_dev() {
4147
return 1;
4148
}
4149
}
4150
-
4150
+
4151
// skip the first two lines
4152
p = fgets(buffer, MAX_PROC_NET_DEV_LINE, fp);
4153
p = fgets(buffer, MAX_PROC_NET_DEV_LINE, fp);
4154
-
4154
+
4155
// read the rest of the lines
4156
for(;1;) {
4157
char *c;
4158
p = fgets(buffer, MAX_PROC_NET_DEV_LINE, fp);
4159
if(!p) break;
4160
-
4160
+
4161
c = strchr(buffer, ':');
4162
if(c) *c = '\t';
4163
-
4163
+
4164
r = sscanf(buffer, "%s %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
4165
iface,
4166
&rbytes, &rpackets, &rerrors, &rdrops, &rfifo, &rframe, &rcompressed, &rmulticast,
@@ -4269,7 +4269,7 @@ int do_proc_net_dev() {
4269
rrd_stats_done(st);
4270
}
4271
}
4272
-
4272
+
4273
return 0;
4274
}
4275
@@ -4294,10 +4294,10 @@ int do_proc_diskstats() {
4294
4295
char buffer[MAX_PROC_DISKSTATS_LINE+1] = "";
4296
char disk[MAX_PROC_DISKSTATS_DISK_NAME + 1] = "";
4297
-
4297
+
4298
int r;
4299
char *p;
4300
-
4300
+
4301
if(fp) {
4302
if(fseek(fp, 0, SEEK_SET) == -1) {
4303
error("Re-opening file /proc/diskstats.");
@@ -4313,7 +4313,7 @@ int do_proc_diskstats() {
4313
return 1;
4314
}
4315
}
4316
-
4316
+
4317
for(;1;) {
4318
unsigned long long major = 0, minor = 0,
4319
reads = 0, reads_merged = 0, readsectors = 0, readms = 0,
@@ -4322,7 +4322,7 @@ int do_proc_diskstats() {
4322
4323
p = fgets(buffer, MAX_PROC_DISKSTATS_LINE, fp);
4324
if(!p) break;
4325
-
4325
+
4326
r = sscanf(buffer, "%llu %llu %s %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
4327
&major, &minor, disk,
4328
&reads, &reads_merged, &readsectors, &readms, &writes, &writes_merged, &writesectors, &writems, ¤tios, &iosms, &wiosms
@@ -4520,7 +4520,7 @@ int do_proc_diskstats() {
4520
rrd_stats_dimension_set(st, "writes", writes);
4521
rrd_stats_done(st);
4522
}
4523
-
4523
+
4524
// --------------------------------------------------------------------
4525
4526
if(do_merged_ops) {
@@ -4577,7 +4577,7 @@ int do_proc_diskstats() {
4577
rrd_stats_done(st);
4578
}
4579
}
4580
-
4580
+
4581
return 0;
4582
}
4583
@@ -4586,7 +4586,7 @@ int do_proc_diskstats() {
4586
4587
int do_proc_net_snmp() {
4588
static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1,
4589
- do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1,
4589
+ do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1,
4590
do_udp_packets = -1, do_udp_errors = -1;
4591
static FILE *fp = NULL;
4592
@@ -4753,7 +4753,7 @@ int do_proc_net_snmp() {
4753
if(r != 14) error("Cannot read /proc/net/snmp TCP line. Expected 14 params, read %d.", r);
4754
4755
// --------------------------------------------------------------------
4756
-
4756
+
4757
// see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
4758
if(do_tcp_sockets) {
4759
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcpsock");
@@ -4769,7 +4769,7 @@ int do_proc_net_snmp() {
4769
}
4770
4771
// --------------------------------------------------------------------
4772
-
4772
+
4773
if(do_tcp_packets) {
4774
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcppackets");
4775
if(!st) {
@@ -4786,7 +4786,7 @@ int do_proc_net_snmp() {
4786
}
4787
4788
// --------------------------------------------------------------------
4789
-
4789
+
4790
if(do_tcp_errors) {
4791
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcperrors");
4792
if(!st) {
@@ -4804,7 +4804,7 @@ int do_proc_net_snmp() {
4804
}
4805
4806
// --------------------------------------------------------------------
4807
-
4807
+
4808
if(do_tcp_handshake) {
4809
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcphandshake");
4810
if(!st) {
@@ -4846,7 +4846,7 @@ int do_proc_net_snmp() {
4846
if(r != 6) error("Cannot read /proc/net/snmp UDP line. Expected 6 params, read %d.", r);
4847
4848
// --------------------------------------------------------------------
4849
-
4849
+
4850
// see http://net-snmp.sourceforge.net/docs/mibs/udp.html
4851
if(do_udp_packets) {
4852
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".udppackets");
@@ -4864,7 +4864,7 @@ int do_proc_net_snmp() {
4864
}
4865
4866
// --------------------------------------------------------------------
4867
-
4867
+
4868
if(do_udp_errors) {
4869
st = rrd_stats_find(RRD_TYPE_NET_SNMP ".udperrors");
4870
if(!st) {
@@ -4886,7 +4886,7 @@ int do_proc_net_snmp() {
4886
}
4887
}
4888
}
4889
-
4889
+
4890
return 0;
4891
}
4892
@@ -4940,7 +4940,7 @@ int do_proc_net_netstat() {
4940
InNoRoutes = 0, InTruncatedPkts = 0,
4941
InOctets = 0, InMcastPkts = 0, InBcastPkts = 0, InMcastOctets = 0, InBcastOctets = 0,
4942
OutOctets = 0, OutMcastPkts = 0, OutBcastPkts = 0, OutMcastOctets = 0, OutBcastOctets = 0;
4943
-
4943
+
4944
int r = sscanf(&buffer[7], "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
4945
&InNoRoutes, &InTruncatedPkts, &InMcastPkts, &OutMcastPkts, &InBcastPkts, &OutBcastPkts,
4946
&InOctets, &OutOctets, &InMcastOctets, &OutMcastOctets, &InBcastOctets, &OutBcastOctets);
@@ -5061,7 +5061,7 @@ int do_proc_net_netstat() {
5061
}
5062
}
5063
}
5064
-
5064
+
5065
return 0;
5066
}
5067
@@ -5140,7 +5140,7 @@ int do_proc_net_stat_conntrack() {
5140
RRD_STATS *st;
5141
5142
// --------------------------------------------------------------------
5143
-
5143
+
5144
if(do_sockets) {
5145
st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".sockets");
5146
if(!st) {
@@ -5334,7 +5334,7 @@ int do_proc_net_ip_vs_stats() {
5334
}
5335
5336
// --------------------------------------------------------------------
5337
-
5337
+
5338
if(do_packets) {
5339
st = rrd_stats_find(RRD_TYPE_NET_IPVS ".packets");
5340
if(!st) {
@@ -5351,7 +5351,7 @@ int do_proc_net_ip_vs_stats() {
5351
}
5352
5353
// --------------------------------------------------------------------
5354
-
5354
+
5355
if(do_bandwidth) {
5356
st = rrd_stats_find(RRD_TYPE_NET_IPVS ".net");
5357
if(!st) {
@@ -5473,7 +5473,7 @@ int do_proc_stat() {
5473
if(r != 2) error("Cannot read /proc/stat intr line. Expected 2 params, read %d.", r);
5474
5475
// --------------------------------------------------------------------
5476
-
5476
+
5477
if(do_interrupts) {
5478
st = rrd_stats_find_bytype("system", id);
5479
if(!st) {
@@ -5498,7 +5498,7 @@ int do_proc_stat() {
5498
if(r != 2) error("Cannot read /proc/stat ctxt line. Expected 2 params, read %d.", r);
5499
5500
// --------------------------------------------------------------------
5501
-
5501
+
5502
if(do_context) {
5503
st = rrd_stats_find_bytype("system", id);
5504
if(!st) {
@@ -5692,7 +5692,7 @@ int do_proc_meminfo() {
5692
RRD_STATS *st;
5693
5694
// --------------------------------------------------------------------
5695
-
5695
+
5696
// http://stackoverflow.com/questions/3019748/how-to-reliably-measure-available-memory-in-linux
5697
unsigned long long MemUsed = MemTotal - MemFree - Cached - Buffers;
5698
@@ -5716,7 +5716,7 @@ int do_proc_meminfo() {
5716
}
5717
5718
// --------------------------------------------------------------------
5719
-
5719
+
5720
unsigned long long SwapUsed = SwapTotal - SwapFree;
5721
5722
if(do_swap) {
@@ -5736,7 +5736,7 @@ int do_proc_meminfo() {
5736
}
5737
5738
// --------------------------------------------------------------------
5739
-
5739
+
5740
if(hwcorrupted && do_hwcorrupt) {
5741
st = rrd_stats_find("mem.hwcorrupt");
5742
if(!st) {
@@ -5752,7 +5752,7 @@ int do_proc_meminfo() {
5752
}
5753
5754
// --------------------------------------------------------------------
5755
-
5755
+
5756
if(do_committed) {
5757
st = rrd_stats_find("mem.committed");
5758
if(!st) {
@@ -5768,7 +5768,7 @@ int do_proc_meminfo() {
5768
}
5769
5770
// --------------------------------------------------------------------
5771
-
5771
+
5772
if(do_writeback) {
5773
st = rrd_stats_find("mem.writeback");
5774
if(!st) {
@@ -5792,7 +5792,7 @@ int do_proc_meminfo() {
5792
}
5793
5794
// --------------------------------------------------------------------
5795
-
5795
+
5796
if(do_kernel) {
5797
st = rrd_stats_find("mem.kernel");
5798
if(!st) {
@@ -5814,7 +5814,7 @@ int do_proc_meminfo() {
5814
}
5815
5816
// --------------------------------------------------------------------
5817
-
5817
+
5818
if(do_slab) {
5819
st = rrd_stats_find("mem.slab");
5820
if(!st) {
@@ -5872,7 +5872,7 @@ int do_proc_vmstat() {
5872
nr_shmem = 0, nr_dirtied = 0, nr_written = 0, nr_anon_transparent_hugepages = 0, nr_dirty_threshold = 0, nr_dirty_background_threshold = 0,
5873
pgpgin = 0, pgpgout = 0, pswpin = 0, pswpout = 0, pgalloc_dma = 0, pgalloc_dma32 = 0, pgalloc_normal = 0, pgalloc_movable = 0, pgfree = 0, pgactivate = 0, pgdeactivate = 0,
5874
pgfault = 0, pgmajfault = 0, pgrefill_dma = 0, pgrefill_dma32 = 0, pgrefill_normal = 0, pgrefill_movable = 0, pgsteal_kswapd_dma = 0, pgsteal_kswapd_dma32 = 0,
5875
- pgsteal_kswapd_normal = 0, pgsteal_kswapd_movable = 0, pgsteal_direct_dma = 0, pgsteal_direct_dma32 = 0, pgsteal_direct_normal = 0, pgsteal_direct_movable = 0,
5875
+ pgsteal_kswapd_normal = 0, pgsteal_kswapd_movable = 0, pgsteal_direct_dma = 0, pgsteal_direct_dma32 = 0, pgsteal_direct_normal = 0, pgsteal_direct_movable = 0,
5876
pgscan_kswapd_dma = 0, pgscan_kswapd_dma32 = 0, pgscan_kswapd_normal = 0, pgscan_kswapd_movable = 0, pgscan_direct_dma = 0, pgscan_direct_dma32 = 0, pgscan_direct_normal = 0,
5877
pgscan_direct_movable = 0, pginodesteal = 0, slabs_scanned = 0, kswapd_inodesteal = 0, kswapd_low_wmark_hit_quickly = 0, kswapd_high_wmark_hit_quickly = 0,
5878
kswapd_skip_congestion_wait = 0, pageoutrun = 0, allocstall = 0, pgrotated = 0, compact_blocks_moved = 0, compact_pages_moved = 0, compact_pagemigrate_failed = 0,
@@ -5992,7 +5992,7 @@ int do_proc_vmstat() {
5992
RRD_STATS *st;
5993
5994
// --------------------------------------------------------------------
5995
-
5995
+
5996
if(do_swapio) {
5997
st = rrd_stats_find("system.swapio");
5998
if(!st) {
@@ -6009,7 +6009,7 @@ int do_proc_vmstat() {
6009
}
6010
6011
// --------------------------------------------------------------------
6012
-
6012
+
6013
if(do_io) {
6014
st = rrd_stats_find("system.io");
6015
if(!st) {
@@ -6026,7 +6026,7 @@ int do_proc_vmstat() {
6026
}
6027
6028
// --------------------------------------------------------------------
6029
-
6029
+
6030
if(do_pgfaults) {
6031
st = rrd_stats_find("system.pgfaults");
6032
if(!st) {
@@ -6064,7 +6064,7 @@ void *proc_main(void *ptr)
6064
6065
gettimeofday(&last, NULL);
6066
last.tv_sec -= update_every;
6067
-
6067
+
6068
// disable (by default) various interface that are not needed
6069
config_get_boolean("plugin:proc:/proc/net/dev", "interface lo", 0);
6070
config_get_boolean("plugin:proc:/proc/net/dev", "interface fireqos_monitor", 0);
@@ -6088,7 +6088,7 @@ void *proc_main(void *ptr)
6088
6089
unsigned long long usec = 0, susec = 0;
6090
for(;1;) {
6091
-
6091
+
6092
// BEGIN -- the job to be done
6093
if(!vdo_proc_net_dev) vdo_proc_net_dev = do_proc_net_dev(usec);
6094
if(!vdo_proc_diskstats) vdo_proc_diskstats = do_proc_diskstats(usec);
@@ -6100,19 +6100,19 @@ void *proc_main(void *ptr)
6100
if(!vdo_proc_meminfo) vdo_proc_meminfo = do_proc_meminfo(usec);
6101
if(!vdo_proc_vmstat) vdo_proc_vmstat = do_proc_vmstat(usec);
6102
// END -- the job is done
6103
-
6103
+
6104
// find the time to sleep in order to wait exactly update_every seconds
6105
gettimeofday(&now, NULL);
6106
usec = usecdiff(&now, &last) - susec;
6107
debug(D_PROCNETDEV_LOOP, "PROCNETDEV: last loop took %llu usec (worked for %llu, sleeped for %llu).", usec + susec, usec, susec);
6108
-
6108
+
6109
if(usec < (update_every * 1000000ULL / 2ULL)) susec = (update_every * 1000000ULL) - usec;
6110
else susec = update_every * 1000000ULL / 2ULL;
6111
-
6111
+
6112
// --------------------------------------------------------------------
6113
6114
if(!vdo_cpu_netdata && getrusage(RUSAGE_SELF, &me) == 0) {
6115
-
6115
+
6116
unsigned long long cpuuser = me.ru_utime.tv_sec * 1000000ULL + me.ru_utime.tv_usec;
6117
unsigned long long cpusyst = me.ru_stime.tv_sec * 1000000ULL + me.ru_stime.tv_usec;
6118
@@ -6128,7 +6128,7 @@ void *proc_main(void *ptr)
6128
rrd_stats_dimension_set(stcpu, "user", cpuuser);
6129
rrd_stats_dimension_set(stcpu, "system", cpusyst);
6130
rrd_stats_done(stcpu);
6131
-
6131
+
6132
bcopy(&me, &me_last, sizeof(struct rusage));
6133
6134
// ----------------------------------------------------------------
@@ -6174,7 +6174,7 @@ void *proc_main(void *ptr)
6174
}
6175
6176
usleep(susec);
6177
-
6177
+
6178
// copy current to last
6179
bcopy(&now, &last, sizeof(struct timeval));
6180
}
@@ -6215,7 +6215,7 @@ void tc_device_commit(struct tc_device *d)
6215
static int enable_new_interfaces = -1;
6216
6217
if(enable_new_interfaces == -1) enable_new_interfaces = config_get_boolean("plugin:tc", "enable new interfaces detected at runtime", 1);
6218
-
6218
+
6219
// we only need to add leaf classes
6220
struct tc_class *c, *x;
6221
@@ -6231,7 +6231,7 @@ void tc_device_commit(struct tc_device *d)
6231
}
6232
}
6233
}
6234
-
6234
+
6235
// debugging:
6236
/*
6237
for ( c = d->classes ; c ; c = c->next) {
@@ -6271,7 +6271,7 @@ void tc_device_commit(struct tc_device *d)
6271
for ( c = d->classes ; c ; c = c->next) {
6272
if(c->isleaf && c->hasparent) {
6273
if(rrd_stats_dimension_set(st, c->id, c->bytes) != 0) {
6274
-
6274
+
6275
// new class, we have to add it
6276
rrd_stats_dimension_add(st, c->id, c->name, 8, 1024 * update_every, RRD_DIMENSION_INCREMENTAL);
6277
rrd_stats_dimension_set(st, c->id, c->bytes);
@@ -6599,7 +6599,7 @@ void *checks_main(void *ptr)
6599
loop_usec = usecdiff(&now, &last);
6600
usec = loop_usec - susec;
6601
debug(D_PROCNETDEV_LOOP, "CHECK: last loop took %llu usec (worked for %llu, sleeped for %llu).", loop_usec, usec, susec);
6602
-
6602
+
6603
if(usec < (update_every * 1000000ULL / 2ULL)) susec = (update_every * 1000000ULL) - usec;
6604
else susec = update_every * 1000000ULL / 2ULL;
6605
@@ -6674,7 +6674,7 @@ struct plugind {
6674
char *qstrsep(char **ptr)
6675
{
6676
if(!*ptr || !**ptr) return NULL;
6677
-
6677
+
6678
char *s, *p = *ptr;
6679
6680
// skip leading spaces
@@ -6736,7 +6736,7 @@ void *pluginsd_worker_thread(void *arg)
6736
else if(!strcmp(s, "SET")) {
6737
char *t;
6738
while((t = strchr(p, '='))) *t = ' ';
6739
-
6739
+
6740
char *dimension = qstrsep(&p);
6741
char *value = qstrsep(&p);
6742
@@ -7037,7 +7037,7 @@ void *pluginsd_main(void *ptr)
7037
if(!cd) fatal("Cannot allocate memory for plugin.");
7038
7039
snprintf(cd->id, CONFIG_MAX_NAME, "plugin:%s", pluginname);
7040
-
7040
+
7041
strncpy(cd->filename, file->d_name, FILENAME_MAX);
7042
snprintf(cd->fullfilename, FILENAME_MAX, "%s/%s", dir_name, cd->filename);
7043
@@ -7107,7 +7107,7 @@ void kill_childs()
7107
pthread_join(w->thread, NULL);
7108
}
7109
7110
- int i;
7110
+ int i;
7111
for (i = 0; static_threads[i].name != NULL ; i++) {
7112
if(static_threads[i].thread) {
7113
debug(D_EXIT, "Stopping %s thread", static_threads[i].name);
@@ -7158,7 +7158,7 @@ void process_childs(int wait)
7158
error("pid %d killed by signal %d.", info.si_pid, info.si_status);
7159
break;
7160
7161
- case CLD_DUMPED:
7161
+ case CLD_DUMPED:
7162
error("pid %d core dumped by signal %d.", info.si_pid, info.si_status);
7163
break;
7164
@@ -7234,7 +7234,7 @@ void prepare_rundir() {
7234
mkdir(rundir, 0775);
7235
snprintf(rundir, FILENAME_MAX, "/run/user/%d/netdata", getpid());
7236
}
7237
-
7237
+
7238
snprintf(pidfile, FILENAME_MAX, "%s/netdata.pid", rundir);
7239
7240
if(mkdir(rundir, 0775) != 0)
@@ -7332,7 +7332,7 @@ int become_daemon(int close_all_files, const char *input, const char *output, co
7332
}
7333
}
7334
}
7335
-
7335
+
7336
if((dev_null = open("/dev/null", O_RDWR, 0666)) == -1) {
7337
perror("Cannot open /dev/null");
7338
if(input_fd != -1) close(input_fd);
@@ -7385,7 +7385,7 @@ int become_daemon(int close_all_files, const char *input, const char *output, co
7385
// close all files
7386
if(close_all_files) {
7387
for(i = sysconf(_SC_OPEN_MAX); i > 0; i--)
7388
- if(
7388
+ if(
7389
((access_fd && i != *access_fd) || !access_fd)
7390
&& i != dev_null
7391
&& i != input_fd
@@ -7410,7 +7410,7 @@ int become_daemon(int close_all_files, const char *input, const char *output, co
7410
input_fd = -1;
7411
}
7412
else dup2(dev_null, STDIN_FILENO);
7413
-
7413
+
7414
if(output_fd != -1) {
7415
if(output_fd != STDOUT_FILENO) {
7416
dup2(output_fd, STDOUT_FILENO);
@@ -7557,8 +7557,8 @@ int unit_test(long delay, long shift)
7557
for(rd = st->dimensions ; rd ; rd = rd->next) {
7558
fprintf(stderr, "\t %s " STORAGE_NUMBER_FORMAT " -> ", rd->id, rd->values[c]);
7559
7560
- if(rd == rdabs) v =
7561
- ( oincrement
7560
+ if(rd == rdabs) v =
7561
+ ( oincrement
7562
+ (increment * (1000000 - shift) / 1000000)
7563
+ c * increment
7564
) * 10;
@@ -7768,7 +7768,7 @@ int main(int argc, char **argv)
7768
7769
// catch all signals
7770
for (i = 1 ; i < 65 ;i++) if(i != SIGSEGV && i != SIGFPE) signal(i, sig_handler);
7771
-
7771
+
7772
for (i = 0; static_threads[i].name != NULL ; i++) {
7773
struct netdata_static_thread *st = &static_threads[i];
7774
int doit = 1;
src/plugin_checks.c
+1
-1
@@ -52,7 +52,7 @@ void *checks_main(void *ptr)
52
loop_usec = usecdiff(&now, &last);
53
usec = loop_usec - susec;
54
debug(D_PROCNETDEV_LOOP, "CHECK: last loop took %llu usec (worked for %llu, sleeped for %llu).", loop_usec, usec, susec);
55
-
55
+
56
if(usec < (rrd_update_every * 1000000ULL / 2ULL)) susec = (rrd_update_every * 1000000ULL) - usec;
57
else susec = rrd_update_every * 1000000ULL / 2ULL;
58
src/plugin_nfacct.c
+4
-4
@@ -150,7 +150,7 @@ void *nfacct_main(void *ptr) {
150
gettimeofday(&now, NULL);
151
usec = usecdiff(&now, &last) - susec;
152
debug(D_NFACCT_LOOP, "nfacct.plugin: last loop took %llu usec (worked for %llu, sleeped for %llu).", usec + susec, usec, susec);
153
-
153
+
154
if(usec < (rrd_update_every * 1000000ULL / 2ULL)) susec = (rrd_update_every * 1000000ULL) - usec;
155
else susec = rrd_update_every * 1000000ULL / 2ULL;
156
@@ -175,7 +175,7 @@ void *nfacct_main(void *ptr) {
175
if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, rrd_update_every, RRDDIM_INCREMENTAL);
176
if(rd) rrddim_set_by_pointer(st, rd, nfacct_list->data[i].pkts);
177
}
178
-
178
+
179
rrdset_done(st);
180
181
// ----------------------------------------------------------------
@@ -195,14 +195,14 @@ void *nfacct_main(void *ptr) {
195
if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * rrd_update_every, RRDDIM_INCREMENTAL);
196
if(rd) rrddim_set_by_pointer(st, rd, nfacct_list->data[i].bytes);
197
}
198
-
198
+
199
rrdset_done(st);
200
}
201
202
// --------------------------------------------------------------------
203
204
usleep(susec);
205
-
205
+
206
// copy current to last
207
bcopy(&now, &last, sizeof(struct timeval));
208
}
src/plugin_proc.c
+7
-7
@@ -31,7 +31,7 @@ void *proc_main(void *ptr)
31
32
gettimeofday(&last, NULL);
33
last.tv_sec -= rrd_update_every;
34
-
34
+
35
// disable (by default) various interface that are not needed
36
config_get_boolean("plugin:proc:/proc/net/dev", "interface lo", 0);
37
config_get_boolean("plugin:proc:/proc/net/dev", "interface fireqos_monitor", 0);
@@ -57,9 +57,9 @@ void *proc_main(void *ptr)
57
58
unsigned long long usec = 0, susec = 0;
59
for(;1;) {
60
-
60
+
61
// BEGIN -- the job to be done
62
-
62
+
63
if(!vdo_proc_interrupts) {
64
debug(D_PROCNETDEV_LOOP, "PROCNETDEV: calling do_proc_interrupts().");
65
vdo_proc_interrupts = do_proc_interrupts(rrd_update_every, usec+susec);
@@ -117,15 +117,15 @@ void *proc_main(void *ptr)
117
}
118
119
// END -- the job is done
120
-
120
+
121
// find the time to sleep in order to wait exactly update_every seconds
122
gettimeofday(&now, NULL);
123
usec = usecdiff(&now, &last) - susec;
124
debug(D_PROCNETDEV_LOOP, "PROCNETDEV: last loop took %llu usec (worked for %llu, sleeped for %llu).", usec + susec, usec, susec);
125
-
125
+
126
if(usec < (rrd_update_every * 1000000ULL / 2ULL)) susec = (rrd_update_every * 1000000ULL) - usec;
127
else susec = rrd_update_every * 1000000ULL / 2ULL;
128
-
128
+
129
// --------------------------------------------------------------------
130
131
if(!vdo_cpu_netdata) {
@@ -203,7 +203,7 @@ void *proc_main(void *ptr)
203
}
204
205
usleep(susec);
206
-
206
+
207
// copy current to last
208
bcopy(&now, &last, sizeof(struct timeval));
209
}
src/plugin_tc.c
+3
-3
@@ -166,7 +166,7 @@ static void tc_device_commit(struct tc_device *d)
166
static int enable_new_interfaces = -1;
167
168
if(enable_new_interfaces == -1) enable_new_interfaces = config_get_boolean("plugin:tc", "enable new interfaces detected at runtime", 1);
169
-
169
+
170
// we only need to add leaf classes
171
struct tc_class *c, *x;
172
@@ -194,7 +194,7 @@ static void tc_device_commit(struct tc_device *d)
194
}
195
}
196
}
197
-
197
+
198
// debugging:
199
/*
200
for ( c = d->classes ; c ; c = c->next) {
@@ -246,7 +246,7 @@ static void tc_device_commit(struct tc_device *d)
246
247
if(!rd) {
248
debug(D_TC_LOOP, "TC: Adding to chart '%s', dimension '%s'", st->id, c->id, c->name);
249
-
249
+
250
// new class, we have to add it
251
rd = rrddim_add(st, c->id, c->name?c->name:c->id, 8, 1024, RRDDIM_INCREMENTAL);
252
}
src/plugins_d.c
+1
-1
@@ -468,7 +468,7 @@ void *pluginsd_main(void *ptr)
468
if(unlikely(!cd)) fatal("Cannot allocate memory for plugin.");
469
470
snprintf(cd->id, CONFIG_MAX_NAME, "plugin:%s", pluginname);
471
-
471
+
472
strncpy(cd->filename, file->d_name, FILENAME_MAX);
473
snprintf(cd->fullfilename, FILENAME_MAX, "%s/%s", dir_name, cd->filename);
474
src/popen.c
+3
-3
@@ -112,7 +112,7 @@ FILE *mypopen(const char *command, pid_t *pidptr)
112
fprintf(stdout, "MYPID %d\n", getpid());
113
fflush(NULL);
114
#endif
115
-
115
+
116
// reset all signals
117
for (i = 1 ; i < 65 ;i++) if(i != SIGSEGV) signal(i, SIG_DFL);
118
@@ -123,7 +123,7 @@ FILE *mypopen(const char *command, pid_t *pidptr)
123
124
void mypclose(FILE *fp, pid_t pid) {
125
debug(D_EXIT, "Request to mypclose() on pid %d", pid);
126
-
126
+
127
/*mypopen_del(fp);*/
128
fclose(fp);
129
@@ -138,7 +138,7 @@ void mypclose(FILE *fp, pid_t pid) {
138
error("pid %d killed by signal %d.", info.si_pid, info.si_status);
139
break;
140
141
- case CLD_DUMPED:
141
+ case CLD_DUMPED:
142
error("pid %d core dumped by signal %d.", info.si_pid, info.si_status);
143
break;
144
src/proc_diskstats.c
+1
-1
@@ -438,6 +438,6 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
438
}
439
}
440
}
441
-
441
+
442
return 0;
443
}
src/proc_meminfo.c
+7
-7
@@ -108,7 +108,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) {
108
RRDSET *st;
109
110
// --------------------------------------------------------------------
111
-
111
+
112
// http://stackoverflow.com/questions/3019748/how-to-reliably-measure-available-memory-in-linux
113
unsigned long long MemUsed = MemTotal - MemFree - Cached - Buffers;
114
@@ -132,7 +132,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) {
132
}
133
134
// --------------------------------------------------------------------
135
-
135
+
136
unsigned long long SwapUsed = SwapTotal - SwapFree;
137
138
if(do_swap) {
@@ -152,7 +152,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) {
152
}
153
154
// --------------------------------------------------------------------
155
-
155
+
156
if(hwcorrupted && do_hwcorrupt) {
157
st = rrdset_find("mem.hwcorrupt");
158
if(!st) {
@@ -168,7 +168,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) {
168
}
169
170
// --------------------------------------------------------------------
171
-
171
+
172
if(do_committed) {
173
st = rrdset_find("mem.committed");
174
if(!st) {
@@ -184,7 +184,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) {
184
}
185
186
// --------------------------------------------------------------------
187
-
187
+
188
if(do_writeback) {
189
st = rrdset_find("mem.writeback");
190
if(!st) {
@@ -208,7 +208,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) {
208
}
209
210
// --------------------------------------------------------------------
211
-
211
+
212
if(do_kernel) {
213
st = rrdset_find("mem.kernel");
214
if(!st) {
@@ -230,7 +230,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) {
230
}
231
232
// --------------------------------------------------------------------
233
-
233
+
234
if(do_slab) {
235
st = rrdset_find("mem.slab");
236
if(!st) {
src/proc_net_ip_vs_stats.c
+2
-2
@@ -65,7 +65,7 @@ int do_proc_net_ip_vs_stats(int update_every, unsigned long long dt) {
65
}
66
67
// --------------------------------------------------------------------
68
-
68
+
69
if(do_packets) {
70
st = rrdset_find(RRD_TYPE_NET_IPVS ".packets");
71
if(!st) {
@@ -82,7 +82,7 @@ int do_proc_net_ip_vs_stats(int update_every, unsigned long long dt) {
82
}
83
84
// --------------------------------------------------------------------
85
-
85
+
86
if(do_bandwidth) {
87
st = rrdset_find(RRD_TYPE_NET_IPVS ".net");
88
if(!st) {
src/proc_net_netstat.c
+2
-2
@@ -56,7 +56,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
56
InNoRoutes = 0, InTruncatedPkts = 0,
57
InOctets = 0, InMcastPkts = 0, InBcastPkts = 0, InMcastOctets = 0, InBcastOctets = 0,
58
OutOctets = 0, OutMcastPkts = 0, OutBcastPkts = 0, OutMcastOctets = 0, OutBcastOctets = 0;
59
-
59
+
60
InNoRoutes = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
61
InTruncatedPkts = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
62
InMcastPkts = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
@@ -180,6 +180,6 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
180
}
181
}
182
}
183
-
183
+
184
return 0;
185
}
src/proc_net_rpc_nfsd.c
+11
-11
@@ -199,7 +199,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
199
error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 4);
200
continue;
201
}
202
-
202
+
203
rc_hits = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
204
rc_misses = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
205
rc_nocache = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
@@ -213,7 +213,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
213
error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 6);
214
continue;
215
}
216
-
216
+
217
fh_stale = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
218
fh_total_lookups = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
219
fh_anonymous_lookups = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
@@ -229,7 +229,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
229
error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 3);
230
continue;
231
}
232
-
232
+
233
io_read = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
234
io_write = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
235
@@ -242,7 +242,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
242
error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 13);
243
continue;
244
}
245
-
245
+
246
th_threads = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
247
th_fullcnt = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
248
th_hist10 = (unsigned long long)(atof(procfile_lineword(ff, l, 3)) * 1000.0);
@@ -273,7 +273,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
273
error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 13);
274
continue;
275
}
276
-
276
+
277
ra_size = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
278
ra_hist10 = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
279
ra_hist20 = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
@@ -302,7 +302,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
302
error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 5);
303
continue;
304
}
305
-
305
+
306
net_count = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
307
net_udp_count = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
308
net_tcp_count = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
@@ -317,7 +317,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
317
error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 6);
318
continue;
319
}
320
-
320
+
321
rpc_count = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
322
rpc_bad_format = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
323
rpc_bad_auth = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
@@ -628,7 +628,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
628
629
for(i = 0; nfsd_proc_values[i].present2 ; i++)
630
rrddim_set(st, nfsd_proc_values[i].name, nfsd_proc_values[i].proc2);
631
-
631
+
632
rrdset_done(st);
633
}
634
@@ -647,7 +647,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
647
648
for(i = 0; nfsd_proc_values[i].present3 ; i++)
649
rrddim_set(st, nfsd_proc_values[i].name, nfsd_proc_values[i].proc3);
650
-
650
+
651
rrdset_done(st);
652
}
653
@@ -666,7 +666,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
666
667
for(i = 0; nfsd_proc_values[i].present4 ; i++)
668
rrddim_set(st, nfsd_proc_values[i].name, nfsd_proc_values[i].proc4);
669
-
669
+
670
rrdset_done(st);
671
}
672
@@ -685,7 +685,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
685
686
for(i = 0; nfsd4_ops_values[i].present ; i++)
687
rrddim_set(st, nfsd4_ops_values[i].name, nfsd4_ops_values[i].value);
688
-
688
+
689
rrdset_done(st);
690
}
691
src/proc_net_snmp.c
+9
-9
@@ -18,7 +18,7 @@
18
int do_proc_net_snmp(int update_every, unsigned long long dt) {
19
static procfile *ff = NULL;
20
static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1,
21
- do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1,
21
+ do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1,
22
do_udp_packets = -1, do_udp_errors = -1;
23
24
if(do_ip_packets == -1) do_ip_packets = config_get_boolean("plugin:proc:/proc/net/snmp", "ipv4 packets", 1);
@@ -87,7 +87,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
87
FragOKs = strtoull(procfile_lineword(ff, l, 17), NULL, 10);
88
FragFails = strtoull(procfile_lineword(ff, l, 18), NULL, 10);
89
FragCreates = strtoull(procfile_lineword(ff, l, 19), NULL, 10);
90
-
90
+
91
// these are not counters
92
if(Forwarding) {}; // is forwarding enabled?
93
if(DefaultTTL) {}; // the default ttl on packets
@@ -222,7 +222,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
222
if(MaxConn) {};
223
224
// --------------------------------------------------------------------
225
-
225
+
226
// see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
227
if(do_tcp_sockets) {
228
st = rrdset_find(RRD_TYPE_NET_SNMP ".tcpsock");
@@ -238,7 +238,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
238
}
239
240
// --------------------------------------------------------------------
241
-
241
+
242
if(do_tcp_packets) {
243
st = rrdset_find(RRD_TYPE_NET_SNMP ".tcppackets");
244
if(!st) {
@@ -255,7 +255,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
255
}
256
257
// --------------------------------------------------------------------
258
-
258
+
259
if(do_tcp_errors) {
260
st = rrdset_find(RRD_TYPE_NET_SNMP ".tcperrors");
261
if(!st) {
@@ -273,7 +273,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
273
}
274
275
// --------------------------------------------------------------------
276
-
276
+
277
if(do_tcp_handshake) {
278
st = rrdset_find(RRD_TYPE_NET_SNMP ".tcphandshake");
279
if(!st) {
@@ -320,7 +320,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
320
SndbufErrors = strtoull(procfile_lineword(ff, l, 6), NULL, 10);
321
322
// --------------------------------------------------------------------
323
-
323
+
324
// see http://net-snmp.sourceforge.net/docs/mibs/udp.html
325
if(do_udp_packets) {
326
st = rrdset_find(RRD_TYPE_NET_SNMP ".udppackets");
@@ -338,7 +338,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
338
}
339
340
// --------------------------------------------------------------------
341
-
341
+
342
if(do_udp_errors) {
343
st = rrdset_find(RRD_TYPE_NET_SNMP ".udperrors");
344
if(!st) {
@@ -360,7 +360,7 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
360
}
361
}
362
}
363
-
363
+
364
return 0;
365
}
366
src/proc_net_stat_conntrack.c
+1
-1
@@ -95,7 +95,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
95
RRDSET *st;
96
97
// --------------------------------------------------------------------
98
-
98
+
99
if(do_sockets) {
100
st = rrdset_find(RRD_TYPE_NET_STAT_CONNTRACK ".sockets");
101
if(!st) {
src/proc_stat.c
+2
-2
@@ -118,7 +118,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
118
unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
119
120
// --------------------------------------------------------------------
121
-
121
+
122
if(do_interrupts) {
123
st = rrdset_find_bytype("system", "intr");
124
if(!st) {
@@ -137,7 +137,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
137
unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
138
139
// --------------------------------------------------------------------
140
-
140
+
141
if(do_context) {
142
st = rrdset_find_bytype("system", "ctxt");
143
if(!st) {
src/proc_vmstat.c
+4
-4
@@ -45,7 +45,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
45
nr_shmem = 0, nr_dirtied = 0, nr_written = 0, nr_anon_transparent_hugepages = 0, nr_dirty_threshold = 0, nr_dirty_background_threshold = 0,
46
pgpgin = 0, pgpgout = 0, pswpin = 0, pswpout = 0, pgalloc_dma = 0, pgalloc_dma32 = 0, pgalloc_normal = 0, pgalloc_movable = 0, pgfree = 0, pgactivate = 0, pgdeactivate = 0,
47
pgfault = 0, pgmajfault = 0, pgrefill_dma = 0, pgrefill_dma32 = 0, pgrefill_normal = 0, pgrefill_movable = 0, pgsteal_kswapd_dma = 0, pgsteal_kswapd_dma32 = 0,
48
- pgsteal_kswapd_normal = 0, pgsteal_kswapd_movable = 0, pgsteal_direct_dma = 0, pgsteal_direct_dma32 = 0, pgsteal_direct_normal = 0, pgsteal_direct_movable = 0,
48
+ pgsteal_kswapd_normal = 0, pgsteal_kswapd_movable = 0, pgsteal_direct_dma = 0, pgsteal_direct_dma32 = 0, pgsteal_direct_normal = 0, pgsteal_direct_movable = 0,
49
pgscan_kswapd_dma = 0, pgscan_kswapd_dma32 = 0, pgscan_kswapd_normal = 0, pgscan_kswapd_movable = 0, pgscan_direct_dma = 0, pgscan_direct_dma32 = 0, pgscan_direct_normal = 0,
50
pgscan_direct_movable = 0, pginodesteal = 0, slabs_scanned = 0, kswapd_inodesteal = 0, kswapd_low_wmark_hit_quickly = 0, kswapd_high_wmark_hit_quickly = 0,
51
kswapd_skip_congestion_wait = 0, pageoutrun = 0, allocstall = 0, pgrotated = 0, compact_blocks_moved = 0, compact_pages_moved = 0, compact_pagemigrate_failed = 0,
@@ -160,7 +160,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
160
RRDSET *st;
161
162
// --------------------------------------------------------------------
163
-
163
+
164
if(do_swapio) {
165
st = rrdset_find("system.swapio");
166
if(!st) {
@@ -177,7 +177,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
177
}
178
179
// --------------------------------------------------------------------
180
-
180
+
181
if(do_io) {
182
st = rrdset_find("system.io");
183
if(!st) {
@@ -194,7 +194,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
194
}
195
196
// --------------------------------------------------------------------
197
-
197
+
198
if(do_pgfaults) {
199
st = rrdset_find("system.pgfaults");
200
if(!st) {
src/procfile.c
+1
-1
@@ -159,7 +159,7 @@ procfile *procfile_parser(procfile *ff) {
159
char *s = ff->data, *e = ff->data, *t = ff->data;
160
uint32_t l = 0, w = 0;
161
e += ff->len;
162
-
162
+
163
ff->lines = pflines_add(ff->lines, w);
164
if(unlikely(!ff->lines)) goto cleanup;
165
src/procfile.h
+1
-1
@@ -1,6 +1,6 @@
1
/*
2
* procfile is a library for reading kernel files from /proc
3
- *
3
+ *
4
* The idea is this:
5
*
6
* - every file is opened once with procfile_open().
src/rrd.c
+3
-3
@@ -421,7 +421,7 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
421
422
st->priority = config_get_number(st->id, "priority", priority);
423
st->enabled = enabled;
424
-
424
+
425
st->isdetail = 0;
426
st->debug = 0;
427
@@ -557,7 +557,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
557
558
rd->entries = st->entries;
559
rd->update_every = st->update_every;
560
-
560
+
561
// prevent incremental calculation spikes
562
rd->counter = 0;
563
@@ -758,7 +758,7 @@ int rrddim_unhide(RRDSET *st, const char *id)
758
collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number value)
759
{
760
debug(D_RRD_CALLS, "rrddim_set_by_pointer() for chart %s, dimension %s, value " COLLECTED_NUMBER_FORMAT, st->name, rd->name, value);
761
-
761
+
762
gettimeofday(&rd->last_collected_time, NULL);
763
rd->collected_value = value;
764
rd->updated = 1;
src/rrd.h
+1
-1
@@ -99,7 +99,7 @@ struct rrddim {
99
// this is a pointer to the config structure
100
// since the config always has a higher priority
101
// (the user overwrites the name of the charts)
102
-
102
+
103
int algorithm; // the algorithm that is applied to add new collected values
104
long multiplier; // the multiplier of the collected values
105
long divisor; // the divider of the collected values
src/rrd2json.c
+1
-1
@@ -241,7 +241,7 @@ void rrd_stats_all_json(BUFFER *wb)
241
}
242
}
243
pthread_rwlock_unlock(&rrdset_root_rwlock);
244
-
244
+
245
buffer_sprintf(wb, "\n\t],\n"
246
"\t\"hostname\": \"%s\",\n"
247
"\t\"update_every\": %d,\n"
src/storage_number.c
+1
-1
@@ -127,7 +127,7 @@ calculated_number unpack_storage_number(storage_number value)
127
128
static char *print_calculated_number_lu_r(char *str, unsigned long uvalue) {
129
char *wstr = str;
130
-
130
+
131
// print each digit
132
do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
133
return wstr;
src/unit_test.c
+4
-4
@@ -76,7 +76,7 @@ void benchmark_storage_number(int loop, int multiplier) {
76
77
mine = (calculated_number)sizeof(storage_number) * (calculated_number)loop;
78
their = (calculated_number)sizeof(calculated_number) * (calculated_number)loop;
79
-
79
+
80
if(mine > their) {
81
fprintf(stderr, "\nNETDATA NEEDS %0.2Lf TIMES MORE MEMORY. Sorry!\n", (long double)(mine / their));
82
}
@@ -115,7 +115,7 @@ void benchmark_storage_number(int loop, int multiplier) {
115
mine = total;
116
117
fprintf(stderr, "user %0.5Lf, system %0.5Lf, total %0.5Lf\n", (long double)(user / 1000000.0), (long double)(system / 1000000.0), (long double)(total / 1000000.0));
118
-
118
+
119
// ------------------------------------------------------------------------
120
121
fprintf(stderr, "SYSTEM LONG DOUBLE PRINTING: ");
@@ -313,8 +313,8 @@ int unit_test(long delay, long shift)
313
for(rd = st->dimensions ; rd ; rd = rd->next) {
314
fprintf(stderr, "\t %s " STORAGE_NUMBER_FORMAT " -> ", rd->id, rd->values[c]);
315
316
- if(rd == rdabs) v =
317
- ( oincrement
316
+ if(rd == rdabs) v =
317
+ ( oincrement
318
+ (increment * (1000000 - shift) / 1000000)
319
+ c * increment
320
) * 10;
src/url.c
+3
-3
@@ -70,12 +70,12 @@ char *url_decode(char *str) {
70
71
else
72
*pbuf++ = *pstr;
73
-
73
+
74
pstr++;
75
}
76
-
76
+
77
*pbuf = '\0';
78
-
78
+
79
return buf;
80
}
81
src/web_buffer.c
+1
-1
@@ -324,7 +324,7 @@ void buffer_increase(BUFFER *b, long free_size_required)
324
325
b->buffer = realloc(b->buffer, b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
326
if(!b->buffer) fatal("Failed to increase data buffer from size %d to %d.", b->size + sizeof(BUFFER_OVERFLOW_EOF) + 2, b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
327
-
327
+
328
b->size += increase;
329
330
buffer_overflow_init(b);
src/web_client.c
+1
-1
@@ -40,7 +40,7 @@ unsigned long long web_clients_count = 0;
40
struct web_client *web_client_create(int listener)
41
{
42
struct web_client *w;
43
-
43
+
44
w = calloc(1, sizeof(struct web_client));
45
if(!w) {
46
error("Cannot allocate new web_client memory.");
web/dashboard.html
+3
-3
@@ -1,5 +1,5 @@
1
<html>
2
-<head>
2
+<head>
3
<title>NetData Dashboard</title>
4
<style type="text/css">
5
html{font-family:sans-serif;}
@@ -95,7 +95,7 @@ This is a template for building custom dashboards. To build a dashboard you just
95
Sparkline charts stretch the values to show the variations between values in more detail.
96
They also have mouse-hover support.
97
<br/>
98
- Sparklines are fantastic. You can inline charts in text. For example this
98
+ Sparklines are fantastic. You can inline charts in text. For example this
99
<div style="display: inline; position: relative;"
100
data-netdata="system.cpu"
101
data-chart-library="sparkline"
@@ -112,7 +112,7 @@ This is a template for building custom dashboards. To build a dashboard you just
112
data-width="60"
113
data-height="15"
114
data-after="-30"
115
- </div> is the bandwidth my netdata server is currently transmitting and this
115
+ </div> is the bandwidth my netdata server is currently transmitting and this
116
117
<div style="display: inline; position: relative;"
118
data-netdata="netdata.requests"
web/dashboard.js
+15
-15
@@ -140,14 +140,14 @@
140
if(typeof jQuery == 'undefined') {
141
var script = document.createElement('script');
142
script.type = 'text/javascript';
143
- script.async = true;
143
+ script.async = true;
144
script.src = NETDATA.jQuery;
145
-
145
+
146
// script.onabort = onError;
147
script.onerror = function(err, t) { NETDATA.error(101, NETDATA.jQuery); };
148
if(typeof callback == "function")
149
script.onload = callback;
150
-
150
+
151
var s = document.getElementsByTagName('script')[0];
152
s.parentNode.insertBefore(script, s);
153
}
@@ -209,7 +209,7 @@
209
NETDATA.loadCharts(targets, ++index, callback);
210
}
211
else {
212
- var url = host + "/api/v1/chart?chart=" + id;
212
+ var url = host + "/api/v1/chart?chart=" + id;
213
214
$.ajax( {
215
url: url,
@@ -266,7 +266,7 @@
266
var self = $(this);
267
var lib = self.data('chart-library') || 'dygraph';
268
var method = lib + 'ChartCreate';
269
-
269
+
270
console.log('Calling ' + method + '()');
271
NETDATA[method].apply(this, arguments);
272
})
@@ -274,7 +274,7 @@
274
var self = $(this);
275
var lib = self.data('chart-library') || 'dygraph';
276
var method = lib + 'ChartUpdate';
277
-
277
+
278
console.log('Calling ' + method + '()');
279
NETDATA[method].apply(this, arguments);
280
});
@@ -342,7 +342,7 @@
342
// get from the 3rd column the 'v' member
343
//return item.c[3].v;
344
//});
345
-
345
+
346
// since we downloaded the data
347
// update the last-updated time to prevent
348
// another download too soon
@@ -532,7 +532,7 @@
532
var numberDecimalMark = self.data('sparkline-numberDecimalMark') || undefined;
533
var numberDigitGroupCount = self.data('sparkline-numberDigitGroupCount') || undefined;
534
var animatedZooms = self.data('sparkline-animatedZooms') || false;
535
-
535
+
536
var options = {
537
type: type,
538
lineColor: lineColor,
@@ -650,7 +650,7 @@
650
else
651
console.log('not updating dygraphs');
652
};
653
-
653
+
654
NETDATA.dygraphChartCreate = function(event, data) {
655
var self = $(this);
656
var width = self.data('width') || NETDATA.chartDefaults.width;
@@ -701,7 +701,7 @@
701
var drawYGrid = self.data('dygraph-drawYGrid') || undefined;
702
var gridLinePattern = self.data('dygraph-gridLinePattern') || null;
703
var gridLineWidth = self.data('dygraph-gridLineWidth') || 0.3;
704
-
704
+
705
var options = {
706
title: title,
707
titleHeight: titleHeight,
@@ -839,7 +839,7 @@
839
var width = self.data('width') || NETDATA.chartDefaults.width;
840
var height = self.data('height') || NETDATA.chartDefaults.height;
841
var chart = self.data('chart');
842
-
842
+
843
self.html('<div id="morris-' + chart.id + '" style="width: ' + width + 'px; height: ' + height + 'px;"></div>');
844
845
// remove the 'time' element from the labels
@@ -902,7 +902,7 @@
902
var self = $(this);
903
var width = self.data('width') || NETDATA.chartDefaults.width;
904
var height = self.data('height') || NETDATA.chartDefaults.height;
905
-
905
+
906
self.raphael(data, {
907
width: width,
908
height: height
@@ -913,7 +913,7 @@
913
var self = $(this);
914
var width = self.data('width') || NETDATA.chartDefaults.width;
915
var height = self.data('height') || NETDATA.chartDefaults.height;
916
-
916
+
917
self.raphael(data, {
918
width: width,
919
height: height
@@ -954,7 +954,7 @@
954
var width = self.data('width') || NETDATA.chartDefaults.width;
955
var height = self.data('height') || NETDATA.chartDefaults.height;
956
var chart = self.data('chart');
957
-
957
+
958
var datatable = new google.visualization.DataTable(data);
959
var gchart;
960
@@ -1051,7 +1051,7 @@
1051
1052
NETDATA.errorReset();
1053
1054
- NETDATA._loadjQuery(function() {
1054
+ NETDATA._loadjQuery(function() {
1055
NETDATA.raphaelInitialize(function() {
1056
NETDATA.morrisInitialize(function() {
1057
NETDATA.peityInitialize(function() {
web/index.html
+1
-1
@@ -9,7 +9,7 @@
9
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
10
<meta name="description" content="">
11
<meta name="author" content="costa@tsaousis.gr">
12
-
12
+
13
<title>NetData</title>
14
15
<!-- Bootstrap CSS -->
web/index.js
+6
-6
@@ -168,7 +168,7 @@ function chartssort(a, b) {
168
if(a.name < b.name) return -1;
169
}
170
else if(a.priority < b.priority) return -1;
171
-
171
+
172
return 1;
173
}
174
@@ -349,7 +349,7 @@ function mainchartControlStateHandler() {
349
}
350
351
function initMainChartIndex(i) {
352
- if(mode == MODE_GROUP_THUMBS)
352
+ if(mode == MODE_GROUP_THUMBS)
353
initMainChart(groupCharts[i]);
354
355
else if(mode == MODE_THUMBS)
@@ -452,7 +452,7 @@ function setMainChartPlay(p) {
452
// 'maxZoomOut': 1,
453
//};
454
//mainchart.last_updated = 0;
455
-
455
+
456
//if(!renderChart(mainchart, pauseGraphs))
457
pauseGraphs();
458
}
@@ -620,7 +620,7 @@ function checkRefreshThread() {
620
var timeout = null;
621
function renderChartCallback() {
622
last_refresh = new Date().getTime();
623
-
623
+
624
if(!page_is_visible) {
625
timeout = setTimeout(triggerRefresh, CHARTS_CHECK_NO_FOCUS);
626
return;
@@ -954,7 +954,7 @@ function switchToGroupGraphs() {
954
var groupCharts = null;
955
function initGroupGraphs(group) {
956
var count = 0;
957
-
957
+
958
if(groupCharts) clearGroupGraphs();
959
groupCharts = new Array();
960
@@ -1112,7 +1112,7 @@ function initCharts() {
1112
return 1;
1113
}
1114
categories.sort(categoriessort);
1115
-
1115
+
1116
function familiessort(a, b) {
1117
if(a.name < b.name) return -1;
1118
return 1;
web/netdata.js
+10
-10
@@ -54,7 +54,7 @@ function renderChart(chart, doNext) {
54
.done(function(jsondata) {
55
if(!jsondata || jsondata.length == 0) return;
56
chart.jsondata = jsondata;
57
-
57
+
58
// Create our data table out of JSON data loaded from server.
59
chart.datatable = new google.visualization.DataTable(chart.jsondata);
60
//console.log(chart.datatable);
@@ -75,7 +75,7 @@ function renderChart(chart, doNext) {
75
else
76
chart.chart = new google.visualization.AreaChart(document.getElementById(chart.div));
77
}
78
-
78
+
79
if(chart.chart) {
80
chart.chart.draw(chart.datatable, chart.chartOptions);
81
chart.refreshCount++;
@@ -178,7 +178,7 @@ function calculateChartPointsToShow(c, divisor, maxtime, group, enable_curve) {
178
c.points_to_show = Math.round(data_points / group);
179
// console.log("rendering with supplied group (group = " + c.group + ", points_to_show = " + c.points_to_show + ')');
180
}
181
-
181
+
182
// console.log("final configuration (group = " + c.group + ", points_to_show = " + c.points_to_show + ')');
183
184
// make sure the line width is not congesting the chart
@@ -200,7 +200,7 @@ function calculateChartPointsToShow(c, divisor, maxtime, group, enable_curve) {
200
201
// do not render curves when we don't have at
202
// least 2 twice the space per point
203
- if(!enable_curve || c.points_to_show > (c.chartOptions.width * c.chartOptions.lineWidth / 2) )
203
+ if(!enable_curve || c.points_to_show > (c.chartOptions.width * c.chartOptions.lineWidth / 2) )
204
c.chartOptions.curveType = 'none';
205
else
206
c.chartOptions.curveType = c.default_curveType;
@@ -313,10 +313,10 @@ function loadCharts(base_url, doNext) {
313
json.charts[i].chartType = "AreaChart";
314
json.charts[i].chartOptions.isStacked = false;
315
json.charts[i].chartOptions.areaOpacity = 0.3;
316
-
316
+
317
json.charts[i].chartOptions.vAxis.viewWindowMode = 'maximized';
318
json.charts[i].non_zero = 0;
319
-
319
+
320
json.charts[i].group = 3;
321
break;
322
@@ -342,7 +342,7 @@ function loadCharts(base_url, doNext) {
342
json.charts[i].non_zero = 0;
343
344
json.charts[i].default_curveType = 'function';
345
-
345
+
346
json.charts[i].group = 3;
347
break;
348
}
@@ -465,7 +465,7 @@ function loadCharts(base_url, doNext) {
465
break;
466
}
467
});
468
-
468
+
469
if(typeof doNext == "function") doNext(json);
470
})
471
.fail(function() {
@@ -487,7 +487,7 @@ function loadCharts(base_url, doNext) {
487
* only accounts for vertical position, not horizontal.
488
*/
489
$.fn.visible = function(partial){
490
-
490
+
491
var $t = $(this),
492
$w = $(window),
493
viewTop = $w.scrollTop(),
@@ -496,7 +496,7 @@ function loadCharts(base_url, doNext) {
496
_bottom = _top + $t.height(),
497
compareTop = partial === true ? _bottom : _top,
498
compareBottom = partial === true ? _top : _bottom;
499
-
499
+
500
return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
501
};
502
})(jQuery);