From 85194fe2be4acb5de34c064884654ae2074a149a Mon Sep 17 00:00:00 2001 From: rafael Date: Fri, 21 Jul 2023 11:23:31 +0200 Subject: [PATCH] 11757 adding inventory demo data script to load util --- .../util/load/generate_inventory_data.sh | 66 +++++ .../load/templates/inventory_linux.template | 192 +++++++++++++ .../load/templates/inventory_windows.template | 257 ++++++++++++++++++ 3 files changed, 515 insertions(+) create mode 100755 pandora_server/util/load/generate_inventory_data.sh create mode 100644 pandora_server/util/load/templates/inventory_linux.template create mode 100644 pandora_server/util/load/templates/inventory_windows.template diff --git a/pandora_server/util/load/generate_inventory_data.sh b/pandora_server/util/load/generate_inventory_data.sh new file mode 100755 index 0000000000..b91ac24af7 --- /dev/null +++ b/pandora_server/util/load/generate_inventory_data.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# (c) 2023 Pandora FMS + +if [ ! -e pandora_xml_stress.agents ] +then + echo "Error, cant find pandora_xml_stress.agets file" + exit +fi + +linux_inventory=1 +windows_inventory=1 + +# Variables +agent_count=5 + +data_in=/var/spool/pandora/data_in/ +description='Demo data Agent' +group='Servers' +current_date=`date +"%Y/%m/%d %H:%M:%S"` +current_utimestamp=`date +%s` + +if [ $linux_inventory -eq 1 ] ; then + + if [ ! -e templates/inventory_linux.template ]; then + echo "Error, cant find inventory linux template" + exit + fi + + echo "Enable linux invetory: adding invetory data to ${agent_count} linux agent" + + for agent_name in $(cat pandora_xml_stress.agents | head ${agent_conunt}); do + echo " - Adding invetory data to ${agent_name} linux agent" + ip_add="10.0.0.$(( RANDOM % 255 + 1 ))" + rand_number=$(( RANDOM % 10 + 1 )) + cat "templates/inventory_linux.template" \ + | sed -e "s/{{description}}/${description}/g" \ + -e "s/{{group}}/${group}/g" \ + -e "s/{{agent_name}}/${agent_name}/g" \ + -e "s|{{date}}|${current_date}|g" \ + -e "s|{{ip_address}}|${ip_add}|g" \ + -e "s|{{rand_number}}|${rand_number}|g" \ + > /${data_in}/${agent_name}.${current_utimestamp}.data + done +fi + +if [ $windows_inventory -eq 1 ]; then + if [ ! -e templates/inventory_windows.template ]; then + echo "Error, cant find inventory Windows template" + exit + fi + echo "Enable Windows invetory: adding invetory data to ${agent_count} Windows agent" + + for agent_name in $(cat pandora_xml_stress.agents | tail ${agent_conunt}); do + echo " - Adding invetory data to ${agent_name} windows agent" + ip_add="172.16.5.$(( RANDOM % 255 + 1 ))" + rand_number=$(( RANDOM % 100 + 1 )) + cat "templates/inventory_windows.template" \ + | sed -e "s/{{description}}/${description}/g" \ + -e "s/{{group}}/${group}/g" \ + -e "s/{{agent_name}}/${agent_name}/g" \ + -e "s|{{date}}|${current_date}|g" \ + -e "s|{{rand_number}}|${rand_number}|g" \ + -e "s|{{ip_address}}|${ip_add}|g" \ + > /${data_in}/${agent_name}.${current_utimestamp}.data + done +fi \ No newline at end of file diff --git a/pandora_server/util/load/templates/inventory_linux.template b/pandora_server/util/load/templates/inventory_linux.template new file mode 100644 index 0000000000..3e1cb25627 --- /dev/null +++ b/pandora_server/util/load/templates/inventory_linux.template @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pandora_server/util/load/templates/inventory_windows.template b/pandora_server/util/load/templates/inventory_windows.template new file mode 100644 index 0000000000..127ca1dfba --- /dev/null +++ b/pandora_server/util/load/templates/inventory_windows.template @@ -0,0 +1,257 @@ + + + + + + CPU + + + + + + + + + + + HD + + + + + + + + + Video + + + + + + + + + NIC + + + + + + + + + Monitors + + + + + + + + RAM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Users + + + + + + + + product_ID + + + + + + + + +