NAME

Daemon::Shutdown - A Shutdown Daemon

SYNOPSIS

This is the core of the shutdown daemon script.

use Daemon::Shutdown; my $sdd = Daemon::Shutdown->new( %args ); $sdd->start();

METHODS

new

Create new instance of Daemon::Shutdown

PARAMS

log_file <Str>

Path to log file

Default: /var/log/sdd.log'

log_level <Str>

Logging level (from Log::Log4perl). Valid are: DEBUG, INFO, WARN, ERROR

Default: INFO

verbose 1|0

If enabled, logging info will be printed to screen as well

Default: 0

test 1|0

If enabled shutdown will not actually be executed.

Default: 0

sleep_before_run <Int>

Time in seconds to sleep before running the monitors. e.g. to give the system time to boot, and not to shut down before users have started using the freshly started system.

Default: 3600

exit_after_trigger 1|0

If enabled will exit the application after a monitor has triggered. Normally it is a moot point, because if a monitor has triggered, then a shutdown is initialised, so the script will stop running anyway.

Default: 0

monitor HASHREF

A hash of monitor definitions. Each hash key must map to a Monitor module, and contain a hash with the parameters for the module.

use_sudo 1|0

Use sudo for shutdown

sudo shutdown -h now

Default: 0

shutdown_binary <Str>

The full path to the shutdown binary

Default: /sbin/poweroff

shutdown_args <ArrayRef>

Any args to pass to your shutdown_binary

Default: none

shutdown_after_triggered_monitors <Str>

The number of monitors which need to be triggered at the same time to cause a shutdown. Can be a number or the word 'all'.

Default: 1

timeout_for_shutdown <Int>

Seconds which the system call for shutdown should wait before timing out.

Default: 10

Example (YAML formatted) configuration file

---
log_level: INFO
log_file: /var/log/sdd.log
shutdown_binary: /sbin/shutdown
shutdown_args:
  - -h
  - now
exit_after_trigger: 0
sleep_before_run: 30
verbose: 0
use_sudo: 0
monitor:
  hdparm:
    loop_sleep: 60
    disks: 
      - /dev/sdb
      - /dev/sdc
      - /dev/sdd

toggle_trigger

Toggle whether a monitor wants to shutdown and, if enough agree, call shutdown

shutdown

Shutdown the system, if not in test mode

start

Start the shutdown daemon

AUTHOR

Robin Clarke, perl at robinclarke.net

BUGS

Please report any bugs or feature requests to https://github.com/robin13/sdd

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Daemon::Shutdown

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2015 Robin Clarke.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.