mentat.module.controller module

This Mentat module is a script providing Mentat system control functions and features.

This script is implemented using the pyzenkit.zenscript framework and so it provides all of its core features. See the documentation for more in-depth details.

The Mentat system is a collection of many real-time processing and post-processing modules. Launching and managing so many processes would be really tedious work. And that is exactly the use-case for this module. Its purpose is to start/stop/restart all preconfigured real-time message processing modules and enable/disable all preconfigured message post-processing modules (cronjobs).

Usage examples

# Display help message and exit.
mentat-controller.py --help

# Run in debug mode (enable output of debugging information to terminal).
mentat-controller.py --debug

# Run with increased logging level.
mentat-controller.py --log-level debug

# Determine the current status of Mentat system and all of its modules.
mentat-controller.py
mentat-controller.py --command status

# Same as above, only execute and produce output in Nagios plugin compatible
# mode.
mentat-controller.py --command status --nagios-plugin --log-level warning

# Start/stop/restart all configured real-time message processing modules.
mentat-controller.py --command start
mentat-controller.py --command stop
mentat-controller.py --command restart

# Enable/Disable all configured message post-processing modules (cronjobs).
mentat-controller.py --command enable
mentat-controller.py --command disable

# Send signal to all configured real-time message processing modules.
mentat-controller.py --command signal-usr1

# Work with particular modules.
mentat-controller.py --command start --target mentat-storage.py
mentat-controller.py --command stop --target mentat-enricher.py mentat-inspector.py
mentat-controller.py --command signal-usr1 --target mentat-inspector-b.py

Available script commands

status (default)

Detect and display the status of configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

start

Start configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

stop

Stop configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

restart

Restart configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

enable

Enable configured cron modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All cron modules will be affected by default.

disable

Disable configured cron modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All cron modules will be affected by default.

signal-hup

Send signal HUP to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

signal-kill

Send signal KILL to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

signal-usr1

Send signal USR1 to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

signal-usr2

Send signal USR2 to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

pidfiles-clean

Clean up dangling PID files (files without matching running process).

Custom configuration

Custom command line options

--target module-id

Target module(s) for the current command (repeatable).

Type: string

--nagios-plugin

Execute as Nagios plugin (flag).

Type: bool, default: False

Custom configuration file options

modules

List of real-time message processing modules that should be managed.

Type: list of dicts

cronjobs

List of message post-processing modules that should be managed.

Type: list of dicts

class mentat.module.controller.MentatControllerScript[source]

Bases: mentat.script.base.MentatBaseScript

Implementation of Mentat module (script) providing Mentat system control functions and features.

CONFIG_CRONJOBS = 'cronjobs'
CONFIG_MODULES = 'modules'
CONFIG_NAGIOS_PLUGIN = 'nagios_plugin'
CONFIG_TARGET = 'target'
cbk_command_disable()[source]

Implementation of the disable command.

Disable configured cron modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_enable()[source]

Implementation of the enable command.

Enable configured cron modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_pidfiles_clean()[source]

Implementation of the pidfiles-clean command.

Clean up dangling PID files (files without matching running process).

cbk_command_restart()[source]

Implementation of the restart command.

Restart configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_signal_hup()[source]

Implementation of the signal-hup command.

Send signal HUP to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_signal_kill()[source]

Implementation of the signal-kill command.

Send signal KILL to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_signal_usr1()[source]

Implementation of the signal-usr1 command.

Send signal USR1 to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_signal_usr2()[source]

Implementation of the signal-usr2 command.

Send signal USR2 to configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_start()[source]

Implementation of the start command.

Start configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_status()[source]

Implementation of the status command (default).

Detect and display the status of configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

cbk_command_stop()[source]

Implementation of the stop command.

Stop configured modules. The --target command line option (repeatable) or target configuration file directive enables user to choose which modules should be affected by the command. All modules will be affected by default.

get_default_command()[source]

Return the name of the default script command. This command will be executed in case it is not explicitly selected either by command line option, or by configuration file directive.

Returns

Name of the default command.

Return type

str

get_system_status()[source]

Convenience method for getting overall system status.

Returns

Structured dictionary with preprocessed information.

Return type

dict