From 2ef6860b5c14c18e7542c152642027e0995a9b76 Mon Sep 17 00:00:00 2001 From: EvanAdam Date: Mon, 3 Mar 2025 16:00:32 +0100 Subject: [PATCH] fix(gorgone): add poller-performance to rrds database Refs:MON-161430 --- .../modules/centreon/statistics/class.pm | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/gorgone/gorgone/modules/centreon/statistics/class.pm b/gorgone/gorgone/modules/centreon/statistics/class.pm index 517c7c6fab6..92aa001f7e3 100644 --- a/gorgone/gorgone/modules/centreon/statistics/class.pm +++ b/gorgone/gorgone/modules/centreon/statistics/class.pm @@ -33,7 +33,6 @@ use Time::HiRes; use RRDs; use EV; -my $result; my %handlers = (TERM => {}, HUP => {}); my ($connector); @@ -377,7 +376,7 @@ sub write_engine_stats { "('$options{data}->{metadata}->{poller_id}', 'Service Check Latency', 'Average', '$3')" ); if ($status == -1) { - $self->{logger}->writeLogError("[statistics] Failed to add statistics in 'nagios_stats table'"); + $self->{logger}->writeLogError("[statistics] Failed to add statistics Service Check Latency in 'nagios_stats table'"); } } @@ -398,6 +397,15 @@ sub write_engine_stats { values => [ $1, $2 , $3 ] ); } elsif ($_ =~ /Active Service Execution Time:\s*([0-9\.]*)\ \/\ ([0-9\.]*)\ \/\ ([0-9\.]*)\ sec/) { + my $status = $self->{class_object_centstorage}->custom_execute( + request => "INSERT INTO `nagios_stats` (instance_id, stat_label, stat_key, stat_value) VALUES " . + "('$options{data}->{metadata}->{poller_id}', 'Service Check Execution Time', 'Min', '$1'), " . + "('$options{data}->{metadata}->{poller_id}', 'Service Check Execution Time', 'Max', '$2'), " . + "('$options{data}->{metadata}->{poller_id}', 'Service Check Execution Time', 'Average', '$3')" + ); + if ($status == -1) { + $self->{logger}->writeLogError("[statistics] Failed to add statistics Service Check Execution Time in 'nagios_stats table'"); + } my $dest_file = $engine_stats_dir . '/nagios_active_service_execution.rrd'; $self->{logger}->writeLogDebug("[statistics] Writing in file '" . $dest_file . "'"); if (!-e $dest_file) { @@ -449,6 +457,15 @@ sub write_engine_stats { values => [ $1, $2 , $3, $4 ] ); } elsif ($_ =~ /Active Host Latency:\s*([0-9\.]*)\ \/\ ([0-9\.]*)\ \/\ ([0-9\.]*)\ sec/) { + my $status = $self->{class_object_centstorage}->custom_execute( + request => "INSERT INTO `nagios_stats` (instance_id, stat_label, stat_key, stat_value) VALUES " . + "('$options{data}->{metadata}->{poller_id}', 'Host Check Latency ', 'Min', '$1'), " . + "('$options{data}->{metadata}->{poller_id}', 'Host Check Latency ', 'Max', '$2'), " . + "('$options{data}->{metadata}->{poller_id}', 'Host Check Latency ', 'Average', '$3')" + ); + if ($status == -1) { + $self->{logger}->writeLogError("[statistics] Failed to add statistics Host Check Latency in 'nagios_stats table'"); + } my $dest_file = $engine_stats_dir . '/nagios_active_host_latency.rrd'; $self->{logger}->writeLogDebug("[statistics] Writing in file '" . $dest_file . "'"); if (!-e $dest_file) { @@ -466,6 +483,15 @@ sub write_engine_stats { values => [ $1, $2 , $3 ] ); } elsif ($_ =~ /Active Host Execution Time:\s*([0-9\.]*)\ \/\ ([0-9\.]*)\ \/\ ([0-9\.]*)\ sec/) { + my $status = $self->{class_object_centstorage}->custom_execute( + request => "INSERT INTO `nagios_stats` (instance_id, stat_label, stat_key, stat_value) VALUES " . + "('$options{data}->{metadata}->{poller_id}', 'Host Check Execution Time', 'Min', '$1'), " . + "('$options{data}->{metadata}->{poller_id}', 'Host Check Execution Time', 'Max', '$2'), " . + "('$options{data}->{metadata}->{poller_id}', 'Host Check Execution Time', 'Average', '$3')" + ); + if ($status == -1) { + $self->{logger}->writeLogError("[statistics] Failed to add statistics Host Check Execution Time in 'nagios_stats table'"); + } my $dest_file = $engine_stats_dir . '/nagios_active_host_execution.rrd'; $self->{logger}->writeLogDebug("[statistics] Writing in file '" . $dest_file . "'"); if (!-e $dest_file) { @@ -518,6 +544,7 @@ sub write_engine_stats { ); } } + $self->{logger}->writeLogInfo("[statistics] poller $options{data}->{metadata}->{poller_id} engine data was integrated in rrd and sql database."); } sub rrd_create {