Added GIS random data to agents

This commit is contained in:
Enrique Martin 2023-11-30 17:41:01 +01:00
parent 76327c6d73
commit 3807baa8ef
8 changed files with 174 additions and 1 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -49,4 +49,94 @@ parent[8]="5"
agent_name[9]="linux-4"
x[9]="226"
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

@ -264,6 +264,37 @@ if ($action === 'create_demo_data') {
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 = [
'server_name' => $server_name,
'id_os' => $id_os,
@ -310,6 +341,34 @@ if ($action === 'create_demo_data') {
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']]++;
$iter_agents_created++;