2009-12-18 Raul Mateos <raulofpandora@gmail.com>
* pandora_dbstress.pl, pandora_db.pl: Clean code, updated year. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2216 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
3f7abb97a0
commit
206e69c947
|
@ -1,3 +1,7 @@
|
||||||
|
2009-12-18 Raul Mateos <raulofpandora@gmail.com>
|
||||||
|
|
||||||
|
* pandora_dbstress.pl, pandora_db.pl: Clean code, updated year.
|
||||||
|
|
||||||
2009-12-18 Ramon Novoa <rnovoa@artica.es>
|
2009-12-18 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* DEBIAN/control: Updated version.
|
* DEBIAN/control: Updated version.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Pandora FMS DB Management
|
# Pandora FMS DB Management
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2005-2008 Artica Soluciones Tecnologicas S.L
|
# Copyright (c) 2005-2009 Artica Soluciones Tecnologicas S.L
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
|
@ -50,7 +50,7 @@ if (enterprise_load (\%conf) == 0) {
|
||||||
# Connect to the DB
|
# Connect to the DB
|
||||||
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
|
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
|
||||||
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
|
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
|
||||||
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;
|
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
pandoradb_main(\%conf, $dbh, $history_dbh);
|
pandoradb_main(\%conf, $dbh, $history_dbh);
|
||||||
|
@ -73,7 +73,7 @@ sub pandora_purgedb ($$) {
|
||||||
# Calculate limit for deletion, today - $conf->{'_days_purge'}
|
# Calculate limit for deletion, today - $conf->{'_days_purge'}
|
||||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
|
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
|
||||||
|
|
||||||
my $ulimit_access_timestamp = time() - 86400;
|
my $ulimit_access_timestamp = time() - 86400;
|
||||||
my $ulimit_timestamp = time() - (86400 * $conf->{'_days_purge'});
|
my $ulimit_timestamp = time() - (86400 * $conf->{'_days_purge'});
|
||||||
my $limit_timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($ulimit_timestamp));
|
my $limit_timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($ulimit_timestamp));
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ sub pandora_compactdb ($$) {
|
||||||
sub pandora_init ($) {
|
sub pandora_init ($) {
|
||||||
my $conf = shift;
|
my $conf = shift;
|
||||||
|
|
||||||
print "\nPandora FMS DB Tool $version Copyright (c) 2004-2008 Artica ST\n";
|
print "\nPandora FMS DB Tool $version Copyright (c) 2004-2009 Artica ST\n";
|
||||||
print "This program is Free Software, licensed under the terms of GPL License v2\n";
|
print "This program is Free Software, licensed under the terms of GPL License v2\n";
|
||||||
print "You can download latest versions and documentation at http://www.pandorafms.org\n\n";
|
print "You can download latest versions and documentation at http://www.pandorafms.org\n\n";
|
||||||
|
|
||||||
|
@ -228,9 +228,9 @@ sub pandora_load_config ($) {
|
||||||
}
|
}
|
||||||
close (CFG);
|
close (CFG);
|
||||||
|
|
||||||
# Check conf tokens
|
# Check conf tokens
|
||||||
foreach my $param ('dbuser', 'dbpass', 'dbname', 'dbhost', 'log_file') {
|
foreach my $param ('dbuser', 'dbpass', 'dbname', 'dbhost', 'log_file') {
|
||||||
die ("[ERROR] Bad config values. Make sure " . $conf->{'_pandora_path'} . " is a valid config file.\n\n") unless defined ($conf->{$param});
|
die ("[ERROR] Bad config values. Make sure " . $conf->{'_pandora_path'} . " is a valid config file.\n\n") unless defined ($conf->{$param});
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read additional tokens from the DB
|
# Read additional tokens from the DB
|
||||||
|
@ -250,7 +250,7 @@ sub pandora_load_config ($) {
|
||||||
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
|
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
|
||||||
db_disconnect ($dbh);
|
db_disconnect ($dbh);
|
||||||
|
|
||||||
printf "Pandora DB now initialized and running (PURGE=" . $conf->{'_days_purge'} . " days, COMPACT=$conf->{'_days_compact'} days, STEP=" . $conf->{'_step_compact'} . ") ... \n\n";
|
printf "Pandora DB now initialized and running (PURGE=" . $conf->{'_days_purge'} . " days, COMPACT=$conf->{'_days_compact'} days, STEP=" . $conf->{'_step_compact'} . ") ... \n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -330,7 +330,7 @@ sub is_policy_module ($$) {
|
||||||
|
|
||||||
# Search policies
|
# Search policies
|
||||||
my $policy_id = get_db_value ($dbh, 'SELECT t3.id FROM tpolicy_agents AS t1 INNER JOIN tpolicy_modules AS t2 ON t1.id_policy = t2.id_policy
|
my $policy_id = get_db_value ($dbh, 'SELECT t3.id FROM tpolicy_agents AS t1 INNER JOIN tpolicy_modules AS t2 ON t1.id_policy = t2.id_policy
|
||||||
INNER JOIN tpolicies AS t3 ON t1.id_policy = t3.id WHERE t1.id_agent = ? AND t2.name LIKE ?', $agent_id, $module_name);
|
INNER JOIN tpolicies AS t3 ON t1.id_policy = t3.id WHERE t1.id_agent = ? AND t2.name LIKE ?', $agent_id, $module_name);
|
||||||
|
|
||||||
# Not a policy module
|
# Not a policy module
|
||||||
return undef unless defined ($policy_id);
|
return undef unless defined ($policy_id);
|
||||||
|
@ -343,7 +343,7 @@ sub is_policy_module ($$) {
|
||||||
##############################################################################
|
##############################################################################
|
||||||
sub help_screen{
|
sub help_screen{
|
||||||
print "\n\nUsage: $0 <path to pandora_server.conf> [options]\n\n";
|
print "\n\nUsage: $0 <path to pandora_server.conf> [options]\n\n";
|
||||||
print "\n\tAvailable options:\n\t\t-d Debug output (very verbose).\n";
|
print "\n\tAvailable options:\n\t\t-d Debug output (very verbose).\n";
|
||||||
print "\t\t-v Verbose output.\n";
|
print "\t\t-v Verbose output.\n";
|
||||||
print "\t\t-q Quiet output.\n";
|
print "\t\t-q Quiet output.\n";
|
||||||
print "\t\t-p Only purge and consistency check, skip compact.\n\n";
|
print "\t\t-p Only purge and consistency check, skip compact.\n\n";
|
||||||
|
|
|
@ -42,7 +42,7 @@ use PandoraFMS::Core;
|
||||||
################################################################################
|
################################################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
my $version = "2.0 PS080903";
|
my $version = "3.0 PS091214";
|
||||||
|
|
||||||
# FLUSH in each IO (only for debug, very slooow)
|
# FLUSH in each IO (only for debug, very slooow)
|
||||||
# ENABLED in DEBUGMODE
|
# ENABLED in DEBUGMODE
|
||||||
|
@ -68,11 +68,11 @@ print " [*] Interval for this workload is $target_interval \n";
|
||||||
my $query_idag;
|
my $query_idag;
|
||||||
|
|
||||||
if ($target_agent ne -1){
|
if ($target_agent ne -1){
|
||||||
if ($target_module ne -1){
|
if ($target_module ne -1){
|
||||||
$query_idag = "select * from tagente_modulo where id_agente = $target_agent AND id_agente_modulo = $target_module";
|
$query_idag = "select * from tagente_modulo where id_agente = $target_agent AND id_agente_modulo = $target_module";
|
||||||
} else {
|
} else {
|
||||||
$query_idag = "select * from tagente_modulo where id_agente = $target_agent";
|
$query_idag = "select * from tagente_modulo where id_agente = $target_agent";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$query_idag = "select * from tagente_modulo";
|
$query_idag = "select * from tagente_modulo";
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ sub process_module($$$$$){
|
||||||
$b = 0;
|
$b = 0;
|
||||||
$factor=rand(20);
|
$factor=rand(20);
|
||||||
for ($a=1;$a<$iterations;$a++){
|
for ($a=1;$a<$iterations;$a++){
|
||||||
$valor = 1 + cos(deg2rad($b));
|
$valor = 1 + cos(deg2rad($b));
|
||||||
$b = $b + $factor/10;
|
$b = $b + $factor/10;
|
||||||
if ($b > 180){
|
if ($b > 180){
|
||||||
$b =0;
|
$b =0;
|
||||||
|
@ -141,8 +141,8 @@ sub process_module($$$$$){
|
||||||
$valor = $valor * $b * 10;
|
$valor = $valor * $b * 10;
|
||||||
$valor = sprintf("%.2f", $valor);
|
$valor = sprintf("%.2f", $valor);
|
||||||
$valor =~ s/\,/\./g;
|
$valor =~ s/\,/\./g;
|
||||||
if (($a % 20) == 0) {
|
if (($a % 20) == 0) {
|
||||||
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
||||||
}
|
}
|
||||||
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
||||||
# print LOG $mysql_date, $target_name, $valor, "\n";
|
# print LOG $mysql_date, $target_name, $valor, "\n";
|
||||||
|
@ -156,13 +156,13 @@ sub process_module($$$$$){
|
||||||
if ( $target_name =~ /random/i ){
|
if ( $target_name =~ /random/i ){
|
||||||
# Random values over line a static line
|
# Random values over line a static line
|
||||||
for ($a=1;$a<$iterations;$a++){
|
for ($a=1;$a<$iterations;$a++){
|
||||||
$valor = rand(15) + rand(15) + rand(15) + rand(15) + rand(15) + rand(15);
|
$valor = rand(15) + rand(15) + rand(15) + rand(15) + rand(15) + rand(15);
|
||||||
$valor = sprintf("%.2f", $valor);
|
$valor = sprintf("%.2f", $valor);
|
||||||
$valor =~ s/\,/\./g;
|
$valor =~ s/\,/\./g;
|
||||||
$utimestamp += $target_interval;
|
$utimestamp += $target_interval;
|
||||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
||||||
if ($a % 20 == 0) {
|
if ($a % 20 == 0) {
|
||||||
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
||||||
}
|
}
|
||||||
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
||||||
#print LOG $mysql_date, $target_name, $valor, "\n";
|
#print LOG $mysql_date, $target_name, $valor, "\n";
|
||||||
|
@ -176,7 +176,7 @@ sub process_module($$$$$){
|
||||||
# Generate pseudo-random data for boolean data
|
# Generate pseudo-random data for boolean data
|
||||||
if ( $target_name =~ /boolean/i ){
|
if ( $target_name =~ /boolean/i ){
|
||||||
for ($a=1;$a<$iterations;$a++){
|
for ($a=1;$a<$iterations;$a++){
|
||||||
$valor = rand(50);
|
$valor = rand(50);
|
||||||
if ($valor > 2){
|
if ($valor > 2){
|
||||||
$valor = 1;
|
$valor = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,7 +185,7 @@ sub process_module($$$$$){
|
||||||
$utimestamp += $target_interval;
|
$utimestamp += $target_interval;
|
||||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
||||||
if ($a % 20 eq 0) {
|
if ($a % 20 eq 0) {
|
||||||
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
||||||
}
|
}
|
||||||
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
||||||
#print LOG $mysql_date, $target_name, $valor, "\n";
|
#print LOG $mysql_date, $target_name, $valor, "\n";
|
||||||
|
@ -203,7 +203,7 @@ sub process_module($$$$$){
|
||||||
$utimestamp += $target_interval;
|
$utimestamp += $target_interval;
|
||||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
||||||
if ($a % 20 eq 0) {
|
if ($a % 20 eq 0) {
|
||||||
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
print "\r -> ".int($a / ($iterations / 100))."% generated for ($target_name) ";
|
||||||
}
|
}
|
||||||
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
pandora_update_agent($pa_config, $timestamp, $target_agent, "none","1.2", $target_interval, $dbh);
|
||||||
#print LOG $mysql_date, $target_name, $valor, "\n";
|
#print LOG $mysql_date, $target_name, $valor, "\n";
|
||||||
|
|
Loading…
Reference in New Issue