procfile_adaptive_initial_allocation = 1;
- time_t started_t = time(NULL);
+ time_t started_t = now_realtime_sec();
get_system_HZ();
get_system_pid_max();
get_system_cpus();
if(unlikely(debug))
fprintf(stderr, "apps.plugin: done Loop No %llu\n", global_iterations_counter);
- time_t current_t = time(NULL);
+ time_t current_t = now_realtime_sec();
// restart check (14400 seconds)
if(current_t - started_t > 14400) exit(0);
}
if(unlikely(v->hash == now_hash && !strcmp(v->name, "now"))) {
- n = time(NULL);
+ n = now_realtime_sec();
buffer_strcat(exp->error_msg, "[ $now = ");
print_parsed_as_constant(exp->error_msg, n);
buffer_strcat(exp->error_msg, " ] ");
freez(buf);
- if(!max_unique_id) max_unique_id = (uint32_t)time(NULL);
- if(!max_alarm_id) max_alarm_id = (uint32_t)time(NULL);
+ if(!max_unique_id) max_unique_id = (uint32_t)now_realtime_sec();
+ if(!max_alarm_id) max_alarm_id = (uint32_t)now_realtime_sec();
host->health_log.next_log_id = max_unique_id + 1;
host->health_log.next_alarm_id = max_alarm_id + 1;
static void rrdsetcalc_link(RRDSET *st, RRDCALC *rc) {
debug(D_HEALTH, "Health linking alarm '%s.%s' to chart '%s' of host '%s'", rc->chart?rc->chart:"NOCHART", rc->name, st->id, st->rrdhost->hostname);
- rc->last_status_change = time(NULL);
+ rc->last_status_change = now_realtime_sec();
rc->rrdset = st;
rc->rrdset_next = st->alarms;
if(!rc->units) rc->units = strdupz(st->units);
{
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
health_alarm_log(st->rrdhost, rc->id, rc->next_event_id++, now, rc->name, rc->rrdset->id, rc->rrdset->family, rc->exec, rc->recipient, now - rc->last_status_change, rc->old_value, rc->value, rc->status, RRDCALC_STATUS_UNINITIALIZED, rc->source, rc->units, rc->info, 0);
}
}
}
{
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
health_alarm_log(st->rrdhost, rc->id, rc->next_event_id++, now, rc->name, rc->rrdset->id, rc->rrdset->family, rc->exec, rc->recipient, now - rc->last_status_change, rc->old_value, rc->value, rc->status, RRDCALC_STATUS_REMOVED, rc->source, rc->units, rc->info, 0);
}
host->hostname,
(host->health_log.next_log_id > 0)?(host->health_log.next_log_id - 1):0,
health_enabled?"true":"false",
- (unsigned long)time(NULL));
+ (unsigned long)now_realtime_sec());
RRDCALC *rc;
for(i = 0, rc = host->alarms; rc ; rc = rc->next) {
);
ae->flags |= HEALTH_ENTRY_FLAG_EXEC_RUN;
- ae->exec_run_timestamp = time(NULL);
+ ae->exec_run_timestamp = now_realtime_sec();
debug(D_HEALTH, "executing command '%s'", command_to_run);
FILE *fp = mypopen(command_to_run, &command_pid);
static inline void health_alarm_log_process(RRDHOST *host) {
static uint32_t stop_at_id = 0;
uint32_t first_waiting = (host->health_log.alarms)?host->health_log.alarms->unique_id:0;
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
pthread_rwlock_rdlock(&host->health_log.alarm_log_rwlock);
debug(D_HEALTH, "Health monitoring iteration no %u started", loop);
int oldstate, runnable = 0;
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
time_t next_run = now + min_run_every;
RRDCALC *rc;
if(unlikely(netdata_exit))
break;
- now = time(NULL);
+ now = now_realtime_sec();
if(now < next_run) {
debug(D_HEALTH, "Health monitoring iteration no %u done. Next iteration in %d secs",
loop, (int) (next_run - now));
return 1;
#endif
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
if(!start) start = now;
if(reset) {
time_t t;
struct tm *tmp, tmbuf;
- t = time(NULL);
+ t = now_realtime_sec();
tmp = localtime_r(&t, &tmbuf);
if (tmp == NULL) return;
struct nlmsghdr *nlh = NULL;
unsigned int seq = 0, portid = 0;
- seq = time(NULL) - 1;
+ seq = now_realtime_sec() - 1;
nl = mnl_socket_open(NETLINK_NETFILTER);
if(!nl) {
cd->enabled = enabled;
cd->update_every = (int) config_get_number(cd->id, "update every", rrd_update_every);
- cd->started_t = time(NULL);
+ cd->started_t = now_realtime_sec();
char *def = "";
snprintfz(cd->cmd, PLUGINSD_CMD_MAX, "exec %s %d %s", cd->fullfilename, cd->update_every, config_get(cd->id, "command options", def));
static inline void mountinfo_reload(int force) {
static time_t last_loaded = 0;
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
if(force || now - last_loaded >= NETDATA_RELOAD_MOUNTINFO_EVERY) {
//#ifdef NETDATA_INTERNAL_CHECKS
void registry_set_cookie(struct web_client *w, const char *guid) {
char edate[100];
- time_t et = time(NULL) + registry.persons_expiration;
+ time_t et = now_realtime_sec() + registry.persons_expiration;
struct tm etmbuf, *etm = gmtime_r(&et, &etmbuf);
strftime(edate, sizeof(edate), "%a, %d %b %Y %H:%M:%S %Z", etm);
void rrdhost_init(char *hostname) {
localhost.hostname = hostname;
localhost.health_log.next_log_id =
- localhost.health_log.next_alarm_id = time(NULL);
+ localhost.health_log.next_alarm_id = now_realtime_sec();
}
void rrdhost_rwlock(RRDHOST *host) {
error("File %s does not have the desired update frequency. Clearing it.", fullfilename);
memset(st, 0, size);
}
- else if((time(NULL) - st->last_updated.tv_sec) > update_every * entries) {
+ else if((now_realtime_sec() - st->last_updated.tv_sec) > update_every * entries) {
errno = 0;
error("File %s is too old. Clearing it.", fullfilename);
memset(st, 0, size);
unsigned long rrd_stats_one_json(RRDSET *st, char *options, BUFFER *wb)
{
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
pthread_rwlock_rdlock(&st->rwlock);
static int cgroup_global_config_read = 0;
static time_t last_run = 0;
- time_t now = time(NULL);
+ time_t now = now_realtime_sec();
if(unlikely(!cgroup_global_config_read)) {
read_cgroup_plugin_configuration();
unsigned long long sutime_sys_fs_cgroup = 0ULL;
// the next time we will run - aligned properly
- unsigned long long sunext = (time(NULL) - (time(NULL) % rrd_update_every) + rrd_update_every) * 1000000ULL;
+ unsigned long long sunext = (now_realtime_sec() - (now_realtime_sec() % rrd_update_every) + rrd_update_every) * 1000000ULL;
RRDSET *stcpu_thread = NULL;
st->debug = 1;
// feed it with the test data
- time_t time_now = 0, time_start = time(NULL);
+ time_t time_now = 0, time_start = now_realtime_sec();
unsigned long c;
collected_number last = 0;
for(c = 0; c < test->feed_entries; c++) {
if (refresh > 0) {
buffer_sprintf(w->response.header, "Refresh: %d\r\n", refresh);
- w->response.data->expires = time(NULL) + refresh;
+ w->response.data->expires = now_realtime_sec() + refresh;
}
else buffer_no_cacheable(w->response.data);
ret = 500;
// if the collected value is too old, don't calculate its value
- if (rrdset_last_entry_t(st) >= (time(NULL) - (st->update_every * st->gap_when_lost_iterations_above)))
+ if (rrdset_last_entry_t(st) >= (now_realtime_sec() - (st->update_every * st->gap_when_lost_iterations_above)))
ret = rrd2value(st,
w->response.data,
&n,
}
else if (refresh > 0) {
buffer_sprintf(w->response.header, "Refresh: %d\r\n", refresh);
- w->response.data->expires = time(NULL) + refresh;
+ w->response.data->expires = now_realtime_sec() + refresh;
}
else buffer_no_cacheable(w->response.data);
if(unlikely(cookie && person_guid[0] && !strcmp(person_guid, REGISTRY_VERIFY_COOKIES_GUID)))
person_guid[0] = '\0';
- return registry_request_access_json(w, person_guid, machine_guid, machine_url, url_name, time(NULL));
+ return registry_request_access_json(w, person_guid, machine_guid, machine_url, url_name, now_realtime_sec());
case 'D':
w->tracking_required = 1;
- return registry_request_delete_json(w, person_guid, machine_guid, machine_url, delete_url, time(NULL));
+ return registry_request_delete_json(w, person_guid, machine_guid, machine_url, delete_url, now_realtime_sec());
case 'S':
w->tracking_required = 1;
- return registry_request_search_json(w, person_guid, machine_guid, machine_url, search_machine_guid, time(NULL));
+ return registry_request_search_json(w, person_guid, machine_guid, machine_url, search_machine_guid, now_realtime_sec());
case 'W':
w->tracking_required = 1;
- return registry_request_switch_json(w, person_guid, machine_guid, machine_url, to_person_guid, time(NULL));
+ return registry_request_switch_json(w, person_guid, machine_guid, machine_url, to_person_guid, now_realtime_sec());
case 'H':
return registry_request_hello_json(w);