2007-02-22 Sancho Lerena <slerena@artica.es>
* bin/pandora_dbstress.pl: Deleted, valid one is on /util * util/crea_modulos_ping.php: This tool create two modules for each existing agents. Used to create ICMP PROC and ICMP DATA network module types to test new Network infraestructure. * util/lista_ip.txt: Our testing IP field :-) * util/agent_creator.php: This PHP console script create a bunch of agents with it's modules (500 agents with 20 modules each by default) to test huge environments. * util/pandora_dbstress.pl: Updated. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@383 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
28eb116928
commit
271acdd997
|
@ -1,3 +1,24 @@
|
|||
2007-02-22 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* bin/pandora_dbstress.pl: Deleted, valid one is on /util
|
||||
|
||||
* util/crea_modulos_ping.php: This tool create two modules for
|
||||
each existing agents. Used to create ICMP PROC and ICMP DATA
|
||||
network module types to test new Network infraestructure.
|
||||
|
||||
* util/lista_ip.txt: Our testing IP field :-)
|
||||
|
||||
* util/agent_creator.php: This PHP console script create a bunch
|
||||
of agents with it's modules (500 agents with 20 modules each by
|
||||
default) to test huge environments.
|
||||
|
||||
* util/pandora_dbstress.pl: Updated.
|
||||
|
||||
2007-02-16 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* pandora_db.pm: Now updates and uses utimestamp fields in
|
||||
tagent_data, tagent_data_string and tagent_status.
|
||||
|
||||
2007-02-01 Manuel Arostegui <marostegui@artica.es>
|
||||
|
||||
* pandora_server/specs/fedoracore5/pandora_server.spec:
|
||||
|
|
|
@ -1,191 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
################################################################################
|
||||
# Pandora DB Stress tool
|
||||
################################################################################
|
||||
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
|
||||
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
|
||||
#
|
||||
#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; either version 2
|
||||
#of the License, or (at your option) any later version.
|
||||
#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.
|
||||
#You should have received a copy of the GNU General Public License
|
||||
#along with this program; if not, write to the Free Software
|
||||
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
################################################################################
|
||||
|
||||
# Configure here target (AGENT_ID for Stress)
|
||||
my $target_agent_id = 8;
|
||||
my $target_interval = 60;
|
||||
my $target_days = 30;
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
# Includes list
|
||||
use strict;
|
||||
use Time::Local; # DateTime basic manipulation
|
||||
use DBI; # DB interface with MySQL
|
||||
use Date::Manip; # Date/Time manipulation
|
||||
use Math::Trig; # Math functions
|
||||
|
||||
# Pandora Modules
|
||||
use pandora_config;
|
||||
use pandora_tools;
|
||||
use pandora_db;
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
my $version = "1.3-dev 070216";
|
||||
|
||||
# FLUSH in each IO (only for debug, very slooow)
|
||||
# ENABLED in DEBUGMODE
|
||||
# DISABLE FOR PRODUCTION
|
||||
$| = 0;
|
||||
|
||||
my %pa_config;
|
||||
|
||||
# Inicio del bucle principal de programa
|
||||
pandora_init(\%pa_config,"Pandora DB Stress tool");
|
||||
|
||||
# Read config file for Global variables
|
||||
pandora_loadconfig (\%pa_config,2);
|
||||
|
||||
# open database, only ONCE. We pass reference to DBI handler ($dbh) to all subprocess
|
||||
my $dbh = DBI->connect("DBI:mysql:pandora:$pa_config{'dbhost'}:3306",$pa_config{'dbuser'}, $pa_config{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
|
||||
|
||||
print " [*] Working for agent ID $target_agent_id \n";
|
||||
print " [*] Generating data of $target_days days ago \n";
|
||||
print " [*] Interval for this workload is $target_interval \n";
|
||||
|
||||
# For each module of $target_agent_id
|
||||
my $query_idag = "select * from tagente_modulo where id_agente = $target_agent_id";
|
||||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
my @data;
|
||||
# Read all alerts and apply to this incoming trap
|
||||
if ($s_idag->rows != 0) {
|
||||
while (@data = $s_idag->fetchrow_array()) {
|
||||
# Fill this module with data !
|
||||
process_module (\%pa_config, $data[0], $target_interval, $data[4], $target_days, $data[2], $target_agent_id, $dbh);
|
||||
}
|
||||
}
|
||||
$s_idag->finish();
|
||||
$dbh->disconnect();
|
||||
print " [*] All work done\n\n";
|
||||
# END of main proc
|
||||
|
||||
|
||||
##############################################################################
|
||||
# SUB process_module ()
|
||||
# Create a full range set of Pseudo random data for id_agente_modulo passed
|
||||
# as second parameter. Depends on module_name to generate a random value
|
||||
# (random) or periodic curve (cuve) values.
|
||||
##############################################################################
|
||||
|
||||
sub process_module(){
|
||||
my $pa_config = $_[0];
|
||||
my $id_agentemodulo = $_[1];
|
||||
my $target_interval = $_[2];
|
||||
my $target_name = $_[3];
|
||||
my $target_days = $_[4];
|
||||
my $target_type = $_[5];
|
||||
my $target_agent = $_[6];
|
||||
my $dbh = $_[7];
|
||||
|
||||
my $factor;
|
||||
$target_type = dame_nombretipomodulo_idagentemodulo ($pa_config, $target_type, $dbh);
|
||||
my $valor = 0; # value storage for data generation
|
||||
my $a; # loopcounter
|
||||
my $b; # counter
|
||||
print " [*] Processing module $target_name \n";
|
||||
my $agent_name = dame_agente_nombre ($pa_config, $target_agent, $dbh);
|
||||
my $err; # not used
|
||||
# Init start time to now - target_days
|
||||
my $fecha_actual = &UnixDate("today","%Y-%m-%d %H:%M:%S");
|
||||
my $m_timestamp = DateCalc($fecha_actual,"- $target_days days",\$err);
|
||||
my $mysql_date;
|
||||
|
||||
# Calculate how many iterations need to fill data range
|
||||
# $target_days*min*sec / $target_interval
|
||||
|
||||
my $iterations = ($target_days * 24 * 60 * 60) / $target_interval;
|
||||
|
||||
print " [D] ID_AgenteMoludo $id_agentemodulo Interval $target_interval ModuleName $target_name Days $target_days Type $target_type Agent $target_agent \n";
|
||||
|
||||
open (LOG,">> pandora_dbstress.log");
|
||||
# Generate MATH/Curve data for beautiful Drawings
|
||||
if ( $target_name =~ /curve/i ){
|
||||
# COS function to draw curves in a regular way
|
||||
$b = 0;
|
||||
$factor=rand(20);
|
||||
for ($a=1;$a<$iterations;$a++){
|
||||
$valor = 1 + cos(deg2rad($b));
|
||||
$b = $b + $factor/10;
|
||||
if ($b > 180){
|
||||
$b =0;
|
||||
}
|
||||
$m_timestamp = DateCalc($m_timestamp,"+ $target_interval seconds",\$err);
|
||||
$mysql_date = &UnixDate($m_timestamp,"%Y-%m-%d %H:%M:%S");
|
||||
$valor = $valor * $b * 10;
|
||||
$valor = sprintf("%.2f", $valor);
|
||||
$valor =~ s/\,/\./g;
|
||||
if (($a % 20) == 0) {
|
||||
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
||||
}
|
||||
pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh);
|
||||
# print LOG $mysql_date, $target_name, $valor, "\n";
|
||||
pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh);
|
||||
pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,100,$dbh);
|
||||
}
|
||||
}
|
||||
|
||||
# Generate pseudo-random data for changing drawings
|
||||
if ( $target_name =~ /random/i ){
|
||||
# Random values over line a static line
|
||||
for ($a=1;$a<$iterations;$a++){
|
||||
$valor = rand(15) + rand(15) + rand(15) + rand(15) + rand(15) + rand(15);
|
||||
$valor = sprintf("%.2f", $valor);
|
||||
$valor =~ s/\,/\./g;
|
||||
$m_timestamp = DateCalc($m_timestamp,"+ $target_interval seconds",\$err);
|
||||
$mysql_date = &UnixDate($m_timestamp,"%Y-%m-%d %H:%M:%S");
|
||||
if ($a % 20 == 0) {
|
||||
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
||||
}
|
||||
pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh);
|
||||
#print LOG $mysql_date, $target_name, $valor, "\n";
|
||||
pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh);
|
||||
pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,100,$dbh);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Generate pseudo-random data for boolean data
|
||||
if ( $target_name =~ /boolean/i ){
|
||||
for ($a=1;$a<$iterations;$a++){
|
||||
$valor = rand(50);
|
||||
if ($valor > 2){
|
||||
$valor = 1;
|
||||
} else {
|
||||
$valor = 0;
|
||||
}
|
||||
$m_timestamp = DateCalc($m_timestamp,"+ $target_interval seconds",\$err);
|
||||
$mysql_date = &UnixDate($m_timestamp,"%Y-%m-%d %H:%M:%S");
|
||||
if ($a % 20 eq 0) {
|
||||
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
||||
}
|
||||
pandora_lastagentcontact($pa_config, $mysql_date, $agent_name, "none","1.2", $target_interval, $dbh);
|
||||
#print LOG $mysql_date, $target_name, $valor, "\n";
|
||||
pandora_writedata($pa_config,$mysql_date,$agent_name,$target_type,$target_name,$valor,0,0,"",$dbh);
|
||||
pandora_writestate ($pa_config,$agent_name,$target_type,$target_name,$valor,$valor,$dbh);
|
||||
}
|
||||
|
||||
}
|
||||
close (LOG);
|
||||
print "\n";
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?PHP
|
||||
|
||||
// Babel - The Free Distributed Auditing System
|
||||
// (c) Artica Soluciones Tecnologicas S.L, 2005-2006
|
||||
// (c) Sancho Lerena 2006
|
||||
//
|
||||
// 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; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
|
||||
// NOT FUNCTIONAL YET
|
||||
|
||||
$target_agents = 500;
|
||||
$target_modules = 20;
|
||||
|
||||
|
||||
$dbname="pandora"; // MySQL DataBase
|
||||
$dbuser="pandora"; // DB User
|
||||
$dbpassword="pandora"; // Password
|
||||
$dbhost="localhost"; // MySQL Host
|
||||
if (! mysql_connect($dbhost,$dbuser,$dbpassword)){
|
||||
exit ('ERROR');
|
||||
}
|
||||
|
||||
mysql_select_db("pandora");
|
||||
for ($a=0; $a < $target_agents; $a++){
|
||||
$id = $a+100;
|
||||
$sql1="INSERT INTO tagente (id_agente, nombre) values ( $id, '$a' )";
|
||||
echo $sql1;
|
||||
mysql_query($sql1);
|
||||
for ($b=0; $b < $target_modules; $b++){
|
||||
if ($b > 5)
|
||||
$sql2="INSERT INTO tagente_modulo (id_agente, nombre, descripcion, id_tipo_modulo) values ( $id, 'random_$b','random_$bdesc', 1 )";
|
||||
else
|
||||
$sql2="INSERT INTO tagente_modulo (id_agente, nombre, descripcion, id_tipo_modulo) values ( $id, 'curve_$b','curve_$bdesc', 1 )";
|
||||
echo $sql2;
|
||||
mysql_query($sql2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,42 @@
|
|||
<?PHP
|
||||
|
||||
// (c) 2007, Sancho Lerena <slerena@openideas.info>
|
||||
//
|
||||
// Generador de modulos de tipo ICMP: Proc y Data para Pandora FMS 1.3
|
||||
// Toma como parametros (definidos en el codigo), el id_agente y el fichero de
|
||||
// entrada con una IP por linea
|
||||
|
||||
$id_agente = 1; // id del agente sobre los que colgar los modulos de PING
|
||||
$id_tipo_proc = 6; // Icmp proc
|
||||
$id_tipo_data = 7; // Icmp latency
|
||||
$filename = "lista_ip.txt";
|
||||
|
||||
$dbname="pandora"; // MySQL DataBase
|
||||
$dbuser="pandora"; // DB User
|
||||
$dbpassword="pandora"; // Password
|
||||
$dbhost="localhost"; // MySQL Host
|
||||
if (! mysql_connect($dbhost,$dbuser,$dbpassword)){
|
||||
exit ('No conecto al MySQL');
|
||||
}
|
||||
mysql_select_db("pandora");
|
||||
|
||||
if (! file_exists($filename))
|
||||
exit ( "No encuentro $filename");
|
||||
|
||||
$fichero = fopen($filename,"r");
|
||||
|
||||
$ip = "";
|
||||
echo "Let's go: ";
|
||||
|
||||
while (!feof($fichero)){
|
||||
$ip = fgets($fichero); // Strip \n
|
||||
$ip = substr($ip,0,strlen($ip)-1);
|
||||
$sql2="INSERT INTO tagente_modulo (id_agente, nombre, descripcion, id_tipo_modulo, ip_target) values ( $id_agente, '$ip (D)','ICMP Alive', $id_tipo_proc , '$ip')";
|
||||
mysql_query($sql2);
|
||||
|
||||
$sql2="INSERT INTO tagente_modulo (id_agente, nombre, descripcion, id_tipo_modulo. ip_target) values ( $id_agente, '$ip (P)','ICMP Latency', $id_tipo_data , '$ip')";
|
||||
mysql_query($sql2);
|
||||
echo ".";
|
||||
}
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,29 @@
|
|||
#!/usr/bin/perl
|
||||
##################################################################################
|
||||
################################################################################
|
||||
# Pandora DB Stress tool
|
||||
##################################################################################
|
||||
################################################################################
|
||||
# Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
|
||||
# Permission is granted to copy, distribute and/or modify this document
|
||||
# under the terms of the GNU Free Documentation License, Version 2.0
|
||||
# or any later version published by the Free Software Foundation at www.gnu.org
|
||||
##################################################################################
|
||||
# Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L
|
||||
#
|
||||
#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; either version 2
|
||||
#of the License, or (at your option) any later version.
|
||||
#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.
|
||||
#You should have received a copy of the GNU General Public License
|
||||
#along with this program; if not, write to the Free Software
|
||||
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
################################################################################
|
||||
|
||||
my $target_interval = 300;
|
||||
my $target_days = 40;
|
||||
my $target_agent = 10; # if not defined, uses ALL agents
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
# Includes list
|
||||
use strict;
|
||||
|
@ -20,17 +37,15 @@ use pandora_config;
|
|||
use pandora_tools;
|
||||
use pandora_db;
|
||||
|
||||
# Configure here target (AGENT_ID for Stress)
|
||||
my $target_agent_id = 3;
|
||||
my $target_interval = 300;
|
||||
my $target_days = 7;
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
my $version = "1.2Beta 060213";
|
||||
my $version = "1.3-dev 070216";
|
||||
|
||||
# FLUSH in each IO (only for debug, very slooow)
|
||||
# ENABLED in DEBUGMODE
|
||||
# DISABLE FOR PRODUCTION
|
||||
$| = 1;
|
||||
$| = 0;
|
||||
|
||||
my %pa_config;
|
||||
|
||||
|
@ -43,26 +58,25 @@ pandora_loadconfig (\%pa_config,2);
|
|||
# open database, only ONCE. We pass reference to DBI handler ($dbh) to all subprocess
|
||||
my $dbh = DBI->connect("DBI:mysql:pandora:$pa_config{'dbhost'}:3306",$pa_config{'dbuser'}, $pa_config{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
|
||||
|
||||
print " [*] Working for agent ID $target_agent_id \n";
|
||||
print " [*] Generating data of $target_days days ago \n";
|
||||
print " [*] Interval for this workload is $target_interval \n";
|
||||
|
||||
# For each module of $target_agent_id
|
||||
my $query_idag = "select * from tagente_modulo where id_agente = $target_agent_id";
|
||||
#my $query_idag = "select * from tagente_modulo where id_agente = $target_agent";
|
||||
my $query_idag = "select * from tagente_modulo";
|
||||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
my @data;
|
||||
# Read all alerts and apply to this incoming trap
|
||||
if ($s_idag->rows != 0) {
|
||||
while (@data = $s_idag->fetchrow_array()) {
|
||||
print " [*] Working for agent ID ".$data[1]." \n";
|
||||
# Fill this module with data !
|
||||
process_module (\%pa_config, $data[0], $target_interval, $data[4], $target_days, $data[2], $target_agent_id, $dbh);
|
||||
process_module (\%pa_config, $data[0], $target_interval, $data[4], $target_days, $data[2], $data[1], $dbh);
|
||||
}
|
||||
}
|
||||
$s_idag->finish();
|
||||
$dbh->disconnect();
|
||||
print " [*] All work done\n\n";
|
||||
|
||||
# END of main proc
|
||||
|
||||
|
||||
|
@ -171,7 +185,6 @@ sub process_module(){
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
close (LOG);
|
||||
print "\n";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue