adding autoinstall for tools and docs
This commit is contained in:
parent
d85e122791
commit
b0aa8f3fb2
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,38 @@
|
|||
### Purpose of this toolkit
|
||||
## Purpose of this toolkit
|
||||
|
||||
This directory contains configuration files and small scripts to generate an environment with simulated data for testing purposes.
|
||||
|
||||
### Quik start
|
||||
To add monitoring data, inventory, groups and users to a pandorafms environment automatically Just execute:
|
||||
```
|
||||
/usr/share/pandora_server/util/load/install_load_data.sh
|
||||
```
|
||||
|
||||
This command will creates:
|
||||
- 30 Agents with inventory linux
|
||||
- 30 Agents whith inventory Windows
|
||||
- 300 Agents
|
||||
- 44 Groups
|
||||
- 34 Users
|
||||
|
||||
Will randonly add users to groups and move agents to groups.
|
||||
Creates a cronjob to generate agent data each 5 min and inventory data once a day.
|
||||
|
||||
_note: make sure you have a licence with at least 300 agents or modify the /usr/share/pandora_server/util/load/pandora_xml_stress.agents to use max your licence limit agent amount before execute_
|
||||
|
||||
## Toolset description.
|
||||
Here we describe the specific use for all the toolset the `install_load_data.sh` used automatically, to be used individualy if its needed
|
||||
|
||||
### Generation of inventory agents
|
||||
The script will use th file pandora_xml_stress.agents take by default the first 30 listed agents and add linux inventory and the last 30 listed agents and add windows inventory.
|
||||
This will generate xml data using the templates on `templates` folder.
|
||||
|
||||
to run it, execute
|
||||
```
|
||||
cd pandorafms/pandora_server/util/load
|
||||
./generate_inventory_data.sh
|
||||
```
|
||||
|
||||
### Generation of XML files to simulate agent load
|
||||
|
||||
There is a tool that comes configured with Pandora FMS to generate test data (pandora_xml_stress) and that generates XML. It has different options and in this directory is provided a configuration file and all the dictionaries and additional files to generate data of 300 agents, with pseudo-random names (like for example "7fb8a1a734c24cc22a5c75eb").
|
||||
|
@ -9,18 +40,18 @@ There is a tool that comes configured with Pandora FMS to generate test data (pa
|
|||
These agents are defined in the "pandora_xml_stress.agents" file. If you want less agents, you can delete elements in this file.
|
||||
|
||||
To execute the XML generation manually from the code repository:
|
||||
|
||||
```
|
||||
cd pandorafms/pandora_server/util/load
|
||||
perl ../pandora_xml_stress.pl pandora_xml_stress.conf
|
||||
|
||||
```
|
||||
This will generate 300 XML in the /var/spool/pandora/data_in directory.
|
||||
|
||||
If you create a scheduled execution of this command every 5 minutes (e.g. through cron), keep in mind that if the PandoraFMS server stops, it could have hundreds of thousands of XML files pending to be processed.
|
||||
|
||||
Create /etc/cron.d/pandora_stress with this content:
|
||||
|
||||
```
|
||||
*/5 * * * * root <putyourscripthere>
|
||||
|
||||
```
|
||||
|
||||
### Generation of groups and users
|
||||
|
||||
|
@ -31,6 +62,7 @@ On the other hand, it will also create a series of groups, taking as source the
|
|||
Finally, it will take all the agents available in Pandora FMS and it will distribute them in an equal and random way among the available groups.
|
||||
|
||||
You should only run it once:
|
||||
|
||||
```
|
||||
cd pandorafms/pandora_server/util/load
|
||||
./create_userandgroups.sh
|
||||
```
|
|
@ -35,7 +35,7 @@ done
|
|||
TOTAL_GROUPS=`cat groupnames.txt | wc -l`
|
||||
for username in `cat usernames.txt`
|
||||
do
|
||||
RAN=`echo $RANDOM % $TOTAL_GROUPS + 1 | bc`
|
||||
RAN=`echo $(($RANDOM % $TOTAL_GROUPS + 1))`
|
||||
GROUP_NAME=`cat groupnames.txt | tail -$RAN | head -1`
|
||||
|
||||
/usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --add_profile $username "Operator (Read)" $GROUP_NAME
|
||||
|
@ -45,7 +45,7 @@ done
|
|||
TOTAL_GROUPS=`cat groupnames.txt | wc -l`
|
||||
for agentname in `/usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --get_agents | cut -f 2 -d ","`
|
||||
do
|
||||
RAN=`echo $RANDOM % $TOTAL_GROUPS + 1 | bc`
|
||||
RAN=`echo $(($RANDOM % $TOTAL_GROUPS + 1))`
|
||||
GROUP_NAME=`cat groupnames.txt | tail -$RAN | head -1`
|
||||
/usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --update_agent $agentname group_name $GROUP_NAME
|
||||
done
|
||||
|
|
|
@ -11,7 +11,7 @@ linux_inventory=1
|
|||
windows_inventory=1
|
||||
|
||||
# Variables
|
||||
agent_count=5
|
||||
agent_count=30
|
||||
|
||||
data_in=/var/spool/pandora/data_in/
|
||||
description='Demo data Agent'
|
||||
|
@ -28,7 +28,7 @@ if [ $linux_inventory -eq 1 ] ; then
|
|||
|
||||
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
|
||||
for agent_name in $(cat pandora_xml_stress.agents | head -n ${agent_count}); do
|
||||
echo " - Adding invetory data to ${agent_name} linux agent"
|
||||
ip_add="10.0.0.$(( RANDOM % 255 + 1 ))"
|
||||
rand_number=$(( RANDOM % 10 + 1 ))
|
||||
|
@ -50,7 +50,7 @@ if [ $windows_inventory -eq 1 ]; then
|
|||
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
|
||||
for agent_name in $(cat pandora_xml_stress.agents | tail -n ${agent_count}); do
|
||||
echo " - Adding invetory data to ${agent_name} windows agent"
|
||||
ip_add="172.16.5.$(( RANDOM % 255 + 1 ))"
|
||||
rand_number=$(( RANDOM % 100 + 1 ))
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
# (c) 2023 Pandora FMS
|
||||
# This script is used to install a set of tools to load data automatically
|
||||
# by default it will creates a set of users, groups and agents
|
||||
# then set a cronjob to insert fake monitoring data to agents each 5 min
|
||||
# and inventory data once a day.
|
||||
|
||||
PREFIX=''
|
||||
|
||||
# Moving directory
|
||||
init_dir=$(pwd)
|
||||
# Get the directory where the script is located
|
||||
script_dir="$(dirname "$0")"
|
||||
# Change the working directory to the script's directory
|
||||
cd "$script_dir" || exit 1
|
||||
|
||||
# Check needed file exists
|
||||
echo ' [INFO] Checking file requirements:'
|
||||
if [ -f $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl ] && \
|
||||
[ -f $(pwd)/pandora_xml_stress.agents ] && \
|
||||
[ -f $(pwd)/pandora_xml_stress.conf ] && \
|
||||
[ -f $(pwd)/create_usersandgroups.sh ] && \
|
||||
[ -f $(pwd)/generate_inventory_data.sh ] && \
|
||||
[ -f $(pwd)/templates/inventory_linux.template ] && \
|
||||
[ -f $(pwd)/templates/inventory_windows.template] && \
|
||||
[ -f $(pwd)/pandora_xml_stress_module_source.txt ]; then
|
||||
echo ' [INFO] All file exist, continue'
|
||||
else
|
||||
echo ' [ERROR] Missing files, please check.' && exit -1
|
||||
fi
|
||||
# Create a set of users and grups
|
||||
echo ' [INFO] Creating demo users and groups:'
|
||||
$(pwd)/generate_inventory_data.sh
|
||||
echo ' [INFO] Waiting for inventory agents to be created:'
|
||||
while [ $(ls $PREFIX/var/spool/pandora/data_in/ | wc -l) -ge 10 ]; do
|
||||
sleep 2
|
||||
echo -ne .
|
||||
done
|
||||
# Load init monitoring data
|
||||
echo ' [INFO] Creating demo agent data:'
|
||||
perl $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl $(pwd)/pandora_xml_stress.conf || echo ' [ERROR] Generating agent data cant be completed'
|
||||
echo ' [INFO] Waiting for agents to be created:'
|
||||
while [ $(ls $PREFIX/var/spool/pandora/data_in/ | wc -l) -ge 10 ]; do
|
||||
sleep 2
|
||||
echo -ne .
|
||||
done
|
||||
# Create a set of users and grups
|
||||
echo ' [INFO] Creating demo users and groups:'
|
||||
$(pwd)/create_usersandgroups.sh
|
||||
# Set cronjobs in /etc/crotab
|
||||
echo ' [INFO] Adding data and inventory data to cronjob'
|
||||
echo "*/5 * * * * root cd $(pwd) && perl $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl $(pwd)/pandora_xml_stress.conf " >> /etc/crontab
|
||||
echo "0 0 * * * root cd $(pwd) && $(pwd)/generate_inventory_data.sh" >> /etc/crontab
|
||||
# Get back init directory
|
||||
cd $init_dir
|
|
@ -0,0 +1,24 @@
|
|||
[1692774345] Generating XML data files for 300 agents from 2023-08-23 09:05:45 to 2023-08-23 09:05:45 interval 300.
|
||||
[1692774345] Total agents: 300
|
||||
Total modules: 3600 (12 per agent)
|
||||
Total XML: 300 (6964 per second)
|
||||
[1692774481] Generating XML data files for 300 agents from 2023-08-23 09:08:01 to 2023-08-23 09:08:01 interval 300.
|
||||
[1692774481] Total agents: 300
|
||||
Total modules: 3600 (12 per agent)
|
||||
Total XML: 300 (6996 per second)
|
||||
[1692775236] Generating XML data files for 300 agents from 2023-08-23 09:20:36 to 2023-08-23 09:20:36 interval 300.
|
||||
[1692775236] Total agents: 300
|
||||
Total modules: 3600 (12 per agent)
|
||||
Total XML: 300 (7036 per second)
|
||||
[1692775282] Generating XML data files for 300 agents from 2023-08-23 09:21:22 to 2023-08-23 09:21:22 interval 300.
|
||||
[1692775282] Total agents: 300
|
||||
Total modules: 3600 (12 per agent)
|
||||
Total XML: 300 (6935 per second)
|
||||
[1692775320] Generating XML data files for 300 agents from 2023-08-23 09:22:00 to 2023-08-23 09:22:00 interval 300.
|
||||
[1692775320] Total agents: 300
|
||||
Total modules: 3600 (12 per agent)
|
||||
Total XML: 300 (6921 per second)
|
||||
[1692775629] Generating XML data files for 300 agents from 2023-08-23 09:27:09 to 2023-08-23 09:27:09 interval 300.
|
||||
[1692775629] Total agents: 300
|
||||
Total modules: 3600 (12 per agent)
|
||||
Total XML: 300 (6927 per second)
|
|
@ -1095,7 +1095,7 @@ Protocol description and more info at: L<< https://pandorafms.com/manual/en/docu
|
|||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright (c) 2005-2023 Pandora FMS.
|
||||
Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
|
||||
|
||||
=cut
|
||||
|
||||
|
|
Loading…
Reference in New Issue