Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Cacti/cacti into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Nov 19, 2024
2 parents 235c5eb + 4646a62 commit df2d7f9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
7 changes: 4 additions & 3 deletions automation_graph_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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=''
Expand Down Expand Up @@ -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');
Expand Down
8 changes: 4 additions & 4 deletions automation_tree_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}
Expand Down
4 changes: 2 additions & 2 deletions host.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 21 additions & 1 deletion lib/api_automation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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');
}
}

0 comments on commit df2d7f9

Please sign in to comment.