#8365 Fix ncm report for multiple agents
This commit is contained in:
parent
3988968198
commit
98bc73a83a
|
@ -29,6 +29,9 @@ ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_i
|
||||||
ALTER TABLE `tncm_agent`
|
ALTER TABLE `tncm_agent`
|
||||||
ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`;
|
ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`;
|
||||||
|
|
||||||
|
ALTER TABLE `treport_content`
|
||||||
|
ADD COLUMN `ncm_agents` MEDIUMTEXT NULL AFTER `status_of_check`;
|
||||||
|
|
||||||
-- Add new vendor and model
|
-- Add new vendor and model
|
||||||
SET @vendor_name = 'Cisco';
|
SET @vendor_name = 'Cisco';
|
||||||
SET @model_name = 'Cisco-Generic';
|
SET @model_name = 'Cisco-Generic';
|
||||||
|
|
|
@ -1036,12 +1036,12 @@ switch ($action) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ncm':
|
case 'ncm':
|
||||||
$id_agent_ncm = $item['id_agent'];
|
$id_agent_ncm = json_decode($item['ncm_agents']);
|
||||||
$ncm_group = $item['id_group'];
|
$ncm_group = $item['id_group'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ncm_backups':
|
case 'ncm_backups':
|
||||||
$id_agent_ncm = $item['id_agent'];
|
$id_agent_ncm = json_decode($item['ncm_agents']);
|
||||||
$ncm_group = $item['id_group'];
|
$ncm_group = $item['id_group'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1973,7 +1973,7 @@ if (is_metaconsole() === true) {
|
||||||
$all_agents = agents_get_agents_selected($ncm_group);
|
$all_agents = agents_get_agents_selected($ncm_group);
|
||||||
html_print_select(
|
html_print_select(
|
||||||
$all_agents,
|
$all_agents,
|
||||||
'agent_ncm',
|
'agent_ncm[]',
|
||||||
$id_agent_ncm,
|
$id_agent_ncm,
|
||||||
'',
|
'',
|
||||||
__('Any'),
|
__('Any'),
|
||||||
|
|
|
@ -2046,13 +2046,15 @@ switch ($action) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ncm_backups':
|
case 'ncm_backups':
|
||||||
$values['id_agent'] = get_parameter('agent_ncm');
|
$agents_ncm = get_parameter('agent_ncm');
|
||||||
|
$values['ncm_agents'] = json_encode($agents_ncm);
|
||||||
$values['id_group'] = get_parameter('ncm_group');
|
$values['id_group'] = get_parameter('ncm_group');
|
||||||
$good_format = true;
|
$good_format = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ncm':
|
case 'ncm':
|
||||||
$values['id_agent'] = get_parameter('agent_ncm');
|
$agents_ncm = get_parameter('agent_ncm');
|
||||||
|
$values['ncm_agents'] = json_encode($agents_ncm);
|
||||||
$values['id_group'] = get_parameter('ncm_group');
|
$values['id_group'] = get_parameter('ncm_group');
|
||||||
$good_format = true;
|
$good_format = true;
|
||||||
break;
|
break;
|
||||||
|
@ -2996,12 +2998,15 @@ switch ($action) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ncm_backups':
|
case 'ncm_backups':
|
||||||
$values['id_agent'] = get_parameter('agent_ncm');
|
$agents_ncm = get_parameter('agent_ncm');
|
||||||
|
$values['ncm_agents'] = json_encode($agents_ncm);
|
||||||
$values['id_group'] = get_parameter('ncm_group');
|
$values['id_group'] = get_parameter('ncm_group');
|
||||||
$good_format = true;
|
$good_format = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ncm':
|
case 'ncm':
|
||||||
|
$agents_ncm = get_parameter('agent_ncm');
|
||||||
|
$values['ncm_agents'] = json_encode($agents_ncm);
|
||||||
$values['id_agent'] = get_parameter('agent_ncm');
|
$values['id_agent'] = get_parameter('agent_ncm');
|
||||||
$values['id_group'] = get_parameter('ncm_group');
|
$values['id_group'] = get_parameter('ncm_group');
|
||||||
$good_format = true;
|
$good_format = true;
|
||||||
|
|
|
@ -7441,45 +7441,52 @@ function reporting_html_ncm_backups($table, $item, $pdf=0)
|
||||||
ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/');
|
ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/');
|
||||||
|
|
||||||
// Create table diff.
|
// Create table diff.
|
||||||
$table_ncm = new stdClass();
|
foreach ($item['data'] as $ncm_agent_key => $ncm_agent) {
|
||||||
$table_ncm->width = '100%';
|
$table_ncm = new stdClass();
|
||||||
$table_ncm->class = 'info_table';
|
if ($pdf === 1) {
|
||||||
$table_ncm->styleTable = 'table-layout: fixed;';
|
$table_ncm->width = '100%';
|
||||||
$table_ncm->headstyle[0] = 'width: 250px';
|
|
||||||
$table_ncm->head = [];
|
|
||||||
$table_ncm->head[0] = __('Date');
|
|
||||||
$table_ncm->head[1] = __('Diff');
|
|
||||||
$table_ncm->caption = $item['caption'];
|
|
||||||
$table_ncm->id = 'ncm_backups';
|
|
||||||
|
|
||||||
$table_ncm->data = [];
|
|
||||||
|
|
||||||
if ($pdf === 0) {
|
|
||||||
foreach ($item['data'] as $key => $row) {
|
|
||||||
$table_ncm->data[] = [
|
|
||||||
$row['updated_at'],
|
|
||||||
$row['diff'],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->colspan['ncm_backups']['cell'] = 3;
|
$table_ncm->class = 'info_table';
|
||||||
$table->cellstyle['ncm_backups']['cell'] = 'text-align: left;';
|
$table_ncm->styleTable = 'table-layout: fixed;';
|
||||||
$table->data['ncm_backups']['cell'] = html_print_table(
|
$table_ncm->headstyle[0] = 'width: 250px';
|
||||||
$table_ncm,
|
$table_ncm->head = [];
|
||||||
true
|
$table_ncm->head[0] = __('Date');
|
||||||
);
|
$table_ncm->head[1] = __('Diff');
|
||||||
} else {
|
$table_ncm->id = 'ncm_backups';
|
||||||
foreach ($item['data'] as $key => $row) {
|
$table_ncm->name = 'ncm_backups';
|
||||||
$table_ncm->data[] = [
|
$table_ncm->title = $ncm_agent['caption'];
|
||||||
$row['updated_at'],
|
$row = [];
|
||||||
($row['diffstr'] === '') ? $row['diff'] : str_replace("\n", '<br>', $row['diffstr']),
|
foreach ($ncm_agent['data'] as $ncm_agent_data) {
|
||||||
];
|
if ($pdf === 1) {
|
||||||
|
$row[] = [
|
||||||
|
$ncm_agent_data['updated_at'],
|
||||||
|
($ncm_agent_data['diffstr'] === '') ? $ncm_agent_data['diff'] : str_replace("\n", '<br>', $ncm_agent_data['diffstr']),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$row[] = [
|
||||||
|
$ncm_agent_data['updated_at'],
|
||||||
|
$ncm_agent_data['diff'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$table_ncm->data = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html_print_table(
|
$table->colspan[$ncm_agent_key]['cell'] = 3;
|
||||||
|
$table->cellstyle[$ncm_agent_key]['cell'] = 'text-align: left;';
|
||||||
|
$table->data[$ncm_agent_key]['cell'] = html_print_table(
|
||||||
$table_ncm,
|
$table_ncm,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($pdf === 1) {
|
||||||
|
$table->width = '100%';
|
||||||
|
return html_print_table(
|
||||||
|
$table,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1645,6 +1645,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
|
||||||
`cat_security_hardening` INT NOT NULL DEFAULT 0,
|
`cat_security_hardening` INT NOT NULL DEFAULT 0,
|
||||||
`ignore_skipped` INT NOT NULL DEFAULT 0,
|
`ignore_skipped` INT NOT NULL DEFAULT 0,
|
||||||
`status_of_check` TINYTEXT,
|
`status_of_check` TINYTEXT,
|
||||||
|
`ncm_agents` MEDIUMTEXT,
|
||||||
PRIMARY KEY(`id_rc`),
|
PRIMARY KEY(`id_rc`),
|
||||||
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
||||||
ON UPDATE CASCADE ON DELETE CASCADE
|
ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
|
|
Loading…
Reference in New Issue