struct target *users_root_target = NULL;
struct target *groups_root_target = NULL;
-struct target *get_users_target(uid_t uid)
+static struct target *get_users_target(uid_t uid)
{
struct target *w;
for(w = users_root_target ; w ; w = w->next)
// find or create a new target
// there are targets that are just aggregated to other target (the second argument)
-struct target *get_apps_groups_target(const char *id, struct target *target, const char *name) {
+static struct target *get_apps_groups_target(const char *id, struct target *target, const char *name) {
int tdebug = 0, thidden = target?target->hidden:0, ends_with = 0;
const char *nid = id;
}
// read the apps_groups.conf file
-int read_apps_groups_conf(const char *file)
+static int read_apps_groups_conf(const char *file)
{
char filename[FILENAME_MAX + 1];
long all_pids_count = 0;
-struct pid_stat *get_pid_entry(pid_t pid) {
+static inline struct pid_stat *get_pid_entry(pid_t pid) {
if(all_pids[pid]) {
all_pids[pid]->new_entry = 0;
return all_pids[pid];
return all_pids[pid];
}
-void del_pid_entry(pid_t pid) {
+static inline void del_pid_entry(pid_t pid) {
if(!all_pids[pid]) {
error("attempted to free pid %d that is not allocated.", pid);
return;
// ----------------------------------------------------------------------------
// update pids from proc
-int read_proc_pid_cmdline(struct pid_stat *p) {
+static inline int read_proc_pid_cmdline(struct pid_stat *p) {
if(unlikely(!p->cmdline_filename)) {
char filename[FILENAME_MAX + 1];
return 0;
}
-int read_proc_pid_ownership(struct pid_stat *p) {
+static inline int read_proc_pid_ownership(struct pid_stat *p) {
if(unlikely(!p->stat_filename)) {
error("pid %d does not have a stat_filename", p->pid);
return 0;
return 1;
}
-int read_proc_pid_stat(struct pid_stat *p) {
+static inline int read_proc_pid_stat(struct pid_stat *p) {
static procfile *ff = NULL;
if(unlikely(!p->stat_filename)) {
p->stat_collected_usec = now_realtime_usec();
file_counter++;
- // p->pid = atol(procfile_lineword(ff, 0, 0+i));
+ // p->pid = str2ul(procfile_lineword(ff, 0, 0+i));
strncpyz(p->comm, procfile_lineword(ff, 0, 1), MAX_COMPARE_NAME);
// p->state = *(procfile_lineword(ff, 0, 2));
- p->ppid = (int32_t) atol(procfile_lineword(ff, 0, 3));
- // p->pgrp = atol(procfile_lineword(ff, 0, 4));
- // p->session = atol(procfile_lineword(ff, 0, 5));
- // p->tty_nr = atol(procfile_lineword(ff, 0, 6));
- // p->tpgid = atol(procfile_lineword(ff, 0, 7));
- // p->flags = strtoull(procfile_lineword(ff, 0, 8), NULL, 10);
+ p->ppid = (int32_t)str2ul(procfile_lineword(ff, 0, 3));
+ // p->pgrp = str2ul(procfile_lineword(ff, 0, 4));
+ // p->session = str2ul(procfile_lineword(ff, 0, 5));
+ // p->tty_nr = str2ul(procfile_lineword(ff, 0, 6));
+ // p->tpgid = str2ul(procfile_lineword(ff, 0, 7));
+ // p->flags = str2ull(procfile_lineword(ff, 0, 8));
unsigned long long last;
last = p->minflt_raw;
- p->minflt_raw = strtoull(procfile_lineword(ff, 0, 9), NULL, 10);
+ p->minflt_raw = str2ull(procfile_lineword(ff, 0, 9));
p->minflt = (p->minflt_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->cminflt_raw;
- p->cminflt_raw = strtoull(procfile_lineword(ff, 0, 10), NULL, 10);
+ p->cminflt_raw = str2ull(procfile_lineword(ff, 0, 10));
p->cminflt = (p->cminflt_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->majflt_raw;
- p->majflt_raw = strtoull(procfile_lineword(ff, 0, 11), NULL, 10);
+ p->majflt_raw = str2ull(procfile_lineword(ff, 0, 11));
p->majflt = (p->majflt_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->cmajflt_raw;
- p->cmajflt_raw = strtoull(procfile_lineword(ff, 0, 12), NULL, 10);
+ p->cmajflt_raw = str2ull(procfile_lineword(ff, 0, 12));
p->cmajflt = (p->cmajflt_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->utime_raw;
- p->utime_raw = strtoull(procfile_lineword(ff, 0, 13), NULL, 10);
+ p->utime_raw = str2ull(procfile_lineword(ff, 0, 13));
p->utime = (p->utime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->stime_raw;
- p->stime_raw = strtoull(procfile_lineword(ff, 0, 14), NULL, 10);
+ p->stime_raw = str2ull(procfile_lineword(ff, 0, 14));
p->stime = (p->stime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->cutime_raw;
- p->cutime_raw = strtoull(procfile_lineword(ff, 0, 15), NULL, 10);
+ p->cutime_raw = str2ull(procfile_lineword(ff, 0, 15));
p->cutime = (p->cutime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->cstime_raw;
- p->cstime_raw = strtoull(procfile_lineword(ff, 0, 16), NULL, 10);
+ p->cstime_raw = str2ull(procfile_lineword(ff, 0, 16));
p->cstime = (p->cstime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
- // p->priority = strtoull(procfile_lineword(ff, 0, 17), NULL, 10);
- // p->nice = strtoull(procfile_lineword(ff, 0, 18), NULL, 10);
- p->num_threads = (int32_t) atol(procfile_lineword(ff, 0, 19));
- // p->itrealvalue = strtoull(procfile_lineword(ff, 0, 20), NULL, 10);
- // p->starttime = strtoull(procfile_lineword(ff, 0, 21), NULL, 10);
- // p->vsize = strtoull(procfile_lineword(ff, 0, 22), NULL, 10);
- // p->rss = strtoull(procfile_lineword(ff, 0, 23), NULL, 10);
- // p->rsslim = strtoull(procfile_lineword(ff, 0, 24), NULL, 10);
- // p->starcode = strtoull(procfile_lineword(ff, 0, 25), NULL, 10);
- // p->endcode = strtoull(procfile_lineword(ff, 0, 26), NULL, 10);
- // p->startstack = strtoull(procfile_lineword(ff, 0, 27), NULL, 10);
- // p->kstkesp = strtoull(procfile_lineword(ff, 0, 28), NULL, 10);
- // p->kstkeip = strtoull(procfile_lineword(ff, 0, 29), NULL, 10);
- // p->signal = strtoull(procfile_lineword(ff, 0, 30), NULL, 10);
- // p->blocked = strtoull(procfile_lineword(ff, 0, 31), NULL, 10);
- // p->sigignore = strtoull(procfile_lineword(ff, 0, 32), NULL, 10);
- // p->sigcatch = strtoull(procfile_lineword(ff, 0, 33), NULL, 10);
- // p->wchan = strtoull(procfile_lineword(ff, 0, 34), NULL, 10);
- // p->nswap = strtoull(procfile_lineword(ff, 0, 35), NULL, 10);
- // p->cnswap = strtoull(procfile_lineword(ff, 0, 36), NULL, 10);
- // p->exit_signal = atol(procfile_lineword(ff, 0, 37));
- // p->processor = atol(procfile_lineword(ff, 0, 38));
- // p->rt_priority = strtoul(procfile_lineword(ff, 0, 39), NULL, 10);
- // p->policy = strtoul(procfile_lineword(ff, 0, 40), NULL, 10);
- // p->delayacct_blkio_ticks = strtoull(procfile_lineword(ff, 0, 41), NULL, 10);
+ // p->priority = str2ull(procfile_lineword(ff, 0, 17));
+ // p->nice = str2ull(procfile_lineword(ff, 0, 18));
+ p->num_threads = (int32_t)str2ul(procfile_lineword(ff, 0, 19));
+ // p->itrealvalue = str2ull(procfile_lineword(ff, 0, 20));
+ // p->starttime = str2ull(procfile_lineword(ff, 0, 21));
+ // p->vsize = str2ull(procfile_lineword(ff, 0, 22));
+ // p->rss = str2ull(procfile_lineword(ff, 0, 23));
+ // p->rsslim = str2ull(procfile_lineword(ff, 0, 24));
+ // p->starcode = str2ull(procfile_lineword(ff, 0, 25));
+ // p->endcode = str2ull(procfile_lineword(ff, 0, 26));
+ // p->startstack = str2ull(procfile_lineword(ff, 0, 27));
+ // p->kstkesp = str2ull(procfile_lineword(ff, 0, 28));
+ // p->kstkeip = str2ull(procfile_lineword(ff, 0, 29));
+ // p->signal = str2ull(procfile_lineword(ff, 0, 30));
+ // p->blocked = str2ull(procfile_lineword(ff, 0, 31));
+ // p->sigignore = str2ull(procfile_lineword(ff, 0, 32));
+ // p->sigcatch = str2ull(procfile_lineword(ff, 0, 33));
+ // p->wchan = str2ull(procfile_lineword(ff, 0, 34));
+ // p->nswap = str2ull(procfile_lineword(ff, 0, 35));
+ // p->cnswap = str2ull(procfile_lineword(ff, 0, 36));
+ // p->exit_signal = str2ul(procfile_lineword(ff, 0, 37));
+ // p->processor = str2ul(procfile_lineword(ff, 0, 38));
+ // p->rt_priority = str2ul(procfile_lineword(ff, 0, 39));
+ // p->policy = str2ul(procfile_lineword(ff, 0, 40));
+ // p->delayacct_blkio_ticks = str2ull(procfile_lineword(ff, 0, 41));
if(enable_guest_charts) {
last = p->gtime_raw;
- p->gtime_raw = strtoull(procfile_lineword(ff, 0, 42), NULL, 10);
+ p->gtime_raw = str2ull(procfile_lineword(ff, 0, 42));
p->gtime = (p->gtime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
last = p->cgtime_raw;
- p->cgtime_raw = strtoull(procfile_lineword(ff, 0, 43), NULL, 10);
+ p->cgtime_raw = str2ull(procfile_lineword(ff, 0, 43));
p->cgtime = (p->cgtime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
if (show_guest_time || p->gtime || p->cgtime) {
return 0;
}
-int read_proc_pid_statm(struct pid_stat *p) {
+static inline int read_proc_pid_statm(struct pid_stat *p) {
static procfile *ff = NULL;
if(unlikely(!p->statm_filename)) {
file_counter++;
- p->statm_size = strtoull(procfile_lineword(ff, 0, 0), NULL, 10);
- p->statm_resident = strtoull(procfile_lineword(ff, 0, 1), NULL, 10);
- p->statm_share = strtoull(procfile_lineword(ff, 0, 2), NULL, 10);
- // p->statm_text = strtoull(procfile_lineword(ff, 0, 3), NULL, 10);
- // p->statm_lib = strtoull(procfile_lineword(ff, 0, 4), NULL, 10);
- // p->statm_data = strtoull(procfile_lineword(ff, 0, 5), NULL, 10);
- // p->statm_dirty = strtoull(procfile_lineword(ff, 0, 6), NULL, 10);
+ p->statm_size = str2ull(procfile_lineword(ff, 0, 0));
+ p->statm_resident = str2ull(procfile_lineword(ff, 0, 1));
+ p->statm_share = str2ull(procfile_lineword(ff, 0, 2));
+ // p->statm_text = str2ull(procfile_lineword(ff, 0, 3));
+ // p->statm_lib = str2ull(procfile_lineword(ff, 0, 4));
+ // p->statm_data = str2ull(procfile_lineword(ff, 0, 5));
+ // p->statm_dirty = str2ull(procfile_lineword(ff, 0, 6));
return 1;
return 0;
}
-int read_proc_pid_io(struct pid_stat *p) {
+static inline int read_proc_pid_io(struct pid_stat *p) {
static procfile *ff = NULL;
if(unlikely(!p->io_filename)) {
unsigned long long last;
last = p->io_logical_bytes_read_raw;
- p->io_logical_bytes_read_raw = strtoull(procfile_lineword(ff, 0, 1), NULL, 10);
+ p->io_logical_bytes_read_raw = str2ull(procfile_lineword(ff, 0, 1));
p->io_logical_bytes_read = (p->io_logical_bytes_read_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->io_collected_usec - p->last_io_collected_usec);
last = p->io_logical_bytes_written_raw;
- p->io_logical_bytes_written_raw = strtoull(procfile_lineword(ff, 1, 1), NULL, 10);
+ p->io_logical_bytes_written_raw = str2ull(procfile_lineword(ff, 1, 1));
p->io_logical_bytes_written = (p->io_logical_bytes_written_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->io_collected_usec - p->last_io_collected_usec);
// last = p->io_read_calls_raw;
- // p->io_read_calls_raw = strtoull(procfile_lineword(ff, 2, 1), NULL, 10);
+ // p->io_read_calls_raw = str2ull(procfile_lineword(ff, 2, 1));
// p->io_read_calls = (p->io_read_calls_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->io_collected_usec - p->last_io_collected_usec);
// last = p->io_write_calls_raw;
- // p->io_write_calls_raw = strtoull(procfile_lineword(ff, 3, 1), NULL, 10);
+ // p->io_write_calls_raw = str2ull(procfile_lineword(ff, 3, 1));
// p->io_write_calls = (p->io_write_calls_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->io_collected_usec - p->last_io_collected_usec);
last = p->io_storage_bytes_read_raw;
- p->io_storage_bytes_read_raw = strtoull(procfile_lineword(ff, 4, 1), NULL, 10);
+ p->io_storage_bytes_read_raw = str2ull(procfile_lineword(ff, 4, 1));
p->io_storage_bytes_read = (p->io_storage_bytes_read_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->io_collected_usec - p->last_io_collected_usec);
last = p->io_storage_bytes_written_raw;
- p->io_storage_bytes_written_raw = strtoull(procfile_lineword(ff, 5, 1), NULL, 10);
+ p->io_storage_bytes_written_raw = str2ull(procfile_lineword(ff, 5, 1));
p->io_storage_bytes_written = (p->io_storage_bytes_written_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->io_collected_usec - p->last_io_collected_usec);
// last = p->io_cancelled_write_bytes_raw;
- // p->io_cancelled_write_bytes_raw = strtoull(procfile_lineword(ff, 6, 1), NULL, 10);
+ // p->io_cancelled_write_bytes_raw = str2ull(procfile_lineword(ff, 6, 1));
// p->io_cancelled_write_bytes = (p->io_cancelled_write_bytes_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (p->io_collected_usec - p->last_io_collected_usec);
if(unlikely(global_iterations_counter == 1)) {
unsigned long long global_stime = 0;
unsigned long long global_gtime = 0;
-int read_proc_stat() {
+static inline int read_proc_stat() {
static char filename[FILENAME_MAX + 1] = "";
static procfile *ff = NULL;
static unsigned long long utime_raw = 0, stime_raw = 0, gtime_raw = 0, gntime_raw = 0, ntime_raw = 0;
unsigned long long last;
last = utime_raw;
- utime_raw = strtoull(procfile_lineword(ff, 0, 1), NULL, 10);
+ utime_raw = str2ull(procfile_lineword(ff, 0, 1));
global_utime = (utime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (collected_usec - last_collected_usec);
// nice time, on user time
last = ntime_raw;
- ntime_raw = strtoull(procfile_lineword(ff, 0, 2), NULL, 10);
+ ntime_raw = str2ull(procfile_lineword(ff, 0, 2));
global_utime += (ntime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (collected_usec - last_collected_usec);
last = stime_raw;
- stime_raw = strtoull(procfile_lineword(ff, 0, 3), NULL, 10);
+ stime_raw = str2ull(procfile_lineword(ff, 0, 3));
global_stime = (stime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (collected_usec - last_collected_usec);
last = gtime_raw;
- gtime_raw = strtoull(procfile_lineword(ff, 0, 10), NULL, 10);
+ gtime_raw = str2ull(procfile_lineword(ff, 0, 10));
global_gtime = (gtime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (collected_usec - last_collected_usec);
if(enable_guest_charts) {
// guest nice time, on guest time
last = gntime_raw;
- gntime_raw = strtoull(procfile_lineword(ff, 0, 11), NULL, 10);
+ gntime_raw = str2ull(procfile_lineword(ff, 0, 11));
global_gtime += (gntime_raw - last) * (USEC_PER_SEC * RATES_DETAIL) / (collected_usec - last_collected_usec);
// remove guest time from user time
#define FILETYPE_TIMERFD 7
#define FILETYPE_SIGNALFD 8
-void file_descriptor_not_used(int id)
+static inline void file_descriptor_not_used(int id)
{
if(id > 0 && id < all_files_size) {
if(unlikely(debug))
fprintf(stderr, "apps.plugin: >> slot %d is empty.\n", id);
- file_descriptor_remove(&all_files[id]);
+ if(unlikely(file_descriptor_remove(&all_files[id]) != (void *)&all_files[id]))
+ error("INTERNAL ERROR: removal of unused fd from index, removed a different fd");
+
#ifdef NETDATA_INTERNAL_CHECKS
all_files[id].magic = 0x00000000;
#endif /* NETDATA_INTERNAL_CHECKS */
else error("Request to decrease counter of fd %d, which is outside the array size (1 to %d)", id, all_files_size);
}
-int file_descriptor_find_or_add(const char *name)
+static inline int file_descriptor_find_or_add(const char *name)
{
static int last_pos = 0;
uint32_t hash = simple_hash(name);
all_files_index.root = NULL;
for(i = 0; i < all_files_size; i++) {
if(!all_files[i].count) continue;
- file_descriptor_add(&all_files[i]);
+ if(unlikely(file_descriptor_add(&all_files[i]) != (void *)&all_files[i]))
+ error("INTERNAL ERROR: duplicate indexing of fd during realloc.");
}
if(unlikely(debug))
#ifdef NETDATA_INTERNAL_CHECKS
all_files[c].magic = 0x0BADCAFE;
#endif /* NETDATA_INTERNAL_CHECKS */
- file_descriptor_add(&all_files[c]);
+ if(unlikely(file_descriptor_add(&all_files[c]) != (void *)&all_files[c]))
+ error("INTERNAL ERROR: duplicate indexing of fd.");
if(unlikely(debug))
fprintf(stderr, "apps.plugin: using fd position %d (name: %s)\n", c, all_files[c].name);
return c;
}
-int read_pid_file_descriptors(struct pid_stat *p) {
+static inline int read_pid_file_descriptors(struct pid_stat *p) {
char dirname[FILENAME_MAX+1];
snprintfz(dirname, FILENAME_MAX, "%s/proc/%d/fd", global_host_prefix, p->pid);
continue;
// check if the fds array is small
- int fdid = atoi(de->d_name);
+ int fdid = (int)str2l(de->d_name);
if(fdid < 0) continue;
if(fdid >= p->fds_size) {
// it is small, extend it
// ----------------------------------------------------------------------------
-int print_process_and_parents(struct pid_stat *p, unsigned long long time) {
+static inline int print_process_and_parents(struct pid_stat *p, unsigned long long time) {
char *prefix = "\\_ ";
int indent = 0;
return indent + 1;
}
-void print_process_tree(struct pid_stat *p, char *msg) {
+static inline void print_process_tree(struct pid_stat *p, char *msg) {
log_date(stderr);
fprintf(stderr, "%s: process %s (%d, %s) with parents:\n", msg, p->comm, p->pid, p->updated?"running":"exited");
print_process_and_parents(p, p->stat_collected_usec);
}
-void find_lost_child_debug(struct pid_stat *pe, unsigned long long lost, int type) {
+static inline void find_lost_child_debug(struct pid_stat *pe, unsigned long long lost, int type) {
int found = 0;
struct pid_stat *p = NULL;
}
}
-unsigned long long remove_exited_child_from_parent(unsigned long long *field, unsigned long long *pfield) {
+static inline unsigned long long remove_exited_child_from_parent(unsigned long long *field, unsigned long long *pfield) {
unsigned long long absorbed = 0;
if(*field > *pfield) {
return absorbed;
}
-void process_exited_processes() {
+static inline void process_exited_processes() {
struct pid_stat *p;
for(p = root_of_pids; p ; p = p->next) {
}
}
-void link_all_processes_to_their_parents(void) {
+static inline void link_all_processes_to_their_parents(void) {
struct pid_stat *p, *pp;
// link all children to their parents
return status;
}
-void collect_data_for_pid(pid_t pid) {
+static inline int collect_data_for_pid(pid_t pid) {
if(unlikely(pid <= 0 || pid > pid_max)) {
error("Invalid pid %d read (expected 1 to %d). Ignoring process.", pid, pid_max);
- return;
+ return 0;
}
struct pid_stat *p = get_pid_entry(pid);
- if(unlikely(!p || p->read)) return;
- p->read = 1;
+ if(unlikely(!p || p->read)) return 0;
+ p->read = 1;
// fprintf(stderr, "Reading process %d (%s), sortlist %d\n", p->pid, p->comm, p->sortlist);
if(unlikely(!managed_log(p, PID_LOG_STAT, read_proc_pid_stat(p))))
// there is no reason to proceed if we cannot get its status
- return;
+ return 0;
read_proc_pid_ownership(p);
if(unlikely(!managed_log(p, PID_LOG_STATM, read_proc_pid_statm(p))))
// there is no reason to proceed if we cannot get its memory status
- return;
+ return 0;
// --------------------------------------------------------------------
// link it
p->updated = 1;
p->keep = 0;
p->keeploops = 0;
+
+ return 1;
}
-int collect_data_for_all_processes_from_proc(void) {
+static int collect_data_for_all_processes_from_proc(void) {
struct pid_stat *p = NULL;
if(all_pids_count) {
}
closedir(dir);
+ if(!all_pids_count)
+ return 0;
+
// normally this is done
// however we may have processes exited while we collected values
// so let's find the exited ones
// 9. find the unique file count for each target
// check: update_apps_groups_statistics()
-void cleanup_exited_pids(void) {
+static void cleanup_exited_pids(void) {
int c;
struct pid_stat *p = NULL;
}
}
-void apply_apps_groups_targets_inheritance(void) {
+static void apply_apps_groups_targets_inheritance(void) {
struct pid_stat *p = NULL;
// children that do not have a target
fprintf(stderr, "apps.plugin: apply_apps_groups_targets_inheritance() made %d loops on the process tree\n", loops);
}
-long zero_all_targets(struct target *root) {
+static long zero_all_targets(struct target *root) {
struct target *w;
long count = 0;
return count;
}
-void aggregate_pid_on_target(struct target *w, struct pid_stat *p, struct target *o) {
+static inline void aggregate_pid_on_target(struct target *w, struct pid_stat *p, struct target *o) {
(void)o;
if(unlikely(!w->fds))
}
}
-void count_targets_fds(struct target *root) {
+static inline void count_targets_fds(struct target *root) {
int c;
struct target *w;
}
}
-void calculate_netdata_statistics(void) {
+static void calculate_netdata_statistics(void) {
apply_apps_groups_targets_inheritance();
zero_all_targets(users_root_target);
double utime_fix_ratio = 1.0, stime_fix_ratio = 1.0, gtime_fix_ratio = 1.0, cutime_fix_ratio = 1.0, cstime_fix_ratio = 1.0, cgtime_fix_ratio = 1.0;
double minflt_fix_ratio = 1.0, majflt_fix_ratio = 1.0, cminflt_fix_ratio = 1.0, cmajflt_fix_ratio = 1.0;
-usec_t send_resource_usage_to_netdata() {
+static usec_t send_resource_usage_to_netdata() {
static struct timeval last = { 0, 0 };
static struct rusage me_last;
return usec;
}
-void normalize_data(struct target *root) {
+static void normalize_data(struct target *root) {
struct target *w;
// childs processing introduces spikes
}
}
-void send_collected_data_to_netdata(struct target *root, const char *type, usec_t usec) {
+static void send_collected_data_to_netdata(struct target *root, const char *type, usec_t usec) {
struct target *w;
send_BEGIN(type, "cpu", usec);
// ----------------------------------------------------------------------------
// generate the charts
-void send_charts_updates_to_netdata(struct target *root, const char *type, const char *title)
+static void send_charts_updates_to_netdata(struct target *root, const char *type, const char *title)
{
struct target *w;
int newly_added = 0;
// ----------------------------------------------------------------------------
// parse command line arguments
-void parse_args(int argc, char **argv)
+static void parse_args(int argc, char **argv)
{
int i, freq = 0;
char *name = NULL;
for(i = 1; i < argc; i++) {
if(!freq) {
- int n = atoi(argv[i]);
+ int n = (int)str2l(argv[i]);
if(n > 0) {
freq = n;
continue;
}
}
+ if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
+ printf("apps.plugin %s\n", VERSION);
+ exit(0);
+ }
+
if(strcmp("debug", argv[i]) == 0) {
debug = 1;
// debug_flags = 0xffffffff;
if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
fprintf(stderr,
- "apps.plugin\n"
+ "apps.plugin %s\n"
"(C) 2016 Costa Tsaousis"
"GPL v3+\n"
"This program is a data collector plugin for netdata.\n"
"NAME read apps_NAME.conf instead of\n"
" apps_groups.conf\n"
" (default NAME=groups)\n"
+ "\n"
+ "version print program version and exit\n"
+ "\n"
+ , VERSION
);
exit(1);
}
if(!name) name = "groups";
if(read_apps_groups_conf(name)) {
- error("Cannot read process groups %s", name);
+ error("Cannot read process groups '%s/apps_%s.conf'. There are no internal defaults. Failing.", config_dir, name);
exit(1);
}
}