You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
#!/usr/bin/perl
|
|
|
|
use lib "/usr/share/BackupPC/lib";
|
|
use BackupPC::Lib;
|
|
use BackupPC::CGI::Lib;
|
|
use POSIX;
|
|
use JSON;
|
|
|
|
# We need to switch to backuppc UID/GID
|
|
my $uid = getuid();
|
|
my $gid = getgid();
|
|
my (undef,undef,$bkpuid,$bkpgid) = getpwnam('backuppc');
|
|
setuid($bkpuid) if ($uid ne $bkpuid);
|
|
setgid($bkpgid) if ($gid ne $bkpgid);
|
|
|
|
my $bpc = BackupPC::Lib->new();
|
|
my $hosts = $bpc->HostInfoRead();
|
|
my $mainConf = $bpc->ConfigDataRead();
|
|
|
|
my $json;
|
|
@{$json->{data}} = ();
|
|
|
|
foreach my $host (keys %$hosts){
|
|
my $hostConf = $bpc->ConfigDataRead($host);
|
|
my $conf = { %$mainConf, %$hostConf };
|
|
my $warning = $conf->{EMailNotifyOldBackupDays};
|
|
my $errors = (defined $conf->{MaxXferError}) ? $conf->{MaxXferError}: '0';
|
|
my $monitoring = $conf->{ZabbixMonitoring} || 1;
|
|
my $status = ($conf->{BackupsDisable} eq '1' or $monitoring eq '0') ? '0' : '1';
|
|
push @{$json->{data}},
|
|
{
|
|
"{#BPCHOST}" => $host,
|
|
"{#BPCNOBACKUPWARNING}" => $warning,
|
|
"{#BPCMAXERROR}" => $errors,
|
|
"{#BPCSTATUS}" => $status,
|
|
};
|
|
}
|
|
print to_json($json);
|
|
exit(0);
|
|
|