Commit 213e7472 authored by Nigel Kukard's avatar Nigel Kukard

Merge branch 'zabbix-retry' into 'master'

Zabbix retry

See merge request !38
parents 7cfe0b89 63e8aff6
Pipeline #3202 passed with stages
in 1 minute and 11 seconds
#!/usr/bin/perl #!/usr/bin/perl
# backstep-traceback - Client software for the AWIT Backstep server # backstep-traceback - Client software for the AWIT Backstep server
# Copyright (c) 2010-2017, AllWorldIT # Copyright (c) 2010-2018, AllWorldIT
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
...@@ -57,7 +57,7 @@ use Sys::Hostname; ...@@ -57,7 +57,7 @@ use Sys::Hostname;
our $VERSION = "1.3.3"; our $VERSION = "1.3.4";
# Constants # Constants
sub LOG_DEBUG { return 5; } sub LOG_DEBUG { return 5; }
...@@ -2678,29 +2678,39 @@ sub zabbixReport ...@@ -2678,29 +2678,39 @@ sub zabbixReport
} }
# Check result of close # Check result of close
my ($res,@data) = runCommand( my $res;
"zabbix_sender", for (my $try = 1; $try < 4; $try++) {
"--config",$globalConfig{'zabbix-config'}, ($res,my @data) = runCommand(
"--with-timestamps", "zabbix_sender",
"--input-file","-", "--config",$globalConfig{'zabbix-config'},
@extraArgs, "--with-timestamps",
{'pipe_array' => [ @zabbixData ]} "--input-file","-",
); @extraArgs,
if ($res) { {'pipe_array' => [ @zabbixData ]}
if ($res == -1) { );
printLog(LOG_ERROR,"ZABBIX: - Zabbix sender could not be spawned: %s",$!); if ($res) {
} elsif (my $signal = $res & 127) { if ($res == -1) {
printLog(LOG_ERROR,"ZABBIX: - Zabbix sender died with signal %s",$signal); printLog(LOG_ERROR,"ZABBIX: - Zabbix sender could not be spawned: %s",$!);
} elsif (my $signal = $res & 127) {
printLog(LOG_ERROR,"ZABBIX: - Zabbix sender died with signal %s",$signal);
} else {
my $exitcode = $? >> 8;
printLog(LOG_ERROR,"ZABBIX: - Zabbix sender died with exit code %s",$exitcode);
}
# If we have something in our stdout buffer, return it
if (defined($data[1]) && $data[1] ne "") {
printLog(LOG_ERROR,"ZABBIX: - STDERR log below\n- - - - - - - - - -\n%s\n- - - - - - - - - -\n",$data[1]);
}
if (defined($data[0]) && $data[0] ne "") {
printLog(LOG_ERROR,"ZABBIX: - STDOUT log below\n- - - - - - - - - -\n%s\n- - - - - - - - - -\n",$data[0]);
}
# Retry
printLog(LOG_ERROR,"ZABBIX: - Retrying... #$try");
sleep(10);
# Success
} else { } else {
my $exitcode = $? >> 8; last;
printLog(LOG_ERROR,"ZABBIX: - Zabbix sender died with exit code %s",$exitcode);
}
# If we have something in our stdout buffer, return it
if (defined($data[1]) && $data[1] ne "") {
printLog(LOG_ERROR,"ZABBIX: - STDERR log below\n- - - - - - - - - -\n%s\n- - - - - - - - - -\n",$data[1]);
}
if (defined($data[0]) && $data[0] ne "") {
printLog(LOG_ERROR,"ZABBIX: - STDOUT log below\n- - - - - - - - - -\n%s\n- - - - - - - - - -\n",$data[0]);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment