implemented os version management
This commit is contained in:
parent
8f04fbec4d
commit
f8911bcf9c
|
@ -62,6 +62,14 @@ CREATE TABLE IF NOT EXISTS `tnetwork_usage_filter` (
|
|||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tconfig_os_version` (
|
||||
`id_os_version` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`product` TEXT,
|
||||
`version` TEXT,
|
||||
`end_of_support` VARCHAR(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_os_version`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
ALTER TABLE `tlayout`
|
||||
ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`,
|
||||
ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`;
|
||||
|
@ -73,6 +81,10 @@ ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`;
|
|||
|
||||
DELETE FROM tconfig WHERE token = 'refr';
|
||||
|
||||
INSERT INTO `tconfig_os_version` (`id_os_version`, `product`, `version`, `end_of_support`) VALUES (1,'Windows.*','7.*','2020/01/14');
|
||||
INSERT INTO `tconfig_os_version` (`id_os_version`, `product`, `version`, `end_of_support`) VALUES (2,'Cisco.*','IOS 3.4.3','2017/05/12');
|
||||
INSERT INTO `tconfig_os_version` (`id_os_version`, `product`, `version`, `end_of_support`) VALUES (3,'Linux.*','Centos 7.*','2022/01/01');
|
||||
|
||||
INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (37,2,'CPU','CPU','','Brand;Clock;Model','',0,2);
|
||||
|
||||
INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (38,2,'RAM','RAM','','Size','',0,2);
|
||||
|
|
|
@ -548,6 +548,21 @@ $tableAgent->data['os'][0] .= html_print_div(
|
|||
true
|
||||
);
|
||||
|
||||
$tableAgent->data['caption_os_version'][0] = __('OS version');
|
||||
$tableAgent->rowclass['os_version'] = 'w540px';
|
||||
$tableAgent->data['os_version'][0] = html_print_input_text(
|
||||
'os_version',
|
||||
$os_version,
|
||||
'',
|
||||
16,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
'w540px'
|
||||
);
|
||||
|
||||
$tableAgent->data['caption_server'][0] = __('Server');
|
||||
$tableAgent->rowclass['server'] = 'w540px';
|
||||
$tableAgent->data['server'][0] = html_print_select(
|
||||
|
|
|
@ -215,6 +215,7 @@ if ($create_agent) {
|
|||
$id_parent = (int) get_parameter_post('id_agent_parent');
|
||||
$server_name = (string) get_parameter_post('server_name');
|
||||
$id_os = (int) get_parameter_post('id_os');
|
||||
$os_version = (string) get_parameter_post('os_version');
|
||||
$disabled = (int) get_parameter_post('disabled');
|
||||
$custom_id = (string) get_parameter_post('custom_id', '');
|
||||
$cascade_protection = (int) get_parameter_post('cascade_protection', 0);
|
||||
|
@ -281,6 +282,7 @@ if ($create_agent) {
|
|||
'comentarios' => $comentarios,
|
||||
'modo' => $modo,
|
||||
'id_os' => $id_os,
|
||||
'os_version' => $os_version,
|
||||
'disabled' => $disabled,
|
||||
'cascade_protection' => $cascade_protection,
|
||||
'cascade_protection_module' => $cascade_protection_module,
|
||||
|
@ -996,6 +998,7 @@ if ($update_agent) {
|
|||
$modo = (int) get_parameter_post('modo', 0);
|
||||
// Mode: Learning, Normal or Autodisabled.
|
||||
$id_os = (int) get_parameter_post('id_os');
|
||||
$os_version = (string) get_parameter_post('os_version');
|
||||
$disabled = (bool) get_parameter_post('disabled');
|
||||
$server_name = (string) get_parameter_post('server_name', '');
|
||||
$id_parent = (int) get_parameter_post('id_agent_parent');
|
||||
|
@ -1119,6 +1122,7 @@ if ($update_agent) {
|
|||
'disabled' => $disabled,
|
||||
'id_parent' => $id_parent,
|
||||
'id_os' => $id_os,
|
||||
'os_version' => $os_version,
|
||||
'modo' => $modo,
|
||||
'alias' => $alias,
|
||||
'alias_as_name' => $alias_as_name,
|
||||
|
@ -1280,6 +1284,7 @@ if ($id_agente) {
|
|||
$server_name = $agent['server_name'];
|
||||
$modo = $agent['modo'];
|
||||
$id_os = $agent['id_os'];
|
||||
$os_version = $agent['os_version'];
|
||||
$disabled = $agent['disabled'];
|
||||
$id_parent = $agent['id_parent'];
|
||||
$custom_id = $agent['custom_id'];
|
||||
|
|
|
@ -870,6 +870,16 @@ switch ($action) {
|
|||
$idAgentModule = $module;
|
||||
break;
|
||||
|
||||
case 'end_of_life':
|
||||
$es = json_decode($item['external_source'], true);
|
||||
|
||||
$text_os_version = $es['os_version'];
|
||||
$end_of_life_date = $es['end_of_life_date'];
|
||||
$os_selector = $es['os_selector'];
|
||||
$group = $es['group'];
|
||||
$recursion = $es['recursion'];
|
||||
break;
|
||||
|
||||
case 'alert_report_actions':
|
||||
$description = $item['description'];
|
||||
$es = json_decode($item['external_source'], true);
|
||||
|
@ -1183,6 +1193,94 @@ $class = 'databox filters';
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_os_selector" class="datos">
|
||||
<td class="bolder"><?php echo __('Operating system'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$os_list = db_get_all_rows_filter('tconfig_os', [], ['id_os', 'name']);
|
||||
|
||||
if ($os === false) {
|
||||
$os = [];
|
||||
}
|
||||
|
||||
$result_select = [];
|
||||
|
||||
foreach ($os as $item) {
|
||||
$result_select[$item['id_os']] = $item['name'];
|
||||
}
|
||||
|
||||
html_print_select(
|
||||
$os_list,
|
||||
'os_selector',
|
||||
$os_selector,
|
||||
''
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_os_version_regexp" class="datos">
|
||||
<td class="bolder">
|
||||
<?php
|
||||
echo __('Operating system version').ui_print_help_tip(
|
||||
__('Case insensitive regular expression for OS version. For example: Centos.* will match with the following OS versions: Centos 6.4, Centos 7'),
|
||||
true
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_input_text(
|
||||
'text_os_version',
|
||||
$text_os_version,
|
||||
'',
|
||||
30,
|
||||
100,
|
||||
false
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_os_end_of_life" class="datos">
|
||||
<td class="bolder"><?php echo __('End of life'); ?></td>
|
||||
<td colspan="6">
|
||||
<?php
|
||||
$end_of_life_date = (string) get_parameter(
|
||||
'end_of_life_date',
|
||||
date(DATE_FORMAT, $utimestamp)
|
||||
);
|
||||
$end_of_life_date = date(DATE_FORMAT, $result['date_from']);
|
||||
|
||||
$timeInputs = [];
|
||||
|
||||
$timeInputs[] = html_print_div(
|
||||
[
|
||||
'id' => 'end_of_life_date',
|
||||
'style' => '',
|
||||
'content' => html_print_div(
|
||||
[
|
||||
'class' => '',
|
||||
'content' => html_print_input_text(
|
||||
'end_of_life_date',
|
||||
$end_of_life_date,
|
||||
'',
|
||||
10,
|
||||
10,
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
echo implode('', $timeInputs);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_agent_regexp" class="datos">
|
||||
<td class="bolder">
|
||||
<?php
|
||||
|
@ -4097,6 +4195,8 @@ html_print_action_buttons($actionButtons, ['type' => 'form_action']);
|
|||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
ui_require_css_file('datepicker');
|
||||
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
|
||||
ui_include_time_picker();
|
||||
ui_require_javascript_file('pandora');
|
||||
|
||||
|
@ -5027,6 +5127,8 @@ $(document).ready (function () {
|
|||
chooseType();
|
||||
chooseSQLquery();
|
||||
|
||||
$("#text-end_of_life_date").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>", showButtonPanel: true});
|
||||
|
||||
$("#id_agents").change(agent_changed_by_multiple_agents);
|
||||
|
||||
// Load selected modules by default
|
||||
|
@ -6291,7 +6393,11 @@ function addGeneralRow() {
|
|||
function loadGeneralAgents(agent_group) {
|
||||
var params = [];
|
||||
|
||||
var group = <?php echo $group; ?>;
|
||||
var group = <?php echo $group ?? -1; ?>;
|
||||
if (group < 0) {
|
||||
return;
|
||||
}
|
||||
console.log("!!!!!!!!!!!!!!!!!!!!!!!!",group);
|
||||
group = agent_group || group;
|
||||
|
||||
params.push("get_agents=1");
|
||||
|
@ -6557,6 +6663,9 @@ function chooseType() {
|
|||
$("#row_group_by").hide();
|
||||
$("#row_type_show").hide();
|
||||
$("#row_use_prefix_notation").hide();
|
||||
$("#row_os_selector").hide();
|
||||
$("#row_os_version_regexp").hide();
|
||||
$("#row_os_end_of_life").hide();
|
||||
|
||||
// SLA list default state.
|
||||
$("#sla_list").hide();
|
||||
|
@ -7137,6 +7246,13 @@ function chooseType() {
|
|||
});
|
||||
break;
|
||||
|
||||
case 'end_of_life':
|
||||
$("#row_os_selector").show();
|
||||
$("#row_os_version_regexp").show();
|
||||
$("#row_group").show();
|
||||
$("#row_os_end_of_life").show();
|
||||
break;
|
||||
|
||||
case 'inventory_changes':
|
||||
$("#row_description").show();
|
||||
$("#row_period").show();
|
||||
|
|
|
@ -1756,6 +1756,17 @@ switch ($action) {
|
|||
$good_format = true;
|
||||
break;
|
||||
|
||||
case 'end_of_life':
|
||||
$es['end_of_life_date'] = get_parameter('end_of_life_date');
|
||||
$es['os_selector'] = get_parameter('os_selector');
|
||||
$es['os_version'] = get_parameter('text_os_version', '');
|
||||
$es['group'] = get_parameter('combo_group', '');
|
||||
$es['recursion'] = get_parameter('recursion', 0);
|
||||
|
||||
$values['external_source'] = json_encode($es);
|
||||
$good_format = true;
|
||||
break;
|
||||
|
||||
case 'alert_report_actions':
|
||||
$alert_templates_to_report = get_parameter('alert_templates');
|
||||
$alert_actions_to_report = get_parameter('alert_actions');
|
||||
|
@ -2699,6 +2710,17 @@ switch ($action) {
|
|||
$good_format = true;
|
||||
break;
|
||||
|
||||
case 'end_of_life':
|
||||
$es['end_of_life_date'] = get_parameter('end_of_life_date');
|
||||
$es['os_selector'] = get_parameter('os_selector');
|
||||
$es['os_version'] = get_parameter('text_os_version', '');
|
||||
$es['group'] = get_parameter('combo_group', '');
|
||||
$es['recursion'] = get_parameter('recursion', 0);
|
||||
|
||||
$values['external_source'] = json_encode($es);
|
||||
$good_format = true;
|
||||
break;
|
||||
|
||||
case 'alert_report_actions':
|
||||
$alert_templates_to_report = get_parameter('alert_templates');
|
||||
$alert_actions_to_report = get_parameter('alert_actions');
|
||||
|
|
|
@ -40,6 +40,191 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
|
|||
return;
|
||||
}
|
||||
|
||||
if ($idOS > 0) {
|
||||
$os = db_get_row_filter('tconfig_os', ['id_os' => $idOS]);
|
||||
$name = $os['name'];
|
||||
$description = $os['description'];
|
||||
$icon = $os['icon_name'];
|
||||
} else {
|
||||
$name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name'))));
|
||||
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
|
||||
$icon = get_parameter('icon', 0);
|
||||
}
|
||||
|
||||
$icon_upload = get_parameter('icon_upload', null);
|
||||
|
||||
$message = '';
|
||||
if ($is_management_allowed === true) {
|
||||
switch ($action) {
|
||||
case 'edit':
|
||||
if ($idOS > 0) {
|
||||
$actionHidden = 'update';
|
||||
$textButton = __('Update');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
} else {
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'next'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
if ($icon_upload !== null && $icon_upload['name'] !== '') {
|
||||
if (isset($_FILES['icon_upload']) === true) {
|
||||
$file_name = $_FILES['icon_upload']['name'];
|
||||
$file_tmp = $_FILES['icon_upload']['tmp_name'];
|
||||
$file_type = $_FILES['icon_upload']['type'];
|
||||
$file_ext = strtolower(end(explode('.', $_FILES['icon_upload']['name'])));
|
||||
|
||||
$allowed_extensions = [
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'png',
|
||||
'svg',
|
||||
];
|
||||
|
||||
$tab = 'manage_os';
|
||||
|
||||
if (in_array($file_ext, $allowed_extensions) === false) {
|
||||
$message = 9;
|
||||
} else {
|
||||
$message = 8;
|
||||
move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$values = [];
|
||||
$values['name'] = $name;
|
||||
$values['description'] = $description;
|
||||
|
||||
if (($icon !== 0) && ($icon != '')) {
|
||||
$values['icon_name'] = $icon;
|
||||
}
|
||||
|
||||
$resultOrId = false;
|
||||
if ($name != '') {
|
||||
$resultOrId = db_process_sql_insert('tconfig_os', $values);
|
||||
}
|
||||
|
||||
if ($resultOrId === false) {
|
||||
$message = 2;
|
||||
$tab = 'builder';
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
} else {
|
||||
$tab = 'manage_os';
|
||||
$message = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2=list&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
if ($icon_upload !== null && $icon_upload['name'] !== '') {
|
||||
if (isset($_FILES['icon_upload']) === true) {
|
||||
$file_name = $_FILES['icon_upload']['name'];
|
||||
$file_tmp = $_FILES['icon_upload']['tmp_name'];
|
||||
$file_type = $_FILES['icon_upload']['type'];
|
||||
$file_ext = strtolower(end(explode('.', $_FILES['icon_upload']['name'])));
|
||||
|
||||
$allowed_extensions = [
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'png',
|
||||
'svg',
|
||||
];
|
||||
|
||||
$tab = 'manage_os';
|
||||
|
||||
if (in_array($file_ext, $allowed_extensions) === false) {
|
||||
$message = 9;
|
||||
} else {
|
||||
$message = 8;
|
||||
move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name'))));
|
||||
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
|
||||
$icon = get_parameter('icon', 0);
|
||||
|
||||
$values = [];
|
||||
$values['name'] = $name;
|
||||
$values['description'] = $description;
|
||||
// Only for Metaconsole. Save the previous name for synchronizing.
|
||||
if (is_metaconsole() === true) {
|
||||
$values['previous_name'] = db_get_value('name', 'tconfig_os', 'id_os', $idOS);
|
||||
}
|
||||
|
||||
if (($icon !== 0) && ($icon != '')) {
|
||||
$values['icon_name'] = $icon;
|
||||
}
|
||||
|
||||
$result = false;
|
||||
if ($name != '') {
|
||||
$result = db_process_sql_update('tconfig_os', $values, ['id_os' => $idOS]);
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
$message = 3;
|
||||
$tab = 'manage_os';
|
||||
} else {
|
||||
$message = 4;
|
||||
$tab = 'builder';
|
||||
$os = db_get_row_filter('tconfig_os', ['id_os' => $idOS]);
|
||||
$name = $os['name'];
|
||||
}
|
||||
|
||||
$actionHidden = 'update';
|
||||
$textButton = __('Update');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$sql = 'SELECT COUNT(id_os) AS count FROM tagente WHERE id_os = '.$idOS;
|
||||
$count = db_get_all_rows_sql($sql);
|
||||
$count = $count[0]['count'];
|
||||
|
||||
if ($count > 0) {
|
||||
$message = 5;
|
||||
} else {
|
||||
$result = (bool) db_process_sql_delete('tconfig_os', ['id_os' => $idOS]);
|
||||
if ($result) {
|
||||
$message = 6;
|
||||
} else {
|
||||
$message = 7;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=list&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'new':
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'next'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$icons = get_list_os_icons_dir();
|
||||
|
||||
$iconData = [];
|
||||
|
@ -62,12 +247,11 @@ $iconData[] = html_print_div(
|
|||
true
|
||||
);
|
||||
|
||||
echo '<form id="form_setup" method="post">';
|
||||
echo '<form id="form_setup" method="post" enctype="multipart/form-data">';
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filter-table-adv';
|
||||
|
||||
// $table->style[0] = 'width: 15%';
|
||||
$table->data[0][] = html_print_label_input_block(
|
||||
__('Name'),
|
||||
html_print_input_text('name', $name, __('Name'), 20, 30, true, false, false, '', 'w250px')
|
||||
|
@ -89,6 +273,11 @@ $table->data[1][] = html_print_label_input_block(
|
|||
html_print_textarea('description', 5, 20, $description, '', true, 'w250px')
|
||||
);
|
||||
|
||||
$table->data[1][] = html_print_label_input_block(
|
||||
'',
|
||||
html_print_input_file('icon_upload', true, ['caption' => __('Upload icon')], 'form_setup')
|
||||
);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
html_print_input_hidden('id_os', $idOS);
|
||||
|
@ -101,7 +290,6 @@ html_print_action_buttons(
|
|||
|
||||
echo '</form>';
|
||||
|
||||
|
||||
function get_list_os_icons_dir()
|
||||
{
|
||||
global $config;
|
||||
|
|
|
@ -45,7 +45,7 @@ if (is_management_allowed() === false) {
|
|||
$is_management_allowed = false;
|
||||
if (is_metaconsole() === false) {
|
||||
$url = '<a target="_blank" href="'.ui_get_meta_url(
|
||||
'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2=list&pure='.(int) $config['pure']
|
||||
'index.php?sec=advanced&sec2=advanced/component_management&tab=list&tab2=list&pure='.(int) $config['pure']
|
||||
).'">'.__('metaconsole').'</a>';
|
||||
} else {
|
||||
$url = __('any node');
|
||||
|
@ -59,107 +59,68 @@ if (is_management_allowed() === false) {
|
|||
);
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
$table->class = 'info_table';
|
||||
$table->head[0] = __('ID');
|
||||
$table->head[1] = __('Icon');
|
||||
$table->head[2] = __('Name');
|
||||
$table->head[3] = __('Description');
|
||||
if ($is_management_allowed === true) {
|
||||
$table->head[4] = __('Actions');
|
||||
}
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'id_os',
|
||||
'icon_img',
|
||||
'name',
|
||||
'description',
|
||||
'options',
|
||||
];
|
||||
|
||||
if ($is_management_allowed === true) {
|
||||
$table->align[4] = 'center';
|
||||
}
|
||||
$column_names = [
|
||||
[
|
||||
'text' => __('ID'),
|
||||
'class' => 'w50px table_action_buttons',
|
||||
],
|
||||
[
|
||||
'text' => __('Icon'),
|
||||
'class' => 'w10px table_action_buttons',
|
||||
],
|
||||
__('Name'),
|
||||
__('Description'),
|
||||
[
|
||||
'text' => __('Options'),
|
||||
'class' => 'w20px table_action_buttons',
|
||||
],
|
||||
];
|
||||
|
||||
$table->size[0] = '5%';
|
||||
if ($is_management_allowed === true) {
|
||||
$table->size[4] = '20px';
|
||||
}
|
||||
|
||||
// Prepare pagination.
|
||||
$offset = (int) get_parameter('offset');
|
||||
$limit = $config['block_size'];
|
||||
$count_osList = db_get_value('count(*)', 'tconfig_os');
|
||||
|
||||
$osList = db_get_all_rows_filter(
|
||||
'tconfig_os',
|
||||
[
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
]
|
||||
);
|
||||
|
||||
if ($osList === false) {
|
||||
$osList = [];
|
||||
}
|
||||
|
||||
$table->data = [];
|
||||
foreach ($osList as $os) {
|
||||
$data = [];
|
||||
$data[] = $os['id_os'];
|
||||
$data[] = ui_print_os_icon($os['id_os'], false, true);
|
||||
if ($is_management_allowed === true) {
|
||||
if (is_metaconsole() === true) {
|
||||
$osNameUrl = 'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&action=edit&tab2=builder&id_os='.$os['id_os'];
|
||||
} else {
|
||||
$osNameUrl = 'index.php?sec=gsetup&sec2=godmode/setup/os&action=edit&tab=builder&id_os='.$os['id_os'];
|
||||
}
|
||||
|
||||
$data[] = html_print_anchor(
|
||||
[
|
||||
'href' => $osNameUrl,
|
||||
'content' => io_safe_output($os['name']),
|
||||
$tableId = 'os_table';
|
||||
// Load datatables user interface.
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => $tableId,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => 'include/ajax/os',
|
||||
'ajax_data' => ['method' => 'drawOSTable'],
|
||||
'ajax_postprocess' => 'process_datatables_item(item)',
|
||||
'no_sortable_columns' => [-1, 1],
|
||||
'order' => [
|
||||
'field' => 'id',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$data[] = io_safe_output($os['name']);
|
||||
}
|
||||
|
||||
$data[] = ui_print_truncate_text(io_safe_output($os['description']), 'description', true, true);
|
||||
|
||||
if ($is_management_allowed === true) {
|
||||
$table->cellclass[][4] = 'table_action_buttons';
|
||||
if ($os['id_os'] > 16) {
|
||||
if (is_metaconsole() === true) {
|
||||
$hrefDelete = 'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&action=delete&tab2=list&id_os='.$os['id_os'];
|
||||
} else {
|
||||
$hrefDelete = 'index.php?sec=gsetup&sec2=godmode/setup/os&action=delete&tab=list&id_os='.$os['id_os'];
|
||||
}
|
||||
|
||||
$data[] = html_print_anchor(
|
||||
[
|
||||
'href' => $hrefDelete,
|
||||
'content' => html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']),
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Free search'),
|
||||
'type' => 'text',
|
||||
'class' => 'w25p',
|
||||
'id' => 'free_search',
|
||||
'name' => 'free_search',
|
||||
],
|
||||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
// The original icons of pandora don't delete.
|
||||
$data[] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
$tablePagination = '';
|
||||
if (isset($data) === true) {
|
||||
html_print_table($table);
|
||||
$tablePagination = ui_pagination(
|
||||
$count_osList,
|
||||
ui_get_url_refresh(['message' => false]),
|
||||
$offset,
|
||||
0,
|
||||
true,
|
||||
'offset',
|
||||
false,
|
||||
''
|
||||
],
|
||||
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
|
||||
'dom_elements' => 'lftpB',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined operating systems') ]);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
$buttons = '';
|
||||
|
@ -183,3 +144,76 @@ html_print_action_buttons(
|
|||
'right_content' => $tablePagination,
|
||||
]
|
||||
);
|
||||
|
||||
echo '<div id="aux" class="invisible"></div>';
|
||||
|
||||
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit">';
|
||||
|
||||
html_print_action_buttons(
|
||||
html_print_submit_button(__('Create OS'), 'update_button', false, ['icon' => 'next'], true),
|
||||
['type' => 'form_action']
|
||||
);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
function process_datatables_item(item) {
|
||||
item.options = '<div class="table_action_buttons">';
|
||||
if (item.enable_delete === true) {
|
||||
var delete_id = item.id_os;
|
||||
item.options += '<a href="javascript:" onclick="delete_os(\'';
|
||||
item.options += delete_id;
|
||||
item.options += '\')" ><?php echo html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'main_menu_icon invert_filter']); ?></a>';
|
||||
}
|
||||
item.options += '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete selected OS
|
||||
*/
|
||||
function delete_os(id) {
|
||||
$('#aux').empty();
|
||||
$('#aux').text('<?php echo __('Are you sure?'); ?>');
|
||||
$('#aux').dialog({
|
||||
title: '<?php echo __('Delete'); ?> ' + id,
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Delete',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'include/ajax/os',
|
||||
method: 'deleteOS',
|
||||
id_os: id
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
var r = JSON.parse(data);
|
||||
if (r.deleted === false) {
|
||||
$('#aux').text('<?php echo __('Not deleted. Error deleting data'); ?>');
|
||||
} else {
|
||||
$('#aux').dialog('close');
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
$('#aux').text('<?php echo __('Not deleted. Error deleting data'); ?>');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -40,24 +40,13 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
|
|||
return;
|
||||
}
|
||||
|
||||
$action = get_parameter('action', 'new');
|
||||
$action = get_parameter('action', '');
|
||||
$idOS = get_parameter('id_os', 0);
|
||||
$id_message = get_parameter('message', 0);
|
||||
if (is_metaconsole() === true) {
|
||||
$tab = get_parameter('tab2', 'list');
|
||||
} else {
|
||||
$tab = get_parameter('tab', 'list');
|
||||
}
|
||||
|
||||
if ($idOS) {
|
||||
$os = db_get_row_filter('tconfig_os', ['id_os' => $idOS]);
|
||||
$name = $os['name'];
|
||||
$description = $os['description'];
|
||||
$icon = $os['icon_name'];
|
||||
} else {
|
||||
$name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name'))));
|
||||
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
|
||||
$icon = get_parameter('icon', 0);
|
||||
$tab = get_parameter('tab', 'manage_os');
|
||||
}
|
||||
|
||||
$is_management_allowed = true;
|
||||
|
@ -65,150 +54,60 @@ if (is_management_allowed() === false) {
|
|||
$is_management_allowed = false;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
if ($is_management_allowed === true) {
|
||||
switch ($action) {
|
||||
case 'edit':
|
||||
$actionHidden = 'update';
|
||||
$textButton = __('Update');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
$values = [];
|
||||
$values['name'] = $name;
|
||||
$values['description'] = $description;
|
||||
|
||||
if (($icon !== 0) && ($icon != '')) {
|
||||
$values['icon_name'] = $icon;
|
||||
}
|
||||
|
||||
$resultOrId = false;
|
||||
if ($name != '') {
|
||||
$resultOrId = db_process_sql_insert('tconfig_os', $values);
|
||||
}
|
||||
|
||||
if ($resultOrId === false) {
|
||||
$message = 2;
|
||||
$tab = 'builder';
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
} else {
|
||||
$tab = 'list';
|
||||
$message = 1;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name'))));
|
||||
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
|
||||
$icon = get_parameter('icon', 0);
|
||||
|
||||
$values = [];
|
||||
$values['name'] = $name;
|
||||
$values['description'] = $description;
|
||||
// Only for Metaconsole. Save the previous name for synchronizing.
|
||||
if (is_metaconsole() === true) {
|
||||
$values['previous_name'] = db_get_value('name', 'tconfig_os', 'id_os', $idOS);
|
||||
}
|
||||
|
||||
if (($icon !== 0) && ($icon != '')) {
|
||||
$values['icon_name'] = $icon;
|
||||
}
|
||||
|
||||
$result = false;
|
||||
if ($name != '') {
|
||||
$result = db_process_sql_update('tconfig_os', $values, ['id_os' => $idOS]);
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
$message = 3;
|
||||
$tab = 'list';
|
||||
} else {
|
||||
$message = 4;
|
||||
$tab = 'builder';
|
||||
$os = db_get_row_filter('tconfig_os', ['id_os' => $idOS]);
|
||||
$name = $os['name'];
|
||||
}
|
||||
|
||||
$actionHidden = 'update';
|
||||
$textButton = __('Update');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$sql = 'SELECT COUNT(id_os) AS count FROM tagente WHERE id_os = '.$idOS;
|
||||
$count = db_get_all_rows_sql($sql);
|
||||
$count = $count[0]['count'];
|
||||
|
||||
if ($count > 0) {
|
||||
$message = 5;
|
||||
} else {
|
||||
$result = (bool) db_process_sql_delete('tconfig_os', ['id_os' => $idOS]);
|
||||
if ($result) {
|
||||
$message = 6;
|
||||
} else {
|
||||
$message = 7;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'new':
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'next'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$buttons = [];
|
||||
$buttons['list'] = [
|
||||
|
||||
$buttons['manage_os'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=list">'.html_print_image(
|
||||
'images/logs@svg.svg',
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=manage_os">'.html_print_image(
|
||||
'images/os@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('List OS'),
|
||||
'title' => __('Manage OS types'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
$buttons['manage_version'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=manage_version">'.html_print_image(
|
||||
'images/os_version@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Manage version expiration dates'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
if ($is_management_allowed === true) {
|
||||
$buttons['builder'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=builder">'.html_print_image(
|
||||
'images/edit.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Builder OS'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
$buttons[$tab]['active'] = true;
|
||||
|
||||
$headerTitle = ($tab === 'builder') ? __('Edit OS') : __('List of Operating Systems');
|
||||
switch ($tab) {
|
||||
case 'builder':
|
||||
$headerTitle = __('Edit OS');
|
||||
break;
|
||||
|
||||
case 'manage_os':
|
||||
case 'list':
|
||||
if ($action === 'edit') {
|
||||
$headerTitle = __('Edit OS');
|
||||
} else {
|
||||
$headerTitle = __('List of Operating Systems');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'manage_version':
|
||||
if ($action === 'edit') {
|
||||
$headerTitle = __('Edit OS version expiration date');
|
||||
} else {
|
||||
$headerTitle = __('List of version expiration dates');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
// Header.
|
||||
|
@ -262,6 +161,14 @@ if (empty($id_message) === false) {
|
|||
echo ui_print_error_message(__('Error deleting'), '', true);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
echo ui_print_success_message(__('Icon successfuly uploaded'), '', true);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
|
@ -269,12 +176,21 @@ if (empty($id_message) === false) {
|
|||
}
|
||||
|
||||
switch ($tab) {
|
||||
case 'manage_os':
|
||||
case 'list':
|
||||
include_once $config['homedir'].'/godmode/setup/os.list.php';
|
||||
if (in_array($action, ['edit', 'save', 'update']) && is_management_allowed() === true) {
|
||||
include_once $config['homedir'].'/godmode/setup/os.builder.php';
|
||||
} else {
|
||||
include_once $config['homedir'].'/godmode/setup/os.list.php';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'builder':
|
||||
include_once $config['homedir'].'/godmode/setup/os.builder.php';
|
||||
case 'manage_version':
|
||||
if (in_array($action, ['edit', 'save', 'update']) && is_management_allowed() === true) {
|
||||
include_once $config['homedir'].'/godmode/setup/os_version.builder.php';
|
||||
} else {
|
||||
include_once $config['homedir'].'/godmode/setup/os_version.list.php';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
/**
|
||||
* OS Builder
|
||||
*
|
||||
* @category Os
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2023 Pandora FMS
|
||||
* Please see https://pandorafms.com/community/ 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Setup Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
ui_require_css_file('datepicker');
|
||||
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
|
||||
ui_include_time_picker();
|
||||
ui_require_javascript_file('pandora');
|
||||
|
||||
if ($idOS > 0) {
|
||||
$os_version = db_get_row_filter('tconfig_os_version', ['id_os_version' => $idOS]);
|
||||
$product = $os_version['product'];
|
||||
$version = $os_version['version'];
|
||||
$end_of_life_date = $os_version['end_of_support'];
|
||||
} else {
|
||||
$product = io_safe_input(strip_tags(io_safe_output((string) get_parameter('product'))));
|
||||
$version = io_safe_input(strip_tags(io_safe_output((string) get_parameter('version'))));
|
||||
$end_of_life_date = get_parameter('end_of_life_date', date("Y/m/d"));
|
||||
}
|
||||
|
||||
$message = '';
|
||||
if ($is_management_allowed === true) {
|
||||
switch ($action) {
|
||||
case 'edit':
|
||||
if ($idOS > 0) {
|
||||
$actionHidden = 'update';
|
||||
$textButton = __('Update');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
} else {
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'next'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
$values = [];
|
||||
// Product and version must be stored with no entities to be able to use REGEXP in queries.
|
||||
// CAREFUL! output of these fields must be encoded to avoid scripting vulnerabilities.
|
||||
$values['product'] = io_safe_output($product);
|
||||
$values['version'] = io_safe_output($version);
|
||||
$values['end_of_support'] = $end_of_life_date;
|
||||
|
||||
$result = db_process_sql_insert('tconfig_os_version', $values);
|
||||
|
||||
if ($result === false) {
|
||||
$message = 2;
|
||||
} else {
|
||||
$message = 1;
|
||||
}
|
||||
|
||||
$tab = 'manage_version';
|
||||
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$product = io_safe_output(get_parameter('product'));
|
||||
$version = io_safe_output(get_parameter('version'));
|
||||
$end_of_life_date = get_parameter('end_of_life_date', 0);
|
||||
$values = [];
|
||||
$values['product'] = $product;
|
||||
$values['version'] = $version;
|
||||
$values['end_of_support'] = $end_of_life_date;
|
||||
hd($values, true);
|
||||
hd($idOS, true);
|
||||
$result = db_process_sql_update('tconfig_os_version', $values, ['id_os_version' => $idOS]);
|
||||
|
||||
if ($result === false) {
|
||||
$message = 4;
|
||||
} else {
|
||||
$message = 3;
|
||||
}
|
||||
|
||||
$tab = 'manage_version';
|
||||
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$sql = 'SELECT COUNT(id_os) AS count FROM tagente WHERE id_os = '.$idOS;
|
||||
$count = db_get_all_rows_sql($sql);
|
||||
$count = $count[0]['count'];
|
||||
|
||||
if ($count > 0) {
|
||||
$message = 5;
|
||||
} else {
|
||||
$result = (bool) db_process_sql_delete('tconfig_os', ['id_os' => $idOS]);
|
||||
if ($result) {
|
||||
$message = 6;
|
||||
} else {
|
||||
$message = 7;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=list&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'new':
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'next'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<form id="form_setup" method="post">';
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filter-table-adv';
|
||||
|
||||
// $table->style[0] = 'width: 15%';
|
||||
$table->data[0][] = html_print_label_input_block(
|
||||
__('Product'),
|
||||
html_print_input_text('product', io_safe_input($product), __('Product'), 20, 300, true, false, false, '', 'w250px')
|
||||
);
|
||||
|
||||
$table->data[0][] = html_print_label_input_block(
|
||||
__('Version'),
|
||||
html_print_input_text('version', io_safe_input($version), __('Version'), 20, 300, true, false, false, '', 'w250px')
|
||||
);
|
||||
|
||||
$timeInputs = [];
|
||||
|
||||
$timeInputs[] = html_print_div(
|
||||
[
|
||||
'id' => 'end_of_life_date',
|
||||
'style' => '',
|
||||
'content' => html_print_div(
|
||||
[
|
||||
'class' => '',
|
||||
'content' => html_print_input_text(
|
||||
'end_of_life_date',
|
||||
$end_of_life_date,
|
||||
'',
|
||||
10,
|
||||
10,
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][] = html_print_label_input_block(
|
||||
__('End of life date'),
|
||||
implode('', $timeInputs)
|
||||
);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
html_print_input_hidden('id_os', $idOS);
|
||||
html_print_input_hidden('action', $actionHidden);
|
||||
|
||||
html_print_action_buttons(
|
||||
html_print_submit_button($textButton, 'update_button', false, $classButton, true),
|
||||
['type' => 'form_action']
|
||||
);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
$("#text-end_of_life_date").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>", showButtonPanel: true});
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/**
|
||||
* Version expiration date editor
|
||||
*
|
||||
* @category Os
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2023 Pandora FMS
|
||||
* Please see https://pandorafms.com/community/ 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Setup Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'product',
|
||||
'version',
|
||||
'end_of_support',
|
||||
'options',
|
||||
];
|
||||
|
||||
$column_names = [
|
||||
__('Product'),
|
||||
__('Version'),
|
||||
__('End of support date'),
|
||||
[
|
||||
'text' => __('Options'),
|
||||
'class' => 'w100px table_action_buttons',
|
||||
],
|
||||
];
|
||||
|
||||
$tableId = 'os_version_table';
|
||||
// Load datatables user interface.
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => $tableId,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => 'include/ajax/os',
|
||||
'ajax_data' => ['method' => 'drawOSVersionTable'],
|
||||
'ajax_postprocess' => 'process_datatables_item(item)',
|
||||
'no_sortable_columns' => [-1],
|
||||
'order' => [
|
||||
'field' => 'id',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Free search'),
|
||||
'type' => 'text',
|
||||
'class' => 'w25p',
|
||||
'id' => 'free_search',
|
||||
'name' => 'free_search',
|
||||
],
|
||||
],
|
||||
],
|
||||
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
|
||||
'dom_elements' => 'lftpB',
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
echo '<div id="aux" class="invisible"></div>';
|
||||
|
||||
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_version&action=edit">';
|
||||
|
||||
html_print_action_buttons(
|
||||
html_print_submit_button(__('Create OS version'), 'update_button', false, ['icon' => 'next'], true),
|
||||
['type' => 'form_action']
|
||||
);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo '<form id="redirect-form" method="post" action="index.php?sec=view&sec2=operation/agentes/estado_agente">';
|
||||
|
||||
html_print_input_hidden('os_version_regex', '');
|
||||
|
||||
echo '</form>';
|
||||
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
function process_datatables_item(item) {
|
||||
id = item.id_os_version;
|
||||
|
||||
idrow = '<b><a href="javascript:" onclick="show_form(\'';
|
||||
idrow += item.id_os_version;
|
||||
idrow += '\')" >'+item.id_os_version+'</a></b>';
|
||||
item.id_os_version = idrow;
|
||||
item.options = '<div class="table_action_buttons">';
|
||||
item.options += '<a href="index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_version&action=edit&id_os=';
|
||||
item.options += id;
|
||||
item.options += '" ><?php echo html_print_image('images/edit.svg', true, ['title' => __('Edit'), 'class' => 'main_menu_icon invert_filter']); ?></a>';
|
||||
|
||||
item.options += '<a href="javascript:" onclick="redirect_to_agents_by_version(\'';
|
||||
item.options += item.version;
|
||||
item.options += '\')" ><?php echo html_print_image('images/agents.svg', true, ['title' => __('Show agents'), 'class' => 'main_menu_icon invert_filter']); ?></a>';
|
||||
|
||||
item.options += '<a href="javascript:" onclick="delete_os_version(\'';
|
||||
item.options += id;
|
||||
item.options += '\')" ><?php echo html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'main_menu_icon invert_filter']); ?></a>';
|
||||
item.options += '</div>';
|
||||
|
||||
item.options += '<form method="post" action="?sec=view&sec2=operation/agentes/estado_agente"></form>';
|
||||
}
|
||||
|
||||
function redirect_to_agents_by_version(version) {
|
||||
$('#hidden-os_version_regex').val(version);
|
||||
$('#redirect-form').submit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete selected OS version
|
||||
*/
|
||||
function delete_os_version(id) {
|
||||
$('#aux').empty();
|
||||
$('#aux').text('<?php echo __('Are you sure?'); ?>');
|
||||
$('#aux').dialog({
|
||||
title: '<?php echo __('Delete'); ?> ' + id,
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Delete',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'include/ajax/os',
|
||||
method: 'deleteOSVersion',
|
||||
id_os_version: id
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
var r = JSON.parse(data);
|
||||
if (r.deleted === false) {
|
||||
$('#aux').text('<?php echo __('Not deleted. Error deleting data'); ?>');
|
||||
} else {
|
||||
$('#aux').dialog('close');
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
$('#aux').text('<?php echo __('Not deleted. Error deleting data'); ?>');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,285 @@
|
|||
<?php
|
||||
/**
|
||||
* Os version.
|
||||
*
|
||||
* @category Os version
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2023 Pandora FMS
|
||||
* Please see https://pandorafms.com/community/ 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Setup Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$action = get_parameter('action', 'new');
|
||||
$id_os_version = get_parameter('id_os_version', 0);
|
||||
if (is_metaconsole() === true) {
|
||||
$tab = get_parameter('tab2', 'list');
|
||||
} else {
|
||||
$tab = get_parameter('tab', 'list');
|
||||
}
|
||||
|
||||
if ($id_os_version) {
|
||||
$os_version = db_get_row_filter('tconfig_os_version', ['id_os_version' => $id_os_version]);
|
||||
$product = $os_version['product'];
|
||||
$version = $os_version['version'];
|
||||
$end_of_life_date = $os_version['end_of_life_date'];
|
||||
} else {
|
||||
$product = io_safe_input(strip_tags(io_safe_output((string) get_parameter('product'))));
|
||||
$version = io_safe_input(strip_tags(io_safe_output((string) get_parameter('version'))));
|
||||
$end_of_life_date = get_parameter('end_of_life_date', 0);
|
||||
}
|
||||
|
||||
$is_management_allowed = true;
|
||||
if (is_management_allowed() === false) {
|
||||
$is_management_allowed = false;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
if ($is_management_allowed === true) {
|
||||
switch ($action) {
|
||||
case 'edit':
|
||||
$action_hidden = 'update';
|
||||
$text_button = __('Update');
|
||||
$class_button = ['icon' => 'wand'];
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
$values = [];
|
||||
$values['product'] = $product;
|
||||
$values['version'] = $version;
|
||||
$values['end_of_life_date'] = $end_of_life_date;
|
||||
|
||||
$result_or_id = false;
|
||||
if ($product !== '') {
|
||||
$result_or_id = db_process_sql_insert('tconfig_os_version', $values);
|
||||
}
|
||||
|
||||
if ($result_or_id === false) {
|
||||
$message = 2;
|
||||
$tab = 'builder';
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
} else {
|
||||
$tab = 'list';
|
||||
$message = 1;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$product = io_safe_input(strip_tags(io_safe_output((string) get_parameter('product'))));
|
||||
$version = io_safe_input(strip_tags(io_safe_output((string) get_parameter('version'))));
|
||||
$end_of_life_date = get_parameter('end_of_life_date', 0);
|
||||
|
||||
$values = [];
|
||||
$values['product'] = $product;
|
||||
$values['version'] = $version;
|
||||
|
||||
$result = false;
|
||||
$result = db_process_sql_update('tconfig_os_version', $values, ['id_os' => $id_os_version]);
|
||||
|
||||
if ($result !== false) {
|
||||
$message = 3;
|
||||
$tab = 'list';
|
||||
} else {
|
||||
$message = 4;
|
||||
$tab = 'builder';
|
||||
$os = db_get_row_filter('tconfig_os', ['id_os' => $idOS]);
|
||||
$name = $os['name'];
|
||||
}
|
||||
|
||||
$actionHidden = 'update';
|
||||
$textButton = __('Update');
|
||||
$classButton = ['icon' => 'wand'];
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os_version&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$sql = 'SELECT COUNT(id_os) AS count FROM tagente WHERE id_os = '.$idOS;
|
||||
$count = db_get_all_rows_sql($sql);
|
||||
$count = $count[0]['count'];
|
||||
|
||||
if ($count > 0) {
|
||||
$message = 5;
|
||||
} else {
|
||||
$result = (bool) db_process_sql_delete('tconfig_os', ['id_os' => $idOS]);
|
||||
if ($result) {
|
||||
$message = 6;
|
||||
} else {
|
||||
$message = 7;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
|
||||
} else {
|
||||
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'new':
|
||||
$actionHidden = 'save';
|
||||
$textButton = __('Create');
|
||||
$classButton = ['icon' => 'next'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$buttons = [];
|
||||
$buttons['list'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=list">'.html_print_image(
|
||||
'images/logs@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('List OS'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
if ($is_management_allowed === true) {
|
||||
$buttons['builder'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=builder">'.html_print_image(
|
||||
'images/edit.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Builder OS'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
$buttons['version_exp_date_editor'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=manage_version">'.html_print_image(
|
||||
'images/edit.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Version expiration date editor'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
$buttons[$tab]['active'] = true;
|
||||
|
||||
switch ($tab) {
|
||||
case 'builder':
|
||||
$headerTitle = __('Edit OS');
|
||||
break;
|
||||
|
||||
case 'manage_version':
|
||||
$headerTitle = __('Version expiration date editor');
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
$headerTitle = __('List of Operating Systems');
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
$headerTitle,
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
true,
|
||||
$buttons,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Servers'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Edit OS'),
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($id_message) === false) {
|
||||
switch ($id_message) {
|
||||
case 1:
|
||||
echo ui_print_success_message(__('Success creating OS'), '', true);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
echo ui_print_error_message(__('Fail creating OS'), '', true);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
echo ui_print_success_message(__('Success updating OS'), '', true);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
echo ui_print_error_message(__('Error updating OS'), '', true);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
echo ui_print_error_message(__('There are agents with this OS.'), '', true);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
echo ui_print_success_message(__('Success deleting'), '', true);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
echo ui_print_error_message(__('Error deleting'), '', true);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
include_once $config['homedir'].'/godmode/setup/os_version.list.php';
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>os@svg</title>
|
||||
<g id="os" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M10,0 C15.5228475,0 20,4.4771525 20,10 C20,15.5228475 15.5228475,20 10,20 C4.4771525,20 0,15.5228475 0,10 C0,4.4771525 4.4771525,0 10,0 Z M6.15259698,6 C4.79331529,6 3.76139537,6.31928651 3.05683722,6.95785953 C2.35227907,7.59643255 2,8.60958751 2,9.99732441 C2,11.3850613 2.35227907,12.3991081 3.05683722,13.0394649 C3.76139537,13.6798216 4.79331529,14 6.15259698,14 C7.51187868,14 8.54208016,13.6807135 9.24320144,13.0421405 C9.94775959,12.4 10.3000387,11.3850613 10.3000387,9.99732441 C10.3000387,8.60958751 9.94861881,7.59643255 9.2457791,6.95785953 C8.54293938,6.31928651 7.51187868,6 6.15259698,6 Z M13.7468746,6.11772575 C12.5474073,6.11772575 11.7019375,6.31125975 11.2104653,6.69832776 C10.718993,7.08539576 10.4732569,7.63745819 10.4732569,8.35451505 C10.4732569,8.74336678 10.5755037,9.08138239 10.7799974,9.36856187 C10.9844911,9.65574136 11.2517077,9.88138239 11.5816471,10.0454849 C11.9115865,10.2095875 12.273317,10.3522854 12.6668385,10.4735786 C13.06036,10.5948718 13.4564592,10.6956522 13.855136,10.7759197 C14.2538128,10.8561873 14.6181209,10.9373467 14.9480603,11.019398 C15.6869872,11.1977703 16.0564506,11.4421405 16.0564506,11.7525084 C16.0564506,12.1627648 15.7540061,12.367893 15.1491172,12.367893 L13.3447609,12.3304348 C12.7811144,12.3304348 12.4185247,12.1556299 12.2569919,11.8060201 C12.095459,11.4564103 11.8600335,11.2816054 11.5507153,11.2816054 L10.9372342,11.2816054 C10.8238175,11.2816054 10.706964,11.3270903 10.5866735,11.4180602 C10.4663831,11.5090301 10.4062379,11.6597547 10.4062379,11.8702341 C10.4062379,12.4338907 10.6897796,12.9039019 11.256863,13.2802676 C11.8239464,13.6566332 12.4597672,13.8448161 13.1643253,13.8448161 L14.7263823,13.8769231 C15.9224127,13.8769231 16.7670232,13.6833891 17.2602139,13.2963211 C17.7534046,12.9092531 18,12.3571906 18,11.6401338 C18,11.1157191 17.8083946,10.6778149 17.4251837,10.3264214 C17.0419728,9.97502787 16.5754178,9.72263099 16.0255188,9.56923077 C15.4756197,9.41583055 14.9282983,9.28472687 14.3835546,9.17591973 C13.8388108,9.0671126 13.3748335,8.94136009 12.9916226,8.79866221 C12.6084117,8.65596433 12.4168063,8.4722408 12.4168063,8.24749164 C12.4168063,7.83723523 12.7192508,7.63210702 13.3241397,7.63210702 L14.8758861,7.66421405 C15.4395326,7.66421405 15.8021223,7.83991081 15.9636551,8.19130435 C16.125188,8.54269788 16.3606135,8.71839465 16.6699317,8.71839465 L17.2834128,8.71839465 C17.3933926,8.71839465 17.5085277,8.67201784 17.6288181,8.57926421 C17.7491086,8.48651059 17.8092538,8.33489409 17.8092538,8.12441472 C17.8092538,7.56075808 17.5265713,7.09074693 16.9612063,6.71438127 C16.3958414,6.33801561 15.7608798,6.14983278 15.0563217,6.14983278 Z M6.15259698,7.44481605 C6.92761095,7.44481605 7.48867981,7.65886288 7.83580358,8.08695652 C8.18292735,8.51505017 8.35648924,9.15273133 8.35648924,10 C8.35648924,10.8472687 8.18292735,11.484058 7.83580358,11.9103679 C7.48867981,12.3366778 6.92761095,12.5498328 6.15259698,12.5498328 C5.37758302,12.5498328 4.81565494,12.3366778 4.46681273,11.9103679 C4.11797053,11.484058 3.94354943,10.8472687 3.94354943,10 C3.94354943,9.15273133 4.11797053,8.51505017 4.46681273,8.08695652 C4.81565494,7.65886288 5.37758302,7.44481605 6.15259698,7.44481605 Z" id="Oval-2" fill="#3F3F3F"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.5 KiB |
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>os version@svg</title>
|
||||
<g id="os-version" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M10,5 C12.7614237,5 15,7.23857625 15,10 C15,12.7614237 12.7614237,15 10,15 C7.23857625,15 5,12.7614237 5,10 C5,7.23857625 7.23857625,5 10,5 Z M8.00124224,8 C7.34616977,8 6.84886128,8.15964326 6.50931677,8.47892977 C6.16977226,8.79821628 6,9.30479376 6,9.99866221 C6,10.6925307 6.16977226,11.1995541 6.50931677,11.5197324 C6.84886128,11.8399108 7.34616977,12 8.00124224,12 C8.6563147,12 9.15279503,11.8403567 9.49068323,11.5210702 C9.83022774,11.2 10,10.6925307 10,9.99866221 C10,9.30479376 9.83064182,8.79821628 9.49192547,8.47892977 C9.15320911,8.15964326 8.6563147,8 8.00124224,8 Z M11.7596741,8 C11.127857,8 10.6825074,8.09977011 10.4236253,8.29931034 C10.1647432,8.49885057 10.0353021,8.78344828 10.0353021,9.15310345 C10.0353021,9.35356322 10.0891604,9.52781609 10.1968771,9.67586207 C10.3045938,9.82390805 10.4453496,9.94022989 10.6191446,10.0248276 C10.7929396,10.1094253 10.9834804,10.1829885 11.1907671,10.2455172 C11.3980539,10.308046 11.6066983,10.36 11.8167006,10.4013793 C12.0267029,10.4427586 12.2186015,10.4845977 12.3923965,10.5268966 C12.7816248,10.6188506 12.976239,10.7448276 12.976239,10.9048276 C12.976239,11.1163218 12.8169269,11.222069 12.4983028,11.222069 L11.5478615,11.2027586 C11.2509618,11.2027586 11.0599683,11.1126437 10.9748812,10.9324138 C10.8897941,10.7521839 10.7657841,10.662069 10.6028513,10.662069 L10.2797013,10.662069 C10.2199593,10.662069 10.1584069,10.6855172 10.0950441,10.7324138 C10.0316814,10.7793103 10,10.8570115 10,10.9655172 C10,11.256092 10.1493551,11.4983908 10.4480652,11.6924138 C10.7467753,11.8864368 11.0816927,11.9834483 11.4528174,11.9834483 L12.275628,12 C12.9056348,12 13.3505318,11.9002299 13.6103191,11.7006897 C13.8701064,11.5011494 14,11.2165517 14,10.8468966 C14,10.5765517 13.8990722,10.3508046 13.6972166,10.1696552 C13.4953609,9.98850575 13.249604,9.8583908 12.9599457,9.77931034 C12.6702874,9.70022989 12.3819869,9.63264368 12.0950441,9.57655172 C11.8081014,9.52045977 11.5637022,9.45563218 11.3618466,9.38206897 C11.1599909,9.30850575 11.0590631,9.2137931 11.0590631,9.09793103 C11.0590631,8.88643678 11.2183752,8.78068966 11.5369993,8.78068966 L12.3543788,8.79724138 C12.6512786,8.79724138 12.842272,8.88781609 12.9273591,9.06896552 C13.0124463,9.25011494 13.1364562,9.34068966 13.299389,9.34068966 L13.622539,9.34068966 C13.6804707,9.34068966 13.7411179,9.31678161 13.8044807,9.26896552 C13.8678434,9.22114943 13.8995248,9.14298851 13.8995248,9.03448276 C13.8995248,8.74390805 13.7506223,8.5016092 13.4528174,8.30758621 C13.1550124,8.11356322 12.8205476,8.01655172 12.4494229,8.01655172 Z M8.00124224,8.72240803 C8.3747412,8.72240803 8.64513458,8.82943144 8.81242236,9.04347826 C8.97971014,9.25752508 9.06335404,9.57636566 9.06335404,10 C9.06335404,10.4236343 8.97971014,10.742029 8.81242236,10.9551839 C8.64513458,11.1683389 8.3747412,11.2749164 8.00124224,11.2749164 C7.62774327,11.2749164 7.35693582,11.1683389 7.18881988,10.9551839 C7.02070393,10.742029 6.93664596,10.4236343 6.93664596,10 C6.93664596,9.57636566 7.02070393,9.25752508 7.18881988,9.04347826 C7.35693582,8.82943144 7.62774327,8.72240803 8.00124224,8.72240803 Z" id="Oval-2" fill="#3F3F3F"></path>
|
||||
<g id="Group" transform="translate(10, 0.9972)" fill="#3F3F3F" fill-rule="nonzero">
|
||||
<path d="M0.239098823,-0.999498516 C0.367920916,-1.0006481 0.46086938,-1.00001443 0.545625818,-0.996148978 C5.85594931,-0.753608542 10,3.63723482 10,9.00280962 C10,11.7312591 8.9006895,14.287461 6.98753217,16.1564431 C5.94922318,17.1707773 5.2256829,17.9806061 4.82608058,18.5663616 C4.51483939,19.0225933 3.89267968,19.1401314 3.43644798,18.8288902 C2.98021627,18.517649 2.86267824,17.8954893 3.17391942,17.4392576 C3.66277305,16.7226734 4.46505413,15.8247132 5.5899319,14.7258091 C7.12171888,13.2293915 8,11.1871442 8,9.00280962 C8,4.70099732 4.69132984,1.19528432 0.454374182,1.00176822 C0.441581214,1.00118392 0.425875842,1.0007459 0.407122626,1.00045278 L0.204431552,1.00096401 L0.173047576,1.00133321 C0.143860257,1.00169127 0.124402045,1.00192997 0.10826377,1.00210401 L0,1.00280962 C-0.55228475,1.00280962 -1,0.555094372 -1,0.00280962244 C-1,-0.549475127 -0.55228475,-0.997190378 0,-0.997190378 L0.0986592653,-0.99792167 L0.14911528,-0.998523592 C0.192941176,-0.999044088 0.192941176,-0.999044088 0.239098823,-0.999498516 Z" id="Oval"></path>
|
||||
<path d="M4,14.0028096 C4.55228475,14.0028096 5,14.4505249 5,15.0028096 L5,17.0028096 L7,17.0028096 C7.51283584,17.0028096 7.93550716,17.3888498 7.99327227,17.8861885 L8,18.0028096 C8,18.5550944 7.55228475,19.0028096 7,19.0028096 L4,19.0028096 C3.44771525,19.0028096 3,18.5550944 3,18.0028096 L3,15.0028096 C3,14.4505249 3.44771525,14.0028096 4,14.0028096 Z" id="Path-87"></path>
|
||||
</g>
|
||||
<g id="Group" transform="translate(5.5, 9.9986) scale(-1, -1) translate(-5.5, -9.9986)translate(1, 0.9972)" fill="#3F3F3F" fill-rule="nonzero">
|
||||
<path d="M5.93830089,14.3635692 C6.30852501,13.9537491 6.94087583,13.9216502 7.35069596,14.2918743 C7.7605161,14.6620984 7.79261501,15.2944492 7.42239089,15.7042693 C7.28217928,15.8594768 7.13715,16.01028 6.98753217,16.1564431 C5.94922318,17.1707773 5.2256829,17.9806061 4.82608058,18.5663616 C4.51483939,19.0225933 3.89267968,19.1401314 3.43644798,18.8288902 C2.98021627,18.517649 2.86267824,17.8954893 3.17391942,17.4392576 C3.66277305,16.7226734 4.46505413,15.8247132 5.5899319,14.7258091 C5.7097935,14.6087152 5.82597871,14.4879044 5.93830089,14.3635692 Z M8.943119,7.56724451 C9.49480124,7.54145411 9.96293532,7.96777368 9.98872572,8.51945593 C9.99623585,8.68010519 10,8.84125436 10,9.00293537 C10,10.3523848 9.73199051,11.6661445 9.21843823,12.8844407 C9.00391256,13.3933584 8.41744587,13.6320103 7.90852821,13.4174846 C7.39961056,13.2029589 7.1609587,12.6164922 7.37548437,12.1075746 C7.78585079,11.1340654 7.99998666,10.0843244 8,9.00292303 C8,8.87239659 7.99696323,8.74238768 7.99090758,8.61285123 C7.96511718,8.06116899 8.39143675,7.59303491 8.943119,7.56724451 Z M5.35650642,1.65292436 C5.7304364,1.24648271 6.3630526,1.2201268 6.76949425,1.59405678 C7.86955054,2.60611849 8.7319506,3.85799548 9.28762134,5.25683726 C9.4915113,5.77010846 9.24070825,6.35148245 8.72743704,6.55537241 C8.21416584,6.75926237 7.63279185,6.50845932 7.42890189,5.99518811 C6.98434699,4.87606861 6.29458082,3.8747904 5.41537399,3.06591219 C5.00893235,2.6919822 4.98257643,2.05936601 5.35650642,1.65292436 Z M0.239098823,-0.999498516 C0.367920916,-1.0006481 0.46086938,-1.00001443 0.545625818,-0.996148978 C1.70508629,-0.943192496 2.82882174,-0.691139109 3.87925052,-0.254949612 C4.38930817,-0.0431486814 4.63109302,0.542033323 4.41929209,1.05209098 C4.20749116,1.56214863 3.62230915,1.80393348 3.1122515,1.59213255 C2.27594636,1.24485768 1.38082518,1.04408237 0.454374182,1.00176822 C0.441581214,1.00118392 0.425875842,1.0007459 0.407122626,1.00045278 L0.204431552,1.00096401 L0.173047576,1.00133321 C0.143860257,1.00169127 0.124402045,1.00192997 0.10826377,1.00210401 L0,1.00280962 C-0.55228475,1.00280962 -1,0.555094372 -1,0.00280962244 C-1,-0.549475127 -0.55228475,-0.997190378 0,-0.997190378 L0.0986592653,-0.99792167 L0.14911528,-0.998523592 C0.192941176,-0.999044088 0.192941176,-0.999044088 0.239098823,-0.999498516 Z" id="Oval"></path>
|
||||
<path d="M4,14.0028096 C4.55228475,14.0028096 5,14.4505249 5,15.0028096 L5,17.0028096 L7,17.0028096 C7.51283584,17.0028096 7.93550716,17.3888498 7.99327227,17.8861885 L8,18.0028096 C8,18.5550944 7.55228475,19.0028096 7,19.0028096 L4,19.0028096 C3.44771525,19.0028096 3,18.5550944 3,18.0028096 L3,15.0028096 C3,14.4505249 3.44771525,14.0028096 4,14.0028096 Z" id="Path-87"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 7.7 KiB |
|
@ -0,0 +1,376 @@
|
|||
<?php
|
||||
/**
|
||||
* Update manager client historical updates backend.
|
||||
*
|
||||
* @category Update Manager
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2023 Pandora FMS
|
||||
* Please see https://pandorafms.com/community/ 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.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
if ((bool) check_acl($config['id_user'], 0, 'PM') === false
|
||||
&& (bool) is_user_admin($config['id_user']) === false
|
||||
) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Setup Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$method = get_parameter('method', null);
|
||||
|
||||
if ($method === 'deleteOS') {
|
||||
global $config;
|
||||
|
||||
$id_os = get_parameter('id_os', null);
|
||||
|
||||
if (empty($id_os) === true || $id_os < 16) {
|
||||
echo json_encode(['deleted' => false]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (db_process_sql_delete(
|
||||
'tconfig_os',
|
||||
['id_os' => $id_os]
|
||||
) === false
|
||||
) {
|
||||
echo json_encode(['deleted' => false]);
|
||||
} else {
|
||||
echo json_encode(['deleted' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($method === 'deleteOSVersion') {
|
||||
global $config;
|
||||
|
||||
$id_os_version = get_parameter('id_os_version', null);
|
||||
|
||||
if (empty($id_os_version) === true || $id_os_version < 1) {
|
||||
echo json_encode(['deleted' => false]);
|
||||
}
|
||||
|
||||
if (db_process_sql_delete(
|
||||
'tconfig_os_version',
|
||||
['id_os_version' => $id_os_version]
|
||||
) === false
|
||||
) {
|
||||
echo json_encode(['deleted' => false]);
|
||||
} else {
|
||||
echo json_encode(['deleted' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($method === 'drawOSTable') {
|
||||
// Datatables offset, limit and order.
|
||||
$filter = get_parameter('filter', []);
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
$orderBy = get_datatable_order(true);
|
||||
|
||||
$sort_field = $orderBy['field'];
|
||||
$order = $orderBy['direction'];
|
||||
|
||||
$pagination = '';
|
||||
|
||||
$pagination = sprintf(
|
||||
' LIMIT %d OFFSET %d ',
|
||||
$length,
|
||||
$start
|
||||
);
|
||||
|
||||
try {
|
||||
ob_start();
|
||||
|
||||
$fields = ['*'];
|
||||
$sql_filters = [];
|
||||
|
||||
if (isset($filter['free_search']) === true
|
||||
&& empty($filter['free_search']) === false
|
||||
) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (`name` like "%%%s%%" OR `description` like "%%%s%%") ',
|
||||
$filter['free_search'],
|
||||
$filter['free_search']
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($order) === true) {
|
||||
$dir = 'asc';
|
||||
if ($order == 'desc') {
|
||||
$dir = 'desc';
|
||||
};
|
||||
|
||||
if (in_array(
|
||||
$sort_field,
|
||||
[
|
||||
'id_os',
|
||||
'name',
|
||||
'description',
|
||||
]
|
||||
) === true
|
||||
) {
|
||||
$order_by = sprintf(
|
||||
'ORDER BY `%s` %s',
|
||||
$sort_field,
|
||||
$dir
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve data.
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM tconfig_os
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s',
|
||||
join(',', $fields),
|
||||
join(' ', $sql_filters),
|
||||
$order_by,
|
||||
$pagination
|
||||
);
|
||||
|
||||
$count_sql = sprintf(
|
||||
'SELECT id_os
|
||||
FROM tconfig_os
|
||||
WHERE 1=1
|
||||
%s',
|
||||
join(' ', $sql_filters)
|
||||
);
|
||||
|
||||
$return = db_get_all_rows_sql($sql);
|
||||
if ($return === false) {
|
||||
$data = [];
|
||||
} else {
|
||||
$data = $return;
|
||||
}
|
||||
|
||||
$data = array_map(
|
||||
function ($item) {
|
||||
$item['icon_img'] = ui_print_os_icon($item['id_os'], false, true);
|
||||
|
||||
if (is_management_allowed() === true) {
|
||||
if (is_metaconsole() === true) {
|
||||
$osNameUrl = 'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&action=edit&tab2=list&id_os='.$item['id_os'];
|
||||
} else {
|
||||
$osNameUrl = 'index.php?sec=gsetup&sec2=godmode/setup/os&action=edit&tab=manage_os&id_os='.$item['id_os'];
|
||||
}
|
||||
|
||||
$item['name'] = html_print_anchor(
|
||||
[
|
||||
'href' => $osNameUrl,
|
||||
'content' => $item['name'],
|
||||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$item['name'] = $item['name'];
|
||||
}
|
||||
|
||||
$item['description'] = ui_print_truncate_text(
|
||||
$item['description'],
|
||||
'description',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
if (is_management_allowed() === true) {
|
||||
$item['enable_delete'] = false;
|
||||
|
||||
if ($item['id_os'] > 16) {
|
||||
$item['enable_delete'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
},
|
||||
$data
|
||||
);
|
||||
|
||||
// Retrieve counter.
|
||||
$count = db_get_value('count(*)', '('.$count_sql.') t');
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $count,
|
||||
'recordsFiltered' => $count,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($method === 'drawOSVersionTable') {
|
||||
// Datatables offset, limit and order.
|
||||
$filter = get_parameter('filter', []);
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
$orderBy = get_datatable_order(true);
|
||||
|
||||
$sort_field = $orderBy['field'];
|
||||
$order = $orderBy['direction'];
|
||||
|
||||
$pagination = '';
|
||||
|
||||
$pagination = sprintf(
|
||||
' LIMIT %d OFFSET %d ',
|
||||
$length,
|
||||
$start
|
||||
);
|
||||
|
||||
try {
|
||||
ob_start();
|
||||
|
||||
$fields = ['*'];
|
||||
$sql_filters = [];
|
||||
|
||||
if (isset($filter['free_search']) === true
|
||||
&& empty($filter['free_search']) === false
|
||||
) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (`product` like "%%%s%%" OR `version` like "%%%s%%") ',
|
||||
$filter['free_search'],
|
||||
$filter['free_search']
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($order) === true) {
|
||||
$dir = 'asc';
|
||||
if ($order == 'desc') {
|
||||
$dir = 'desc';
|
||||
};
|
||||
|
||||
if (in_array(
|
||||
$sort_field,
|
||||
[
|
||||
'product',
|
||||
'version',
|
||||
'end_of_support',
|
||||
]
|
||||
) === true
|
||||
) {
|
||||
$order_by = sprintf(
|
||||
'ORDER BY `%s` %s',
|
||||
$sort_field,
|
||||
$dir
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve data.
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM tconfig_os_version
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s',
|
||||
join(',', $fields),
|
||||
join(' ', $sql_filters),
|
||||
$order_by,
|
||||
$pagination
|
||||
);
|
||||
|
||||
$count_sql = sprintf(
|
||||
'SELECT id_os_version
|
||||
FROM tconfig_os_version
|
||||
WHERE 1=1
|
||||
%s',
|
||||
join(' ', $sql_filters)
|
||||
);
|
||||
|
||||
$return = db_get_all_rows_sql($sql);
|
||||
|
||||
if ($return === false) {
|
||||
$data = [];
|
||||
} else {
|
||||
// Format end of life date.
|
||||
$return = array_map(
|
||||
function ($item) {
|
||||
$date_string = date_w_fixed_tz($item['end_of_support']);
|
||||
$timestamp = strtotime($date_string);
|
||||
$date_without_time = date('F j, Y', $timestamp);
|
||||
$item['end_of_support'] = $date_without_time;
|
||||
return $item;
|
||||
},
|
||||
$return
|
||||
);
|
||||
|
||||
$data = $return;
|
||||
}
|
||||
|
||||
// Retrieve counter.
|
||||
$count = db_get_value('count(*)', '('.$count_sql.') t');
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $count,
|
||||
'recordsFiltered' => $count,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
|
@ -213,6 +213,8 @@ $hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
|
|||
|
||||
case 'sparse':
|
||||
$params['pdf'] = true;
|
||||
hd(grafico_modulo_sparse($params), true);
|
||||
hd("resultadoooooooooooooooooooooooooooo", true);
|
||||
echo grafico_modulo_sparse($params);
|
||||
break;
|
||||
|
||||
|
|
|
@ -497,7 +497,8 @@ function agents_get_agents(
|
|||
],
|
||||
$return=false,
|
||||
$disabled_agent=0,
|
||||
$use_meta_table=false
|
||||
$use_meta_table=false,
|
||||
$join_os_table=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -720,6 +721,18 @@ function agents_get_agents(
|
|||
ON tpolicy_agents.id_agent=tagente.id_agente';
|
||||
}
|
||||
|
||||
if ($join_os_table === true) {
|
||||
$os_version_join = '
|
||||
INNER JOIN tconfig_os
|
||||
ON tagente.id_os = tconfig_os.id_os
|
||||
INNER JOIN tconfig_os_version
|
||||
ON tconfig_os.name REGEXP tconfig_os_version.product
|
||||
';
|
||||
unset($filter['os_version_end_of_life']);
|
||||
} else {
|
||||
$os_version_join = '';
|
||||
}
|
||||
|
||||
if ($extra) {
|
||||
$where = sprintf(
|
||||
'(%s OR (%s)) AND (%s) AND (%s) %s AND %s %s %s %s',
|
||||
|
@ -754,11 +767,12 @@ function agents_get_agents(
|
|||
FROM `%s` tagente
|
||||
LEFT JOIN tagent_secondary_group
|
||||
ON tagent_secondary_group.id_agent=tagente.id_agente
|
||||
%s
|
||||
%s %s
|
||||
WHERE %s %s',
|
||||
implode(',', $fields),
|
||||
$table_name,
|
||||
$policy_join,
|
||||
$os_version_join,
|
||||
$where,
|
||||
$order
|
||||
);
|
||||
|
|
|
@ -4865,7 +4865,7 @@ function html_print_header_logo_image(bool $menuCollapsed, bool $return=false)
|
|||
* Key disabled: Whether to disable the input or not.
|
||||
* Key class: HTML class
|
||||
*/
|
||||
function html_print_input_file($name, $return=false, $options=false)
|
||||
function html_print_input_file($name, $return=false, $options=false, $inline_upload_anchor_to_form='')
|
||||
{
|
||||
$output = '';
|
||||
// Start to build the input.
|
||||
|
@ -4912,11 +4912,49 @@ function html_print_input_file($name, $return=false, $options=false)
|
|||
$output .= ($options['caption'] ?? __('Select a file'));
|
||||
|
||||
$output .= '</label>';
|
||||
|
||||
if ($inline_upload_anchor_to_form !== '') {
|
||||
// Add script to submit targeted form.
|
||||
$output .= '<script>';
|
||||
$output .= 'function submitForm(formID) {
|
||||
var form = $("#"+formID);
|
||||
console.log(form);
|
||||
form.submit();
|
||||
}';
|
||||
$output .= '</script>';
|
||||
$output .= '<div style="display: inherit;">';
|
||||
}
|
||||
|
||||
$output .= '<span class="inputFileSpan" id="span-'.$name.'"> </span>';
|
||||
|
||||
if ($inline_upload_anchor_to_form !== '') {
|
||||
$output .= '<div id="span-'.$name.'-anchor" class="hidden_block">';
|
||||
$output .= html_print_button(
|
||||
__('Upload'),
|
||||
'upload-icon-btn',
|
||||
false,
|
||||
sprintf(
|
||||
'javascript:submitForm("%s")',
|
||||
$inline_upload_anchor_to_form
|
||||
),
|
||||
[
|
||||
'mode' => 'link',
|
||||
'style' => 'min-width: initial;',
|
||||
],
|
||||
true,
|
||||
);
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
||||
if ($inline_upload_anchor_to_form !== '') {
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
||||
// Add script.
|
||||
$output .= '<script>';
|
||||
$output .= 'let inputElement = document.getElementById("file-'.$name.'");
|
||||
let inputFilename = document.getElementById("span-'.$name.'");
|
||||
let inputFilenameAnchor = document.getElementById("span-'.$name.'-anchor");
|
||||
inputElement.addEventListener("change", ()=>{
|
||||
let inputImage = document.querySelector("input[type=file]").files[0];
|
||||
if (inputImage.name.length >= 45) {
|
||||
|
@ -4924,6 +4962,7 @@ function html_print_input_file($name, $return=false, $options=false)
|
|||
inputFilename.innerText = name;
|
||||
} else {
|
||||
inputFilename.innerText = inputImage.name;
|
||||
inputFilenameAnchor.classList.remove("hidden_block");
|
||||
}
|
||||
});';
|
||||
$output .= '</script>';
|
||||
|
@ -7208,4 +7247,4 @@ function html_print_wizard_diagnosis(
|
|||
} else {
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -773,6 +773,13 @@ function reporting_make_reporting_data(
|
|||
);
|
||||
break;
|
||||
|
||||
case 'end_of_life':
|
||||
$report['contents'][] = reporting_end_of_life(
|
||||
$report,
|
||||
$content
|
||||
);
|
||||
break;
|
||||
|
||||
case 'alert_report_actions':
|
||||
$report['contents'][] = reporting_alert_report_actions(
|
||||
$report,
|
||||
|
@ -3562,6 +3569,112 @@ function reporting_agent_module_status($report, $content)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* OS Version End of Life
|
||||
*
|
||||
* @param array $report Info Report.
|
||||
* @param array $content Info content.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function reporting_end_of_life($report, $content)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$return['type'] = 'end_of_life';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('End of life');
|
||||
}
|
||||
|
||||
$return['title'] = io_safe_output($content['name']);
|
||||
$return['landscape'] = $content['landscape'];
|
||||
$return['pagebreak'] = $content['pagebreak'];
|
||||
$return['subtitle'] = __('End of life report');
|
||||
$return['description'] = io_safe_output($content['description']);
|
||||
$return['date'] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$return['data'] = [];
|
||||
|
||||
$external_source = json_decode(
|
||||
$content['external_source'],
|
||||
true
|
||||
);
|
||||
|
||||
$servers_ids = [0];
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$servers_ids = array_column(metaconsole_get_servers(), 'id');
|
||||
}
|
||||
|
||||
foreach ($servers_ids as $server_id) {
|
||||
if (is_metaconsole() === true) {
|
||||
$connection = metaconsole_get_connection_by_id($server_id);
|
||||
if (metaconsole_connect($connection) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$agents = agents_get_agents(
|
||||
[],
|
||||
[
|
||||
'alias',
|
||||
'direccion',
|
||||
'name',
|
||||
'os_version',
|
||||
],
|
||||
'AR',
|
||||
[
|
||||
'field' => 'nombre',
|
||||
'order' => 'ASC',
|
||||
],
|
||||
false,
|
||||
0,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$es_os_version = $external_source['os_version'];
|
||||
|
||||
$es_limit_eol_datetime = DateTime::createFromFormat('Y/m/d', $external_source['end_of_life_date']);
|
||||
|
||||
// Post-process returned agents to filter agents using correctly formatted fields.
|
||||
foreach ($agents as $idx => $agent) {
|
||||
// Must perform this query and subsequent operations in each iteration (note this is costly) since OS version field may contain HTML entities in BD and decoding can't be fully handled with mysql methods when doing a REGEXP.
|
||||
$result_end_of_life = db_get_value_sql('SELECT end_of_support FROM tconfig_os_version WHERE "'.io_safe_output($agent['os_version']).'" REGEXP version');
|
||||
$agent_eol_datetime = DateTime::createFromFormat('Y/m/d', $result_end_of_life);
|
||||
|
||||
if ((preg_match('/'.$es_os_version.'/', $agent['os_version']) || $es_os_version === '') && $result_end_of_life !== false && $es_limit_eol_datetime >= $agent_eol_datetime) {
|
||||
// Agent matches an existing OS version.
|
||||
$agents[$idx]['end_of_life'] = $result_end_of_life;
|
||||
} else {
|
||||
// Set agent to be filtered out.
|
||||
$agents[$idx] = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($agents !== false) {
|
||||
$agents = array_filter($agents);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$res[$connection['server_name']] = $agents;
|
||||
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$return['data'] = $res;
|
||||
} else {
|
||||
$return['data'] = $agents;
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
|
||||
function reporting_exception(
|
||||
$report,
|
||||
$content,
|
||||
|
|
|
@ -391,6 +391,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
|
|||
reporting_html_agent_module_status($table, $item);
|
||||
break;
|
||||
|
||||
case 'end_of_life':
|
||||
reporting_html_end_of_life($table, $item);
|
||||
break;
|
||||
|
||||
case 'alert_report_actions':
|
||||
reporting_html_alert_report_actions($table, $item);
|
||||
break;
|
||||
|
@ -2440,6 +2444,123 @@ function reporting_html_agent_module_status($table, $item, $pdf=0)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Html report end of life.
|
||||
*
|
||||
* @param object $table Head table or false if it comes from pdf.
|
||||
* @param array $item Items data.
|
||||
* @param integer $pdf Pdf output.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function reporting_html_end_of_life($table, $item, $pdf=0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$return_pdf = '';
|
||||
|
||||
if (empty($item['data']) === true) {
|
||||
if ($pdf !== 0) {
|
||||
$return_pdf .= __('No items');
|
||||
} else {
|
||||
$table->colspan['group_report']['cell'] = 3;
|
||||
$table->cellstyle['group_report']['cell'] = 'text-align: center;';
|
||||
$table->data['group_report']['cell'] = __('No items');
|
||||
}
|
||||
} else {
|
||||
$table_info = new stdClass();
|
||||
$table_info->width = '99%';
|
||||
|
||||
$table_info->align = [];
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$table_info->align['server'] = 'left';
|
||||
}
|
||||
|
||||
$table_info->align['agent_alias'] = 'left';
|
||||
$table_info->align['ip'] = 'left';
|
||||
$table_info->align['os_type'] = 'left';
|
||||
$table_info->align['os_version'] = 'left';
|
||||
$table_info->align['end_of_life'] = 'left';
|
||||
|
||||
$table_info->headstyle = [];
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$table_info->headstyle['server'] = 'text-align: left';
|
||||
}
|
||||
|
||||
$table_info->headstyle['agent_alias'] = 'text-align: left';
|
||||
$table_info->headstyle['ip'] = 'text-align: left';
|
||||
$table_info->headstyle['os_type'] = 'text-align: left';
|
||||
$table_info->headstyle['os_version'] = 'text-align: left';
|
||||
$table_info->headstyle['end_of_life'] = 'text-align: left';
|
||||
|
||||
$table_info->head = [];
|
||||
if (is_metaconsole() === true) {
|
||||
$table_info->head['server'] = __('Server');
|
||||
}
|
||||
|
||||
$table_info->head['agent_alias'] = __('Agent alias');
|
||||
$table_info->head['ip'] = __('IP');
|
||||
$table_info->head['os_type'] = __('OS Type');
|
||||
$table_info->head['os_version'] = __('OS Version');
|
||||
$table_info->head['end_of_life'] = __('End of life');
|
||||
|
||||
$table_info->data = [];
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
foreach ($item['data'] as $server_name => $agents_per_server) {
|
||||
foreach ($agents_per_server as $agent) {
|
||||
$row = [];
|
||||
|
||||
$row['server'] = $server_name;
|
||||
$row['agent_alias'] = $agent['alias'];
|
||||
$row['ip'] = $agent['direccion'];
|
||||
$row['os_type'] = $agent['name'];
|
||||
$row['os_version'] = $agent['os_version'];
|
||||
$date_string = date_w_fixed_tz($agent['end_of_life']);
|
||||
$timestamp = strtotime($date_string);
|
||||
$date_without_time = date('F j, Y', $timestamp);
|
||||
$row['end_of_life'] = $date_without_time;
|
||||
|
||||
$table_info->data[] = $row;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($item['data'] as $data) {
|
||||
$row = [];
|
||||
|
||||
$row['agent_alias'] = $data['alias'];
|
||||
$row['ip'] = $data['direccion'];
|
||||
$row['os_type'] = $data['name'];
|
||||
$row['os_version'] = $data['os_version'];
|
||||
$date_string = date_w_fixed_tz($data['end_of_life']);
|
||||
$timestamp = strtotime($date_string);
|
||||
$date_without_time = date('F j, Y', $timestamp);
|
||||
$row['end_of_life'] = $date_without_time;
|
||||
|
||||
$table_info->data[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
if ($pdf !== 0) {
|
||||
$table_info->title = $item['title'];
|
||||
$table_info->titleclass = 'title_table_pdf';
|
||||
$table_info->titlestyle = 'text-align:left;';
|
||||
$return_pdf .= html_print_table($table_info, true);
|
||||
} else {
|
||||
$table->colspan['data']['cell'] = 3;
|
||||
$table->cellstyle['data']['cell'] = 'text-align: center;';
|
||||
$table->data['data']['cell'] = html_print_table($table_info, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($pdf !== 0) {
|
||||
return $return_pdf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to print to HTML Exception report.
|
||||
*
|
||||
|
|
|
@ -814,6 +814,11 @@ function reports_get_report_types($template=false, $not_editor=false)
|
|||
'name' => __('Agents/Modules status'),
|
||||
];
|
||||
|
||||
$types['end_of_life'] = [
|
||||
'optgroup' => __('Grouped'),
|
||||
'name' => __('End of life'),
|
||||
];
|
||||
|
||||
// Only pandora managers have access to the whole database.
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$types['sql'] = [
|
||||
|
|
|
@ -169,6 +169,7 @@ $refr = get_parameter('refr', 0);
|
|||
$recursion = get_parameter('recursion', 0);
|
||||
$status = (int) get_parameter('status', -1);
|
||||
$os = (int) get_parameter('os', 0);
|
||||
$os_version_regex = trim(get_parameter('os_version_regex', ''));
|
||||
$policies = (array) get_parameter('policies', []);
|
||||
$ag_custom_fields = (array) get_parameter('ag_custom_fields', []);
|
||||
|
||||
|
@ -393,6 +394,18 @@ $table->data[1][0] = html_print_label_input_block(
|
|||
html_print_select($fields, 'os', $os, '', 'All', 0, true)
|
||||
);
|
||||
|
||||
$table->data[1][1] = html_print_label_input_block(
|
||||
__('Operating System version').ui_print_help_tip(__('Case insensitive regular expression, e.g. Rocky.* will match the following OS version: Rocky Linux 8.7'), true),
|
||||
html_print_input_text(
|
||||
'os_version_regex',
|
||||
$os_version_regex,
|
||||
'',
|
||||
35,
|
||||
255,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
if (function_exists('policies_get_policies') === true) {
|
||||
$pre_fields = policies_get_policies(false, ['id', 'name']);
|
||||
$fields = [];
|
||||
|
@ -401,7 +414,7 @@ if (function_exists('policies_get_policies') === true) {
|
|||
}
|
||||
}
|
||||
|
||||
$table->data[1][1] = html_print_label_input_block(
|
||||
$table->data[2][0] = html_print_label_input_block(
|
||||
__('Policies'),
|
||||
html_print_select($fields, 'policies[]', $policies, '', 'All', 0, true, true)
|
||||
);
|
||||
|
@ -443,8 +456,8 @@ foreach ($custom_fields as $custom_field) {
|
|||
$div_custom_fields .= '</div></div>';
|
||||
}
|
||||
|
||||
$table->colspan[2][0] = 2;
|
||||
$table->data[2][0] = ui_toggle(
|
||||
$table->colspan[3][0] = 2;
|
||||
$table->data[3][0] = ui_toggle(
|
||||
$div_custom_fields,
|
||||
__('Agent custom fields'),
|
||||
'',
|
||||
|
@ -872,6 +885,10 @@ if ($os > 0) {
|
|||
$id_os_sql = ' AND id_os = '.$os;
|
||||
}
|
||||
|
||||
if ($os_version_regex !== '') {
|
||||
$id_os_sql .= ' AND os_version REGEXP \''.$os_version_regex.'\'';
|
||||
}
|
||||
|
||||
if ($all_policies === false && is_array($policies) && count($policies) > 0) {
|
||||
$policies_sql = ' AND tpolicy_agents.id_policy IN ('.implode(',', $policies).')';
|
||||
}
|
||||
|
|
|
@ -652,6 +652,17 @@ CREATE TABLE IF NOT EXISTS `tconfig_os` (
|
|||
PRIMARY KEY (`id_os`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tconfig_os_version`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tconfig_os_version` (
|
||||
`id_os_version` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`product` TEXT,
|
||||
`version` TEXT,
|
||||
`end_of_support` VARCHAR(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_os_version`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tcontainer`
|
||||
-- -----------------------------------------------------
|
||||
|
|
|
@ -2636,3 +2636,15 @@ INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`,`filename`,`path`) VALUES (
|
|||
INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Zoom on data graphs','Do you know that Pandora FMS allows you to zoom in on a part of the graph. With that you will expand the information of the graph. If you are looking at a graph for a month and you zoom in, you will be able to see the data for that interval. If you use a graph with full resolution data (we call them TIP graphs) you will be able to see the detail of each piece of data, even if your graph has thousands of samples.','',1);
|
||||
SELECT @last_id := LAST_INSERT_ID();
|
||||
INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`,`filename`,`path`) VALUES (@last_id,'zoom_en_graficas.png','images/tips/');
|
||||
|
||||
|
||||
--
|
||||
-- Dumping data for table `tconfig_os_version`
|
||||
--
|
||||
|
||||
LOCK TABLES `tconfig_os_version` WRITE;
|
||||
INSERT INTO `tconfig_os_version` (`id_os_version`, `product`, `version`, `end_of_support`) VALUES
|
||||
(1,'Windows.*','7.*','2020/01/14'),
|
||||
(2,'Cisco.*','IOS 3.4.3','2017/05/12'),
|
||||
(3,'Linux.*','Centos 7.*','2022/01/01');
|
||||
UNLOCK TABLES;
|
||||
|
|
|
@ -3915,17 +3915,21 @@ Create a new entry in B<tagente> optionaly with position information
|
|||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$$) {
|
||||
sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$$$) {
|
||||
# If parameter event_id is not undef, then create an extended event
|
||||
# related to it instead launch new event.
|
||||
my ($pa_config, $server_name, $agent_name, $address,
|
||||
$group_id, $parent_id, $os_id,
|
||||
$description, $interval, $dbh, $timezone_offset,
|
||||
$longitude, $latitude, $altitude, $position_description,
|
||||
$custom_id, $url_address, $agent_mode, $alias, $event_id) = @_;
|
||||
$custom_id, $url_address, $agent_mode, $alias, $event_id, $os_version) = @_;
|
||||
|
||||
logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10);
|
||||
|
||||
if (!defined $os_version) {
|
||||
$os_version = '';
|
||||
}
|
||||
|
||||
if (!defined($group_id)) {
|
||||
$group_id = pandora_get_agent_group($pa_config, $dbh, $agent_name);
|
||||
if ($group_id <= 0) {
|
||||
|
@ -3951,9 +3955,10 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$$) {
|
|||
'url_address' => $url_address,
|
||||
'timezone_offset' => $timezone_offset,
|
||||
'alias' => safe_input($alias),
|
||||
'update_module_count' => 1, # Force to replicate in metaconsole
|
||||
});
|
||||
|
||||
'os_version' => $os_version,
|
||||
'update_module_count' => 1, # Force to replicate in metaconsole
|
||||
});
|
||||
|
||||
my $agent_id = db_insert ($dbh, 'id_agente', "INSERT INTO tagente $columns", @{$values});
|
||||
|
||||
# Save GIS data
|
||||
|
|
|
@ -788,8 +788,8 @@ sub get_recon_credential_macro($$$) {
|
|||
################################################################################
|
||||
# Guess the OS using xprobe2 or nmap.
|
||||
################################################################################
|
||||
sub PandoraFMS::Recon::Base::guess_os($$;$) {
|
||||
my ($self, $device, $string_flag) = @_;
|
||||
sub PandoraFMS::Recon::Base::guess_os($$;$$$) {
|
||||
my ($self, $device, $string_flag, $return_version_only) = @_;
|
||||
|
||||
return $self->{'os_id'}{$device} if defined($self->{'os_id'}{$device});
|
||||
|
||||
|
@ -810,15 +810,32 @@ sub PandoraFMS::Recon::Base::guess_os($$;$) {
|
|||
if (-x $self->{'pa_config'}->{'nmap'}) {
|
||||
my $return = `"$self->{pa_config}->{nmap}" -sSU -T5 -F -O --osscan-limit $device 2>$DEVNULL`;
|
||||
return OS_OTHER if ($? != 0);
|
||||
my $str_os;
|
||||
my ($str_os, $os_version);
|
||||
if ($return =~ /Aggressive OS guesses:(.*?)(?>\(\d+%\),)|^OS details:(.*?)$/mi) {
|
||||
if(defined($1) && $1 ne "") {
|
||||
$str_os = $1;
|
||||
} else {
|
||||
$str_os = $2;
|
||||
}
|
||||
|
||||
my $pandora_os = pandora_get_os($self->{'dbh'}, $str_os);
|
||||
my $pandora_os_name = pandora_get_os_by_id($self->{'dbh'}, $pandora_os);
|
||||
|
||||
if ($return_version_only == 1) {
|
||||
if ($str_os =~ /$pandora_os_name/i) {
|
||||
$os_version = $'; # Get string after matched found OS name.
|
||||
$os_version =~ s/^\s+//; # Remove leading spaces.
|
||||
$os_version =~ s/\s+$//; # Remove trailing spaces.
|
||||
} else {
|
||||
$os_version = '';
|
||||
}
|
||||
|
||||
return $os_version;
|
||||
|
||||
}
|
||||
|
||||
return $str_os if is_enabled($string_flag);
|
||||
return pandora_get_os($self->{'dbh'}, $str_os);
|
||||
return $pandora_os;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1640,6 +1657,10 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
|
|||
$os_id = $self->guess_os($data->{'agent'}{'direccion'});
|
||||
}
|
||||
|
||||
if (is_empty($data->{'agent'}{'os_version'})) {
|
||||
$data->{'agent'}{'os_version'} = $self->guess_os($data->{'agent'}{'direccion'}, undef, 1);
|
||||
}
|
||||
|
||||
$self->call('message', "Agent accepted: ".$data->{'agent'}{'nombre'}, 5);
|
||||
|
||||
# Agent creation.
|
||||
|
@ -1681,7 +1702,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
|
|||
$os_id, $data->{'agent'}->{'description'},
|
||||
$data->{'agent'}{'interval'}, $self->{'dbh'},
|
||||
$data->{'agent'}{'timezone_offset'}, undef, undef, undef, undef,
|
||||
undef, undef, 1, $data->{'agent'}{'alias'}
|
||||
undef, undef, 1, $data->{'agent'}{'alias'}, undef, $data->{'agent'}{'os_version'}
|
||||
);
|
||||
|
||||
# Add found IP addresses to the agent.
|
||||
|
|
|
@ -6671,6 +6671,19 @@ sub cli_set_event_storm_protection () {
|
|||
db_do ($dbh, 'UPDATE tconfig SET value=? WHERE token=?', $value, 'event_storm_protection');
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Set existing OS and OS version for a specific agent
|
||||
# Related option: --agent_set_os
|
||||
##############################################################################
|
||||
sub cli_agent_set_os() {
|
||||
my ($id_agente,$id_os,$os_version) = @ARGV[2..4];
|
||||
|
||||
my $os_name = get_db_value($dbh, 'SELECT name FROM tconfig_os WHERE id_os = ?',$id_os);
|
||||
exist_check($id_os,'tconfig_os',$os_name);
|
||||
|
||||
db_process_update($dbh, 'tagente', {'id_os' => $id_os, 'os_version' => $os_version}, {'id_agente' => $id_agente});
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Return event name given a event id
|
||||
##############################################################################
|
||||
|
@ -8147,7 +8160,11 @@ sub pandora_manage_main ($$$) {
|
|||
elsif ($param eq '--set_event_storm_protection') {
|
||||
param_check($ltotal, 1);
|
||||
cli_set_event_storm_protection();
|
||||
}
|
||||
}
|
||||
elsif ($param eq '--agent_set_os') {
|
||||
param_check($ltotal, 3, 1);
|
||||
cli_agent_set_os();
|
||||
}
|
||||
elsif ($param eq '--create_custom_graph') {
|
||||
param_check($ltotal, 11);
|
||||
cli_create_custom_graph();
|
||||
|
|
Loading…
Reference in New Issue