Changeset 19871
- Timestamp:
- Oct 2, 2008, 2:41:55 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous-Server/bin/nebdiskd (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/bin/nebdiskd
r19796 r19871 3 3 # Copyright (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: nebdiskd,v 1. 8 2008-10-01 20:42:31jhoblitt Exp $5 # $Id: nebdiskd,v 1.9 2008-10-03 00:41:55 jhoblitt Exp $ 6 6 7 7 use strict; … … 106 106 107 107 eval { 108 my @valid_mounts; 108 # empty the mount table 109 $dbh->do("DELETE FROM mount"); 110 print "flushed mount table\n" if $debug; 111 112 # repopulate the mount table with all valid mounts that we are 113 # supposed to be watching 114 my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)"); 109 115 110 116 # determine valid mountpoints … … 123 129 next; 124 130 } 125 push @valid_mounts, $mnt; 126 } 127 # empty the mount table 128 $dbh->do("DELETE FROM mount"); 129 print "flushed mount table\n" if $debug; 130 131 # repopulate the mount table with all valid mounts that we are 132 # supposed to be watching 133 my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)"); 134 # get stats on all currently mounted volumes 135 # this has to be done AFTER we determine what the valid mountpoints 136 # are incase is_mountpoint() invokes the automounter 137 foreach my $mnt (@valid_mounts) { 131 132 # fetch stats on the mounted device. this has to be done AFTER 133 # we determine if it's a valid mountpoint incase 134 # is_mountpoint() invokes the automounter 138 135 my $dev_info = df($mnt, 1024); 139 136 unless (defined $dev_info) { … … 141 138 next; 142 139 } 140 143 141 $query->execute($mnt, @$dev_info{qw( blocks used )}); 144 142 print "adding $mnt to db\n" if $debug; 143 145 144 } 146 145 … … 281 280 282 281 283 sub fix_disk_stats284 {285 my $stats = shift;286 287 # take the hash returned by Sys::Statistics::Linux::DiskUsage->new->get and288 # replace the keynames with those of the mountpoint for each device289 my %new_stats;290 foreach my $key (keys %$stats) {291 my $disk = $stats->{$key};292 $new_stats{$disk->{mountpoint}} = $disk;293 }294 295 return \%new_stats;296 }297 298 282 __END__ 299 283
Note:
See TracChangeset
for help on using the changeset viewer.
