Enhance backuppc reporting script

Including reporting the new file size, and sending all the info at once in JSON format
tags/zabbix-agent-addons-0.2.65-1
Daniel Berteaud 6 years ago
parent 02d58e3e53
commit 26b5624421
  1. 24
      zabbix_scripts/check_backuppc_sudo

@ -27,6 +27,7 @@ my $fullAge = $incrAge = $lastAge = -1;
my $lastXferErrors = 0; my $lastXferErrors = 0;
my $maxErrors = 0; my $maxErrors = 0;
if ( @backups ) {
for ( my $i = 0 ; $i < @backups ; $i++ ) { for ( my $i = 0 ; $i < @backups ; $i++ ) {
if ( $backups[$i]{type} eq "full" ) { if ( $backups[$i]{type} eq "full" ) {
$fullCnt++; $fullCnt++;
@ -52,7 +53,12 @@ if ( $lastAge < 0 ) {
} else { } else {
$lastAge = sprintf("%.1f", (time - $lastAge) / (24 * 3600)); $lastAge = sprintf("%.1f", (time - $lastAge) / (24 * 3600));
} }
$lastXferErrors = $backups[@backups-1]{xferErrs} if ( @backups ); $lastXferErrors = $backups[@backups-1]{xferErrs};
$lastSizeNew = $backups[@backups-1]{sizeNew};
$lastDuration = $backups[@backups-1]{endTime} - $backups[@backups-1]{startTime};
$lastType = $backups[@backups-1]{type};
}
$maxErrors = $conf->{MaxXferError} if (defined $conf->{MaxXferError}); $maxErrors = $conf->{MaxXferError} if (defined $conf->{MaxXferError});
if ($what eq 'errors') { if ($what eq 'errors') {
@ -64,13 +70,25 @@ if ($what eq 'errors'){
} elsif ($what eq 'size') { } elsif ($what eq 'size') {
print $fullSize; print $fullSize;
} elsif ($what eq 'duration') { } elsif ($what eq 'duration') {
print $fullDur; print $lastDuration;
} elsif ($what eq 'notify') { } elsif ($what eq 'notify') {
print $conf->{EMailNotifyOldBackupDays}; print $conf->{EMailNotifyOldBackupDays};
} elsif ($what eq 'all') {
print to_json(
{
max_errors => $maxErrors,
last_age => $lastAge,
full_size => $fullSize,
new_size => $lastSizeNew,
full_duration => $fullDur,
duration => $lastDuration,
last_type => $lastType
}
);
} else { } else {
print<<"EOF"; print<<"EOF";
Usage: $0 <host> [errors|age|size|duration] Usage: $0 <host> [errors|age|size|duration|all]
EOF EOF
} }

Loading…
Cancel
Save