Changeset 12580
- Timestamp:
- Mar 23, 2007, 2:40:11 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Nebulous-Server/Build.PL (modified) (1 diff)
-
Nebulous-Server/bin/nebdiskd (modified) (3 diffs)
-
Nebulous/Build.PL (modified) (1 diff)
-
Nebulous/bin/nebdiskd (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Build.PL
r12553 r12580 78 78 create_makefile_pl => 'passthrough', 79 79 requires => { 80 'Config::YAML' => '1.42', 80 81 'URI' => '1.30', 81 82 'SOAP::Lite' => '0.69', -
trunk/Nebulous-Server/bin/nebdiskd
r12005 r12580 3 3 # Copyright (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: nebdiskd,v 1. 1 2007-02-23 01:10:57jhoblitt Exp $5 # $Id: nebdiskd,v 1.2 2007-03-24 00:40:11 jhoblitt Exp $ 6 6 7 7 use strict; … … 11 11 $VERSION = '0.02'; 12 12 13 use Net::Server::Daemonize qw(daemonize); 13 use Config::YAML; 14 use DBI; 15 use File::Spec; 16 use Nebulous::Server::SQL; 17 use Net::Server::Daemonize qw( daemonize unlink_pid_file ); 14 18 use Sys::Statistics::Linux::DiskUsage; 15 use DBI;16 use Nebulous::Server::SQL;17 19 18 20 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 19 21 use Pod::Usage qw( pod2usage ); 20 22 21 my ($debug, $db, $dbuser, $dbpass); 22 23 $db = $ENV{'NEB_DB'} unless $db; 24 $dbuser = $ENV{'NEB_USER'} unless $dbuser; 25 $dbpass = $ENV{'NEB_PASS'} unless $dbpass; 26 27 our $POLL_INTERVAL = 5; 28 23 my ($debug, $db, $dbuser, $dbpass, $pidfile, $stop, $restart, $verbose); 29 24 GetOptions( 30 'debug|d' => \$debug, 31 'db=s' => \$db, 32 'user=s' => \$dbuser, 33 'pass=s' => \$dbpass, 25 'debug' => \$debug, 26 'db|d=s' => \$db, 27 'user|u=s' => \$dbuser, 28 'pass|p=s' => \$dbpass, 29 'pidfile=s' => \$pidfile, 30 'stop|s' => \$stop, 31 'restart|r' => \$restart, 32 'verbose|v' => \$verbose, 34 33 ) || pod2usage( 2 ); 34 35 my $rcfile = "$ENV{HOME}/.nebdiskrc"; 36 $rcfile = File::Spec->canonpath($rcfile); 37 38 my $c = read_rcfile($rcfile); 39 40 $db ||= $c->get_db || $ENV{'NEB_DB'}; 41 $dbuser ||= $c->get_dbuser || $ENV{'NEB_USER'}; 42 $dbpass ||= $c->get_dbpass || $ENV{'NEB_PASS'}; 43 $pidfile ||= $c->get_pidfile || "/var/tmp/nebdiskd"; 44 my $mounts = $c->get_mounts; 45 my $poll_interval = $c->get_poll_interval || 5; 46 47 if ($restart || $stop) { 48 my $status = kill_pid_file($pidfile); 49 exit($status) if $stop; 50 } 51 52 $c->set_db($db); 53 $c->set_dbuser($dbuser); 54 $c->set_dbpass($dbpass); 55 $c->set_pidfile($pidfile); 56 $c->set_poll_interval($poll_interval); 57 $c->write; 35 58 36 59 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 39 62 40 63 daemonize( 41 'jhoblitt',# User42 'wheel',# Group43 undef# PID file64 $<, # User 65 $), # Group 66 $pidfile, # PID file 44 67 ) unless $debug; 45 68 46 my $sql = Nebulous::Server::SQL->new; 47 48 my $dbh = DBI->connect( 49 "DBI:mysql:database=$db:host=localhost", 50 $dbuser, 51 $dbpass, 52 { 53 RaiseError => 1, 54 PrintError => 0, 55 AutoCommit => 0, 56 }, 57 ); 58 59 $dbh->do( $sql->set_transaction_model ); 60 $dbh->commit; 61 62 my $lxs = Sys::Statistics::Linux::DiskUsage->new; 63 64 while (1) { 65 my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)"); 66 $dbh->do("DELETE FROM mount"); 67 68 my $stats = $lxs->get; 69 foreach my $dev (keys %$stats) { 70 my $mnt = $stats->{$dev}; 71 my %mount; 72 $query->execute(@$mnt{qw( mountpoint total usage )}); 69 $SIG{TERM} = sub { unlink_pid_file($pidfile); exit(); }; 70 $SIG{INT} = $SIG{TERM}; 71 $SIG{HUP} = sub { $c = read_rcfile($rcfile) }; 72 73 my $dbh = setup_db( 74 db => $db, 75 dbuser => $dbuser, 76 dbpass => $dbpass, 77 ); 78 79 poll_mounts( 80 dbh => $dbh, 81 poll_interval => $poll_interval, 82 debug => $debug, 83 ) or die "poll_mounts() should not have returned"; 84 85 sub poll_mounts 86 { 87 my %p = @_; 88 89 my $dbh = $p{dbh} or return; 90 my $poll_interval = $p{poll_interval} || 60; 91 my $debug = $p{debug} || 0; 92 93 my $lxs = Sys::Statistics::Linux::DiskUsage->new; 94 95 while (1) { 96 # list of mount points to stat so that the automounter will mount these 97 # volumes if they have been unmounted. 98 stat_dirs($mounts); 99 100 my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)"); 101 $dbh->do("DELETE FROM mount"); 102 print "flushed mount table\n" if $debug; 103 104 my $stats = $lxs->get; 105 foreach my $dev (keys %$stats) { 106 my $mnt = $stats->{$dev}; 107 my %mount; 108 $query->execute(@$mnt{qw( mountpoint total usage )}); 109 print "adding $mnt->{mountpoint} to db\n" if $debug; 110 } 111 112 $dbh->commit; 113 114 sleep $poll_interval; 73 115 } 74 116 } 117 118 sub read_rcfile 119 { 120 my $rcfile = shift; 121 122 return unless defined $rcfile; 123 124 if (!-f $rcfile) { 125 open(my $fh, '>', $rcfile) or die "can't open file: $!"; 126 close($fh) or die "can't close file:$!"; 127 } 128 129 return Config::YAML->new( 130 config => $rcfile, 131 output => $rcfile, 132 ); 133 } 134 135 136 sub setup_db 137 { 138 my %p = @_; 139 140 return unless defined $p{db} 141 and defined $p{dbuser} 142 and defined $p{dbpass}; 143 144 my $sql = Nebulous::Server::SQL->new; 145 146 my $dbh = DBI->connect( 147 "DBI:mysql:database=$p{db}:host=localhost", 148 $p{dbuser}, 149 $p{dbpass}, 150 { 151 RaiseError => 1, 152 PrintError => 1, 153 AutoCommit => 0, 154 }, 155 ); 156 157 $dbh->do( $sql->set_transaction_model ); 75 158 $dbh->commit; 76 159 77 sleep $POLL_INTERVAL; 78 } 160 return $dbh; 161 } 162 163 164 sub stat_dirs 165 { 166 my $mounts = shift; 167 168 return unless defined $mounts; 169 170 foreach my $path (@$mounts) { 171 stat File::Spec->canonpath($path) or warn "can not stat path: $path"; 172 print "stated $path\n" if $debug; 173 } 174 } 175 176 # 177 # This function, originally named check_pid_file() was copied from 178 # Net::Server::Daemonize '0.05' licensed under the Perl license. It has been 179 # renamed and modified to kill off process who's PID value is stored in pidfile. 180 # 181 182 sub kill_pid_file { 183 my $pid_file = shift; 184 185 ### no pid_file = return success 186 return 1 unless -e $pid_file; 187 188 ### get the currently listed pid 189 if( ! open(_PID,$pid_file) ){ 190 die "Couldn't open existant pid_file \"$pid_file\" [$!]\n"; 191 } 192 my $_current_pid = <_PID>; 193 close _PID; 194 my $current_pid = $_current_pid =~ /^(\d{1,10})/ ? $1 : die "Couldn't find pid in existing pid_file"; 195 196 my $exists = undef; 197 198 ### try a proc file system 199 if( -d '/proc' ) { 200 $exists = -e "/proc/$current_pid"; 201 202 ### try ps 203 #}elsif( -x '/bin/ps' ){ # not as portable 204 # the ps command itself really isn't portable 205 # this follows BSD syntax ps (BSD's and linux) 206 # this will fail on Unix98 syntax ps (Solaris, etc) 207 }elsif( `ps h o pid p $$` =~ /^\s*$$\s*$/ ){ # can I play ps on myself ? 208 $exists = `ps h o pid p $current_pid`; 209 210 } 211 212 ### running process exists, ouch 213 if( $exists ){ 214 215 if( $current_pid == $$ ){ 216 warn "Pid_file created by this same process. Doing nothing.\n"; 217 return 1; 218 }else{ 219 kill 'TERM', $current_pid 220 or die "Failed to signal process ($current_pid)"; 221 unlink $pid_file || die "Couldn't remove pid_file \"$pid_file\" [$!]\n"; 222 return 1; 223 224 } 225 } 226 } 227 228 __END__ 229 230 =pod 231 232 =head1 NAME 233 234 nebdiskd - Nebulous mounted volume capacity monitoring daemon 235 236 =head1 SYNOPSIS 237 238 nebdiskd [--db <db name>] [--user <db username>] [--pass <db password>] [--debug] [--pidfile <filename>] [--stop] [--restart] [--verbose] 239 240 =head1 DESCRIPTION 241 242 This program looks for mounted volumes, at a configurable interval, and records 243 statistics about them into a database. 244 245 =head1 OPTIONS 246 247 =over 4 248 249 =item * --db|-d <db name> 250 251 Name of database (C<namespace>) to write too. 252 253 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 254 variable is set. 255 256 =item * --user|-u <db username> 257 258 Username to authenticate with. 259 260 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 261 variable is set. 262 263 =item * --pass|-p <db password> 264 265 Password to authenticate with. 266 267 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 268 variable is set. 269 270 =item * --debug 271 272 This flag prevents the program from "daemonizing" so output can be sent to 273 C<stdout>/C<stderr> and a debugger used on the running process. 274 275 =item * --pidfile <filename> 276 277 Filename to log the running daemon's PID too. 278 279 Optional, if this option is omitted and no value is defined in the 280 F<.nebdiskrc> then no pidfile is created. 281 282 =item * --stop|-s 283 284 Uses the pidfile to kill an already running daemon. 285 286 =item * --restart|-r 287 288 Uses the pidfile to kill an already running daemon and then starts a new 289 instance. 290 291 =item * --verbose|-r 292 293 Turns on informational/debugging messages to be sent to the 294 C<stderr>/C<stdout>. This option is probably not very usefully unless combined 295 with C<--debug>. 296 297 =back 298 299 =head1 ENVIRONMENT 300 301 These environment variables may be used in place of the specified command line 302 options. All command line option will override the corresponding environment 303 value. 304 305 =over 4 306 307 =item * C<NEB_DB> 308 309 Equivalent to --db|-d 310 311 =item * C<NEB_USER> 312 313 Equivalent to --user|-u 314 315 =item * C<NEB_PASS> 316 317 Equivalent to --pass|-p 318 319 =back 320 321 =head1 RCFILE 322 323 This program will attempt to read an C<rcfile> from F<$HOME/.nebdiskrc> and if 324 found will use it's values to override program defaults. Please not that the 325 precedence for values is: command line, rcfile, environment variables. 326 327 The format of the C<rcfile> is in L<YAML> format and uses the following values: 328 329 --- 330 db: nebulous 331 dbpass: '@neb@' 332 dbuser: nebulous 333 mounts: 334 - /mnt 335 - /tmp 336 - /usr 337 pidfile: /var/tmp/nebdiskd 338 poll_interval: 5 339 340 The values C<db>, C<dbpass>, C<dbuser>, and C<pidfile> have the same semantics 341 as their command line and/or environment variable equivalents. 342 343 =over 4 344 345 =item * C<mounts> 346 347 A list of "paths" to C<stat(2)> before mounted volumes are polled. The propose 348 of this option is to attempt to keep "automounted" volumes mounted while this 349 program is running. 350 351 This value may be omitted or left blank. 352 353 =item * C<poll_interval> 354 355 The number of seconds to wait between checks for mounted volumes. 356 357 This value may be omitted or left blank. The default value is C<60>s. 358 359 =back 360 361 =head1 CREDITS 362 363 Just me, myself, and I. 364 365 =head1 SUPPORT 366 367 Please contact the author directly via e-mail. 368 369 =head1 AUTHOR 370 371 Joshua Hoblitt <jhoblitt@cpan.org> 372 373 =head1 COPYRIGHT 374 375 Copyright (C) 2007 Joshua Hoblitt. All rights reserved. 376 377 This program is free software; you can redistribute it and/or modify it under 378 the terms of the GNU General Public License as published by the Free Software 379 Foundation; either version 2 of the License, or (at your option) any later 380 version. 381 382 This program is distributed in the hope that it will be useful, but WITHOUT ANY 383 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 384 PARTICULAR PURPOSE. See the GNU General Public License for more details. 385 386 You should have received a copy of the GNU General Public License along with 387 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 388 Place - Suite 330, Boston, MA 02111-1307, USA. 389 390 The full text of the license can be found in the L<perlgpl> Pod as supplied 391 with Perl 5.8.1 and later. 392 393 =head1 SEE ALSO 394 395 L<Nebulous::Server>, L<YAML> 396 397 =cut -
trunk/Nebulous/Build.PL
r12553 r12580 78 78 create_makefile_pl => 'passthrough', 79 79 requires => { 80 'Config::YAML' => '1.42', 80 81 'URI' => '1.30', 81 82 'SOAP::Lite' => '0.69', -
trunk/Nebulous/bin/nebdiskd
r12005 r12580 3 3 # Copyright (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: nebdiskd,v 1. 1 2007-02-23 01:10:57jhoblitt Exp $5 # $Id: nebdiskd,v 1.2 2007-03-24 00:40:11 jhoblitt Exp $ 6 6 7 7 use strict; … … 11 11 $VERSION = '0.02'; 12 12 13 use Net::Server::Daemonize qw(daemonize); 13 use Config::YAML; 14 use DBI; 15 use File::Spec; 16 use Nebulous::Server::SQL; 17 use Net::Server::Daemonize qw( daemonize unlink_pid_file ); 14 18 use Sys::Statistics::Linux::DiskUsage; 15 use DBI;16 use Nebulous::Server::SQL;17 19 18 20 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 19 21 use Pod::Usage qw( pod2usage ); 20 22 21 my ($debug, $db, $dbuser, $dbpass); 22 23 $db = $ENV{'NEB_DB'} unless $db; 24 $dbuser = $ENV{'NEB_USER'} unless $dbuser; 25 $dbpass = $ENV{'NEB_PASS'} unless $dbpass; 26 27 our $POLL_INTERVAL = 5; 28 23 my ($debug, $db, $dbuser, $dbpass, $pidfile, $stop, $restart, $verbose); 29 24 GetOptions( 30 'debug|d' => \$debug, 31 'db=s' => \$db, 32 'user=s' => \$dbuser, 33 'pass=s' => \$dbpass, 25 'debug' => \$debug, 26 'db|d=s' => \$db, 27 'user|u=s' => \$dbuser, 28 'pass|p=s' => \$dbpass, 29 'pidfile=s' => \$pidfile, 30 'stop|s' => \$stop, 31 'restart|r' => \$restart, 32 'verbose|v' => \$verbose, 34 33 ) || pod2usage( 2 ); 34 35 my $rcfile = "$ENV{HOME}/.nebdiskrc"; 36 $rcfile = File::Spec->canonpath($rcfile); 37 38 my $c = read_rcfile($rcfile); 39 40 $db ||= $c->get_db || $ENV{'NEB_DB'}; 41 $dbuser ||= $c->get_dbuser || $ENV{'NEB_USER'}; 42 $dbpass ||= $c->get_dbpass || $ENV{'NEB_PASS'}; 43 $pidfile ||= $c->get_pidfile || "/var/tmp/nebdiskd"; 44 my $mounts = $c->get_mounts; 45 my $poll_interval = $c->get_poll_interval || 5; 46 47 if ($restart || $stop) { 48 my $status = kill_pid_file($pidfile); 49 exit($status) if $stop; 50 } 51 52 $c->set_db($db); 53 $c->set_dbuser($dbuser); 54 $c->set_dbpass($dbpass); 55 $c->set_pidfile($pidfile); 56 $c->set_poll_interval($poll_interval); 57 $c->write; 35 58 36 59 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 39 62 40 63 daemonize( 41 'jhoblitt',# User42 'wheel',# Group43 undef# PID file64 $<, # User 65 $), # Group 66 $pidfile, # PID file 44 67 ) unless $debug; 45 68 46 my $sql = Nebulous::Server::SQL->new; 47 48 my $dbh = DBI->connect( 49 "DBI:mysql:database=$db:host=localhost", 50 $dbuser, 51 $dbpass, 52 { 53 RaiseError => 1, 54 PrintError => 0, 55 AutoCommit => 0, 56 }, 57 ); 58 59 $dbh->do( $sql->set_transaction_model ); 60 $dbh->commit; 61 62 my $lxs = Sys::Statistics::Linux::DiskUsage->new; 63 64 while (1) { 65 my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)"); 66 $dbh->do("DELETE FROM mount"); 67 68 my $stats = $lxs->get; 69 foreach my $dev (keys %$stats) { 70 my $mnt = $stats->{$dev}; 71 my %mount; 72 $query->execute(@$mnt{qw( mountpoint total usage )}); 69 $SIG{TERM} = sub { unlink_pid_file($pidfile); exit(); }; 70 $SIG{INT} = $SIG{TERM}; 71 $SIG{HUP} = sub { $c = read_rcfile($rcfile) }; 72 73 my $dbh = setup_db( 74 db => $db, 75 dbuser => $dbuser, 76 dbpass => $dbpass, 77 ); 78 79 poll_mounts( 80 dbh => $dbh, 81 poll_interval => $poll_interval, 82 debug => $debug, 83 ) or die "poll_mounts() should not have returned"; 84 85 sub poll_mounts 86 { 87 my %p = @_; 88 89 my $dbh = $p{dbh} or return; 90 my $poll_interval = $p{poll_interval} || 60; 91 my $debug = $p{debug} || 0; 92 93 my $lxs = Sys::Statistics::Linux::DiskUsage->new; 94 95 while (1) { 96 # list of mount points to stat so that the automounter will mount these 97 # volumes if they have been unmounted. 98 stat_dirs($mounts); 99 100 my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)"); 101 $dbh->do("DELETE FROM mount"); 102 print "flushed mount table\n" if $debug; 103 104 my $stats = $lxs->get; 105 foreach my $dev (keys %$stats) { 106 my $mnt = $stats->{$dev}; 107 my %mount; 108 $query->execute(@$mnt{qw( mountpoint total usage )}); 109 print "adding $mnt->{mountpoint} to db\n" if $debug; 110 } 111 112 $dbh->commit; 113 114 sleep $poll_interval; 73 115 } 74 116 } 117 118 sub read_rcfile 119 { 120 my $rcfile = shift; 121 122 return unless defined $rcfile; 123 124 if (!-f $rcfile) { 125 open(my $fh, '>', $rcfile) or die "can't open file: $!"; 126 close($fh) or die "can't close file:$!"; 127 } 128 129 return Config::YAML->new( 130 config => $rcfile, 131 output => $rcfile, 132 ); 133 } 134 135 136 sub setup_db 137 { 138 my %p = @_; 139 140 return unless defined $p{db} 141 and defined $p{dbuser} 142 and defined $p{dbpass}; 143 144 my $sql = Nebulous::Server::SQL->new; 145 146 my $dbh = DBI->connect( 147 "DBI:mysql:database=$p{db}:host=localhost", 148 $p{dbuser}, 149 $p{dbpass}, 150 { 151 RaiseError => 1, 152 PrintError => 1, 153 AutoCommit => 0, 154 }, 155 ); 156 157 $dbh->do( $sql->set_transaction_model ); 75 158 $dbh->commit; 76 159 77 sleep $POLL_INTERVAL; 78 } 160 return $dbh; 161 } 162 163 164 sub stat_dirs 165 { 166 my $mounts = shift; 167 168 return unless defined $mounts; 169 170 foreach my $path (@$mounts) { 171 stat File::Spec->canonpath($path) or warn "can not stat path: $path"; 172 print "stated $path\n" if $debug; 173 } 174 } 175 176 # 177 # This function, originally named check_pid_file() was copied from 178 # Net::Server::Daemonize '0.05' licensed under the Perl license. It has been 179 # renamed and modified to kill off process who's PID value is stored in pidfile. 180 # 181 182 sub kill_pid_file { 183 my $pid_file = shift; 184 185 ### no pid_file = return success 186 return 1 unless -e $pid_file; 187 188 ### get the currently listed pid 189 if( ! open(_PID,$pid_file) ){ 190 die "Couldn't open existant pid_file \"$pid_file\" [$!]\n"; 191 } 192 my $_current_pid = <_PID>; 193 close _PID; 194 my $current_pid = $_current_pid =~ /^(\d{1,10})/ ? $1 : die "Couldn't find pid in existing pid_file"; 195 196 my $exists = undef; 197 198 ### try a proc file system 199 if( -d '/proc' ) { 200 $exists = -e "/proc/$current_pid"; 201 202 ### try ps 203 #}elsif( -x '/bin/ps' ){ # not as portable 204 # the ps command itself really isn't portable 205 # this follows BSD syntax ps (BSD's and linux) 206 # this will fail on Unix98 syntax ps (Solaris, etc) 207 }elsif( `ps h o pid p $$` =~ /^\s*$$\s*$/ ){ # can I play ps on myself ? 208 $exists = `ps h o pid p $current_pid`; 209 210 } 211 212 ### running process exists, ouch 213 if( $exists ){ 214 215 if( $current_pid == $$ ){ 216 warn "Pid_file created by this same process. Doing nothing.\n"; 217 return 1; 218 }else{ 219 kill 'TERM', $current_pid 220 or die "Failed to signal process ($current_pid)"; 221 unlink $pid_file || die "Couldn't remove pid_file \"$pid_file\" [$!]\n"; 222 return 1; 223 224 } 225 } 226 } 227 228 __END__ 229 230 =pod 231 232 =head1 NAME 233 234 nebdiskd - Nebulous mounted volume capacity monitoring daemon 235 236 =head1 SYNOPSIS 237 238 nebdiskd [--db <db name>] [--user <db username>] [--pass <db password>] [--debug] [--pidfile <filename>] [--stop] [--restart] [--verbose] 239 240 =head1 DESCRIPTION 241 242 This program looks for mounted volumes, at a configurable interval, and records 243 statistics about them into a database. 244 245 =head1 OPTIONS 246 247 =over 4 248 249 =item * --db|-d <db name> 250 251 Name of database (C<namespace>) to write too. 252 253 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 254 variable is set. 255 256 =item * --user|-u <db username> 257 258 Username to authenticate with. 259 260 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 261 variable is set. 262 263 =item * --pass|-p <db password> 264 265 Password to authenticate with. 266 267 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 268 variable is set. 269 270 =item * --debug 271 272 This flag prevents the program from "daemonizing" so output can be sent to 273 C<stdout>/C<stderr> and a debugger used on the running process. 274 275 =item * --pidfile <filename> 276 277 Filename to log the running daemon's PID too. 278 279 Optional, if this option is omitted and no value is defined in the 280 F<.nebdiskrc> then no pidfile is created. 281 282 =item * --stop|-s 283 284 Uses the pidfile to kill an already running daemon. 285 286 =item * --restart|-r 287 288 Uses the pidfile to kill an already running daemon and then starts a new 289 instance. 290 291 =item * --verbose|-r 292 293 Turns on informational/debugging messages to be sent to the 294 C<stderr>/C<stdout>. This option is probably not very usefully unless combined 295 with C<--debug>. 296 297 =back 298 299 =head1 ENVIRONMENT 300 301 These environment variables may be used in place of the specified command line 302 options. All command line option will override the corresponding environment 303 value. 304 305 =over 4 306 307 =item * C<NEB_DB> 308 309 Equivalent to --db|-d 310 311 =item * C<NEB_USER> 312 313 Equivalent to --user|-u 314 315 =item * C<NEB_PASS> 316 317 Equivalent to --pass|-p 318 319 =back 320 321 =head1 RCFILE 322 323 This program will attempt to read an C<rcfile> from F<$HOME/.nebdiskrc> and if 324 found will use it's values to override program defaults. Please not that the 325 precedence for values is: command line, rcfile, environment variables. 326 327 The format of the C<rcfile> is in L<YAML> format and uses the following values: 328 329 --- 330 db: nebulous 331 dbpass: '@neb@' 332 dbuser: nebulous 333 mounts: 334 - /mnt 335 - /tmp 336 - /usr 337 pidfile: /var/tmp/nebdiskd 338 poll_interval: 5 339 340 The values C<db>, C<dbpass>, C<dbuser>, and C<pidfile> have the same semantics 341 as their command line and/or environment variable equivalents. 342 343 =over 4 344 345 =item * C<mounts> 346 347 A list of "paths" to C<stat(2)> before mounted volumes are polled. The propose 348 of this option is to attempt to keep "automounted" volumes mounted while this 349 program is running. 350 351 This value may be omitted or left blank. 352 353 =item * C<poll_interval> 354 355 The number of seconds to wait between checks for mounted volumes. 356 357 This value may be omitted or left blank. The default value is C<60>s. 358 359 =back 360 361 =head1 CREDITS 362 363 Just me, myself, and I. 364 365 =head1 SUPPORT 366 367 Please contact the author directly via e-mail. 368 369 =head1 AUTHOR 370 371 Joshua Hoblitt <jhoblitt@cpan.org> 372 373 =head1 COPYRIGHT 374 375 Copyright (C) 2007 Joshua Hoblitt. All rights reserved. 376 377 This program is free software; you can redistribute it and/or modify it under 378 the terms of the GNU General Public License as published by the Free Software 379 Foundation; either version 2 of the License, or (at your option) any later 380 version. 381 382 This program is distributed in the hope that it will be useful, but WITHOUT ANY 383 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 384 PARTICULAR PURPOSE. See the GNU General Public License for more details. 385 386 You should have received a copy of the GNU General Public License along with 387 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 388 Place - Suite 330, Boston, MA 02111-1307, USA. 389 390 The full text of the license can be found in the L<perlgpl> Pod as supplied 391 with Perl 5.8.1 and later. 392 393 =head1 SEE ALSO 394 395 L<Nebulous::Server>, L<YAML> 396 397 =cut
Note:
See TracChangeset
for help on using the changeset viewer.
