marcus67/little_brother

View on GitHub
doc/youtube-presentations/2019-06-09_little-brother.config

Summary

Maintainability
Test Coverage
#    Copyright (C) 2019  Marcus Rickert
#
#    See https://github.com/marcus67/little_brother
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# This file contains a LittleBrother configuration with several active rules for a master host.

[LittleBrother]

# Interval in seconds between applying the rules to the collected process statistics. Default: 5
check_interval = 5

# Logging level of the application. Default: INFO
# Allowed values: DEBUG, INFO, WARNING, ERROR
log_level=DEBUG

# Run the application in debugging mode. If active any exception will print a
# stack trace and terminate the application. Do not activate in "production" mode.
# Default: False
debug_mode=True

[AppControl]

# If active, the processes on the host will be checked. Use "False" if users
# do not log onto the master host. Default: True
scan_active = true

# Sets the number of days that user play statistics will be available in the frontend.
# Default: 7
process_lookback_in_days = 14

# Sets the number of future days that user play time configuration will be available in the frontend.
# Default: 7
admin_lookahead_in_days = 14

# Use this to replace the canonical hostname retrieved from the system. This hostname will accur in all statistics.
hostname = ubuntu

# Set the minimum duration in seconds that a process has to be active to be considered relevant "play time".
# Default: 60. Increase if there e.g. are short scheduled processes running on the hosts matching the patterns
# of "play" processes.
min_activity_duration = 120

#[MasterConnector]
# Unique token that identifies a slave host with the master host. It has to match the
# corresponding entry on the slave hosts.
# access_token=SOME_LONG_AND_SECRET_TOKEN

#[ClientProcessHandler]
# Interval in seconds between two checks of the processes on a host. Default: 10
# Since reading the process table is often a time-consuming task it may be suitable to increase
# this value to about 20-60 seconds.
#check_interval = 20


#[ClientDeviceHandler]
# Interval in seconds between two pings to configured monitored devices. Default: 10
# Since pinging is often a time-consuming task it may be suitable to increase this value to about 30-60 seconds.
#check_interval = 30

# Path of the "ping" utility. Default: /bin/ping
#ping_command = /SOME/OTHER/PATH/PING

# Regular expression to extract the round trip time from a ping call. Use paranthethes to mark the actual time duration
# in milliseconds. Default: rtt min/avg/max/mdev = [\d\.]+/([\d\.]+)/[\d\.]+/[\d\.]+ ms
#ping_result_regex = SOME OTHER ELABORATE EXPRESSION


[AudioHandler]
# Set the volume of the audio output in percent. Default: None, hence no attempt will be made to change the setting.
#audio_mixer_volume=150

# Select the engine of the speech output.
# Permitted values:
# * pyttsx3 : Use the library of the same name to generate the speech output. (Default)
# * google : Use the libray 'python_google_speak' to generate the speech output. Note that this library requires an
#            internet connection!
# * external : Use an external command to generate the speech output. See setting 'speech_generator_cmd_line'.
speech_engine=google

# If true, the generated files will be cached in the spool directory (see below). Default: False
#cache_audio_files = True

# Set the speed of the speech generator in words per minutes. Default: 100
# speech_words_per_minute = 80

# Set the mimimum waiting time in seconds before a spoken messages is repeated. Any request to issue the same messages
# before this time will be silently ignored. Default: 30
#mininum_waiting_time_before_repeat = 20

# Set the directory where generated speech files will be cached. Default: /var/spool/little-brother
#spool_dir = "/tmp"

# Set the prefix of the filenames used for generated speech files. Default: little-brother-speech-
#audio_file_prefix = "my-prefix-"

# Set the path of the mixer tool. Default: /usr/bin/amixer
#audio_mixer_bin = '/bin/amixer'

# Set the default locale of the speech output if the monitored user does not have a locale configured. If both are unset
# the system default locale will be used. Default: None
#locale = de_DE

# Set the command line for the external speech generation tool.
# Default: /usr/bin/festival --tts --language american_english {inline}
# The command line may contain the following patterns will be replaced before its execution:
# * {infile} : name of a file containing the text to be spoken
# * {text}: text to be spoken

[StatusServer]

# Set IP address that the webserver will listen to. Default: 0.0.0.0, hence it will listen to all local interfaces.
host=localhost
# Set the port number, the webserver will listen to. Default: None, hence the webserver will not be started.
port=5560
# Set the password for the administration user ("admin"). Default: None
admin_password=hello
# Set a unique secret which will be used to generate HTML cookies
app_secret=SOME_OTHER_LONG_AND_SECRET_TOKEN
# Set a prefix for all web pages of the application. Default: None, which implies no prefix at all
#proxy_prefix=/LittleBrother


[Persistence]
# See http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html#module-sqlalchemy.dialects.mysql.pymysql
# Set the details and credentials for connecting to the backend database

