Skip to content

votdev/openmediavault-autoshutdown

 
 

Repository files navigation

openmediavault-autoshutdown plugin

Bugs reports: Please provide a full verbose or FAKE-Mode log with the git issue.

How it works:

The Autoshutdown script checks the status of the network and the server. A set of check in the script are known as a "cycle". Between the cycles the script goes into sleep for x seconds. The checks run on the system have different priorities from 0 = highest to 6 = lowest:

  1. Stay up-range: UPHOURS (Server in the time range, where it should be online)
  2. Check for active IPs over network interfaces
  3. Ports (Network sockets) over network interfaces
    Ports (Docker/Podman host ports)
    Check for logged in users
    Samba status check
  4. UL/DL-Rate in kB/s over active network interfaces
  5. HDD IO rate check in kB/s
    Check if S.M.A.R.T. tests are running
  6. Check for active processes
  7. Check for user plugins

If a check with a higher priority gives back a positive result, then no check with a lower priority is executed, the script reset the cycles and sleep for x seconds. If all check run with a negative result the script reduces the cycles by one and goes to sleep for x seconds until the next cycle. If all cycles are 0 (zero) the server is shutdown.

Let's have a look at a simple example:

--- autoshutdown.conf ---
ENABLE=true
CYCLES=4
SLEEP=180
RANGE="5..100"
CHECKCLOCKACTIVE="true"
UPHOURS="06:00..20:00"
NSOCKETNUMBERS="21,22,80,3689,6991,9091,49152"
ULDLCHECK="true"
ULDLRATE=50
LOADAVERAGECHECK="true"
LOADAVERAGE=40
SYSLOG="true"
VERBOSE="false"
FAKE="false"
TEMPPROCNAMES="-"

It is 10:00 am. Autoshutdown does the first check:

Prio 0: UPHOURS
They are set to "06:00..20:00" which means 06:00 - 20:00 (6am to 8pm). No further checks needed, the script sleeps until 8pm.

It is 20:01 (8:01pm) now and Autoshutdown does further checks:

Prio 1: IPs
Let's assume, that only IP 137 is online, so the check is negative, next check.

Prio 2: Ports
Let's assume, that there is no connection on any port to watch. The check is negative, next check.

Prio 3: UL/DL-Rate
Maybe a DL is running with 238 kB/s over the last minute. The check is positive, no more checks needed. Autoshutdown goes to sleep for 180 seconds.

Prio 4 and 6:
Not needed, because a check with a higher priority is positive.

Configuration options details:

For details of what value should be set in the autoshutdown.conf, and there meaning, see autoshutdown.default

Exit code details:

0 - Script completed successfully.
143 - Script error detected in supervision cycle.
142 - Shutdown mechanism failed to run correctly.
141 - Initialisation failed for a component.
140 - Invalid configuration value where no default is available.
139 - A required configuration file was not found.
138 - No valid network interface found on system.

About

OpenMediaVault plugin to provide frontend for autoshutdown script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 88.9%
  • PHP 6.0%
  • SaltStack 2.7%
  • Jinja 2.4%