FAQ | This is a LIVE service | Changelog

Commit 6e536df5 authored by Dr Adam Thorn's avatar Dr Adam Thorn
Browse files

Prepend reporting lines with the zfs target name

This will let us use zfs_target as the name of a subtest which
in turn means we would be able to separately log and graph multiple
backup targets associated with a single host.

This change does not affect the current parsing performed when
we input data into postgres: it uses non-anchored regexps to
identify SpaceUsed etc so prepending extra text won't change
parent 3941a9df
......@@ -3,6 +3,6 @@ Priority: optional
Section: otherosfs
Maintainer: Chemistry COs <support@ch.cam.ac.uk>
Architecture: all
Version: 0.9-ch84
Version: 0.9-ch85
Depends: zfs-dkms, postgresql-13 | postgresql-9.5 | postgresql-9.4 , liblockfile-simple-perl, libdbi-perl, libjson-perl, libzfs-perl-chem, libnet-openssh-perl, libdbd-pg-perl, mbuffer, rsync, nfs-kernel-server, pv, libwww-curl-perl
Description: a backup system using ZFS (repository 'backup-scheduler')
......@@ -57,7 +57,7 @@ foreach my $hr (@{$all}) {
my $hostname=$hr->[0];
print "Considering $hostname\n";
my $bb=new Hobbit ({test=>'backup',hostname=>$hostname,ttl=>'60m'});
$bb->print("Backup status on $this_server\n");
$bb->print("Backup status on $this_server\n\n");
......@@ -69,10 +69,15 @@ foreach my $hr (@{$all}) {
while (my $row=$sti->fetchrow_hashref) {
$rows_for_this_host += 1;
my $zfs_target = $row->{'zfs_target'};
if ($row->{'disabled'}) {
$bb->color_line('green',$row->{'backup_task_name'}." is disabled\n");
} else {
my $backup_task_name = $row->{'backup_task_name'};
$bb->print("Backup target: $zfs_target\n");
my $detail = $stj->fetchrow_arrayref();
my $filename = $hostname . '_' . @{$detail}[0];
......@@ -84,14 +89,14 @@ foreach my $hr (@{$all}) {
$bb->color_line('red', "$conffile is missing\n");
my $thisquota = &thisquota($row->{'zfs_target'});
my $parentquota = &parentquota($row->{'zfs_target'});
my $thisquota = &thisquota($zfs_target);
my $parentquota = &parentquota($zfs_target);
if($thisquota ne 'none') {
$bb->color_line('green', "Quota of $thisquota is set\n");
} elsif($parentquota ne 'none') {
$bb->color_line('green', "Parent has quota $parentquota set\n");
} else {
$bb->color_line('red', "Neither " . $row->{'zfs_target'} . " or its parent has a quota set\n");
$bb->color_line('red', "Neither " . $zfs_target . " or its parent has a quota set\n");
my $backup_age;
......@@ -137,7 +142,6 @@ foreach my $hr (@{$all}) {
# or, b) the time between the last successful backup and when the conn test was last green
my $timediff = $backup_age - $time_since_online;
my $backup_msg = '';
my $backup_task_name = $row->{'backup_task_name'};
my $msg_online_host = "%s is online and was last backed up %f seconds ago.";
my $msg_offline_host = "%s last seen online %f seconds ago, and was last backed up %f seconds before that.";
......@@ -162,24 +166,23 @@ foreach my $hr (@{$all}) {
# Check for each line; we'll probably need to rewrite the hobbit parser for this
my $used=&space($row->{'zfs_target'});
$bb->print("Backup target: $row->{'zfs_target'}\n");
my $used=&space($zfs_target);
if ($used > $row->{'space_red'}) {
$bb->color_line('red',"SpaceUsed: ".(100*$used)."% [&gt; ".(100*$row->{'space_red'})."% ]\n");
$bb->color_line('red',"$zfs_target SpaceUsed: ".(100*$used)."% [&gt; ".(100*$row->{'space_red'})."% ]\n");
} elsif ($used > $row->{'space_yellow'}) {
$bb->color_line('yellow',"SpaceUsed: ".(100*$used)."% [&gt; ".(100*$row->{'space_yellow'})."% ]\n");
$bb->color_line('yellow',"$zfs_target SpaceUsed: ".(100*$used)."% [&gt; ".(100*$row->{'space_yellow'})."% ]\n");
} else {
$bb->color_line('green',"SpaceUsed: ".(100*$used)."% [&le; ".(100*$row->{'space_yellow'})."% ]\n");
$bb->color_line('green',"$zfs_target SpaceUsed: ".(100*$used)."% [&le; ".(100*$row->{'space_yellow'})."% ]\n");
if ($row->{'prune_count'}==0) {
$bb->color_line('red','No pruning configured\n');
if (defined($row->{'exec'})) {
$bb->print("runtime: $row->{'exec'}\n");
$bb->print("$zfs_target runtime: $row->{'exec'}\n");
my $count=&snapshots($row->{'zfs_target'});
$bb->print("Snapshots: $count\n");
my $count=&snapshots($zfs_target);
$bb->print("Snapshots: $count\n\n");
if($rows_for_this_host == 0) {
my $msg = "No results logged for host. Check backup_log table: maybe there has not yet been a succesful backup?\n";
Supports Markdown
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