diff --git a/include/ThreadedActivityStats.h b/include/ThreadedActivityStats.h index 3b143c9ef7..0f9e9f7f8c 100644 --- a/include/ThreadedActivityStats.h +++ b/include/ThreadedActivityStats.h @@ -77,11 +77,10 @@ class ThreadedActivityStats { void updateStatsBegin(struct timeval *begin); void updateStatsEnd(u_long duration_ms); - void setNotExecutedAttivity() { not_executed = true; num_not_executed++; } - void setSlowPeriodicActivity() { is_slow = true; num_is_slow++; } + void setNotExecutedAttivity(bool _not_executed) { not_executed = _not_executed; if(_not_executed) num_not_executed++; } + void setSlowPeriodicActivity(bool _slow) { is_slow = _slow; if(_slow) num_is_slow++; } inline void setScheduledTime(time_t t) { scheduled_time = t; } inline void setDeadline(time_t t) { deadline = t; } - inline void clearErrors() { not_executed = false; is_slow = false; } inline void setCurrentProgress(int _progress) { progress = min(max(_progress, 0), 100); } void resetStats(); diff --git a/src/ThreadPool.cpp b/src/ThreadPool.cpp index a8f4fbdfe2..ab4554b020 100644 --- a/src/ThreadPool.cpp +++ b/src/ThreadPool.cpp @@ -113,15 +113,6 @@ void ThreadPool::run() { /* **************************************************** */ -static bool ignoreDeadlineExceeded(char *path) { - /* These scripts are allowed to exceeed their deadline */ - return((strcmp(path, HOUSEKEEPING_SCRIPT_PATH) == 0) || - (strcmp(path, DISCOVER_SCRIPT_PATH) == 0) || - (strcmp(path, TIMESERIES_SCRIPT_PATH) == 0)); -} - -/* **************************************************** */ - bool ThreadPool::queueJob(ThreadedActivity *ta, char *path, NetworkInterface *iface, time_t scheduled_time, time_t deadline) { QueuedThreadData *q; ThreadedActivityStats *stats = ta->getThreadedActivityStats(iface, true); @@ -129,16 +120,12 @@ bool ThreadPool::queueJob(ThreadedActivity *ta, char *path, NetworkInterface *if if(isTerminating()) return(false); - if(stats) - stats->clearErrors(); - if(!ta->isQueueable(iface)) { if(stats) { - if(ta->get_state(iface) == threaded_activity_state_queued) { - stats->setNotExecutedAttivity(); - } else if((ta->get_state(iface) == threaded_activity_state_running) && !ignoreDeadlineExceeded(path)) { - stats->setSlowPeriodicActivity(); - } + if(ta->get_state(iface) == threaded_activity_state_queued) + stats->setNotExecutedAttivity(true); + else if((ta->get_state(iface) == threaded_activity_state_running)) + stats->setSlowPeriodicActivity(true); } return(false); /* Task still running or already queued, don't re-queue it */ diff --git a/src/ThreadedActivity.cpp b/src/ThreadedActivity.cpp index 97f5e842b5..9490fc77f1 100644 --- a/src/ThreadedActivity.cpp +++ b/src/ThreadedActivity.cpp @@ -393,9 +393,14 @@ void ThreadedActivity::runScript(char *script_path, NetworkInterface *iface, tim /* Set the deadline and the threaded activity in the vm so they can be accessed */ l->setThreadedActivityData(this, thstats, deadline); - if(thstats) + if(thstats) { thstats->setCurrentProgress(0); + /* Reset the internal state for the current execution */ + thstats->setNotExecutedAttivity(false); + thstats->setSlowPeriodicActivity(false); + } + gettimeofday(&begin, NULL); updateThreadedActivityStatsBegin(iface, &begin); @@ -417,13 +422,12 @@ void ThreadedActivity::runScript(char *script_path, NetworkInterface *iface, tim thstats->setDeadline(time(NULL) + getPeriodicity()); if((max_duration_ms > 0) && (msec_diff > 2*max_duration_ms)) { - thstats->setSlowPeriodicActivity(); - } else - thstats->clearErrors(); + thstats->setSlowPeriodicActivity(true); + } } } else if(deadline) { if(isDeadlineApproaching(deadline)) - thstats->setSlowPeriodicActivity(); + thstats->setSlowPeriodicActivity(true); } if(l && !reuse_vm)