Merge branch 'ent-10906-Carga-de-datos-de-demo' of brutus.artica.es:artica/pandorafms into ent-10906-Carga-de-datos-de-demo

This commit is contained in:
alejandro.campos@artica.es 2023-12-01 09:49:37 +01:00
commit cb60581bcf
9 changed files with 185 additions and 14 deletions

View File

@ -18,6 +18,10 @@ os_versions[]="RHEL 8.2"
os_versions[]="RHEL 8.1" os_versions[]="RHEL 8.1"
os_versions[]="Alma Linux 9.1" os_versions[]="Alma Linux 9.1"
latitude="RANDOM;37;42"
longitude="RANDOM;-8;-1"
altitude="0"
[modules] [modules]
name[1]="Host Alive" name[1]="Host Alive"

View File

@ -18,6 +18,10 @@ os_versions[]="RHEL 8.2"
os_versions[]="RHEL 8.1" os_versions[]="RHEL 8.1"
os_versions[]="Alma Linux 9.1" os_versions[]="Alma Linux 9.1"
latitude="RANDOM;37;42"
longitude="RANDOM;-8;-1"
altitude="0"
[modules] [modules]
name[1]="Network Usage" name[1]="Network Usage"

View File

@ -17,6 +17,10 @@ os_versions[]="Home Microsoft Windows 10 Pro"
os_versions[]="Microsoft Windows 10 Home" os_versions[]="Microsoft Windows 10 Home"
os_versions[]="Microsoft Windows 2018" os_versions[]="Microsoft Windows 2018"
latitude="RANDOM;37;42"
longitude="RANDOM;-8;-1"
altitude="0"
[modules] [modules]
name[1]="Network Usage" name[1]="Network Usage"

View File

@ -17,6 +17,10 @@ os_versions[]="11.2"
os_versions[]="11.3" os_versions[]="11.3"
os_versions[]="10.3" os_versions[]="10.3"
latitude="RANDOM;37;42"
longitude="RANDOM;-8;-1"
altitude="0"
[modules] [modules]
name[1]="Network Usage" name[1]="Network Usage"

View File

@ -16,6 +16,10 @@ os_versions[]="13.1"
os_versions[]="13.2" os_versions[]="13.2"
os_versions[]="13.3" os_versions[]="13.3"
latitude="RANDOM;37;42"
longitude="RANDOM;-8;-1"
altitude="0"
[modules] [modules]
name[1]="Network Usage" name[1]="Network Usage"

View File

@ -16,6 +16,10 @@ os_versions[]="C9200L"
os_versions[]="C9300LM" os_versions[]="C9300LM"
os_versions[]="C9600" os_versions[]="C9600"
latitude="RANDOM;37;42"
longitude="RANDOM;-8;-1"
altitude="0"
[modules] [modules]
name[1]="CPU Usage (5 min avg)" name[1]="CPU Usage (5 min avg)"

View File

@ -50,3 +50,93 @@ agent_name[9]="linux-4"
x[9]="226" x[9]="226"
y[9]="595" y[9]="595"
parent[9]="5" parent[9]="5"
agent_name[10]="cisco-2"
x[10]="1036"
y[10]="711"
parent[10]="1"
agent_name[11]="freebsd-2"
x[11]="892"
y[11]="-47"
parent[11]="1"
agent_name[12]="macos-2"
x[12]="1150"
y[12]="409"
parent[12]="1"
agent_name[13]="windows-3"
x[13]="686"
y[13]="875"
parent[13]="10"
agent_name[14]="windows-4"
x[14]="1452"
y[14]="847"
parent[14]="10"
agent_name[15]="linux-5"
x[15]="314"
y[15]="845"
parent[15]="13"
agent_name[16]="linux-6"
x[16]="474"
y[16]="1043"
parent[16]="13"
agent_name[17]="linux-7"
x[17]="1812"
y[17]="1011"
parent[17]="14"
agent_name[18]="linux-8"
x[18]="1828"
y[18]="723"
parent[18]="14"
agent_name[19]="cisco-3"
x[19]="1824"
y[19]="285"
parent[19]="3"
agent_name[20]="freebsd-3"
x[20]="-82"
y[20]="583"
parent[20]="9"
agent_name[21]="macos-3"
x[21]="-140"
y[21]="299"
parent[21]="20"
agent_name[22]="windows-5"
x[22]="-390"
y[22]="385"
parent[22]="20"
agent_name[23]="windows-6"
x[23]="-470"
y[23]="671"
parent[23]="20"
agent_name[24]="linux-9"
x[24]="-296"
y[24]="899"
parent[24]="20"
agent_name[25]="linux-10"
x[25]="-25"
y[25]="961"
parent[25]="20"
agent_name[26]="linux-11"
x[26]="1683"
y[26]="13"
parent[26]="19"
agent_name[27]="linux-12"
x[27]="2135"
y[27]="51"
parent[27]="19"

View File

