breaking configs into normal configs and default configs, and updating sanoid to use both files

This commit is contained in:
Jim Salter 2015-04-01 15:21:25 -04:00
parent 5c157f821c
commit 270c95be69
3 changed files with 71 additions and 67 deletions

7
sanoid
View File

@ -15,10 +15,12 @@ use Time::Local; # to parse dates in reverse
my $pscmd = '/bin/ps';
my $zfs = '/sbin/zfs';
my $conf_file = '/etc/sanoid/sanoid.conf';
my $default_conf_file = '/etc/sanoid/sanoid.defaults.conf';
# parse config file
my %config = init($conf_file);
my %config = init($conf_file,$default_conf_file);
# if we call getsnaps(%config,1) it will forcibly update the cache, TTL or no TTL
my $forcecacheupdate = 0;
@ -515,9 +517,10 @@ sub getsnaps {
####################################################################################
sub init {
my ($conf_file) = @_;
my ($conf_file, $default_conf_file) = @_;
my %config;
tie my %defaults, 'Config::IniFiles', ( -file => $default_conf_file );
tie my %ini, 'Config::IniFiles', ( -file => $conf_file );
# we'll use these later to normalize potentially true and false values on any toggle keys

View File

@ -50,68 +50,3 @@
daily_crit = 60
###################################################################################
# default template - contains same values as hardcoded, unless you override here. #
# ALL values set here, so useful as documentation even if #
# nothing is actually overridden. #
###################################################################################
[template_default]
template = yes
# If any snapshot type is set to 0, we will not take snapshots for it - and will immediately
# prune any of those type snapshots already present.
#
# Otherwise, if autoprune is set, we will prune any snapshots of that type which are older
# than (setting * periodicity) - so if daily = 90, we'll prune any dailies older than 90 days.
autoprune = yes
hourly = 48
daily = 90
monthly = 6
yearly = 0
min_percent_free = 10
# We will automatically take snapshots if autosnap is on, at the desired times configured
# below (or immediately, if we don't have one since the last preferred time for that type).
#
# Note that we will not take snapshots for a given type if that type is set to 0 above,
# regardless of the autosnap setting - for example, if yearly=0 we will not take yearlies
# even if we've defined a preferred time for yearlies and autosnap is on.
autosnap = 1;
# hourly - top of the hour
hourly_min = 0;
# daily - at 23:59 (most people expect a daily to contain everything done DURING that day)
daily_hour = 23;
daily_min = 59;
# monthly - immediately at the beginning of the month (ie 00:00 of day 1)
monthly_mday = 1;
monthly_hour = 0;
monthly_min = 0;
# yearly - immediately at the beginning of the year (ie 00:00 on Jan 1)
yearly_mon = 1;
yearly_mday = 1;
yearly_hour = 0;
yearly_min = 0;
# monitoring plugin - define warn / crit levels for each snapshot type by age, in units of one period down
# example hourly_warn = 90 means issue WARNING if most recent hourly snapshot is not less than 90 minutes old,
# daily_crit = 36 means issue CRITICAL if most recent daily snapshot is not less than 36 hours old,
# monthly_warn = 36 means issue WARNING if most recent monthly snapshot is not less than 36 days old... etc.
#
# monitor_dont_warn = yes will cause the monitoring service to report warnings as text, but with status OK.
# monitor_dont_crit = yes will cause the monitoring service to report criticals as text, but with status OK.
#
# setting any value to 0 will keep the monitoring service from monitoring that snapshot type on that section at all.
monitor = yes
monitor_dont_warn = no
monitor_dont_crit = no
hourly_warn = 90
hourly_crit = 360
daily_warn = 28
daily_crit = 32
monthly_warn = 32
monthly_crit = 35
yearly_warn = 0
yearly_crit = 0

66
sanoid.defaults.conf Normal file
View File

@ -0,0 +1,66 @@
###################################################################################
# default template - DO NOT EDIT THIS FILE DIRECTLY. #
# If you wish to override default values, you can create your #
# own [template_default] in /etc/sanoid/sanoid.conf. #
# #
# you have been warned. #
###################################################################################
[template_default]
template = yes
# If any snapshot type is set to 0, we will not take snapshots for it - and will immediately
# prune any of those type snapshots already present.
#
# Otherwise, if autoprune is set, we will prune any snapshots of that type which are older
# than (setting * periodicity) - so if daily = 90, we'll prune any dailies older than 90 days.
autoprune = yes
hourly = 48
daily = 90
monthly = 6
yearly = 0
min_percent_free = 10
# We will automatically take snapshots if autosnap is on, at the desired times configured
# below (or immediately, if we don't have one since the last preferred time for that type).
#
# Note that we will not take snapshots for a given type if that type is set to 0 above,
# regardless of the autosnap setting - for example, if yearly=0 we will not take yearlies
# even if we've defined a preferred time for yearlies and autosnap is on.
autosnap = 1;
# hourly - top of the hour
hourly_min = 0;
# daily - at 23:59 (most people expect a daily to contain everything done DURING that day)
daily_hour = 23;
daily_min = 59;
# monthly - immediately at the beginning of the month (ie 00:00 of day 1)
monthly_mday = 1;
monthly_hour = 0;
monthly_min = 0;
# yearly - immediately at the beginning of the year (ie 00:00 on Jan 1)
yearly_yday = 1;
yearly_hour = 0;
yearly_min = 0;
# monitoring plugin - define warn / crit levels for each snapshot type by age, in units of one period down
# example hourly_warn = 90 means issue WARNING if most recent hourly snapshot is not less than 90 minutes old,
# daily_crit = 36 means issue CRITICAL if most recent daily snapshot is not less than 36 hours old,
# monthly_warn = 36 means issue WARNING if most recent monthly snapshot is not less than 36 days old... etc.
#
# monitor_dont_warn = yes will cause the monitoring service to report warnings as text, but with status OK.
# monitor_dont_crit = yes will cause the monitoring service to report criticals as text, but with status OK.
#
# setting any value to 0 will keep the monitoring service from monitoring that snapshot type on that section at all.
monitor = yes
monitor_dont_warn = no
monitor_dont_crit = no
hourly_warn = 90
hourly_crit = 360
daily_warn = 28
daily_crit = 32
monthly_warn = 32
monthly_crit = 35
yearly_warn = 0
yearly_crit = 0