Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gorgone): add poller-performance to rrds database #2173

Open
wants to merge 1 commit into
base: dev-23.10.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions gorgone/gorgone/modules/centreon/statistics/class.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use Time::HiRes;
use RRDs;
use EV;

my $result;
my %handlers = (TERM => {}, HUP => {});
my ($connector);

Expand Down Expand Up @@ -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'");
}
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down