Index: /trunk/Nebulous-Server/bin/nebdiskd
===================================================================
--- /trunk/Nebulous-Server/bin/nebdiskd	(revision 34906)
+++ /trunk/Nebulous-Server/bin/nebdiskd	(revision 34907)
@@ -11,7 +11,5 @@
 use Config::YAML;
 use DBI;
-use File::Mountpoint qw( is_mountpoint );
 use File::Spec;
-use Filesys::Df;
 use Log::Log4perl;
 use Nebulous::Server::SQL;
@@ -192,5 +190,4 @@
     eval {
         my $r_query = $dbh->prepare_cached("REPLACE INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, ?, ?,note FROM volume WHERE mountpoint = ?");
-#	my $d_query = $dbh->prepare_cached("UPDATE mountedvol SET allocate = ?, available = ? WHERE mountpoint = ?");
         my $d_query = $dbh->prepare_cached("DELETE FROM mountedvol WHERE mountpoint = ?");
 
@@ -199,6 +196,6 @@
         {
             # there may be multiple vol_ids per mountpoint but we only need to
-            # check each mointpont once
-            my $query = $dbh->prepare_cached("SELECT DISTINCT mountpoint FROM volume");
+            # check each mountpoint once
+            my $query = $dbh->prepare_cached("SELECT DISTINCT host, mountpoint FROM volume");
             $query->execute;
             while (my $row = $query->fetchrow_hashref) {
@@ -211,63 +208,13 @@
         foreach my $mnt (@$mounts) {
             my $mountpoint = $mnt->{'mountpoint'};
-            $log->debug("checking $mountpoint");
-            # this /SHOULD/ fail if the mount point is handled by the
-            # automounter and it fails to mount
-            my $tries = 0;
-	    my $valid_mountpoint = 1;
-	    unless (exists($host_failure_counts{$mountpoint})) {
-		$host_failure_counts{$mountpoint} = 0;
-	    }
-            TEST: eval {
-                $tries++;
-                unless (is_mountpoint($mountpoint)) {
-		    unless(defined($host_removed{$mountpoint})) {
-			$log->warn("$mountpoint is not a valid mountpoint ($tries $host_failure_counts{$mountpoint})");
-		    }
-		    $valid_mountpoint = 0;
-                }
-            };
-
-            # fetch stats on the mounted device.  this has to be done AFTER
-            # we determine if it's a valid mountpoint incase
-            # is_mountpoint() invokes the automounter
-            my $dev_info = df($mountpoint, 1024);
+	    my $hostname = $mnt->{'host'};
+ 	    my $valid_mountpoint = 1;
+
+            # fetch stats on the device using ssh and df
+            my $dev_info = df_through_ssh($hostname, $mountpoint, 1024);
             unless (defined $dev_info) {
 		$valid_mountpoint = 0;
-            }
-
-            if (!$valid_mountpoint) {
-                # try is_mountpoint() again if $retry > 1
-                if ($tries < $retry) {
-                    $log->warn("retrying test of $mountpoint");
-                    goto TEST; 
-                }
-		$host_failure_counts{$mountpoint}++;
-		
-		if (!(defined($host_removed{$mountpoint})) || !($host_removed{$mountpoint})) {
-		    if (($host_failure_counts{$mountpoint} > $failure_limit)) {
-			$host_removed{$mountpoint} = 1;
-			$log->warn("Removing $mountpoint from the mountedvol table ($host_failure_counts{$mountpoint} > $failure_limit) No further warnings unless state changes.");
-			$d_query->execute($mountpoint);
-		    }
-		    else {
-			$log->warn("Mountpoint $mountpoint has had $host_failure_counts{$mountpoint} failures. Will remove after $failure_limit");
-		    }
-		}
-		next;
-		
-	    }
-	    if ($host_failure_counts{$mountpoint} != 0) {
-		$host_removed{$mountpoint} = 0;
-		$log->warn("Mountpoint $mountpoint failures cleared ($host_failure_counts{$mountpoint})");
-		$host_failure_counts{$mountpoint} = 0;
-	    }
-
-            # fetch stats on the mounted device.  this has to be done AFTER
-            # we determine if it's a valid mountpoint incase
-            # is_mountpoint() invokes the automounter
-            $dev_info = df($mountpoint, 1024);
-            unless (defined $dev_info) {
                 $log->error("can't find device info for $mountpoint");
+		$d_query->execute($mountpoint);
                 next;
             }
@@ -278,13 +225,6 @@
 
         }
-
-#        $dbh->do("call getmountedvol()");
-
-#        $dbh->commit;
-#        $log->debug("commited to database");
     };
     if ($@) {
-#        $dbh->rollback;
-#        $log->debug("rolledback transaction");
         $log->logdie($@);
     }
@@ -391,7 +331,6 @@
   # this follows BSD syntax ps (BSD's and linux)
   # this will fail on Unix98 syntax ps (Solaris, etc)
-  }elsif( `ps h o pid p $$` =~ /^\s*$$\s*$/ ){ # can I play ps on myself ?
-    $exists = `ps h o pid p $current_pid`;
-
+  } elsif( `ps h o pid p $$` =~ /^\s*$$\s*$/ ){ # can I play ps on myself ?
+      $exists = `ps h o pid p $current_pid`;
   }
 
@@ -412,4 +351,22 @@
 }
 
+sub df_through_ssh {
+    my $hostname = shift;
+    my $mountpoint = shift;
+    my $units = shift;
+    $log->debug("Getting info from mountpoint = [$mountpoint] / unit = [$units] / hostname = [$hostname]");
+    my $df_data = qx/ssh $hostname 'df $mountpoint' | grep -v Filesystem/;
+    $df_data =~ s/\s+/:/g;
+    $log->debug("Received from ssh = [$df_data]");
+    unless ($df_data) {
+	return undef;
+    }
+    my @data = split(/:/, $df_data);
+    my %df_info = ();
+    $df_info{"blocks"} = $data[1];
+    $df_info{"used"} = $data[2];
+    $log->debug("blocks = " . $df_info{"blocks"} . " / used = " . $df_info{"used"});
+    return \%df_info;
+}
 
 __END__
