#include "common.h"
char *global_host_prefix = "";
int enable_ksm = 1;
// time(NULL) in milliseconds
unsigned long long timems(void) {
struct timeval now;
gettimeofday(&now, NULL);
return now.tv_sec * 1000000ULL + now.tv_usec;
}
int usecsleep(unsigned long long usec) {
#ifndef NETDATA_WITH_USLEEP
// we expect microseconds (1.000.000 per second)
// but timespec is nanoseconds (1.000.000.000 per second)
struct timespec req = { .tv_sec = usec / 1000000, .tv_nsec = (usec % 1000000) * 1000 }, rem;
while(nanosleep(&req, &rem) == -1) {
if(likely(errno == EINTR)) {
info("nanosleep() interrupted (while sleeping for %llu microseconds).", usec);
req.tv_sec = rem.tv_sec;
req.tv_nsec = rem.tv_nsec;
}
else {
error("Cannot nanosleep() for %llu microseconds.", usec);
break;
}
}
return 0;
#else
int ret = usleep(usec);
if(unlikely(ret == -1 && errno == EINVAL)) {
// on certain systems, usec has to be up to 999999
if(usec > 999999) {
int counter = usec / 999999;
while(counter--)
usleep(999999);
usleep(usec % 999999);
}
else {
error("Cannot usleep() for %llu microseconds.", usec);
return ret;
}
}
if(ret != 0)
error("usleep() failed for %llu microseconds.", usec);
return ret;
#endif
}
unsigned char netdata_map_chart_names[256] = {
[0] = '\0', //
[1] = '_', //
[2] = '_', //
[3] = '_', //
[4] = '_', //
[5] = '_', //
[6] = '_', //
[7] = '_', //
[8] = '_', //
[9] = '_', //
[10] = '_', //
[11] = '_', //
[12] = '_', //
[13] = '_', //
[14] = '_', //
[15] = '_', //
[16] = '_', //
[17] = '_', //
[18] = '_', //
[19] = '_', //
[20] = '_', //
[21] = '_', //
[22] = '_', //
[23] = '_', //
[24] = '_', //
[25] = '_', //
[26] = '_', //
[27] = '_', //
[28] = '_', //
[29] = '_', //
[30] = '_', //
[31] = '_', //
[32] = '_', //
[33] = '_', // !
[34] = '_', // "
[35] = '_', // #
[36] = '_', // $
[37] = '_', // %
[38] = '_', // &
[39] = '_', // '
[40] = '_', // (
[41] = '_', // )
[42] = '_', // *
[43] = '_', // +
[44] = '.', // ,
[45] = '-', // -
[46] = '.', // .
[47] = '/', // /
[48] = '0', // 0
[49] = '1', // 1
[50] <