Added server conf option for self monitoring agent name

This commit is contained in:
Calvo 2023-11-06 13:30:49 +01:00
parent 96d8fe33f3
commit a0e1274ee6
5 changed files with 22 additions and 5 deletions

View File

@ -79,11 +79,17 @@ class Element
public function __construct(
$ajax_controller='include/ajax/general_tactical_view.ajax'
) {
global $config;
$this->interval = 0;
$this->title = __('Default element');
$this->ajaxController = $ajax_controller;
// Without ACL.
$agent = db_get_row('tagente', 'nombre', 'pandora.internals', '*');
$agent_name = $config['self_monitoring_agent_name'];
if (empty($agent_name) === true) {
$agent_name = 'pandora.internals';
}
$agent = db_get_row('tagente', 'nombre', $agent_name, '*');
if (is_array($agent) === true) {
$this->monitoringAgent = $agent;
}

View File

@ -818,6 +818,8 @@ sub main() {
&& $Config{"self_monitoring"} == 1
&& !is_metaconsole(\%Config)
&& time() - $thr_time_ref > $Config{'self_monitoring_interval'}) {
# Update agent name token.
pandora_set_tconfig_token($DBH, 'self_monitoring_agent_name', $Config{'self_monitoring_agent_name'});
$thr_time_ref = time();
pandora_thread_monitoring (\%Config, $DBH, \@Servers);
}

View File

@ -422,6 +422,9 @@ self_monitoring 1
# Self monitoring interval (in seconds).
self_monitoring_interval 300
# Self monitoring agent name.
self_monitoring_agent_name pandora.internals
# Update parent from the agent xml
update_parent 1

View File

@ -416,6 +416,9 @@ sub pandora_load_config {
# Self monitoring interval
$pa_config->{'self_monitoring_interval'} = 300; # 5.1SP1
# Self monitoring agent name.
$pa_config->{'self_monitoring_agent_name'} = 'pandora.internals'; # 7.774
# Process XML data files as a stack
$pa_config->{"dataserver_lifo"} = 0; # 5.0
@ -1041,6 +1044,9 @@ 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/^self_monitoring_agent_name\s+(.*)/i) {
$pa_config->{'self_monitoring_agent_name'} = clean_blank($1);
}
elsif ($parametro =~ m/^update_parent\s+([0-1])/i) {
$pa_config->{'update_parent'} = clean_blank($1);
}

View File

@ -6315,7 +6315,7 @@ sub pandora_self_monitoring ($$) {
my $xml_output = "";
$xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='" . $pa_config->{'rb_product_name'} . " Server version " . $pa_config->{'version'} . "' agent_name='pandora.internals' agent_alias='pandora.internals' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
$xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='" . $pa_config->{'rb_product_name'} . " Server version " . $pa_config->{'version'} . "' agent_name='" . $pa_config->{"self_monitoring_agent_name"} . "' agent_alias='" . $pa_config->{"self_monitoring_agent_name"} . "' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
$xml_output .=" <module>";
$xml_output .=" <name>Status</name>";
$xml_output .=" <type>generic_proc</type>";
@ -6514,7 +6514,7 @@ sub pandora_self_monitoring ($$) {
$xml_output .= "</agent_data>";
my $filename = $pa_config->{"incomingdir"}."/pandora.internals.self".$utimestamp.".data";
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{"self_monitoring_agent_name"}.".self".$utimestamp.".data";
open (XMLFILE, ">", $filename) or die "[FATAL] Could not open internal monitoring XML file for deploying monitorization at '$filename'";
print XMLFILE $xml_output;
close (XMLFILE);
@ -6539,7 +6539,7 @@ sub pandora_thread_monitoring ($$$) {
# All trhead modules are "Status" module sons.
$module_parent = 'Status';
$xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='" . $pa_config->{'rb_product_name'} . " Server version " . $pa_config->{'version'} . "' agent_name='pandora.internals' agent_alias='pandora.internals' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
$xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='" . $pa_config->{'rb_product_name'} . " Server version " . $pa_config->{'version'} . "' agent_name='" . $pa_config->{'self_monitoring_agent_name'} . "' agent_alias='pandora.internals' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
foreach my $server (@{$servers}) {
my $producer_stats = $server->getProducerStats();
while (my ($tid, $stats) = each(%{$producer_stats})) {
@ -6605,7 +6605,7 @@ sub pandora_thread_monitoring ($$$) {
}
$xml_output .= "</agent_data>";
my $filename = $pa_config->{"incomingdir"}."/pandora.internals.threads.".$utimestamp.".data";
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'self_monitoring_agent_name'}.".threads.".$utimestamp.".data";
open (XMLFILE, ">", $filename) or die "[FATAL] Could not write to the thread monitoring XML file '$filename'";
print XMLFILE $xml_output;
close (XMLFILE);