report for ncm simple
This commit is contained in:
parent
68c2400b9c
commit
19643cd685
|
@ -829,6 +829,10 @@ switch ($action) {
|
|||
$select_by_group = $es['select_by_group'];
|
||||
break;
|
||||
|
||||
case 'ncm':
|
||||
$idAgent = $item['id_agent'];
|
||||
break;
|
||||
|
||||
default:
|
||||
// It's not possible.
|
||||
break;
|
||||
|
@ -6319,6 +6323,11 @@ function chooseType() {
|
|||
} else {
|
||||
$("#row_profiles_group").hide();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ncm':
|
||||
$("#row_agent").show();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -774,8 +774,59 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
$not = (($negative === true) ? ' !' : '');
|
||||
$query .= sprintf('%s %s= %f', $field, $not, $value);
|
||||
} else if (is_array($value)) {
|
||||
$values_check = array_keys($value);
|
||||
$ranges = false;
|
||||
$initialized = false;
|
||||
foreach ($values_check as $operation) {
|
||||
if ($ranges === true && $initialized === true) {
|
||||
$query .= ' '.$join.' ';
|
||||
} else {
|
||||
$initialized = true;
|
||||
}
|
||||
|
||||
if ($operation === '>') {
|
||||
$query .= sprintf("%s > '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($operation === '>=') {
|
||||
$query .= sprintf("%s >= '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($operation === '<') {
|
||||
$query .= sprintf("%s < '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($operation === '<=') {
|
||||
$query .= sprintf("%s <= '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($operation === '!=') {
|
||||
$query .= sprintf("%s != '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($operation === '=') {
|
||||
$query .= sprintf("%s = '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($negative === true && $operation === '>') {
|
||||
$query .= sprintf("%s <= '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($negative === true && $operation === '>=') {
|
||||
$query .= sprintf("%s < '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($negative === true && $operation === '<') {
|
||||
$query .= sprintf("%s >= '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($negative === true && $operation === '<=') {
|
||||
$query .= sprintf("%s > '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($negative === true && $operation === '!=') {
|
||||
$query .= sprintf("%s = '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
} else if ($negative === true && $operation === '=') {
|
||||
$query .= sprintf("%s != '%s'", $field, $value[$operation]);
|
||||
$ranges = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ranges !== true) {
|
||||
$not = (($negative === true) ? 'NOT' : '');
|
||||
$query .= sprintf('%s %s IN ("%s")', $field, $not, implode('", "', $value));
|
||||
}
|
||||
} else {
|
||||
if ($value === '') {
|
||||
// Search empty string.
|
||||
|
|
|
@ -873,6 +873,14 @@ function reporting_make_reporting_data(
|
|||
);
|
||||
break;
|
||||
|
||||
case 'ncm':
|
||||
$report['contents'][] = reporting_ncm_config(
|
||||
$report,
|
||||
$content,
|
||||
$pdf
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
|
|
|
@ -437,6 +437,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
|
|||
$mini
|
||||
);
|
||||
break;
|
||||
|
||||
case 'ncm':
|
||||
reporting_html_ncm_config($table, $item);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($item['type'] == 'agent_module') {
|
||||
|
@ -5977,3 +5981,43 @@ function reporting_html_permissions($table, $item, $pdf=0)
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HTML content for ncm configuration diff report.
|
||||
*
|
||||
* @param array $item Content generated by reporting_ncm_config.
|
||||
*
|
||||
* @return string HTML code.
|
||||
*/
|
||||
function reporting_html_ncm_config($table, $item, $pdf=0)
|
||||
{
|
||||
$key = uniqid();
|
||||
if ($pdf === 0) {
|
||||
ui_require_javascript_file('diff2html-ui.min');
|
||||
ui_require_css_file('diff2html.min');
|
||||
$script = "$(document).ready(function() {
|
||||
const configuration = {
|
||||
drawFileList: false,
|
||||
collapsed: true,
|
||||
matching: 'lines',
|
||||
outputFormat: 'side-by-side',
|
||||
};
|
||||
const diff2htmlUi = new Diff2HtmlUI(
|
||||
document.getElementById('".$key."'),
|
||||
atob('".base64_encode($item['data'])."'),
|
||||
configuration
|
||||
);
|
||||
diff2htmlUi.draw();
|
||||
});";
|
||||
$content = '<div class="w100p" id="'.$key.'"></div class="w100p">';
|
||||
$content .= '<script>'.$script.'</script>';
|
||||
$table->data[1] = $content;
|
||||
$table->colspan[1][0] = 2;
|
||||
} else {
|
||||
$content = '<div style="text-align:left;margin-left: 14px;">';
|
||||
$content .= str_replace("\n", '<br>', $item['data']);
|
||||
$content .= '</div>';
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -911,6 +911,11 @@ function reports_get_report_types($template=false, $not_editor=false)
|
|||
];
|
||||
}
|
||||
|
||||
$types['ncm'] = [
|
||||
'optgroup' => __('NCM'),
|
||||
'name' => __('Network configuration changes'),
|
||||
];
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Class to manage some advanced operations over strings.
|
||||
*
|
||||
* @category Class
|
||||
* @package Pandora FMS
|
||||
* @subpackage Tools
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
namespace PandoraFMS\Tools;
|
||||
|
||||
global $config;
|
||||
|
||||
/**
|
||||
* Files class definition.
|
||||
*/
|
||||
class Strings
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves a diff output for given strings.
|
||||
*
|
||||
* @param string $a A.
|
||||
* @param string $b B.
|
||||
*
|
||||
* @return string Diff or error.
|
||||
*/
|
||||
public static function diff(string $a, string $b)
|
||||
{
|
||||
$A = sys_get_temp_dir().'/A-'.uniqid();
|
||||
$B = sys_get_temp_dir().'/B-'.uniqid();
|
||||
|
||||
file_put_contents($A, \io_safe_output($a));
|
||||
file_put_contents($B, \io_safe_output($b));
|
||||
|
||||
$cmd = 'diff -u '.$A.' '.$B.' 2>&1';
|
||||
exec($cmd, $output, $rc);
|
||||
|
||||
unlink($A);
|
||||
unlink($B);
|
||||
|
||||
$output = join("\n", $output);
|
||||
|
||||
if ($rc <= 1) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
return 'Error ['.$rc.']: '.$output;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue