function camm_recreate_tree() { global $cacti_camm_components; $rezult = 1; /* ================= input validation ================= */ camm_input_validate_input_regex(get_request_var_request("type"), "^snmptt|syslog\$", 'Uncorrect input data'); /* ==================================================== */ //error checking if (is_error_message()) { $rezult = "Input validation error."; } //business logic if ($rezult == 1) { $tree_type = (string) (isset($_POST['type']) ? $_POST['type'] : "snmptt"); if ($cacti_camm_components[$tree_type]) { $rezult = camm_poller_recreate_tree($tree_type); } else { $rezult = $tree_type . " component NOT USED"; } } //output if ($rezult == '1') { echo camm_JEncode(array('success' => true)); } else { echo camm_JEncode(array('failure' => true, 'error' => $rezult)); } }
} } if ($tree_to_recreate["snmptt"] && $tree_to_recreate["syslog"]) { //if need update all trees - may be truncate tree table if they index too mach big $max_tree_key = db_fetch_cell("SELECT max(`id`) FROM `plugin_camm_tree`;"); if ($max_tree_key > 1000000) { db_execute("TRUNCATE table `plugin_camm_tree`;"); camm_debug("S4. We are update all trees - may be truncate tree table if they index too mach big"); } } //and now real recreating tree if ($tree_to_recreate["snmptt"]) { camm_poller_recreate_tree("snmptt"); } if ($tree_to_recreate["syslog"]) { camm_poller_recreate_tree("syslog"); } /* display_help - displays the usage of the function */ function display_help() { print "camm Process Control Version 1.0, Copyright 2005 - Susanin\n\n"; print "usage: poller_camm.php [-d] [-h] [--help] [-v] [--version]\n\n"; print "-f - Force the execution of a purge process\n"; print "-d - Display verbose output during execution\n"; print "-v --version - Display this help message\n"; print "-h --help - display this help message\n"; } function purge_camm_records($start) { global $config, $camm_debug, $cacti_camm_components; $camm_snmptt_delay_purge_day = read_config_option("camm_snmptt_delay_purge_day");