Remove sample_agent.
Remove sample_agent, since it is not used anymore and has performance issues.
This commit is contained in:
parent
172cb38045
commit
58ff352df8
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// 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; version 2
|
||||
// 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.
|
||||
require_once __DIR__.'/../include/config.php';
|
||||
require_once __DIR__.'/../include/auth/mysql.php';
|
||||
require_once __DIR__.'/../include/functions.php';
|
||||
require_once __DIR__.'/../include/functions_db.php';
|
||||
/*
|
||||
* Review if sample agent is active and deploys configuration for
|
||||
* visual consoles if necessary
|
||||
*/
|
||||
global $config;
|
||||
|
||||
// Deployment of sample agent for visual consoles.
|
||||
if ($config['sample_agent'] == 1 && !isset($config['sample_agent_deployed'])) {
|
||||
$id_agente = db_get_sql('SELECT id_agente FROM tagente WHERE nombre = "Sample_Agent";');
|
||||
$modules = db_get_all_rows_filter('tagente_modulo', ['id_agente' => $id_agente], 'id_agente_modulo');
|
||||
$count_modules = count($modules);
|
||||
|
||||
// Update of layout 1 (Rack sample).
|
||||
$images_rack_server = [
|
||||
'rack_server_rack',
|
||||
'rack_server',
|
||||
'rack_switch',
|
||||
'rack_firewall',
|
||||
'rack_double_server',
|
||||
'rack_frame',
|
||||
'rack_pdu',
|
||||
];
|
||||
$query = 'UPDATE `tlayout_data` SET `id_agent` = '.$id_agente.', `id_agente_modulo` = CASE ';
|
||||
for ($i = 0; $i < $count_modules; $i++) {
|
||||
$query .= 'WHEN `image` = "'.$images_rack_server[$i].'" THEN '.$modules[$i]['id_agente_modulo'].' ';
|
||||
}
|
||||
|
||||
$query .= 'END WHERE `id_layout` = 1 AND `image` IN ("'.implode('","', $images_rack_server).'");';
|
||||
|
||||
db_process_sql($query);
|
||||
// Update of layout 2 (Dashboard).
|
||||
$query = 'UPDATE `tlayout_data` SET `id_agent`= '.$id_agente.', `id_agente_modulo` = CASE ';
|
||||
$query .= 'WHEN `id` = 107 THEN '.$modules[0]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 108 THEN '.$modules[1]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 109 THEN '.$modules[2]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 110 THEN '.$modules[2]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 111 THEN '.$modules[3]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 112 THEN '.$modules[4]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 113 THEN '.$modules[5]['id_agente_modulo'].' ';
|
||||
$query .= 'WHEN `id` = 114 THEN '.$modules[6]['id_agente_modulo'].' ';
|
||||
$query .= 'END WHERE `id_layout` = 2 AND `id` IN (107,108,109,110,111,112,113,114);';
|
||||
|
||||
db_process_sql($query);
|
||||
|
||||
// This setting will avoid regenerate all the times the visual consoles.
|
||||
config_update_value('sample_agent_deployed', 1);
|
||||
}
|
||||
|
||||
extensions_add_main_function('sample_agent_deployment');
|
|
@ -348,15 +348,6 @@ self_monitoring 1
|
|||
# Self monitoring interval (in seconds).
|
||||
self_monitoring_interval 300
|
||||
|
||||
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
|
||||
# will make sample data. Disabled by default.
|
||||
|
||||
sample_agent 0
|
||||
|
||||
# Pandora Sample Agent interval (in seconds).
|
||||
|
||||
sample_agent_interval 600
|
||||
|
||||
# Update parent from the agent xml
|
||||
|
||||
#update_parent 1
|
||||
|
|
|
@ -340,15 +340,6 @@ restart_delay 60
|
|||
|
||||
self_monitoring 1
|
||||
|
||||
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
|
||||
# will make sample data. Disabled by default.
|
||||
|
||||
sample_agent 0
|
||||
|
||||
# Pandora Sample Agent interval (in seconds).
|
||||
|
||||
sample_agent_interval 600
|
||||
|
||||
# Update parent from the agent xml
|
||||
|
||||
#update_parent 1
|
||||
|
|
|
@ -491,16 +491,6 @@ sub pandora_server_tasks ($) {
|
|||
pandora_self_monitoring ($pa_config, $dbh);
|
||||
}
|
||||
|
||||
# Pandora sample agent
|
||||
if (defined($pa_config->{'sample_agent'})) {
|
||||
if ($pa_config->{'sample_agent'} == 1
|
||||
&& !is_metaconsole($pa_config)
|
||||
&& $counter % $pa_config->{'sample_agent_interval'} == 0){
|
||||
pandora_sample_agent ($pa_config);
|
||||
}
|
||||
pandora_update_config_token ($dbh, 'sample_agent', $pa_config->{'sample_agent'});
|
||||
}
|
||||
|
||||
# Avoid counter overflow
|
||||
if ($counter >= ~0){
|
||||
$counter = 0;
|
||||
|
|
|
@ -422,15 +422,6 @@ self_monitoring 1
|
|||
# Self monitoring interval (in seconds).
|
||||
self_monitoring_interval 300
|
||||
|
||||
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
|
||||
# will make sample data. Disabled by default.
|
||||
|
||||
sample_agent 0
|
||||
|
||||
# Pandora Sample Agent interval (in seconds).
|
||||
|
||||
sample_agent_interval 600
|
||||
|
||||
# Update parent from the agent xml
|
||||
|
||||
update_parent 1
|
||||
|
|
|
@ -345,15 +345,6 @@ restart_delay 60
|
|||
# Self monitoring interval (in seconds).
|
||||
#self_monitoring_interval 300
|
||||
|
||||
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
|
||||
# will make sample data. Disabled by default.
|
||||
|
||||
sample_agent 0
|
||||
|
||||
# Pandora Sample Agent interval (in seconds).
|
||||
|
||||
sample_agent_interval 600
|
||||
|
||||
# Update parent from the agent xml
|
||||
|
||||
#update_parent 1
|
||||
|
|
|
@ -415,12 +415,6 @@ sub pandora_load_config {
|
|||
# Self monitoring interval
|
||||
$pa_config->{'self_monitoring_interval'} = 300; # 5.1SP1
|
||||
|
||||
# Sample Agent
|
||||
$pa_config->{'sample_agent'} = 0;
|
||||
|
||||
# Sample agent interval
|
||||
$pa_config->{'sample_agent_interval'} = 600;
|
||||
|
||||
# Process XML data files as a stack
|
||||
$pa_config->{"dataserver_lifo"} = 0; # 5.0
|
||||
|
||||
|
@ -1014,12 +1008,6 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^self_monitoring_interval\s+([0-9]*)/i) {
|
||||
$pa_config->{'self_monitoring_interval'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^sample_agent\s+([0-1])/i) {
|
||||
$pa_config->{'sample_agent'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^sample_agent_interval\s+([0-9]*)/i) {
|
||||
$pa_config->{'sample_agent_interval'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^update_parent\s+([0-1])/i) {
|
||||
$pa_config->{'update_parent'} = clean_blank($1);
|
||||
}
|
||||
|
|
|
@ -100,8 +100,6 @@ Exported Functions:
|
|||
|
||||
=item * C<pandora_thread_monitoring>
|
||||
|
||||
=item * C<pandora_sample_agent>
|
||||
|
||||
=back
|
||||
|
||||
=head1 METHODS
|
||||
|
@ -261,7 +259,6 @@ our @EXPORT = qw(
|
|||
pandora_server_statistics
|
||||
pandora_self_monitoring
|
||||
pandora_thread_monitoring
|
||||
pandora_sample_agent
|
||||
pandora_process_policy_queue
|
||||
pandora_sync_agents_integria
|
||||
pandora_get_integria_ticket_types
|
||||
|
@ -6135,84 +6132,6 @@ sub pandora_thread_monitoring ($$$) {
|
|||
close (XMLFILE);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< xml_module_template (I<$module_name>, I<$module_type>, I<$module_data>) >>
|
||||
|
||||
Module template for sample agent
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub xml_module_template ($$$) {
|
||||
my ($module_name, $module_type, $module_data) = @_;
|
||||
my $output = "<module>\n";
|
||||
|
||||
$module_name = "<![CDATA[".$module_name."]]>" if $module_name =~ /[\s+.]+/;
|
||||
$module_data = "<![CDATA[".$module_data."]]>" if $module_data =~ /[\s+.]+/;
|
||||
|
||||
$output .= "\t<name>".$module_name."</name>\n";
|
||||
$output .= "\t<type>".$module_type."</type>\n";
|
||||
$output .= "\t<data>".$module_data."</data>\n";
|
||||
$output .= "</module>\n";
|
||||
|
||||
return $output;
|
||||
}
|
||||
##########################################################################
|
||||
=head2 C<< pandora_sample_agent (I<$pa_config>) >>
|
||||
|
||||
Pandora agent for make sample data
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_sample_agent ($) {
|
||||
|
||||
my ($pa_config) = @_;
|
||||
|
||||
my $utimestamp = time ();
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
|
||||
# First line
|
||||
my $xml_output = "<?xml version='1.0' encoding='UTF-8'?>\n";
|
||||
# Header
|
||||
$xml_output = "<agent_data agent_name='Sample_Agent' agent_alias='Sample_Agent' description='Agent for sample generation purposes' group='Servers' os_name='$OS' os_version='$OS_VERSION' interval='".$pa_config->{'sample_agent_interval'}."' version='" . $pa_config->{'version'} . "' timestamp='".$timestamp."'>\n";
|
||||
# Boolean ever return TRUE
|
||||
$xml_output .= xml_module_template ("Boolean ever true", "generic_proc","1");
|
||||
# Boolean return TRUE at 80% of times
|
||||
my $sample_boolean_mostly_true = 1;
|
||||
$sample_boolean_mostly_true = 0 if rand(9) > 7;
|
||||
$xml_output .= xml_module_template ("Boolean mostly true", "generic_proc",$sample_boolean_mostly_true);
|
||||
# Boolean return false at 80% of times
|
||||
my $sample_boolean_mostly_false = 0;
|
||||
$sample_boolean_mostly_false = 1 if rand(9) > 7;
|
||||
$xml_output .= xml_module_template ("Boolean mostly false", "generic_proc", $sample_boolean_mostly_false);
|
||||
# Boolean ever return FALSE
|
||||
$xml_output .= xml_module_template ("Boolean ever false", "generic_proc","0");
|
||||
# Random integer between 0 and 100
|
||||
$xml_output .= xml_module_template ("Random integer values", "generic_data",int(rand(100)));
|
||||
# Random values obtained with sinusoidal curves between 0 and 100 values
|
||||
my $b = 1;
|
||||
my $sample_serie_curve = 1 + cos(deg2rad($b));
|
||||
$b = $b + rand(20)/10;
|
||||
$b = 0 if ($b > 180);
|
||||
$sample_serie_curve = $sample_serie_curve * $b * 10;
|
||||
$sample_serie_curve =~ s/\,/\./g;
|
||||
$xml_output .= xml_module_template ("Random serie curve", "generic_data", $sample_serie_curve);
|
||||
# String with 10 random characters
|
||||
my $sample_random_text = "";
|
||||
my @characters = ('a'..'z','A'..'Z');
|
||||
for (1...10){
|
||||
$sample_random_text .= $characters[int(rand(@characters))];
|
||||
}
|
||||
$xml_output .= xml_module_template ("Random text", "generic_data_string", $sample_random_text);
|
||||
# End of xml
|
||||
$xml_output .= "</agent_data>";
|
||||
# File path definition
|
||||
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".sample.".$utimestamp.".data";
|
||||
# Opening, Writing and closing of XML
|
||||
open (my $xmlfile, ">", $filename) or die "[FATAL] Could not open sample XML file for deploying monitorization at '$filename'";
|
||||
print $xmlfile $xml_output;
|
||||
close ($xmlfile);
|
||||
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< set_master (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
|
|
Loading…
Reference in New Issue