From 67f76cadfc3d038f20bf015a101bd08e34369a70 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Dec 2017 16:08:27 +0100 Subject: [PATCH] Added -g option to pandora_perf_report MySQL optimization --- pandora_server/util/pandora_perf_report.pl | 121 ++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_perf_report.pl b/pandora_server/util/pandora_perf_report.pl index 76fe9f2f7f..a5b2a25605 100644 --- a/pandora_server/util/pandora_perf_report.pl +++ b/pandora_server/util/pandora_perf_report.pl @@ -36,6 +36,17 @@ my $STRESS_AGENT_XML = { # Hash representing data coming from an XML data 'agent_alias' => $STRESS_AGENT_NAME, 'module' => [] }; +my $DUMP_CNF_ONLY = 0; +my $HELP=<&STDOUT"; + close STDOUT; + open STDOUT, '>', '/dev/null'; +} + +############################################################################ +# Restore STDOUT, recover output +############################################################################ +sub restore_stdout { + close STDOUT; + open STDOUT, '>&', $OLD_STDOUT; +} + ################################################################################ +# # Main. +# ################################################################################ my %conf; -# Connect to the DB. + +if ($#ARGV < 0) { + print $HELP; + exit 0; +} + +if ((defined($ARGV[1])) && ($ARGV[1] =~ /-g/i)) { + $DUMP_CNF_ONLY = 1; +} + + +if ($DUMP_CNF_ONLY == 1) { + + print generate_optimized_my_cnf(); + + exit 0; +} + + +# close STDOUT +close_stdout(); + +# Init Pandora FMS libs pandora_init(\%conf,"Pandora FMS Performance Report Tool"); pandora_load_config(\%conf); + +# close STDOUT +restore_stdout(); + +# Connect to the DB. my $dbh = db_connect($conf{'dbengine'}, $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'}); # Do not show server messages when running the stress tests.