diff --git a/automation_graph_rules.php b/automation_graph_rules.php index 3183854017..2186d3fbf1 100644 --- a/automation_graph_rules.php +++ b/automation_graph_rules.php @@ -358,12 +358,12 @@ function automation_graph_rules_form_actions() { db_execute('DELETE FROM automation_match_rule_items WHERE ' . array_to_sql_or($selected_items, 'rule_id')); } elseif (get_nfilter_request_var('drp_action') == AUTOMATION_ACTION_GRAPH_DUPLICATE) { /* duplicate */ for ($i=0;($i < cacti_count($selected_items));$i++) { - automation_log('form_actions duplicate: ' . $selected_items[$i] . ' name: ' . get_nfilter_request_var('name_format'), AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log('form_actions duplicate: ' . $selected_items[$i] . ' name: ' . get_nfilter_request_var('name_format'), AUTOMATION_LOG_HIGH); duplicate_automation_graph_rules($selected_items[$i], get_nfilter_request_var('name_format')); } } elseif (get_nfilter_request_var('drp_action') == AUTOMATION_ACTION_GRAPH_ENABLE) { /* enable */ for ($i=0;($i < cacti_count($selected_items));$i++) { - automation_log('form_actions enable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log('form_actions enable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH); db_execute_prepared("UPDATE automation_graph_rules SET enabled='on' @@ -372,7 +372,7 @@ function automation_graph_rules_form_actions() { } } elseif (get_nfilter_request_var('drp_action') == AUTOMATION_ACTION_GRAPH_DISABLE) { /* disable */ for ($i=0;($i < cacti_count($selected_items));$i++) { - automation_log('form_actions disable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log('form_actions disable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH); db_execute_prepared("UPDATE automation_graph_rules SET enabled='' @@ -704,6 +704,7 @@ function automation_graph_rules_edit() { /* * display the rule items ------------------------------------------------------------------------------- */ + if (isset($rule['id'])) { # display graph rules for host match display_match_rule_items(__('Device Selection Criteria'), $rule, AUTOMATION_RULE_TYPE_GRAPH_MATCH, 'automation_graph_rules.php'); diff --git a/automation_tree_rules.php b/automation_tree_rules.php index fd0e628dd3..d5989d59aa 100644 --- a/automation_tree_rules.php +++ b/automation_tree_rules.php @@ -353,26 +353,26 @@ function automation_tree_rules_form_actions() { if ($selected_items != false) { if (get_nfilter_request_var('drp_action') == AUTOMATION_ACTION_TREE_DELETE) { /* DELETE */ - automation_log('form_actions DELETE: ' . serialize($selected_items), AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log('form_actions DELETE: ' . serialize($selected_items), AUTOMATION_LOG_HIGH); db_execute('DELETE FROM automation_tree_rules WHERE ' . array_to_sql_or($selected_items, 'id')); db_execute('DELETE FROM automation_tree_rule_items WHERE ' . array_to_sql_or($selected_items, 'rule_id')); db_execute('DELETE FROM automation_match_rule_items WHERE ' . array_to_sql_or($selected_items, 'rule_id')); } elseif (get_nfilter_request_var('drp_action') == AUTOMATION_ACTION_TREE_DUPLICATE) { /* duplicate */ for ($i=0;($i < cacti_count($selected_items));$i++) { - automation_log('form_actions duplicate: ' . $selected_items[$i], AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log('form_actions duplicate: ' . $selected_items[$i], AUTOMATION_LOG_HIGH); duplicate_automation_tree_rules($selected_items[$i], get_nfilter_request_var('name_format')); } } elseif (get_nfilter_request_var('drp_action') == AUTOMATION_ACTION_TREE_ENABLE) { /* enable */ for ($i=0;($i < cacti_count($selected_items));$i++) { - automation_log('form_actions enable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log('form_actions enable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH); db_execute_prepared("UPDATE automation_tree_rules SET enabled='on' WHERE id = ?", array($selected_items[$i])); } } elseif (get_nfilter_request_var('drp_action') == AUTOMATION_ACTION_TREE_DISABLE) { /* disable */ for ($i=0;($i < cacti_count($selected_items));$i++) { - automation_log('form_actions disable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log('form_actions disable: ' . $selected_items[$i], AUTOMATION_LOG_HIGH); db_execute_prepared("UPDATE automation_tree_rules SET enabled='' WHERE id = ?", array($selected_items[$i])); } diff --git a/host.php b/host.php index 1b3da84223..069ac74909 100644 --- a/host.php +++ b/host.php @@ -373,9 +373,9 @@ function form_actions() { api_tree_item_save(0, get_nfilter_request_var('tree_id'), TREE_ITEM_TYPE_HOST, get_nfilter_request_var('tree_item_id'), '', 0, $selected_item, 0, 1, 1, false); } } elseif (get_request_var('drp_action') == 6) { // automation - automation_log(__FUNCTION__ . ' called, action: ' . get_request_var('drp_action'), AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log(__FUNCTION__ . ' called, action: ' . get_request_var('drp_action'), AUTOMATION_LOG_HIGH); - automation_log(__FUNCTION__ . ', items: ' . get_nfilter_request_var('selected_items'), AUTOMATION_LOG_HIGH, POLLER_VERBOSITY_MEDIUM); + automation_log(__FUNCTION__ . ', items: ' . get_nfilter_request_var('selected_items'), AUTOMATION_LOG_HIGH); /* work on all selected hosts */ foreach ($selected_items as $host_id) { diff --git a/lib/api_automation.php b/lib/api_automation.php index ec2cf6a307..0df4e994e6 100644 --- a/lib/api_automation.php +++ b/lib/api_automation.php @@ -1423,7 +1423,7 @@ function api_automation_column_exists($column, $tables) { return false; } -function display_match_rule_items($title, $rule_id, $rule_type, $module) { +function display_match_rule_items($title, $rule, $rule_type, $module) { global $automation_op_array, $automation_oper, $automation_tree_header_types; $rule_id = $rule['id']; @@ -5440,3 +5440,23 @@ function automation_validate_import_columns($table, &$data, &$debug_data) { return true; } + +/** + * automation_log - logs a string to Cacti's log file or optionally to the browser + * + * @param string $string - the string to append to the log file + * @param $level - (int) only log if above the specified log level + */ +function automation_log($string, $level = AUTOMATION_LOG_LOW) { + + if (function_exists('read_config_option')) { + define('AUTOMATION_LEVEL', read_config_option('automation_log_level')); + } else { + define('AUTOMATION_LEVEL', 1); + } + + if (AUTOMATION_LEVEL >= $level) { + cacti_log($string, false, 'AUTOMATION'); + } +} +