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

--debug crashes program #220

Closed
wyoung opened this issue May 3, 2018 · 1 comment
Closed

--debug crashes program #220

wyoung opened this issue May 3, 2018 · 1 comment

Comments

@wyoung
Copy link

wyoung commented May 3, 2018

I get the following when adding --debug to the sanoid command line:

Filesystem noise/noise has:
Use of uninitialized value in division (/) at /usr/local/bin/sanoid line 385.
     0 total snapshots (newest: 0.0 hours old)

That repeats once per top-level file system in the pool, then sanoid exits without having done anything.

@sparky3387
Copy link

Patch to fix this

--- b/sanoid    2018-06-16 10:06:17.224001648 +1000
+++ a/sanoid    2018-06-16 10:01:35.344445522 +1000
@@ -381,16 +381,20 @@
                my $path = $config{$section}{'path'};
                print "Filesystem $path has:\n";
                print "     $snapsbypath{$path}{'numsnaps'} total snapshots ";
-               print "(newest: ";
-               my $newest = sprintf("%.1f",$snapsbypath{$path}{'newest'} / 60 / 60);
-               print "$newest hours old)\n";
+               if ($snapsbypath{$path}{'numsnaps'}==0) {
+                       print "(no current snapshots)"
+               } else {
+                       print "(newest: ";
+                       my $newest = sprintf("%.1f",$snapsbypath{$path}{'newest'} / 60 / 60);
+                       print "$newest hours old)\n";

-               foreach my $type (keys %{ $snapsbytype{$path} }){
-                       print "          $snapsbytype{$path}{$type}{'numsnaps'} $type\n";
-                       print "              desired: $config{$section}{$type}\n";
-                       print "              newest: ";
-                       my $newest = sprintf("%.1f",($snapsbytype{$path}{$type}{'newest'} / 60 / 60));
-                       print "$newest hours old, named $snapsbytype{$path}{$type}{'newestname'}\n";
+                       foreach my $type (keys %{ $snapsbytype{$path} }){
+                               print "          $snapsbytype{$path}{$type}{'numsnaps'} $type\n";
+                               print "              desired: $config{$section}{$type}\n";
+                               print "              newest: ";
+                               my $newest = sprintf("%.1f",($snapsbytype{$path}{$type}{'newest'} / 60 / 60));
+                               print "$newest hours old, named $snapsbytype{$path}{$type}{'newestname'}\n";
+                       }
                }
                print "\n\n";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants