// find if it already exists in the data
for(e = base->head; e ; e = e->next)
- if(e->hash == hash && !strsame(e->name, s))
+ if(e->hash == hash && !strcmp(e->name, s))
break;
#ifdef NETDATA_INTERNAL_CHECKS
ARL_ENTRY *e = base->next_keyword;
// it should be the first entry (pointed by base->next_keyword)
- if(likely(!strsame(keyword, e->name))) {
+ if(likely(!strcmp(keyword, e->name))) {
// it is
#ifdef NETDATA_INTERNAL_CHECKS
static int config_value_compare(void* a, void* b) {
if(((struct config_value *)a)->hash < ((struct config_value *)b)->hash) return -1;
else if(((struct config_value *)a)->hash > ((struct config_value *)b)->hash) return 1;
- else return strsame(((struct config_value *)a)->name, ((struct config_value *)b)->name);
+ else return strcmp(((struct config_value *)a)->name, ((struct config_value *)b)->name);
}
#define config_value_index_add(co, cv) (struct config_value *)avl_insert_lock(&((co)->values_index), (avl *)(cv))
static int config_compare(void* a, void* b) {
if(((struct config *)a)->hash < ((struct config *)b)->hash) return -1;
else if(((struct config *)a)->hash > ((struct config *)b)->hash) return 1;
- else return strsame(((struct config *)a)->name, ((struct config *)b)->name);
+ else return strcmp(((struct config *)a)->name, ((struct config *)b)->name);
}
avl_tree_lock config_root_index = {
// this is a loaded value from the config file
// if it is different that the default, mark it
if(!(cv->flags & CONFIG_VALUE_CHECKED)) {
- if(strsame(cv->value, default_value) != 0) cv->flags |= CONFIG_VALUE_CHANGED;
+ if(strcmp(cv->value, default_value) != 0) cv->flags |= CONFIG_VALUE_CHANGED;
cv->flags |= CONFIG_VALUE_CHECKED;
}
}
s = config_get(section, name, s);
if(!s) return value;
- if(!strsame(s, "yes") || !strsame(s, "auto") || !strsame(s, "on demand")) return 1;
+ if(!strcmp(s, "yes") || !strcmp(s, "auto") || !strcmp(s, "on demand")) return 1;
return 0;
}
s = config_get(section, name, s);
if(!s) return value;
- if(!strsame(s, "yes"))
+ if(!strcmp(s, "yes"))
return CONFIG_ONDEMAND_YES;
- else if(!strsame(s, "no"))
+ else if(!strcmp(s, "no"))
return CONFIG_ONDEMAND_NO;
- else if(!strsame(s, "auto") || !strsame(s, "on demand"))
+ else if(!strcmp(s, "auto") || !strcmp(s, "on demand"))
return CONFIG_ONDEMAND_ONDEMAND;
return value;
if(cv->flags & CONFIG_VALUE_LOADED)
return cv->value;
- if(strsame(cv->value, value) != 0) {
+ if(strcmp(cv->value, value) != 0) {
cv->flags |= CONFIG_VALUE_CHANGED;
freez(cv->value);
if(!cv) cv = config_value_create(co, name, value);
cv->flags |= CONFIG_VALUE_USED;
- if(strsame(cv->value, value) != 0) {
+ if(strcmp(cv->value, value) != 0) {
cv->flags |= CONFIG_VALUE_CHANGED;
freez(cv->value);
config_global_write_lock();
for(co = config_root; co ; co = co->next) {
- if(!strsame(co->name, "global") ||
- !strsame(co->name, "plugins") ||
- !strsame(co->name, "registry") ||
- !strsame(co->name, "health") ||
- !strsame(co->name, "backend"))
+ if(!strcmp(co->name, "global") ||
+ !strcmp(co->name, "plugins") ||
+ !strcmp(co->name, "registry") ||
+ !strcmp(co->name, "health") ||
+ !strcmp(co->name, "backend"))
pri = 0;
else if(!strncmp(co->name, "plugin:", 7)) pri = 1;
else pri = 2;
name++;
}
for(target = apps_groups_root_target ; target ; target = target->next) {
- if(!target->target && strsame(name, target->name) == 0)
+ if(!target->target && strcmp(name, target->name) == 0)
break;
}
if(unlikely(debug)) {
return 1;
else
- return strsame(((struct file_descriptor *)a)->name, ((struct file_descriptor *)b)->name);
+ return strcmp(((struct file_descriptor *)a)->name, ((struct file_descriptor *)b)->name);
}
int file_descriptor_iterator(avl *a) { if(a) {}; return 0; }
if(name[0] == '/') type = FILETYPE_FILE;
else if(strncmp(name, "pipe:", 5) == 0) type = FILETYPE_PIPE;
else if(strncmp(name, "socket:", 7) == 0) type = FILETYPE_SOCKET;
- else if(strsame(name, "anon_inode:inotify") == 0 || strsame(name, "inotify") == 0) type = FILETYPE_INOTIFY;
- else if(strsame(name, "anon_inode:[eventfd]") == 0) type = FILETYPE_EVENTFD;
- else if(strsame(name, "anon_inode:[eventpoll]") == 0) type = FILETYPE_EVENTPOLL;
- else if(strsame(name, "anon_inode:[timerfd]") == 0) type = FILETYPE_TIMERFD;
- else if(strsame(name, "anon_inode:[signalfd]") == 0) type = FILETYPE_SIGNALFD;
+ else if(strcmp(name, "anon_inode:inotify") == 0 || strcmp(name, "inotify") == 0) type = FILETYPE_INOTIFY;
+ else if(strcmp(name, "anon_inode:[eventfd]") == 0) type = FILETYPE_EVENTFD;
+ else if(strcmp(name, "anon_inode:[eventpoll]") == 0) type = FILETYPE_EVENTPOLL;
+ else if(strcmp(name, "anon_inode:[timerfd]") == 0) type = FILETYPE_TIMERFD;
+ else if(strcmp(name, "anon_inode:[signalfd]") == 0) type = FILETYPE_SIGNALFD;
else if(strncmp(name, "anon_inode:", 11) == 0) {
if(unlikely(debug))
fprintf(stderr, "apps.plugin: FIXME: unknown anonymous inode: %s\n", name);
p->fds[c] = -p->fds[c];
while((de = readdir(fds))) {
- if(strsame(de->d_name, ".") == 0 || strsame(de->d_name, "..") == 0)
+ if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
continue;
// check if the fds array is small
// 2. the target has the prefix
// 3. the target has the suffix
// 4. the target is something inside cmdline
- if( (!w->starts_with && !w->ends_with && w->comparehash == hash && !strsame(w->compare, p->comm))
+ if( (!w->starts_with && !w->ends_with && w->comparehash == hash && !strcmp(w->compare, p->comm))
|| (w->starts_with && !w->ends_with && !strncmp(w->compare, p->comm, w->comparelen))
- || (!w->starts_with && w->ends_with && pclen >= w->comparelen && !strsame(w->compare, &p->comm[pclen - w->comparelen]))
+ || (!w->starts_with && w->ends_with && pclen >= w->comparelen && !strcmp(w->compare, &p->comm[pclen - w->comparelen]))
|| (proc_pid_cmdline_is_needed && w->starts_with && w->ends_with && strstr(p->cmdline, w->compare))
) {
if(w->target) p->target = w->target;
}
}
- if(strsame("version", argv[i]) == 0 || strsame("-v", argv[i]) == 0) {
+ if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
printf("apps.plugin %s\n", VERSION);
exit(0);
}
- if(strsame("debug", argv[i]) == 0) {
+ if(strcmp("debug", argv[i]) == 0) {
debug = 1;
// debug_flags = 0xffffffff;
continue;
}
- if(strsame("no-childs", argv[i]) == 0 || strsame("without-childs", argv[i]) == 0) {
+ if(strcmp("no-childs", argv[i]) == 0 || strcmp("without-childs", argv[i]) == 0) {
include_exited_childs = 0;
continue;
}
- if(strsame("with-childs", argv[i]) == 0) {
+ if(strcmp("with-childs", argv[i]) == 0) {
include_exited_childs = 1;
continue;
}
- if(strsame("with-guest", argv[i]) == 0) {
+ if(strcmp("with-guest", argv[i]) == 0) {
enable_guest_charts = 1;
continue;
}
- if(strsame("no-guest", argv[i]) == 0 || strsame("without-guest", argv[i]) == 0) {
+ if(strcmp("no-guest", argv[i]) == 0 || strcmp("without-guest", argv[i]) == 0) {
enable_guest_charts = 0;
continue;
}
- if(strsame("with-files", argv[i]) == 0) {
+ if(strcmp("with-files", argv[i]) == 0) {
enable_file_charts = 1;
continue;
}
- if(strsame("no-files", argv[i]) == 0 || strsame("without-files", argv[i]) == 0) {
+ if(strcmp("no-files", argv[i]) == 0 || strcmp("without-files", argv[i]) == 0) {
enable_file_charts = 0;
continue;
}
- if(strsame("no-users", argv[i]) == 0 || strsame("without-users", argv[i]) == 0) {
+ if(strcmp("no-users", argv[i]) == 0 || strcmp("without-users", argv[i]) == 0) {
enable_users_charts = 0;
continue;
}
- if(strsame("no-groups", argv[i]) == 0 || strsame("without-groups", argv[i]) == 0) {
+ if(strcmp("no-groups", argv[i]) == 0 || strcmp("without-groups", argv[i]) == 0) {
enable_groups_charts = 0;
continue;
}
- if(strsame("-h", argv[i]) == 0 || strsame("--help", argv[i]) == 0) {
+ if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
fprintf(stderr,
"apps.plugin %s\n"
"(C) 2016 Costa Tsaousis"
if(!enabled || frequency < 1)
goto cleanup;
- if(!strsame(source, "as collected")) {
+ if(!strcmp(source, "as collected")) {
options = BACKEND_SOURCE_DATA_AS_COLLECTED;
}
- else if(!strsame(source, "average")) {
+ else if(!strcmp(source, "average")) {
options = BACKEND_SOURCE_DATA_AVERAGE;
}
- else if(!strsame(source, "sum") || !strsame(source, "volume")) {
+ else if(!strcmp(source, "sum") || !strcmp(source, "volume")) {
options = BACKEND_SOURCE_DATA_SUM;
}
else {
goto cleanup;
}
- if(!strsame(type, "graphite") || !strsame(type, "graphite:plaintext")) {
+ if(!strcmp(type, "graphite") || !strcmp(type, "graphite:plaintext")) {
default_port = 2003;
if(options == BACKEND_SOURCE_DATA_AS_COLLECTED)
backend_request_formatter = format_dimension_collected_graphite_plaintext;
backend_response_checker = process_graphite_response;
}
- else if(!strsame(type, "opentsdb") || !strsame(type, "opentsdb:telnet")) {
+ else if(!strcmp(type, "opentsdb") || !strcmp(type, "opentsdb:telnet")) {
default_port = 4242;
if(options == BACKEND_SOURCE_DATA_AS_COLLECTED)
backend_request_formatter = format_dimension_collected_opentsdb_telnet;
static int name_value_compare(void* a, void* b) {
if(((NAME_VALUE *)a)->hash < ((NAME_VALUE *)b)->hash) return -1;
else if(((NAME_VALUE *)a)->hash > ((NAME_VALUE *)b)->hash) return 1;
- else return strsame(((NAME_VALUE *)a)->name, ((NAME_VALUE *)b)->name);
+ else return strcmp(((NAME_VALUE *)a)->name, ((NAME_VALUE *)b)->name);
}
static inline NAME_VALUE *dictionary_name_value_index_find_nolock(DICTIONARY *dict, const char *name, uint32_t hash) {
critical_hash = simple_hash("CRITICAL");
}
- if(unlikely(v->hash == this_hash && !strsame(v->name, "this"))) {
+ if(unlikely(v->hash == this_hash && !strcmp(v->name, "this"))) {
n = (exp->this)?*exp->this:NAN;
buffer_strcat(exp->error_msg, "[ $this = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == after_hash && !strsame(v->name, "after"))) {
+ if(unlikely(v->hash == after_hash && !strcmp(v->name, "after"))) {
n = (exp->after && *exp->after)?*exp->after:NAN;
buffer_strcat(exp->error_msg, "[ $after = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == before_hash && !strsame(v->name, "before"))) {
+ if(unlikely(v->hash == before_hash && !strcmp(v->name, "before"))) {
n = (exp->before && *exp->before)?*exp->before:NAN;
buffer_strcat(exp->error_msg, "[ $before = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == now_hash && !strsame(v->name, "now"))) {
+ if(unlikely(v->hash == now_hash && !strcmp(v->name, "now"))) {
n = now_realtime_sec();
buffer_strcat(exp->error_msg, "[ $now = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == status_hash && !strsame(v->name, "status"))) {
+ if(unlikely(v->hash == status_hash && !strcmp(v->name, "status"))) {
n = (exp->status)?*exp->status:RRDCALC_STATUS_UNINITIALIZED;
buffer_strcat(exp->error_msg, "[ $status = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == removed_hash && !strsame(v->name, "REMOVED"))) {
+ if(unlikely(v->hash == removed_hash && !strcmp(v->name, "REMOVED"))) {
n = RRDCALC_STATUS_REMOVED;
buffer_strcat(exp->error_msg, "[ $REMOVED = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == uninitialized_hash && !strsame(v->name, "UNINITIALIZED"))) {
+ if(unlikely(v->hash == uninitialized_hash && !strcmp(v->name, "UNINITIALIZED"))) {
n = RRDCALC_STATUS_UNINITIALIZED;
buffer_strcat(exp->error_msg, "[ $UNINITIALIZED = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == undefined_hash && !strsame(v->name, "UNDEFINED"))) {
+ if(unlikely(v->hash == undefined_hash && !strcmp(v->name, "UNDEFINED"))) {
n = RRDCALC_STATUS_UNDEFINED;
buffer_strcat(exp->error_msg, "[ $UNDEFINED = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == clear_hash && !strsame(v->name, "CLEAR"))) {
+ if(unlikely(v->hash == clear_hash && !strcmp(v->name, "CLEAR"))) {
n = RRDCALC_STATUS_CLEAR;
buffer_strcat(exp->error_msg, "[ $CLEAR = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == warning_hash && !strsame(v->name, "WARNING"))) {
+ if(unlikely(v->hash == warning_hash && !strcmp(v->name, "WARNING"))) {
n = RRDCALC_STATUS_WARNING;
buffer_strcat(exp->error_msg, "[ $WARNING = ");
print_parsed_as_constant(exp->error_msg, n);
return n;
}
- if(unlikely(v->hash == critical_hash && !strsame(v->name, "CRITICAL"))) {
+ if(unlikely(v->hash == critical_hash && !strcmp(v->name, "CRITICAL"))) {
n = RRDCALC_STATUS_CRITICAL;
buffer_strcat(exp->error_msg, "[ $CRITICAL = ");
print_parsed_as_constant(exp->error_msg, n);
}
// check for a possible host missmatch
- //if(strsame(pointers[1], host->hostname))
+ //if(strcmp(pointers[1], host->hostname))
// error("Health: line %zu of file '%s' provides an alarm for host '%s' but this is named '%s'.", line, filename, pointers[1], host->hostname);
ae->unique_id = unique_id;
int rrdvar_compare(void* a, void* b) {
if(((RRDVAR *)a)->hash < ((RRDVAR *)b)->hash) return -1;
else if(((RRDVAR *)a)->hash > ((RRDVAR *)b)->hash) return 1;
- else return strsame(((RRDVAR *)a)->name, ((RRDVAR *)b)->name);
+ else return strcmp(((RRDVAR *)a)->name, ((RRDVAR *)b)->name);
}
static inline RRDVAR *rrdvar_index_add(avl_tree_lock *tree, RRDVAR *rv) {
}
static inline int rrdcalc_is_matching_this_rrdset(RRDCALC *rc, RRDSET *st) {
- if( (rc->hash_chart == st->hash && !strsame(rc->chart, st->id)) ||
- (rc->hash_chart == st->hash_name && !strsame(rc->chart, st->name)))
+ if( (rc->hash_chart == st->hash && !strcmp(rc->chart, st->id)) ||
+ (rc->hash_chart == st->hash_name && !strcmp(rc->chart, st->name)))
return 1;
return 0;
uint32_t hash = simple_hash(name);
for( rc = st->alarms; rc ; rc = rc->rrdset_next ) {
- if(unlikely(rc->hash == hash && !strsame(rc->name, name)))
+ if(unlikely(rc->hash == hash && !strcmp(rc->name, name)))
return rc;
}
// make sure it does not already exist
for(rc = host->alarms; rc ; rc = rc->next) {
- if (unlikely(rc->chart && rc->hash == hash_name && rc->hash_chart == hash_chart && !strsame(name, rc->name) && !strsame(chart, rc->chart))) {
+ if (unlikely(rc->chart && rc->hash == hash_name && rc->hash_chart == hash_chart && !strcmp(name, rc->name) && !strcmp(chart, rc->chart))) {
debug(D_HEALTH, "Health alarm '%s.%s' already exists in host '%s'.", chart, name, host->hostname);
error("Health alarm '%s.%s' already exists in host '%s'.", chart, name, host->hostname);
return 1;
// re-use old IDs, by looking them up in the alarm log
ALARM_ENTRY *ae;
for(ae = host->health_log.alarms; ae ;ae = ae->next) {
- if(unlikely(ae->hash_name == hash_name && ae->hash_chart == hash_chart && !strsame(name, ae->name) && !strsame(chart, ae->chart))) {
+ if(unlikely(ae->hash_name == hash_name && ae->hash_chart == hash_chart && !strcmp(name, ae->name) && !strcmp(chart, ae->chart))) {
if(next_event_id) *next_event_id = ae->alarm_event_id + 1;
return ae->alarm_id;
}
RRDCALCTEMPLATE *rt;
for(rt = st->rrdhost->templates; rt ; rt = rt->next) {
- if(rt->hash_context == st->hash_context && !strsame(rt->context, st->context)
+ if(rt->hash_context == st->hash_context && !strcmp(rt->context, st->context)
&& (!rt->family_pattern || simple_pattern_matches(rt->family_pattern, st->family))) {
RRDCALC *rc = rrdcalc_create(st->rrdhost, rt, st->id);
if(unlikely(!rc))
RRDCALCTEMPLATE *t, *last = NULL;
for (t = host->templates; t ; last = t, t = t->next) {
- if(unlikely(t->hash_name == rt->hash_name && !strsame(t->name, rt->name))) {
+ if(unlikely(t->hash_name == rt->hash_name && !strcmp(t->name, rt->name))) {
error("Health configuration template '%s' already exists for host '%s'.", rt->name, host->hostname);
return 0;
}
else if(rc) {
if(hash == hash_on && !strcasecmp(key, HEALTH_ON_KEY)) {
if(rc->chart) {
- if(strsame(rc->chart, value))
+ if(strcmp(rc->chart, value))
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rc->name, key, rc->chart, value, value);
}
else if(hash == hash_exec && !strcasecmp(key, HEALTH_EXEC_KEY)) {
if(rc->exec) {
- if(strsame(rc->exec, value))
+ if(strcmp(rc->exec, value))
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rc->name, key, rc->exec, value, value);
}
else if(hash == hash_recipient && !strcasecmp(key, HEALTH_RECIPIENT_KEY)) {
if(rc->recipient) {
- if(strsame(rc->recipient, value))
+ if(strcmp(rc->recipient, value))
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rc->name, key, rc->recipient, value, value);
}
else if(hash == hash_units && !strcasecmp(key, HEALTH_UNITS_KEY)) {
if(rc->units) {
- if(strsame(rc->units, value))
+ if(strcmp(rc->units, value))
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rc->name, key, rc->units, value, value);
}
else if(hash == hash_info && !strcasecmp(key, HEALTH_INFO_KEY)) {
if(rc->info) {
- if(strsame(rc->info, value))
+ if(strcmp(rc->info, value))
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rc->name, key, rc->info, value, value);
else if(rt) {
if(hash == hash_on && !strcasecmp(key, HEALTH_ON_KEY)) {
if(rt->context) {
- if(strsame(rt->context, value))
+ if(strcmp(rt->context, value))
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rt->name, key, rt->context, value, value);
}
else if(hash == hash_exec && !strcasecmp(key, HEALTH_EXEC_KEY)) {
if(rt->exec) {
- if(strsame(rt->exec, value))
+ if(strcmp(rt->exec, value))
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rt->name, key, rt->exec, value, value);
}
else if(hash == hash_recipient && !strcasecmp(key, HEALTH_RECIPIENT_KEY)) {
if(rt->recipient) {
- if(strsame(rt->recipient, value))
+ if(strcmp(rt->recipient, value))
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rt->name, key, rt->recipient, value, value);
}
else if(hash == hash_units && !strcasecmp(key, HEALTH_UNITS_KEY)) {
if(rt->units) {
- if(strsame(rt->units, value))
+ if(strcmp(rt->units, value))
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rt->name, key, rt->units, value, value);
}
else if(hash == hash_info && !strcasecmp(key, HEALTH_INFO_KEY)) {
if(rt->info) {
- if(strsame(rt->info, value))
+ if(strcmp(rt->info, value))
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
line, path, filename, rt->name, key, rt->info, value, value);
}
else if((de->d_type == DT_LNK || de->d_type == DT_REG || de->d_type == DT_UNKNOWN) &&
- len > 5 && !strsame(&de->d_name[len - 5], ".conf")) {
+ len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) {
health_readfile(path, de->d_name);
}
return hval;
}
+static inline int simple_hash_strcmp(const char *name, const char *b, uint32_t *hash) {
+ unsigned char *s = (unsigned char *) name;
+ uint32_t hval = 0x811c9dc5;
+ int ret = 0;
+ while (*s) {
+ if(!ret) ret = *s - *b++;
+ hval *= 16777619;
+ hval ^= (uint32_t) *s++;
+ }
+ *hash = hval;
+ return ret;
+}
+
static inline int str2i(const char *s) {
int n = 0;
char c, negative = (*s == '-');
return n;
}
-#ifdef NETDATA_STRSAME
-static inline int strsame(const char *a, const char *b) {
+#ifdef NETDATA_STRCMP_OVERRIDE
+static inline int strcmp(const char *a, const char *b) {
if(unlikely(a == b)) return 0;
while(*a && *a == *b) { a++; b++; }
return *a - *b;
}
-#else
-#define strsame(a, b) strcmp(a, b)
#endif // NETDATA_STRSAME
static inline int read_single_number_file(const char *filename, unsigned long long *result) {
int open_log_file(int fd, FILE **fp, const char *filename, int *enabled_syslog) {
int f;
- if(!filename || !*filename || !strsame(filename, "none"))
+ if(!filename || !*filename || !strcmp(filename, "none"))
filename = "/dev/null";
- if(!strsame(filename, "syslog")) {
+ if(!strcmp(filename, "syslog")) {
filename = "/dev/null";
syslog_init();
if(enabled_syslog) *enabled_syslog = 1;
// don't do anything if the user is willing
// to have the standard one
- if(!strsame(filename, "system")) {
+ if(!strcmp(filename, "system")) {
if(fd != -1) return fd;
filename = "stdout";
}
- if(!strsame(filename, "stdout"))
+ if(!strcmp(filename, "stdout"))
f = STDOUT_FILENO;
- else if(!strsame(filename, "stderr"))
+ else if(!strcmp(filename, "stderr"))
f = STDERR_FILENO;
else {
web_enable_gzip = config_get_boolean("global", "enable web responses gzip compression", web_enable_gzip);
char *s = config_get("global", "web compression strategy", "default");
- if(!strsame(s, "default"))
+ if(!strcmp(s, "default"))
web_gzip_strategy = Z_DEFAULT_STRATEGY;
- else if(!strsame(s, "filtered"))
+ else if(!strcmp(s, "filtered"))
web_gzip_strategy = Z_FILTERED;
- else if(!strsame(s, "huffman only"))
+ else if(!strcmp(s, "huffman only"))
web_gzip_strategy = Z_HUFFMAN_ONLY;
- else if(!strsame(s, "rle"))
+ else if(!strcmp(s, "rle"))
web_gzip_strategy = Z_RLE;
- else if(!strsame(s, "fixed"))
+ else if(!strcmp(s, "fixed"))
web_gzip_strategy = Z_FIXED;
else {
error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
{
i = 1;
while(i < argc) {
- if(strsame(argv[i], "-pidfile") == 0 && (i+1) < argc) {
+ if(strcmp(argv[i], "-pidfile") == 0 && (i+1) < argc) {
strncpyz(pidfile, argv[i+1], FILENAME_MAX);
fprintf(stderr, "%s: deprecated option -- %s -- please use -P instead.\n", argv[0], argv[i]);
remove_option(i, &argc, argv);
}
- else if(strsame(argv[i], "-nodaemon") == 0 || strsame(argv[i], "-nd") == 0) {
+ else if(strcmp(argv[i], "-nodaemon") == 0 || strcmp(argv[i], "-nd") == 0) {
dont_fork = 1;
fprintf(stderr, "%s: deprecated option -- %s -- please use -D instead.\n ", argv[0], argv[i]);
remove_option(i, &argc, argv);
}
- else if(strsame(argv[i], "-ch") == 0 && (i+1) < argc) {
+ else if(strcmp(argv[i], "-ch") == 0 && (i+1) < argc) {
config_set("global", "host access prefix", argv[i+1]);
fprintf(stderr, "%s: deprecated option -- %s -- please use -s instead.\n", argv[0], argv[i]);
remove_option(i, &argc, argv);
}
- else if(strsame(argv[i], "-l") == 0 && (i+1) < argc) {
+ else if(strcmp(argv[i], "-l") == 0 && (i+1) < argc) {
config_set("global", "history", argv[i+1]);
fprintf(stderr, "%s: deprecated option -- %s -- This option will be removed with V2.*.\n", argv[0], argv[i]);
remove_option(i, &argc, argv);
{
char* stacksize_string = "stacksize=";
char* debug_flags_string = "debug_flags=";
- if(strsame(optarg, "unittest") == 0) {
+ if(strcmp(optarg, "unittest") == 0) {
rrd_update_every = 1;
if(run_all_mockup_tests()) exit(1);
if(unit_test_storage()) exit(1);
fprintf(stderr, "\n\nALL TESTS PASSED\n\n");
exit(0);
}
- else if(strsame(optarg, "simple-pattern") == 0) {
+ else if(strcmp(optarg, "simple-pattern") == 0) {
if(optind + 2 > argc) {
fprintf(stderr, "%s", "\nUSAGE: -W simple-pattern 'pattern' 'string'\n\n"
" Checks if 'pattern' matches the given 'string'.\n"
static int tc_device_compare(void* a, void* b) {
if(((struct tc_device *)a)->hash < ((struct tc_device *)b)->hash) return -1;
else if(((struct tc_device *)a)->hash > ((struct tc_device *)b)->hash) return 1;
- else return strsame(((struct tc_device *)a)->id, ((struct tc_device *)b)->id);
+ else return strcmp(((struct tc_device *)a)->id, ((struct tc_device *)b)->id);
}
avl_tree tc_device_root_index = {
static int tc_class_compare(void* a, void* b) {
if(((struct tc_class *)a)->hash < ((struct tc_class *)b)->hash) return -1;
else if(((struct tc_class *)a)->hash > ((struct tc_class *)b)->hash) return 1;
- else return strsame(((struct tc_class *)a)->id, ((struct tc_class *)b)->id);
+ else return strcmp(((struct tc_class *)a)->id, ((struct tc_class *)b)->id);
}
#define tc_class_index_add(st, rd) (struct tc_class *)avl_insert(&((st)->classes_index), (avl *)(rd))
if(unlikely(c == x)) continue;
if(x->parentid && (
- ( c->hash == x->parent_hash && strsame(c->id, x->parentid) == 0) ||
- (c->leafid && c->leaf_hash == x->parent_hash && strsame(c->leafid, x->parentid) == 0))) {
+ ( c->hash == x->parent_hash && strcmp(c->id, x->parentid) == 0) ||
+ (c->leafid && c->leaf_hash == x->parent_hash && strcmp(c->leafid, x->parentid) == 0))) {
// debug(D_TC_LOOP, "TC: In device '%s', class '%s' (leafid: '%s') has as leaf class '%s' (parentid: '%s').", d->name?d->name:d->id, c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->name?x->name:x->id, x->parentid?x->parentid:x->id);
c->isleaf = 0;
x->hasparent = 1;
debug(D_TC_LOOP, "TC: Updating chart for device '%s'", d->name?d->name:d->id);
rrdset_next(d->st_bytes);
- if(unlikely(d->name_updated && d->name && strsame(d->id, d->name) != 0)) {
+ if(unlikely(d->name_updated && d->name && strcmp(d->id, d->name) != 0)) {
rrdset_set_name(d->st_bytes, d->name);
d->name_updated = 0;
}
rrddim_set_by_pointer(d->st_bytes, c->rd_bytes, c->bytes);
// if it has a name, different to the id
- if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
+ if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
// update the rrd dimension with the new name
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_bytes->id, c->rd_bytes->id, c->name);
rrddim_set_name(d->st_bytes, c->rd_bytes, c->name);
rrddim_set_by_pointer(d->st_packets, c->rd_packets, c->packets);
// if it has a name, different to the id
- if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
+ if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
// update the rrd dimension with the new name
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_packets->id, c->rd_packets->id, c->name);
rrddim_set_name(d->st_packets, c->rd_packets, c->name);
rrddim_set_by_pointer(d->st_dropped, c->rd_dropped, c->dropped);
// if it has a name, different to the id
- if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
+ if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
// update the rrd dimension with the new name
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_dropped->id, c->rd_dropped->id, c->name);
rrddim_set_name(d->st_dropped, c->rd_dropped, c->name);
rrddim_set_by_pointer(d->st_tokens, c->rd_tokens, c->tokens);
// if it has a name, different to the id
- if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
+ if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
// update the rrd dimension with the new name
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_tokens->id, c->rd_tokens->id, c->name);
rrddim_set_name(d->st_tokens, c->rd_tokens, c->name);
rrddim_set_by_pointer(d->st_ctokens, c->rd_ctokens, c->ctokens);
// if it has a name, different to the id
- if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
+ if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
// update the rrd dimension with the new name
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_ctokens->id, c->rd_ctokens->id, c->name);
rrddim_set_name(d->st_ctokens, c->rd_ctokens, c->name);
freez(c->name);
c->name = NULL;
- if(likely(name && *name && strsame(c->id, name) != 0)) {
+ if(likely(name && *name && strcmp(c->id, name) != 0)) {
debug(D_TC_LOOP, "TC: Setting device '%s', class '%s' name to '%s'", d->id, id, name);
c->name = strdupz(name);
c->name_updated = 1;
freez(d->name);
d->name = NULL;
- if(likely(name && *name && strsame(d->id, name) != 0)) {
+ if(likely(name && *name && strcmp(d->id, name) != 0)) {
debug(D_TC_LOOP, "TC: Setting device '%s' name to '%s'", d->id, name);
d->name = strdupz(name);
d->name_updated = 1;
freez(d->family);
d->family = NULL;
- if(likely(family && *family && strsame(d->id, family) != 0)) {
+ if(likely(family && *family && strcmp(d->id, family) != 0)) {
debug(D_TC_LOOP, "TC: Setting device '%s' family to '%s'", d->id, family);
d->family = strdupz(family);
d->family_updated = 1;
first_hash = simple_hash(words[0]);
- if(unlikely(device && first_hash == CLASS_HASH && strsame(words[0], "class") == 0)) {
+ if(unlikely(device && first_hash == CLASS_HASH && strcmp(words[0], "class") == 0)) {
// debug(D_TC_LOOP, "CLASS line on class id='%s', parent='%s', parentid='%s', leaf='%s', leafid='%s'", words[2], words[3], words[4], words[5], words[6]);
// words[1] : class type
// words[2] : N:XX
// words[3] : parent or root
- if(likely(words[1] && words[2] && words[3] && (strsame(words[3], "parent") == 0 || strsame(words[3], "root") == 0))) {
+ if(likely(words[1] && words[2] && words[3] && (strcmp(words[3], "parent") == 0 || strcmp(words[3], "root") == 0))) {
//char *type = words[1]; // the class: htb, fq_codel, etc
// we are only interested for HTB classes
- //if(strsame(type, "htb") != 0) continue;
+ //if(strcmp(type, "htb") != 0) continue;
char *id = words[2]; // the class major:minor
char *parent = words[3]; // 'parent' or 'root'
char *leaf = words[5]; // 'leaf'
char *leafid = words[6]; // leafid
- if(strsame(parent, "root") == 0) {
+ if(strcmp(parent, "root") == 0) {
parentid = NULL;
leafid = NULL;
}
- else if(!leaf || strsame(leaf, "leaf") != 0)
+ else if(!leaf || strcmp(leaf, "leaf") != 0)
leafid = NULL;
char leafbuf[20 + 1] = "";
class = NULL;
}
}
- else if(unlikely(first_hash == END_HASH && strsame(words[0], "END") == 0)) {
+ else if(unlikely(first_hash == END_HASH && strcmp(words[0], "END") == 0)) {
// debug(D_TC_LOOP, "END line");
if(likely(device)) {
device = NULL;
class = NULL;
}
- else if(unlikely(first_hash == BEGIN_HASH && strsame(words[0], "BEGIN") == 0)) {
+ else if(unlikely(first_hash == BEGIN_HASH && strcmp(words[0], "BEGIN") == 0)) {
// debug(D_TC_LOOP, "BEGIN line on device '%s'", words[1]);
if(likely(words[1] && *words[1])) {
class = NULL;
}
- else if(unlikely(device && class && first_hash == SENT_HASH && strsame(words[0], "Sent") == 0)) {
+ else if(unlikely(device && class && first_hash == SENT_HASH && strcmp(words[0], "Sent") == 0)) {
// debug(D_TC_LOOP, "SENT line '%s'", words[1]);
if(likely(words[1] && *words[1])) {
class->bytes = str2ull(words[1]);
if(likely(words[10] && *words[10]))
class->requeues = str2ull(words[8]);
}
- else if(unlikely(device && class && class->updated && first_hash == LENDED_HASH && strsame(words[0], "lended:") == 0)) {
+ else if(unlikely(device && class && class->updated && first_hash == LENDED_HASH && strcmp(words[0], "lended:") == 0)) {
// debug(D_TC_LOOP, "LENDED line '%s'", words[1]);
if(likely(words[1] && *words[1]))
class->lended = str2ull(words[1]);
if(likely(words[5] && *words[5]))
class->giants = str2ull(words[5]);
}
- else if(unlikely(device && class && class->updated && first_hash == TOKENS_HASH && strsame(words[0], "tokens:") == 0)) {
+ else if(unlikely(device && class && class->updated && first_hash == TOKENS_HASH && strcmp(words[0], "tokens:") == 0)) {
// debug(D_TC_LOOP, "TOKENS line '%s'", words[1]);
if(likely(words[1] && *words[1]))
class->tokens = str2ull(words[1]);
if(likely(words[3] && *words[3]))
class->ctokens = str2ull(words[3]);
}
- else if(unlikely(device && first_hash == SETDEVICENAME_HASH && strsame(words[0], "SETDEVICENAME") == 0)) {
+ else if(unlikely(device && first_hash == SETDEVICENAME_HASH && strcmp(words[0], "SETDEVICENAME") == 0)) {
// debug(D_TC_LOOP, "SETDEVICENAME line '%s'", words[1]);
if(likely(words[1] && *words[1]))
tc_device_set_device_name(device, words[1]);
}
- else if(unlikely(device && first_hash == SETDEVICEGROUP_HASH && strsame(words[0], "SETDEVICEGROUP") == 0)) {
+ else if(unlikely(device && first_hash == SETDEVICEGROUP_HASH && strcmp(words[0], "SETDEVICEGROUP") == 0)) {
// debug(D_TC_LOOP, "SETDEVICEGROUP line '%s'", words[1]);
if(likely(words[1] && *words[1]))
tc_device_set_device_family(device, words[1]);
}
- else if(unlikely(device && first_hash == SETCLASSNAME_HASH && strsame(words[0], "SETCLASSNAME") == 0)) {
+ else if(unlikely(device && first_hash == SETCLASSNAME_HASH && strcmp(words[0], "SETCLASSNAME") == 0)) {
// debug(D_TC_LOOP, "SETCLASSNAME line '%s' '%s'", words[1], words[2]);
char *id = words[1];
char *path = words[2];
if(likely(id && *id && path && *path))
tc_device_set_class_name(device, id, path);
}
- else if(unlikely(first_hash == WORKTIME_HASH && strsame(words[0], "WORKTIME") == 0)) {
+ else if(unlikely(first_hash == WORKTIME_HASH && strcmp(words[0], "WORKTIME") == 0)) {
// debug(D_TC_LOOP, "WORKTIME line '%s' '%s'", words[1], words[2]);
getrusage(RUSAGE_THREAD, &thread);
}
#ifdef DETACH_PLUGINS_FROM_NETDATA
- else if(unlikely(first_hash == MYPID_HASH && (strsame(words[0], "MYPID") == 0))) {
+ else if(unlikely(first_hash == MYPID_HASH && (strcmp(words[0], "MYPID") == 0))) {
// debug(D_TC_LOOP, "MYPID line '%s'", words[1]);
char *id = words[1];
pid_t pid = atol(id);
#endif
char *words[MAX_WORDS] = { NULL };
- uint32_t SET_HASH = simple_hash("SET");
uint32_t BEGIN_HASH = simple_hash("BEGIN");
uint32_t END_HASH = simple_hash("END");
uint32_t FLUSH_HASH = simple_hash("FLUSH");
// debug(D_PLUGINSD, "PLUGINSD: words 0='%s' 1='%s' 2='%s' 3='%s' 4='%s' 5='%s' 6='%s' 7='%s' 8='%s' 9='%s'", words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);
- hash = simple_hash(s);
-
- if(likely(hash == SET_HASH && !strsame(s, "SET"))) {
+ if(likely(!simple_hash_strcmp(s, "SET", &hash))) {
char *dimension = words[1];
char *value = words[2];
if(value) rrddim_set(st, dimension, strtoll(value, NULL, 0));
}
- else if(likely(hash == BEGIN_HASH && !strsame(s, "BEGIN"))) {
+ else if(likely(hash == BEGIN_HASH && !strcmp(s, "BEGIN"))) {
char *id = words[1];
char *microseconds_txt = words[2];
else rrdset_next(st);
}
}
- else if(likely(hash == END_HASH && !strsame(s, "END"))) {
+ else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
if(unlikely(!st)) {
error("PLUGINSD: '%s' is requesting an END, without a BEGIN. Disabling it.", cd->fullfilename);
cd->enabled = 0;
count++;
}
- else if(likely(hash == FLUSH_HASH && !strsame(s, "FLUSH"))) {
+ else if(likely(hash == FLUSH_HASH && !strcmp(s, "FLUSH"))) {
debug(D_PLUGINSD, "PLUGINSD: '%s' is requesting a FLUSH", cd->fullfilename);
st = NULL;
}
- else if(likely(hash == CHART_HASH && !strsame(s, "CHART"))) {
+ else if(likely(hash == CHART_HASH && !strcmp(s, "CHART"))) {
int noname = 0;
st = NULL;
- if((words[1]) != NULL && (words[2]) != NULL && strsame(words[1], words[2]) == 0)
+ if((words[1]) != NULL && (words[2]) != NULL && strcmp(words[1], words[2]) == 0)
noname = 1;
char *type = words[1];
}
else debug(D_PLUGINSD, "PLUGINSD: Chart '%s' already exists. Not adding it again.", st->id);
}
- else if(likely(hash == DIMENSION_HASH && !strsame(s, "DIMENSION"))) {
+ else if(likely(hash == DIMENSION_HASH && !strcmp(s, "DIMENSION"))) {
char *id = words[1];
char *name = words[2];
char *algorithm = words[3];
}
else if(unlikely(st->debug)) debug(D_PLUGINSD, "PLUGINSD: dimension %s/%s already exists. Not adding it again.", st->id, id);
}
- else if(unlikely(hash == DISABLE_HASH && !strsame(s, "DISABLE"))) {
+ else if(unlikely(hash == DISABLE_HASH && !strcmp(s, "DISABLE"))) {
info("PLUGINSD: '%s' called DISABLE. Disabling it.", cd->fullfilename);
cd->enabled = 0;
killpid(cd->pid, SIGTERM);
break;
}
#ifdef DETACH_PLUGINS_FROM_NETDATA
- else if(likely(hash == MYPID_HASH && !strsame(s, "MYPID"))) {
+ else if(likely(hash == MYPID_HASH && !strcmp(s, "MYPID"))) {
char *pid_s = words[1];
pid_t pid = strtod(pid_s, NULL, 0);
if(likely(pid)) cd->pid = pid;
debug(D_PLUGINSD, "PLUGINSD: %s is on pid %d", cd->id, cd->pid);
}
- else if(likely(hash == STOPPING_WAKE_ME_UP_PLEASE_HASH && !strsame(s, "STOPPING_WAKE_ME_UP_PLEASE"))) {
+ else if(likely(hash == STOPPING_WAKE_ME_UP_PLEASE_HASH && !strcmp(s, "STOPPING_WAKE_ME_UP_PLEASE"))) {
error("PLUGINSD: '%s' (pid %d) called STOPPING_WAKE_ME_UP_PLEASE.", cd->fullfilename, cd->pid);
now_realtime_timeval(&now);
debug(D_PLUGINSD, "PLUGINSD: Examining file '%s'", file->d_name);
- if(unlikely(strsame(file->d_name, ".") == 0 || strsame(file->d_name, "..") == 0)) continue;
+ if(unlikely(strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0)) continue;
int len = (int) strlen(file->d_name);
if(unlikely(len <= (int)PLUGINSD_FILE_SUFFIX_LEN)) continue;
- if(unlikely(strsame(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) {
+ if(unlikely(strcmp(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) {
debug(D_PLUGINSD, "PLUGINSD: File '%s' does not end in '%s'.", file->d_name, PLUGINSD_FILE_SUFFIX);
continue;
}
// check if it runs already
for(cd = pluginsd_root ; cd ; cd = cd->next)
- if(unlikely(strsame(cd->filename, file->d_name) == 0)) break;
+ if(unlikely(strcmp(cd->filename, file->d_name) == 0)) break;
if(likely(cd && !cd->obsolete)) {
debug(D_PLUGINSD, "PLUGINSD: plugin '%s' is already running", cd->filename);
struct dirent *dp;
while( (dp = readdir(dirp)) ) {
// . and .. are also files in empty folders.
- if(unlikely(strsame(dp->d_name, ".") == 0 || strsame(dp->d_name, "..") == 0)) {
+ if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
continue;
}
// search it, from the last position to the end
for(d = last ; d ; d = d->next) {
- if(unlikely(hash == d->hash && !strsame(name, d->name))) {
+ if(unlikely(hash == d->hash && !strcmp(name, d->name))) {
last = d->next;
return d;
}
// search it from the beginning to the last position we used
for(d = netdev_root ; d != last ; d = d->next) {
- if(unlikely(hash == d->hash && !strsame(name, d->name))) {
+ if(unlikely(hash == d->hash && !strcmp(name, d->name))) {
last = d->next;
return d;
}
char *key = procfile_lineword(ff, l, 0);
uint32_t hash = simple_hash(key);
- if(unlikely(hash == hash_ipext && strsame(key, "IpExt") == 0)) {
+ if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) {
size_t h = l++;
words = procfile_linewords(ff, l);
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_tcpext && strsame(key, "TcpExt") == 0)) {
+ else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) {
size_t h = l++;
words = procfile_linewords(ff, l);
if(do_proc4 == -1) do_proc4 = config_get_boolean("plugin:proc:/proc/net/rpc/nfs", "NFS v4 procedures", 1);
// if they are enabled, reset them to 1
- // later we do them =2 to avoid doing strsame() for all lines
+ // later we do them =2 to avoid doing strcmp() for all lines
if(do_net) do_net = 1;
if(do_rpc) do_rpc = 1;
if(do_proc2) do_proc2 = 1;
type = procfile_lineword(ff, l, 0);
- if(do_net == 1 && strsame(type, "net") == 0) {
+ if(do_net == 1 && strcmp(type, "net") == 0) {
if(words < 5) {
error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 5);
continue;
if(sum == 0ULL) do_net = -1;
else do_net = 2;
}
- else if(do_rpc == 1 && strsame(type, "rpc") == 0) {
+ else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
if(words < 4) {
error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 6);
continue;
if(sum == 0ULL) do_rpc = -1;
else do_rpc = 2;
}
- else if(do_proc2 == 1 && strsame(type, "proc2") == 0) {
+ else if(do_proc2 == 1 && strcmp(type, "proc2") == 0) {
// the first number is the count of numbers present
// so we start for word 2
}
else do_proc2 = 2;
}
- else if(do_proc3 == 1 && strsame(type, "proc3") == 0) {
+ else if(do_proc3 == 1 && strcmp(type, "proc3") == 0) {
// the first number is the count of numbers present
// so we start for word 2
}
else do_proc3 = 2;
}
- else if(do_proc4 == 1 && strsame(type, "proc4") == 0) {
+ else if(do_proc4 == 1 && strcmp(type, "proc4") == 0) {
// the first number is the count of numbers present
// so we start for word 2
if(do_proc4ops == -1) do_proc4ops = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v4 operations", 1);
// if they are enabled, reset them to 1
- // later we do them =2 to avoid doing strsame() for all lines
+ // later we do them =2 to avoid doing strcmp() for all lines
if(do_rc) do_rc = 1;
if(do_fh) do_fh = 1;
if(do_io) do_io = 1;
type = procfile_lineword(ff, l, 0);
- if(do_rc == 1 && strsame(type, "rc") == 0) {
+ if(do_rc == 1 && strcmp(type, "rc") == 0) {
if(words < 4) {
error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 4);
continue;
if(sum == 0ULL) do_rc = -1;
else do_rc = 2;
}
- else if(do_fh == 1 && strsame(type, "fh") == 0) {
+ else if(do_fh == 1 && strcmp(type, "fh") == 0) {
if(words < 6) {
error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 6);
continue;
if(sum == 0ULL) do_fh = -1;
else do_fh = 2;
}
- else if(do_io == 1 && strsame(type, "io") == 0) {
+ else if(do_io == 1 && strcmp(type, "io") == 0) {
if(words < 3) {
error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 3);
continue;
if(sum == 0ULL) do_io = -1;
else do_io = 2;
}
- else if(do_th == 1 && strsame(type, "th") == 0) {
+ else if(do_th == 1 && strcmp(type, "th") == 0) {
if(words < 13) {
error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 13);
continue;
}
else do_th = 2;
}
- else if(do_ra == 1 && strsame(type, "ra") == 0) {
+ else if(do_ra == 1 && strcmp(type, "ra") == 0) {
if(words < 13) {
error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 13);
continue;
}
else do_ra = 2;
}
- else if(do_net == 1 && strsame(type, "net") == 0) {
+ else if(do_net == 1 && strcmp(type, "net") == 0) {
if(words < 5) {
error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 5);
continue;
if(sum == 0ULL) do_net = -1;
else do_net = 2;
}
- else if(do_rpc == 1 && strsame(type, "rpc") == 0) {
+ else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
if(words < 6) {
error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 6);
continue;
if(sum == 0ULL) do_rpc = -1;
else do_rpc = 2;
}
- else if(do_proc2 == 1 && strsame(type, "proc2") == 0) {
+ else if(do_proc2 == 1 && strcmp(type, "proc2") == 0) {
// the first number is the count of numbers present
// so we start for word 2
}
else do_proc2 = 2;
}
- else if(do_proc3 == 1 && strsame(type, "proc3") == 0) {
+ else if(do_proc3 == 1 && strcmp(type, "proc3") == 0) {
// the first number is the count of numbers present
// so we start for word 2
}
else do_proc3 = 2;
}
- else if(do_proc4 == 1 && strsame(type, "proc4") == 0) {
+ else if(do_proc4 == 1 && strcmp(type, "proc4") == 0) {
// the first number is the count of numbers present
// so we start for word 2
}
else do_proc4 = 2;
}
- else if(do_proc4ops == 1 && strsame(type, "proc4ops") == 0) {
+ else if(do_proc4ops == 1 && strcmp(type, "proc4ops") == 0) {
// the first number is the count of numbers present
// so we start for word 2
uint32_t i, hash = simple_hash(name);
for(i = 0; nc[i].name ;i++)
- if(unlikely(nc[i].hash == hash && !strsame(nc[i].name, name)))
+ if(unlikely(nc[i].hash == hash && !strcmp(nc[i].name, name)))
return &nc[i].value;
fatal("Cannot find key '%s' in /proc/net/snmp internal array.", name);
uint32_t hash = simple_hash(key);
for(i = 0 ; nc[i].name ;i++) {
- if(unlikely(hash == nc[i].hash && !strsame(key, nc[i].name))) {
+ if(unlikely(hash == nc[i].hash && !strcmp(key, nc[i].name))) {
nc[i].value = str2ull(procfile_lineword(ff, values_line, w));
break;
}
char *key = procfile_lineword(ff, l, 0);
uint32_t hash = simple_hash(key);
- if(unlikely(hash == hash_ip && strsame(key, "Ip") == 0)) {
+ if(unlikely(hash == hash_ip && strcmp(key, "Ip") == 0)) {
size_t h = l++;
- if(strsame(procfile_lineword(ff, l, 0), "Ip") != 0) {
+ if(strcmp(procfile_lineword(ff, l, 0), "Ip") != 0) {
error("Cannot read Ip line from /proc/net/snmp.");
break;
}
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_icmp && strsame(key, "Icmp") == 0)) {
+ else if(unlikely(hash == hash_icmp && strcmp(key, "Icmp") == 0)) {
size_t h = l++;
- if(strsame(procfile_lineword(ff, l, 0), "Icmp") != 0) {
+ if(strcmp(procfile_lineword(ff, l, 0), "Icmp") != 0) {
error("Cannot read Icmp line from /proc/net/snmp.");
break;
}
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_icmpmsg && strsame(key, "IcmpMsg") == 0)) {
+ else if(unlikely(hash == hash_icmpmsg && strcmp(key, "IcmpMsg") == 0)) {
size_t h = l++;
- if(strsame(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) {
+ if(strcmp(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) {
error("Cannot read IcmpMsg line from /proc/net/snmp.");
break;
}
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_tcp && strsame(key, "Tcp") == 0)) {
+ else if(unlikely(hash == hash_tcp && strcmp(key, "Tcp") == 0)) {
size_t h = l++;
- if(strsame(procfile_lineword(ff, l, 0), "Tcp") != 0) {
+ if(strcmp(procfile_lineword(ff, l, 0), "Tcp") != 0) {
error("Cannot read Tcp line from /proc/net/snmp.");
break;
}
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_udp && strsame(key, "Udp") == 0)) {
+ else if(unlikely(hash == hash_udp && strcmp(key, "Udp") == 0)) {
size_t h = l++;
- if(strsame(procfile_lineword(ff, l, 0), "Udp") != 0) {
+ if(strcmp(procfile_lineword(ff, l, 0), "Udp") != 0) {
error("Cannot read Udp line from /proc/net/snmp.");
break;
}
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_udplite && strsame(key, "UdpLite") == 0)) {
+ else if(unlikely(hash == hash_udplite && strcmp(key, "UdpLite") == 0)) {
size_t h = l++;
- if(strsame(procfile_lineword(ff, l, 0), "UdpLite") != 0) {
+ if(strcmp(procfile_lineword(ff, l, 0), "UdpLite") != 0) {
error("Cannot read UdpLite line from /proc/net/snmp.");
break;
}
(strchr (Fs_name, ':') != NULL \
|| ((Fs_name)[0] == '/' \
&& (Fs_name)[1] == '/' \
- && (strsame (Fs_type, "smbfs") == 0 \
- || strsame (Fs_type, "cifs") == 0)) \
- || (strsame("-hosts", Fs_name) == 0))
+ && (strcmp (Fs_type, "smbfs") == 0 \
+ || strcmp (Fs_type, "cifs") == 0)) \
+ || (strcmp("-hosts", Fs_name) == 0))
#endif
#define ME_DUMMY_0(Fs_name, Fs_type) \
- (strsame (Fs_type, "autofs") == 0 \
- || strsame (Fs_type, "proc") == 0 \
- || strsame (Fs_type, "subfs") == 0 \
+ (strcmp (Fs_type, "autofs") == 0 \
+ || strcmp (Fs_type, "proc") == 0 \
+ || strcmp (Fs_type, "subfs") == 0 \
/* for Linux 2.6/3.x */ \
- || strsame (Fs_type, "debugfs") == 0 \
- || strsame (Fs_type, "devpts") == 0 \
- || strsame (Fs_type, "fusectl") == 0 \
- || strsame (Fs_type, "mqueue") == 0 \
- || strsame (Fs_type, "rpc_pipefs") == 0 \
- || strsame (Fs_type, "sysfs") == 0 \
+ || strcmp (Fs_type, "debugfs") == 0 \
+ || strcmp (Fs_type, "devpts") == 0 \
+ || strcmp (Fs_type, "fusectl") == 0 \
+ || strcmp (Fs_type, "mqueue") == 0 \
+ || strcmp (Fs_type, "rpc_pipefs") == 0 \
+ || strcmp (Fs_type, "sysfs") == 0 \
/* FreeBSD, Linux 2.4 */ \
- || strsame (Fs_type, "devfs") == 0 \
+ || strcmp (Fs_type, "devfs") == 0 \
/* for NetBSD 3.0 */ \
- || strsame (Fs_type, "kernfs") == 0 \
+ || strcmp (Fs_type, "kernfs") == 0 \
/* for Irix 6.5 */ \
- || strsame (Fs_type, "ignore") == 0)
+ || strcmp (Fs_type, "ignore") == 0)
/* Historically, we have marked as "dummy" any file system of type "none",
but now that programs like du need to know about bind-mounted directories,
we grant an exception to any with "bind" in its list of mount options.
I.e., those are *not* dummy entries. */
# define ME_DUMMY(Fs_name, Fs_type) \
- (ME_DUMMY_0 (Fs_name, Fs_type) || strsame (Fs_type, "none") == 0)
+ (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
// ----------------------------------------------------------------------------
&& mi->mount_source
&& mi->filesystem_hash == filesystem_hash
&& mi->mount_source_hash == mount_source_hash
- && !strsame(mi->filesystem, filesystem)
- && !strsame(mi->mount_source, mount_source)))
+ && !strcmp(mi->filesystem, filesystem)
+ && !strcmp(mi->mount_source, mount_source)))
return mi;
return NULL;
if(unlikely(mi->filesystem
&& mi->super_options
&& mi->filesystem_hash == filesystem_hash
- && !strsame(mi->filesystem, filesystem))) {
+ && !strcmp(mi->filesystem, filesystem))) {
// super_options is a comma separated list
char *s = mi->super_options, *e;
size_t len = strlen(s);
if(len < 2) return 0;
if(len == 2) {
- if(!strsame(s, "ro")) return 1;
+ if(!strcmp(s, "ro")) return 1;
return 0;
}
if(!strncmp(s, "ro,", 3)) return 1;
if(unlikely(bind)) {
struct mountinfo *mi;
for(mi = root; mi ; mi = mi->next) {
- if(unlikely(strsame(mnt->mnt_dir, mi->mount_point) == 0)) {
+ if(unlikely(strcmp(mnt->mnt_dir, mi->mount_point) == 0)) {
fprintf(stderr, "Mount point '%s' is BIND\n", mi->mount_point);
mi->flags |= MOUNTINFO_IS_BIND;
break;
long priority;
int isthistotal;
- if(unlikely(strsame(id, "cpu")) == 0) {
+ if(unlikely(strcmp(id, "cpu")) == 0) {
title = "Total CPU utilization";
type = "system";
context = "system.cpu";
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_intr && strsame(row_key, "intr") == 0)) {
+ else if(unlikely(hash == hash_intr && strcmp(row_key, "intr") == 0)) {
unsigned long long value = str2ull(procfile_lineword(ff, l, 1));
// --------------------------------------------------------------------
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_ctxt && strsame(row_key, "ctxt") == 0)) {
+ else if(unlikely(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0)) {
unsigned long long value = str2ull(procfile_lineword(ff, l, 1));
// --------------------------------------------------------------------
rrdset_done(st);
}
}
- else if(unlikely(hash == hash_processes && !processes && strsame(row_key, "processes") == 0)) {
+ else if(unlikely(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0)) {
processes = str2ull(procfile_lineword(ff, l, 1));
}
- else if(unlikely(hash == hash_procs_running && !running && strsame(row_key, "procs_running") == 0)) {
+ else if(unlikely(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0)) {
running = str2ull(procfile_lineword(ff, l, 1));
}
- else if(unlikely(hash == hash_procs_blocked && !blocked && strsame(row_key, "procs_blocked") == 0)) {
+ else if(unlikely(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0)) {
blocked = str2ull(procfile_lineword(ff, l, 1));
}
}
return 200;
}
- if(unlikely(person_guid[0] && !strsame(person_guid, REGISTRY_VERIFY_COOKIES_GUID)))
+ if(unlikely(person_guid[0] && !strcmp(person_guid, REGISTRY_VERIFY_COOKIES_GUID)))
person_guid[0] = '\0';
// ------------------------------------------------------------------------
uuid_unparse_lower(uuid, result);
#ifdef NETDATA_INTERNAL_CHECKS
- if(strsame(guid, result))
+ if(strcmp(guid, result))
info("Registry: source GUID '%s' and re-generated GUID '%s' differ!", guid, result);
#endif /* NETDATA_INTERNAL_CHECKS */
}
delete_url = registry_fix_url(delete_url, NULL);
// make sure the user is not deleting the url it uses
- if(!strsame(delete_url, pu->url->url)) {
+ if(!strcmp(delete_url, pu->url->url)) {
info("Registry Delete Request: delete URL is the one currently accessed, person: '%s', machine '%s', url '%s', delete url '%s'"
, p->guid, m->guid, pu->url->url, delete_url);
return NULL;
// we blacklist them here, so that the next version of netdata will generate
// new ones.
- if(!strsame(guid, "8a795b0c-2311-11e6-8563-000c295076a6")
- || !strsame(guid, "4aed1458-1c3e-11e6-a53f-000c290fc8f5")
+ if(!strcmp(guid, "8a795b0c-2311-11e6-8563-000c295076a6")
+ || !strcmp(guid, "4aed1458-1c3e-11e6-a53f-000c290fc8f5")
) {
error("Blacklisted machine GUID '%s' found.", guid);
return 1;
if(hash1 < hash2) return -1;
else if(hash1 > hash2) return 1;
- else return strsame(((REGISTRY_PERSON_URL *)a)->url->url, ((REGISTRY_PERSON_URL *)b)->url->url);
+ else return strcmp(((REGISTRY_PERSON_URL *)a)->url->url, ((REGISTRY_PERSON_URL *)b)->url->url);
}
inline REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, const char *url) {
pu->machine = m;
}
- if(strsame(pu->machine_name, name)) {
+ if(strcmp(pu->machine_name, name)) {
// the name of the PERSON_URL has changed !
pu = registry_person_url_reallocate(p, m, u, name, namelen, when, pu);
}
int registry_url_compare(void *a, void *b) {
if(((REGISTRY_URL *)a)->hash < ((REGISTRY_URL *)b)->hash) return -1;
else if(((REGISTRY_URL *)a)->hash > ((REGISTRY_URL *)b)->hash) return 1;
- else return strsame(((REGISTRY_URL *)a)->url, ((REGISTRY_URL *)b)->url);
+ else return strcmp(((REGISTRY_URL *)a)->url, ((REGISTRY_URL *)b)->url);
}
inline REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) {
static int rrdfamily_compare(void *a, void *b) {
if(((RRDFAMILY *)a)->hash_family < ((RRDFAMILY *)b)->hash_family) return -1;
else if(((RRDFAMILY *)a)->hash_family > ((RRDFAMILY *)b)->hash_family) return 1;
- else return strsame(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
+ else return strcmp(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
}
#define rrdfamily_index_add(host, rc) (RRDFAMILY *)avl_insert_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
static int rrdset_compare(void* a, void* b) {
if(((RRDSET *)a)->hash < ((RRDSET *)b)->hash) return -1;
else if(((RRDSET *)a)->hash > ((RRDSET *)b)->hash) return 1;
- else return strsame(((RRDSET *)a)->id, ((RRDSET *)b)->id);
+ else return strcmp(((RRDSET *)a)->id, ((RRDSET *)b)->id);
}
#define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl *)(st))
if(A->hash_name < B->hash_name) return -1;
else if(A->hash_name > B->hash_name) return 1;
- else return strsame(A->name, B->name);
+ else return strcmp(A->name, B->name);
}
RRDSET *rrdset_index_add_name(RRDHOST *host, RRDSET *st) {
result = avl_search_lock(&host->rrdset_root_index_name, (avl *) (&(tmp.avlname)));
if(result) {
RRDSET *st = rrdset_from_avlname(result);
- if(strsame(st->magic, RRDSET_MAGIC))
+ if(strcmp(st->magic, RRDSET_MAGIC))
error("Search for RRDSET %s returned an invalid RRDSET %s (name %s)", name, st->id, st->name);
// fprintf(stderr, "FOUND: %s\n", name);
static int rrddim_compare(void* a, void* b) {
if(((RRDDIM *)a)->hash < ((RRDDIM *)b)->hash) return -1;
else if(((RRDDIM *)a)->hash > ((RRDDIM *)b)->hash) return 1;
- else return strsame(((RRDDIM *)a)->id, ((RRDDIM *)b)->id);
+ else return strcmp(((RRDDIM *)a)->id, ((RRDDIM *)b)->id);
}
#define rrddim_index_add(st, rd) (RRDDIM *)avl_insert_lock(&((st)->dimensions_index), (avl *)(rd))
int rrdset_type_id(const char *name)
{
- if(unlikely(strsame(name, RRDSET_TYPE_AREA_NAME) == 0)) return RRDSET_TYPE_AREA;
- else if(unlikely(strsame(name, RRDSET_TYPE_STACKED_NAME) == 0)) return RRDSET_TYPE_STACKED;
- else if(unlikely(strsame(name, RRDSET_TYPE_LINE_NAME) == 0)) return RRDSET_TYPE_LINE;
+ if(unlikely(strcmp(name, RRDSET_TYPE_AREA_NAME) == 0)) return RRDSET_TYPE_AREA;
+ else if(unlikely(strcmp(name, RRDSET_TYPE_STACKED_NAME) == 0)) return RRDSET_TYPE_STACKED;
+ else if(unlikely(strcmp(name, RRDSET_TYPE_LINE_NAME) == 0)) return RRDSET_TYPE_LINE;
return RRDSET_TYPE_LINE;
}
int rrd_memory_mode_id(const char *name)
{
- if(unlikely(!strsame(name, RRD_MEMORY_MODE_RAM_NAME)))
+ if(unlikely(!strcmp(name, RRD_MEMORY_MODE_RAM_NAME)))
return RRD_MEMORY_MODE_RAM;
- else if(unlikely(!strsame(name, RRD_MEMORY_MODE_MAP_NAME)))
+ else if(unlikely(!strcmp(name, RRD_MEMORY_MODE_MAP_NAME)))
return RRD_MEMORY_MODE_MAP;
return RRD_MEMORY_MODE_SAVE;
int rrddim_algorithm_id(const char *name)
{
- if(strsame(name, RRDDIM_INCREMENTAL_NAME) == 0) return RRDDIM_INCREMENTAL;
- if(strsame(name, RRDDIM_ABSOLUTE_NAME) == 0) return RRDDIM_ABSOLUTE;
- if(strsame(name, RRDDIM_PCENT_OVER_ROW_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_ROW_TOTAL;
- if(strsame(name, RRDDIM_PCENT_OVER_DIFF_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_DIFF_TOTAL;
+ if(strcmp(name, RRDDIM_INCREMENTAL_NAME) == 0) return RRDDIM_INCREMENTAL;
+ if(strcmp(name, RRDDIM_ABSOLUTE_NAME) == 0) return RRDDIM_ABSOLUTE;
+ if(strcmp(name, RRDDIM_PCENT_OVER_ROW_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_ROW_TOTAL;
+ if(strcmp(name, RRDDIM_PCENT_OVER_DIFF_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_DIFF_TOTAL;
return RRDDIM_ABSOLUTE;
}
void rrdset_set_name(RRDSET *st, const char *name)
{
- if(unlikely(st->name && !strsame(st->name, name)))
+ if(unlikely(st->name && !strcmp(st->name, name)))
return;
debug(D_RRD_CALLS, "rrdset_set_name() old: %s, new: %s", st->name, name);
snprintfz(fullfilename, FILENAME_MAX, "%s/main.db", cache_dir);
if(rrd_memory_mode != RRD_MEMORY_MODE_RAM) st = (RRDSET *)mymmap(fullfilename, size, ((rrd_memory_mode == RRD_MEMORY_MODE_MAP)?MAP_SHARED:MAP_PRIVATE), 0);
if(st) {
- if(strsame(st->magic, RRDSET_MAGIC) != 0) {
+ if(strcmp(st->magic, RRDSET_MAGIC) != 0) {
errno = 0;
info("Initializing file %s.", fullfilename);
memset(st, 0, size);
}
- else if(strsame(st->id, fullid) != 0) {
+ else if(strcmp(st->id, fullid) != 0) {
errno = 0;
error("File %s contents are not for chart %s. Clearing it.", fullfilename, fullid);
// munmap(st, size);
st->isdetail = 0;
st->debug = 0;
- // if(!strsame(st->id, "disk_util.dm-0")) {
+ // if(!strcmp(st->id, "disk_util.dm-0")) {
// st->debug = 1;
// error("enabled debugging for '%s'", st->id);
// }
struct timeval now;
now_realtime_timeval(&now);
- if(strsame(rd->magic, RRDDIMENSION_MAGIC) != 0) {
+ if(strcmp(rd->magic, RRDDIMENSION_MAGIC) != 0) {
errno = 0;
info("Initializing file %s.", fullfilename);
memset(rd, 0, size);
error("File %s is too old. Clearing it.", fullfilename);
memset(rd, 0, size);
}
- else if(strsame(rd->id, id) != 0) {
+ else if(strcmp(rd->id, id) != 0) {
errno = 0;
error("File %s contents are not for dimension %s. Clearing it.", fullfilename, id);
// munmap(rd, size);
void rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name)
{
- if(unlikely(rd->name && !strsame(rd->name, name)))
+ if(unlikely(rd->name && !strcmp(rd->name, name)))
return;
debug(D_RRD_CALLS, "rrddim_set_name() from %s.%s to %s.%s", st->name, rd->name, st->name, name);
// find it and enable it
for(c = 0, d = r->st->dimensions; d ;c++, d = d->next) {
- if(unlikely((hash == d->hash && !strsame(d->id, tok)) || !strsame(d->name, tok))) {
+ if(unlikely((hash == d->hash && !strcmp(d->id, tok)) || !strcmp(d->name, tok))) {
r->od[c] &= ~RRDR_HIDDEN;
// since the user needs this dimension
break;
case SIMPLE_PATTERN_SUFFIX:
- if(unlikely(strsame(&str[len - m->len], m->match) == 0)) {
+ if(unlikely(strcmp(&str[len - m->len], m->match) == 0)) {
if(!m->child) return 1;
return 0;
}
case SIMPLE_PATTERN_EXACT:
default:
- if(unlikely(strsame(str, m->match) == 0)) {
+ if(unlikely(strcmp(str, m->match) == 0)) {
if(!m->child) return 1;
return 0;
}
char *s = procfile_lineword(ff, i, 0);
uint32_t hash = simple_hash(s);
- if(unlikely(hash == user_hash && !strsame(s, "user")))
+ if(unlikely(hash == user_hash && !strcmp(s, "user")))
cp->user = str2ull(procfile_lineword(ff, i, 1));
- else if(unlikely(hash == system_hash && !strsame(s, "system")))
+ else if(unlikely(hash == system_hash && !strcmp(s, "system")))
cp->system = str2ull(procfile_lineword(ff, i, 1));
}
char *s = procfile_lineword(ff, i, 1);
uint32_t hash = simple_hash(s);
- if(unlikely(hash == Read_hash && !strsame(s, "Read")))
+ if(unlikely(hash == Read_hash && !strcmp(s, "Read")))
io->Read += str2ull(procfile_lineword(ff, i, 2));
- else if(unlikely(hash == Write_hash && !strsame(s, "Write")))
+ else if(unlikely(hash == Write_hash && !strcmp(s, "Write")))
io->Write += str2ull(procfile_lineword(ff, i, 2));
/*
- else if(unlikely(hash == Sync_hash && !strsame(s, "Sync")))
+ else if(unlikely(hash == Sync_hash && !strcmp(s, "Sync")))
io->Sync += str2ull(procfile_lineword(ff, i, 2));
- else if(unlikely(hash == Async_hash && !strsame(s, "Async")))
+ else if(unlikely(hash == Async_hash && !strcmp(s, "Async")))
io->Async += str2ull(procfile_lineword(ff, i, 2));
- else if(unlikely(hash == Total_hash && !strsame(s, "Total")))
+ else if(unlikely(hash == Total_hash && !strcmp(s, "Total")))
io->Total += str2ull(procfile_lineword(ff, i, 2));
*/
}
if(cg->enabled) {
struct cgroup *t;
for (t = cgroup_root; t; t = t->next) {
- if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strsame(t->chart_id, cg->chart_id)) {
+ if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
if (!strncmp(t->chart_id, "/system.slice/", 14) && !strncmp(cg->chart_id, "/init.scope/system.slice/", 25)) {
error("Control group with chart id '%s' already exists with id '%s' and is enabled. Swapping them by enabling cgroup with id '%s' and disabling cgroup with id '%s'.",
cg->chart_id, t->id, cg->id, t->id);
struct cgroup *cg;
for(cg = cgroup_root; cg ; cg = cg->next) {
- if(hash == cg->hash && strsame(id, cg->id) == 0)
+ if(hash == cg->hash && strcmp(id, cg->id) == 0)
break;
}
{
struct cgroup *t;
for(t = cgroup_root; t ; t = t->next) {
- if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strsame(t->chart_id, cg->chart_id)) {
+ if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
debug(D_CGROUP, "Enabling duplicate of cgroup '%s' with id '%s', because the original with id '%s' stopped.", t->chart_id, t->id, cg->id);
t->enabled = 1;
t->options &= ~CGROUP_OPTIONS_DISABLED_DUPLICATE;
b->len = b->size;
}
- if(b->buffer[b->size] != '\0' || strsame(&b->buffer[b->size + 1], BUFFER_OVERFLOW_EOF)) {
+ if(b->buffer[b->size] != '\0' || strcmp(&b->buffer[b->size + 1], BUFFER_OVERFLOW_EOF)) {
error("BUFFER: detected overflow at line %lu, at function %s() of file '%s'.", line, function, file);
buffer_overflow_init(b);
}
}
static inline const char *fix_units(const char *units) {
- if(!units || !*units || !strsame(units, "empty") || !strsame(units, "null")) return "";
- if(!strsame(units, "percentage") || !strsame(units, "percent") || !strsame(units, "pcent")) return "%";
+ if(!units || !*units || !strcmp(units, "empty") || !strcmp(units, "null")) return "";
+ if(!strcmp(units, "percentage") || !strcmp(units, "percent") || !strcmp(units, "pcent")) return "%";
return units;
}
static inline const char *color_map(const char *color) {
// colors from:
// https://github.com/badges/shields/blob/master/colorscheme.json
- if(!strsame(color, "brightgreen")) return "#4c1";
- else if(!strsame(color, "green")) return "#97CA00";
- else if(!strsame(color, "yellow")) return "#dfb317";
- else if(!strsame(color, "yellowgreen")) return "#a4a61d";
- else if(!strsame(color, "orange")) return "#fe7d37";
- else if(!strsame(color, "red")) return "#e05d44";
- else if(!strsame(color, "blue")) return "#007ec6";
- else if(!strsame(color, "grey")) return "#555";
- else if(!strsame(color, "gray")) return "#555";
- else if(!strsame(color, "lightgrey")) return "#9f9f9f";
- else if(!strsame(color, "lightgray")) return "#9f9f9f";
+ if(!strcmp(color, "brightgreen")) return "#4c1";
+ else if(!strcmp(color, "green")) return "#97CA00";
+ else if(!strcmp(color, "yellow")) return "#dfb317";
+ else if(!strcmp(color, "yellowgreen")) return "#a4a61d";
+ else if(!strcmp(color, "orange")) return "#fe7d37";
+ else if(!strcmp(color, "red")) return "#e05d44";
+ else if(!strcmp(color, "blue")) return "#007ec6";
+ else if(!strcmp(color, "grey")) return "#555";
+ else if(!strcmp(color, "gray")) return "#555";
+ else if(!strcmp(color, "lightgrey")) return "#9f9f9f";
+ else if(!strcmp(color, "lightgray")) return "#9f9f9f";
return color;
}
*dv = '\0';
if(value_is_null) {
- if(!*value_buffer || !strsame(value_buffer, "null"))
+ if(!*value_buffer || !strcmp(value_buffer, "null"))
break;
}
else {
if(unlikely(isalnum(*units)))
separator = " ";
- if(unlikely(!strsame(units, "seconds"))) {
+ if(unlikely(!strcmp(units, "seconds"))) {
size_t s = (size_t)value;
size_t d = s / 86400;
s = s % 86400;
snprintfz(value_string, VALUE_STRING_SIZE, "%02zu:%02zu:%02zu", h, m, s);
}
- else if(unlikely(!strsame(units, "minutes"))) {
+ else if(unlikely(!strcmp(units, "minutes"))) {
size_t m = (size_t)value;
size_t d = m / (60 * 24);
m = m % (60 * 24);
snprintfz(value_string, VALUE_STRING_SIZE, "%zuh %zum", h, m);
}
- else if(unlikely(!strsame(units, "hours"))) {
+ else if(unlikely(!strcmp(units, "hours"))) {
size_t h = (size_t)value;
size_t d = h / 24;
h = h % 24;
while(o && *o && (tok = mystrsep(&o, ", |"))) {
if(!*tok) continue;
- if(!strsame(tok, "nonzero"))
+ if(!strcmp(tok, "nonzero"))
ret |= RRDR_OPTION_NONZERO;
- else if(!strsame(tok, "flip") || !strsame(tok, "reversed") || !strsame(tok, "reverse"))
+ else if(!strcmp(tok, "flip") || !strcmp(tok, "reversed") || !strcmp(tok, "reverse"))
ret |= RRDR_OPTION_REVERSED;
- else if(!strsame(tok, "jsonwrap"))
+ else if(!strcmp(tok, "jsonwrap"))
ret |= RRDR_OPTION_JSON_WRAP;
- else if(!strsame(tok, "min2max"))
+ else if(!strcmp(tok, "min2max"))
ret |= RRDR_OPTION_MIN2MAX;
- else if(!strsame(tok, "ms") || !strsame(tok, "milliseconds"))
+ else if(!strcmp(tok, "ms") || !strcmp(tok, "milliseconds"))
ret |= RRDR_OPTION_MILLISECONDS;
- else if(!strsame(tok, "abs") || !strsame(tok, "absolute") || !strsame(tok, "absolute_sum") || !strsame(tok, "absolute-sum"))
+ else if(!strcmp(tok, "abs") || !strcmp(tok, "absolute") || !strcmp(tok, "absolute_sum") || !strcmp(tok, "absolute-sum"))
ret |= RRDR_OPTION_ABSOLUTE;
- else if(!strsame(tok, "seconds"))
+ else if(!strcmp(tok, "seconds"))
ret |= RRDR_OPTION_SECONDS;
- else if(!strsame(tok, "null2zero"))
+ else if(!strcmp(tok, "null2zero"))
ret |= RRDR_OPTION_NULL2ZERO;
- else if(!strsame(tok, "objectrows"))
+ else if(!strcmp(tok, "objectrows"))
ret |= RRDR_OPTION_OBJECTSROWS;
- else if(!strsame(tok, "google_json"))
+ else if(!strcmp(tok, "google_json"))
ret |= RRDR_OPTION_GOOGLE_JSON;
- else if(!strsame(tok, "percentage"))
+ else if(!strcmp(tok, "percentage"))
ret |= RRDR_OPTION_PERCENTAGE;
- else if(!strsame(tok, "unaligned"))
+ else if(!strcmp(tok, "unaligned"))
ret |= RRDR_OPTION_NOT_ALIGNED;
}
uint32_t web_client_api_request_v1_data_format(char *name)
{
- if(!strsame(name, DATASOURCE_FORMAT_DATATABLE_JSON)) // datatable
+ if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSON)) // datatable
return DATASOURCE_DATATABLE_JSON;
- else if(!strsame(name, DATASOURCE_FORMAT_DATATABLE_JSONP)) // datasource
+ else if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSONP)) // datasource
return DATASOURCE_DATATABLE_JSONP;
- else if(!strsame(name, DATASOURCE_FORMAT_JSON)) // json
+ else if(!strcmp(name, DATASOURCE_FORMAT_JSON)) // json
return DATASOURCE_JSON;
- else if(!strsame(name, DATASOURCE_FORMAT_JSONP)) // jsonp
+ else if(!strcmp(name, DATASOURCE_FORMAT_JSONP)) // jsonp
return DATASOURCE_JSONP;
- else if(!strsame(name, DATASOURCE_FORMAT_SSV)) // ssv
+ else if(!strcmp(name, DATASOURCE_FORMAT_SSV)) // ssv
return DATASOURCE_SSV;
- else if(!strsame(name, DATASOURCE_FORMAT_CSV)) // csv
+ else if(!strcmp(name, DATASOURCE_FORMAT_CSV)) // csv
return DATASOURCE_CSV;
- else if(!strsame(name, DATASOURCE_FORMAT_TSV) || !strsame(name, "tsv-excel")) // tsv
+ else if(!strcmp(name, DATASOURCE_FORMAT_TSV) || !strcmp(name, "tsv-excel")) // tsv
return DATASOURCE_TSV;
- else if(!strsame(name, DATASOURCE_FORMAT_HTML)) // html
+ else if(!strcmp(name, DATASOURCE_FORMAT_HTML)) // html
return DATASOURCE_HTML;
- else if(!strsame(name, DATASOURCE_FORMAT_JS_ARRAY)) // array
+ else if(!strcmp(name, DATASOURCE_FORMAT_JS_ARRAY)) // array
return DATASOURCE_JS_ARRAY;
- else if(!strsame(name, DATASOURCE_FORMAT_SSV_COMMA)) // ssvcomma
+ else if(!strcmp(name, DATASOURCE_FORMAT_SSV_COMMA)) // ssvcomma
return DATASOURCE_SSV_COMMA;
- else if(!strsame(name, DATASOURCE_FORMAT_CSV_JSON_ARRAY)) // csvjsonarray
+ else if(!strcmp(name, DATASOURCE_FORMAT_CSV_JSON_ARRAY)) // csvjsonarray
return DATASOURCE_CSV_JSON_ARRAY;
return DATASOURCE_JSON;
uint32_t web_client_api_request_v1_data_google_format(char *name)
{
- if(!strsame(name, "json"))
+ if(!strcmp(name, "json"))
return DATASOURCE_DATATABLE_JSONP;
- else if(!strsame(name, "html"))
+ else if(!strcmp(name, "html"))
return DATASOURCE_HTML;
- else if(!strsame(name, "csv"))
+ else if(!strcmp(name, "csv"))
return DATASOURCE_CSV;
- else if(!strsame(name, "tsv-excel"))
+ else if(!strcmp(name, "tsv-excel"))
return DATASOURCE_TSV;
return DATASOURCE_JSON;
int web_client_api_request_v1_data_group(char *name, int def)
{
- if(!strsame(name, "average"))
+ if(!strcmp(name, "average"))
return GROUP_AVERAGE;
- else if(!strsame(name, "min"))
+ else if(!strcmp(name, "min"))
return GROUP_MIN;
- else if(!strsame(name, "max"))
+ else if(!strcmp(name, "max"))
return GROUP_MAX;
- else if(!strsame(name, "sum"))
+ else if(!strcmp(name, "sum"))
return GROUP_SUM;
- else if(!strsame(name, "incremental-sum"))
+ else if(!strcmp(name, "incremental-sum"))
return GROUP_INCREMENTAL_SUM;
return def;
char *value = mystrsep(&url, "?&");
if (!value || !*value) continue;
- if(!strsame(value, "all")) all = 1;
- else if(!strsame(value, "active")) all = 0;
+ if(!strcmp(value, "all")) all = 1;
+ else if(!strcmp(value, "active")) all = 0;
}
buffer_flush(w->response.data);
if(!name || !*name) continue;
if(!value || !*value) continue;
- if(!strsame(name, "after")) after = strtoul(value, NULL, 0);
+ if(!strcmp(name, "after")) after = strtoul(value, NULL, 0);
}
buffer_flush(w->response.data);
// name and value are now the parameters
// they are not null and not empty
- if(!strsame(name, "chart")) chart = value;
+ if(!strcmp(name, "chart")) chart = value;
//else {
/// buffer_sprintf(w->response.data, "Unknown parameter '%s' in request.", name);
// goto cleanup;
if(!name || !*name) continue;
if(!value || !*value) continue;
- if(!strsame(name, "format")) {
- if(!strsame(value, ALLMETRICS_FORMAT_SHELL))
+ if(!strcmp(name, "format")) {
+ if(!strcmp(value, ALLMETRICS_FORMAT_SHELL))
format = ALLMETRICS_SHELL;
- else if(!strsame(value, ALLMETRICS_FORMAT_PROMETHEUS))
+ else if(!strcmp(value, ALLMETRICS_FORMAT_PROMETHEUS))
format = ALLMETRICS_PROMETHEUS;
else
format = 0;
// name and value are now the parameters
// they are not null and not empty
- if(!strsame(name, "chart")) chart = value;
- else if(!strsame(name, "dimension") || !strsame(name, "dim") || !strsame(name, "dimensions") || !strsame(name, "dims")) {
+ if(!strcmp(name, "chart")) chart = value;
+ else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
if(!dimensions)
dimensions = buffer_create(100);
buffer_strcat(dimensions, "|");
buffer_strcat(dimensions, value);
}
- else if(!strsame(name, "after")) after_str = value;
- else if(!strsame(name, "before")) before_str = value;
- else if(!strsame(name, "points")) points_str = value;
- else if(!strsame(name, "group")) {
+ else if(!strcmp(name, "after")) after_str = value;
+ else if(!strcmp(name, "before")) before_str = value;
+ else if(!strcmp(name, "points")) points_str = value;
+ else if(!strcmp(name, "group")) {
group = web_client_api_request_v1_data_group(value, GROUP_AVERAGE);
}
- else if(!strsame(name, "options")) {
+ else if(!strcmp(name, "options")) {
options |= web_client_api_request_v1_data_options(value);
}
- else if(!strsame(name, "label")) label = value;
- else if(!strsame(name, "units")) units = value;
- else if(!strsame(name, "label_color")) label_color = value;
- else if(!strsame(name, "value_color")) value_color = value;
- else if(!strsame(name, "multiply")) multiply_str = value;
- else if(!strsame(name, "divide")) divide_str = value;
- else if(!strsame(name, "refresh")) refresh_str = value;
- else if(!strsame(name, "precision")) precision_str = value;
- else if(!strsame(name, "alarm")) alarm = value;
+ else if(!strcmp(name, "label")) label = value;
+ else if(!strcmp(name, "units")) units = value;
+ else if(!strcmp(name, "label_color")) label_color = value;
+ else if(!strcmp(name, "value_color")) value_color = value;
+ else if(!strcmp(name, "multiply")) multiply_str = value;
+ else if(!strcmp(name, "divide")) divide_str = value;
+ else if(!strcmp(name, "refresh")) refresh_str = value;
+ else if(!strcmp(name, "precision")) precision_str = value;
+ else if(!strcmp(name, "alarm")) alarm = value;
}
if(!chart || !*chart) {
int refresh = 0;
if(refresh_str && *refresh_str) {
- if(!strsame(refresh_str, "auto")) {
+ if(!strcmp(refresh_str, "auto")) {
if(rc) refresh = rc->update_every;
else if(options & RRDR_OPTION_NOT_ALIGNED)
refresh = st->update_every;
// name and value are now the parameters
// they are not null and not empty
- if(!strsame(name, "chart")) chart = value;
- else if(!strsame(name, "dimension") || !strsame(name, "dim") || !strsame(name, "dimensions") || !strsame(name, "dims")) {
+ if(!strcmp(name, "chart")) chart = value;
+ else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
if(!dimensions) dimensions = buffer_create(100);
buffer_strcat(dimensions, "|");
buffer_strcat(dimensions, value);
}
- else if(!strsame(name, "after")) after_str = value;
- else if(!strsame(name, "before")) before_str = value;
- else if(!strsame(name, "points")) points_str = value;
- else if(!strsame(name, "group")) {
+ else if(!strcmp(name, "after")) after_str = value;
+ else if(!strcmp(name, "before")) before_str = value;
+ else if(!strcmp(name, "points")) points_str = value;
+ else if(!strcmp(name, "group")) {
group = web_client_api_request_v1_data_group(value, GROUP_AVERAGE);
}
- else if(!strsame(name, "format")) {
+ else if(!strcmp(name, "format")) {
format = web_client_api_request_v1_data_format(value);
}
- else if(!strsame(name, "options")) {
+ else if(!strcmp(name, "options")) {
options |= web_client_api_request_v1_data_options(value);
}
- else if(!strsame(name, "callback")) {
+ else if(!strcmp(name, "callback")) {
responseHandler = value;
}
- else if(!strsame(name, "filename")) {
+ else if(!strcmp(name, "filename")) {
outFileName = value;
}
- else if(!strsame(name, "tqx")) {
+ else if(!strcmp(name, "tqx")) {
// parse Google Visualization API options
// https://developers.google.com/chart/interactive/docs/dev/implementing_data_source
char *tqx_name, *tqx_value;
if(!tqx_name || !*tqx_name) continue;
if(!tqx_value || !*tqx_value) continue;
- if(!strsame(tqx_name, "version"))
+ if(!strcmp(tqx_name, "version"))
google_version = tqx_value;
- else if(!strsame(tqx_name, "reqId"))
+ else if(!strcmp(tqx_name, "reqId"))
google_reqId = tqx_value;
- else if(!strsame(tqx_name, "sig")) {
+ else if(!strcmp(tqx_name, "sig")) {
google_sig = tqx_value;
google_timestamp = strtoul(google_sig, NULL, 0);
}
- else if(!strsame(tqx_name, "out")) {
+ else if(!strcmp(tqx_name, "out")) {
google_out = tqx_value;
format = web_client_api_request_v1_data_google_format(google_out);
}
- else if(!strsame(tqx_name, "responseHandler"))
+ else if(!strcmp(tqx_name, "responseHandler"))
responseHandler = tqx_value;
- else if(!strsame(tqx_name, "outFileName"))
+ else if(!strcmp(tqx_name, "outFileName"))
outFileName = tqx_value;
}
}
uint32_t hash = simple_hash(name);
- if(hash == hash_action && !strsame(name, "action")) {
+ if(hash == hash_action && !strcmp(name, "action")) {
uint32_t vhash = simple_hash(value);
- if(vhash == hash_access && !strsame(value, "access")) action = 'A';
- else if(vhash == hash_hello && !strsame(value, "hello")) action = 'H';
- else if(vhash == hash_delete && !strsame(value, "delete")) action = 'D';
- else if(vhash == hash_search && !strsame(value, "search")) action = 'S';
- else if(vhash == hash_switch && !strsame(value, "switch")) action = 'W';
+ if(vhash == hash_access && !strcmp(value, "access")) action = 'A';
+ else if(vhash == hash_hello && !strcmp(value, "hello")) action = 'H';
+ else if(vhash == hash_delete && !strcmp(value, "delete")) action = 'D';
+ else if(vhash == hash_search && !strcmp(value, "search")) action = 'S';
+ else if(vhash == hash_switch && !strcmp(value, "switch")) action = 'W';
#ifdef NETDATA_INTERNAL_CHECKS
else error("unknown registry action '%s'", value);
#endif /* NETDATA_INTERNAL_CHECKS */
}
/*
- else if(hash == hash_redirects && !strsame(name, "redirects"))
+ else if(hash == hash_redirects && !strcmp(name, "redirects"))
redirects = atoi(value);
*/
- else if(hash == hash_machine && !strsame(name, "machine"))
+ else if(hash == hash_machine && !strcmp(name, "machine"))
machine_guid = value;
- else if(hash == hash_url && !strsame(name, "url"))
+ else if(hash == hash_url && !strcmp(name, "url"))
machine_url = value;
else if(action == 'A') {
- if(hash == hash_name && !strsame(name, "name"))
+ if(hash == hash_name && !strcmp(name, "name"))
url_name = value;
}
else if(action == 'D') {
- if(hash == hash_delete_url && !strsame(name, "delete_url"))
+ if(hash == hash_delete_url && !strcmp(name, "delete_url"))
delete_url = value;
}
else if(action == 'S') {
- if(hash == hash_for && !strsame(name, "for"))
+ if(hash == hash_for && !strcmp(name, "for"))
search_machine_guid = value;
}
else if(action == 'W') {
- if(hash == hash_to && !strsame(name, "to"))
+ if(hash == hash_to && !strcmp(name, "to"))
to_person_guid = value;
}
#ifdef NETDATA_INTERNAL_CHECKS
debug(D_WEB_CLIENT, "%llu: Searching for API v1 command '%s'.", w->id, tok);
uint32_t hash = simple_hash(tok);
- if(hash == hash_data && !strsame(tok, "data"))
+ if(hash == hash_data && !strcmp(tok, "data"))
return web_client_api_request_v1_data(w, url);
- else if(hash == hash_chart && !strsame(tok, "chart"))
+ else if(hash == hash_chart && !strcmp(tok, "chart"))
return web_client_api_request_v1_chart(w, url);
- else if(hash == hash_charts && !strsame(tok, "charts"))
+ else if(hash == hash_charts && !strcmp(tok, "charts"))
return web_client_api_request_v1_charts(w, url);
- else if(hash == hash_registry && !strsame(tok, "registry"))
+ else if(hash == hash_registry && !strcmp(tok, "registry"))
return web_client_api_request_v1_registry(w, url);
- else if(hash == hash_badge && !strsame(tok, "badge.svg"))
+ else if(hash == hash_badge && !strcmp(tok, "badge.svg"))
return web_client_api_request_v1_badge(w, url);
- else if(hash == hash_alarms && !strsame(tok, "alarms"))
+ else if(hash == hash_alarms && !strcmp(tok, "alarms"))
return web_client_api_request_v1_alarms(w, url);
- else if(hash == hash_alarm_log && !strsame(tok, "alarm_log"))
+ else if(hash == hash_alarm_log && !strcmp(tok, "alarm_log"))
return web_client_api_request_v1_alarm_log(w, url);
- else if(hash == hash_alarm_variables && !strsame(tok, "alarm_variables"))
+ else if(hash == hash_alarm_variables && !strcmp(tok, "alarm_variables"))
return web_client_api_request_v1_alarm_variables(w, url);
- else if(hash == hash_raw && !strsame(tok, "allmetrics"))
+ else if(hash == hash_raw && !strcmp(tok, "allmetrics"))
return web_client_api_request_v1_allmetrics(w, url);
else {
char *tok = mystrsep(&url, "/?&");
if(tok && *tok) {
debug(D_WEB_CLIENT, "%llu: Searching for API version '%s'.", w->id, tok);
- if(strsame(tok, "v1") == 0)
+ if(strcmp(tok, "v1") == 0)
return web_client_api_request_v1(w, url);
else {
buffer_flush(w->response.data);
// parse the grouping method required
tok = mystrsep(&url, "/");
if(tok && *tok) {
- if(strsame(tok, "max") == 0) group_method = GROUP_MAX;
- else if(strsame(tok, "average") == 0) group_method = GROUP_AVERAGE;
- else if(strsame(tok, "sum") == 0) group_method = GROUP_SUM;
+ if(strcmp(tok, "max") == 0) group_method = GROUP_MAX;
+ else if(strcmp(tok, "average") == 0) group_method = GROUP_AVERAGE;
+ else if(strcmp(tok, "sum") == 0) group_method = GROUP_SUM;
else debug(D_WEB_CLIENT, "%llu: Unknown group method '%s'", w->id, tok);
}
}
if(url) {
// parse nonzero
tok = mystrsep(&url, "/");
- if(tok && *tok && strsame(tok, "nonzero") == 0) nonzero = 1;
+ if(tok && *tok && strcmp(tok, "nonzero") == 0) nonzero = 1;
}
w->response.data->contenttype = CT_APPLICATION_JSON;
tok = mystrsep(&args, "&");
if(tok && *tok) {
char *name = mystrsep(&tok, "=");
- if(name && *name && strsame(name, "tqx") == 0) {
+ if(name && *name && strcmp(name, "tqx") == 0) {
char *key = mystrsep(&tok, ":");
char *value = mystrsep(&tok, ";");
if(key && value && *key && *value) {
- if(strsame(key, "version") == 0)
+ if(strcmp(key, "version") == 0)
google_version = value;
- else if(strsame(key, "reqId") == 0)
+ else if(strcmp(key, "reqId") == 0)
google_reqId = value;
- else if(strsame(key, "sig") == 0)
+ else if(strcmp(key, "sig") == 0)
google_sig = value;
- else if(strsame(key, "out") == 0)
+ else if(strcmp(key, "out") == 0)
google_out = value;
- else if(strsame(key, "responseHandler") == 0)
+ else if(strcmp(key, "responseHandler") == 0)
google_responseHandler = value;
- else if(strsame(key, "outFileName") == 0)
+ else if(strcmp(key, "outFileName") == 0)
google_outFileName = value;
}
}
last_timestamp_in_data = strtoul(google_sig, NULL, 0);
// check the client wants json
- if(strsame(google_out, "json") != 0) {
+ if(strcmp(google_out, "json") != 0) {
buffer_sprintf(w->response.data,
"%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.'}]});",
google_responseHandler, google_version, google_reqId, google_out);
uint32_t hash = simple_hash(tok);
debug(D_WEB_CLIENT, "%llu: Processing command '%s'.", w->id, tok);
- if(hash == hash_api && strsame(tok, "api") == 0) {
+ if(hash == hash_api && strcmp(tok, "api") == 0) {
// the client is requesting api access
code = web_client_api_request(w, url);
}
- else if(hash == hash_netdata_conf && strsame(tok, "netdata.conf") == 0) {
+ else if(hash == hash_netdata_conf && strcmp(tok, "netdata.conf") == 0) {
code = 200;
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending netdata.conf ...", w->id);
buffer_flush(w->response.data);
generate_config(w->response.data, 0);
}
- else if(hash == hash_data && strsame(tok, WEB_PATH_DATA) == 0) { // "data"
+ else if(hash == hash_data && strcmp(tok, WEB_PATH_DATA) == 0) { // "data"
// the client is requesting rrd data -- OLD API
code = web_client_api_old_data_request(w, url, DATASOURCE_JSON);
}
- else if(hash == hash_datasource && strsame(tok, WEB_PATH_DATASOURCE) == 0) { // "datasource"
+ else if(hash == hash_datasource && strcmp(tok, WEB_PATH_DATASOURCE) == 0) { // "datasource"
// the client is requesting google datasource -- OLD API
code = web_client_api_old_data_request(w, url, DATASOURCE_DATATABLE_JSONP);
}
- else if(hash == hash_graph && strsame(tok, WEB_PATH_GRAPH) == 0) { // "graph"
+ else if(hash == hash_graph && strcmp(tok, WEB_PATH_GRAPH) == 0) { // "graph"
// the client is requesting an rrd graph -- OLD API
// get the name of the data to show
buffer_strcat(w->response.data, "Graph name?\r\n");
}
}
- else if(hash == hash_list && strsame(tok, "list") == 0) {
+ else if(hash == hash_list && strcmp(tok, "list") == 0) {
// OLD API
code = 200;
for ( ; st ; st = st->next )
buffer_sprintf(w->response.data, "%s\n", st->name);
}
- else if(hash == hash_all_json && strsame(tok, "all.json") == 0) {
+ else if(hash == hash_all_json && strcmp(tok, "all.json") == 0) {
// OLD API
code = 200;
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending JSON list of all monitors of RRD_STATS...", w->id);
rrd_stats_all_json(w->response.data);
}
#ifdef NETDATA_INTERNAL_CHECKS
- else if(hash == hash_exit && strsame(tok, "exit") == 0) {
+ else if(hash == hash_exit && strcmp(tok, "exit") == 0) {
code = 200;
w->response.data->contenttype = CT_TEXT_PLAIN;
buffer_flush(w->response.data);
error("web request to exit received.");
netdata_cleanup_and_exit(0);
}
- else if(hash == hash_debug && strsame(tok, "debug") == 0) {
+ else if(hash == hash_debug && strcmp(tok, "debug") == 0) {
buffer_flush(w->response.data);
// get the name of the data to show
buffer_strcat(w->response.data, "debug which chart?\r\n");
}
}
- else if(hash == hash_mirror && strsame(tok, "mirror") == 0) {
+ else if(hash == hash_mirror && strcmp(tok, "mirror") == 0) {
code = 200;
debug(D_WEB_CLIENT_ACCESS, "%llu: Mirroring...", w->id);
*e = '\0';
}
- if(!*ip || *ip == '*' || !strsame(ip, "any") || !strsame(ip, "all"))
+ if(!*ip || *ip == '*' || !strcmp(ip, "any") || !strcmp(ip, "all"))
ip = NULL;
if(!*port)
port = buffer2;