Example #1
0
        if ($last_run_daily == '') {
            /* since the poller has never run before, let's fake it out */
            db_execute("REPLACE INTO settings (name, value) VALUES ('dsstats_last_daily_run_time', '" . date('Y-m-d G:i:s', $current_time) . "')");
        }
        /* if it's time to update daily statistics, do so now */
        if ($last_run_daily != '' && strtotime($last_run_daily) + $daily_interval * 60 < $current_time || $forcerun) {
            /* run the daily stats */
            dsstats_get_and_store_ds_avgpeak_values('daily');
            log_dsstats_statistics('DAILY');
            db_execute("REPLACE INTO settings (name, value) VALUES ('dsstats_last_daily_run_time', '" . date('Y-m-d G:i:s', $current_time) . "')");
        }
    }
    /* lastly, let's see if it's time to run the major stats */
    if ($last_run_major == '') {
        /* since the poller has never run before, let's fake it out */
        db_execute("REPLACE INTO settings (name, value) VALUES ('dsstats_last_major_run_time', '" . date('Y-m-d G:i:s', $current_time) . "')");
    } else {
        $last_major_day = date('Y-m-d', strtotime($last_run_major));
        $next_major_day = strtotime($last_major_day . ' ' . $major_time) + 86400;
    }
    /* if its time to run major statistics, do so now */
    if ($last_run_major != '' && $next_major_day < $current_time || $forcerun) {
        /* run the major stats, log first to keep other processes from running */
        db_execute("REPLACE INTO settings (name, value) VALUES ('dsstats_last_major_run_time', '" . date('Y-m-d G:i:s', $current_time) . "')");
        dsstats_get_and_store_ds_avgpeak_values('weekly');
        dsstats_get_and_store_ds_avgpeak_values('monthly');
        dsstats_get_and_store_ds_avgpeak_values('yearly');
        log_dsstats_statistics('MAJOR');
    }
}
dsstats_debug('Polling Ending');
Example #2
0
function dsstats_boost_bottom()
{
    global $config;
    include_once $config["base_path"] . "/lib/rrd.php";
    /* run the daily stats. log to database to prevent secondary runs */
    db_execute("REPLACE INTO settings (name, value) VALUES ('dsstats_last_daily_run_time', '" . date("Y-m-d G:i:s", time()) . "')");
    dsstats_get_and_store_ds_avgpeak_values("daily");
    log_dsstats_statistics("DAILY");
}