Пример #1
0
    maint_debug("Purging Required - Files Found {$purge}");
    /* take the purge in steps */
    while (true) {
        maint_debug('Grabbing 1000 RRDfiles to Remove');
        $file_array = db_fetch_assoc('SELECT id, name, local_data_id, action 
			FROM data_source_purge_action
			ORDER BY name
			LIMIT 1000');
        if (sizeof($file_array) == 0) {
            break;
        }
        if (sizeof($file_array) || $force) {
            /* there's something to do for us now */
            remove_files($file_array);
            if ($force) {
                cleanup_ds_and_graphs();
            }
        }
    }
    /* record the start time */
    list($micro, $seconds) = explode(' ', microtime());
    $poller_end = $seconds + $micro;
    $string = sprintf('MAINT STATS: Time:%4.4f Purged:%s Archived:%s RRDfiles', $poller_end - $poller_start, $purged, $archived);
    cacti_log($string, true, 'SYSTEM');
}
/* removing security tokens older than 90 days */
if (read_config_option('auth_cache_enabled') == 'on') {
    db_execute("DELETE FROM user_auth_cache WHERE last_update<'" . date('Y-m-d H:i:s', time() - 86400 * 90) . "'");
} else {
    db_execute('TRUNCATE TABLE user_auth_cache');
}
Пример #2
0
            exit;
    }
}
/* are my tables already present? */
$sql = "show tables from `" . $database_default . "` like 'plugin_rrdclean_action'";
#$result = db_fetch_assoc($sql) or die (mysql_error());
$result = db_fetch_assoc($sql);
/* if the table that holds the actions is present, work on it */
if (sizeof($result)) {
    /* Get all files to act on */
    $file_array = db_fetch_assoc("SELECT " . "plugin_rrdclean_action.id, " . "plugin_rrdclean_action.name, " . "plugin_rrdclean_action.local_data_id, " . "plugin_rrdclean_action.action " . "FROM " . "plugin_rrdclean_action");
    if (sizeof($file_array) > 0 || $force) {
        /* there's something to do for us now */
        remove_files($file_array, $debug);
        if ($force) {
            cleanup_ds_and_graphs($debug);
        }
    }
}
/*
 * remove_files
 * remove all unwanted files; the list is given by table plugin_rrdclean_action
 */
function remove_files($file_array, $debug)
{
    global $config;
    include_once $config["library_path"] . "/api_graph.php";
    include_once $config["library_path"] . "/api_data_source.php";
    cacti_log("RRDClean is now running on " . sizeof($file_array) . " items", true, "RRDCLEAN");
    /* determine the location of the RRA files */
    if (isset($config["rra_path"])) {