@ -114,7 +114,7 @@ type[11]="module_graph"
image[11]="black" image[11]="black"
agent_name[11]="linux-1" agent_name[11]="linux-1"
module[11]="CPU Load" module[11]="CPU Load"
interval[11]="86N00" interval[11]="86400"
graph_type[11]="area" graph_type[11]="area"
label[11]="" label[11]=""
label_position[11]="down" label_position[11]="down"
@ -127,7 +127,7 @@ type[12]="module_graph"
image[12]="black" image[12]="black"
agent_name[12]="linux-1" agent_name[12]="linux-1"
module[12]="Memory Usage" module[12]="Memory Usage"
interval[12]="86N00" interval[12]="86400"
graph_type[12]="area" graph_type[12]="area"
label[12]="" label[12]=""
label_position[12]="down" label_position[12]="down"
@ -140,7 +140,7 @@ type[13]="module_graph"
image[13]="black" image[13]="black"
agent_name[13]="linux-1" agent_name[13]="linux-1"
module[13]="Disk Usage" module[13]="Disk Usage"
interval[13]="86N00" interval[13]="86400"
graph_type[13]="area" graph_type[13]="area"
label[13]="" label[13]=""
label_position[13]="down" label_position[13]="down"

View File

@ -264,6 +264,37 @@ if ($action === 'create_demo_data') {
reset($os_versions); reset($os_versions);
} }
$latitude = 0;
$longitude = 0;
$altitude = 0;
if (isset($agent_data['latitude']) === true) {
$gis_parsed = explode(';', $agent_data['latitude']);
if ((string) $gis_parsed[0] === 'RANDOM') {
$latitude = rand($gis_parsed[1], $gis_parsed[2]);
} else {
$latitude = $agent_data['latitude'];
}
}
if (isset($agent_data['longitude']) === true) {
$gis_parsed = explode(';', $agent_data['longitude']);
if ((string) $gis_parsed[0] === 'RANDOM') {
$longitude = rand($gis_parsed[1], $gis_parsed[2]);
} else {
$longitude = $agent_data['longitude'];
}
}
if (isset($agent_data['altitude']) === true) {
$gis_parsed = explode(';', $agent_data['altitude']);
if ((string) $gis_parsed[0] === 'RANDOM') {
$altitude = rand($gis_parsed[1], $gis_parsed[2]);
} else {
$altitude = $agent_data['altitude'];
}
}
$values = [ $values = [
'server_name' => $server_name, 'server_name' => $server_name,
'id_os' => $id_os, 'id_os' => $id_os,
@ -310,6 +341,34 @@ if ($action === 'create_demo_data') {
continue; continue;
} }
// Register GIS data
$values = [
'tagente_id_agente' => $created_agent_id,
'current_longitude' => $longitude,
'current_latitude' => $latitude,
'current_altitude' => $altitude,
'stored_longitude' => $longitude,
'stored_latitude' => $latitude,
'stored_altitude' => $altitude,
'number_of_packages' => 1,
'manual_placement' => 1,
];
$result = db_process_sql_insert('tgis_data_status', $values);
if ($result !== false) {
$values = [
'item_id' => $created_agent_id,
'table_name' => 'tgis_data_status',
];
$result = (bool) db_process_sql_insert('tdemo_data', $values);
if ($result === false) {
// Rollback GIS data creation if could not be registered in tdemo_data.
db_process_sql_delete('tgis_data_status', ['tagente_id_agente' => $created_agent_id]);
}
}
$agents_created_count[$agent_data['agent_alias']]++; $agents_created_count[$agent_data['agent_alias']]++;
$iter_agents_created++; $iter_agents_created++;
@ -2131,19 +2190,13 @@ if ($action === 'create_demo_data') {
if (isset($items_array['graph_type']) === true) { if (isset($items_array['graph_type']) === true) {
$element_values['type_graph'] = $items_array['graph_type']; $element_values['type_graph'] = $items_array['graph_type'];
} }
if (isset($items_array['image']) === true) {
$element_values['image'] = $items_array['image'];
}
} }
if ($items_array['type'] === 'custom_graph') { if ($items_array['type'] === 'custom_graph') {
if (isset($items_array['image']) === false
|| is_string($items_array['image']) === false
) {
// The above fields are required for this item.
register_error(
DEMO_VISUAL_CONSOLE,
__('Error in %s: image field must be specified for custom_graph item type. Skipping creation of item with index %d', $filename, ($item_access_idx - 1))
);
continue;
}
if (isset($items_array['graph_name']) === true if (isset($items_array['graph_name']) === true
&& is_string($items_array['graph_name']) === true && is_string($items_array['graph_name']) === true
@ -2160,6 +2213,10 @@ if ($action === 'create_demo_data') {
if (isset($items_array['interval']) === true) { if (isset($items_array['interval']) === true) {
$element_values['period'] = $items_array['interval']; $element_values['period'] = $items_array['interval'];
} }
if (isset($items_array['image']) === true) {
$element_values['image'] = $items_array['image'];
}
} }
if ($items_array['type'] === 'icon') { if ($items_array['type'] === 'icon') {