# Set the name of the database driver. Default: mysql+pymysql
# For more information on how to configure the database driver see https://docs.sqlalchemy.org/en/13/core/engines.html
#
database_driver = mysql+pymysql
# Set the name of the database host. Default: 'localhost'
database_host = localhost
# Set the port number of the database running on the host above. Default: 3306  (for mysql)
database_port = 3306
# Name of the database scheme used to create the tables for the application. Default: little_brother
database_name = little_brother
# Name of the database user accessing the scheme above (application user). Default: little_brother
database_user = little_brother
# Password of the user above. Default: None
database_password = my_little_brothers_password

# The remaining part of the configuration file is for defining rulesets describing which user is allowed to access
# the computer during which time periods.
# For a more detailed description see https://github.com/marcus67/little_brother

# This is a simple ruleset for a user (user1) consisting of a simple rule:
# * All processes matching 'sh' will be tracked.
# * No access before 16:00 hours (4PM) or after 23:00 hours (11PM).
# * The overall access time is limited to 1 hour and 30 minutes.
# * The maximum access time per session is 20 minutes.
# * After each access session there will have to be a break period of at least 10 minutes.

[PopupHandler]
# Choose the handler for showing a popup notification
# Possible values:
# * xmessage: use "apt-get install x11-utils" to install
# * gxmessage: use "apt-get install gxmessage" to install
# * zenity: use "apt-get install zenity" to install
# * yad: use "apt-get install yad" to install
# The default is None, which deactivates popup notifications.
popup_engine=zenity

# Choose the encoding of the string passed to the notification tools. Defaults to "UTF-8".
encoding=UTF-8

# Set the mimimum waiting time in seconds before a popup messages is repeated. Any request to issue the same messages
# before this time will be silently ignored. Default: 30
mininum_waiting_time_before_repeat = 10

#######################################################################################################################
#######################################################################################################################
#######################################################################################################################

[RuleSetUser1]
username=seth
process_name_pattern=.*sh|systemd
min_time_of_day=16:00
max_time_of_day=23:00
max_time_per_day=1h30m
max_activity_duration=20m
min_break=10m

# This is a more elaborate rule set for 'user2' consisting of three rules and an extra device specification.
# The rules have a priority value (defaults to 1) associated with them. Rules with higher values take
# precedence over rules with lower values.
#
# Common to all rules:
#
# * All processes matching shells or systemd sessions will be tracked.
# * The configured devices will be checked for usage.

# Priority 4 (Maybe Wednesdays are special?!)
#
# * Free play mode

[RuleSetUser2Wednesdays]
username=jennifer
priority=4
context=weekday
context_details=wednesdays
free_play=true

# Priority 3 (weekend rule = valid for Saturdays and Sundays)
#
# * No access before 9:00 hours (9AM) or after 21:00 hours (9PM).
# * The overall access time is limited to 2 hours and 40 minutes.
# * The maximum access time per session is one hour.
# * After each access session there will have to be a break period of at least 30 minutes.

[RuleSetUser2Weekend]
username=jennifer
priority=3
context=weekday
context_details=weekend
process_name_pattern=.*sh|systemd
min_time_of_day=9:00
max_time_of_day=21:00
max_time_per_day=160m
max_activity_duration=1h
min_break=30m
scan_devices = true

# Priority 2 (vacation rule defined by the German vacation schedule (downloaded from the internet)
#
# * No access before 8:30 hours (8:30AM) or after 22:00 hours (10PM).
# * The overall access time is limited to 4 hours.
# * The maximum access time per session is one hour and 30 minutes.
# * After each access session there will have to be a break period of at least 30 minutes.

[RuleSetUser2Vacation]
username=jennifer
priority=2
context=german-vacation-calendar
context_details=Nordrhein-Westfalen
context_label=vacation
process_name_pattern=.*sh|systemd
min_time_of_day=8:30
max_time_of_day=22:00
max_time_per_day=4h
max_activity_duration=90m
min_break=30m
scan_devices = true

# Priority 1 (default rule as "catch all")
#
# * No access before 16:00 hours (4PM) or after 19:30 hours (7:30PM).
# * The overall access time is limited to 45 minutes.
# * The maximum access time per session is 45 minutes.
# * After each access session there will have to be a break period of at least 30 minutes.

[RuleSetUser2Default]
username=jennifer
locale=en
process_name_pattern=.*sh|systemd
context_label=Standard
min_time_of_day=16:00
max_time_of_day=19:30
max_time_per_day=45m
max_activity_duration=45m
min_break=30m
scan_devices = true

# In addition to the rules above LittleBrother will ping the device iphone-user2.my-domain for activity.
# The device is considered active if the rolling average (over a sample size of 10) of ping delay is below
# 90 milliseconds for at least 60 seconds.

[ClientDeviceIPhoneUser2]
name= iphone_user2
username = jennifer
hostname = iphone-user2.my-domain
min_activity_duration = 60
max_active_ping_delay = 90
sample_size = 10