Skip to content
Snippets Groups Projects
Commit aa24b19b authored by Jan Mach's avatar Jan Mach
Browse files

Made ordnung in cronjob files in configuration directory.

* All cronjob files were moved into separate subdirectory within main Mentat`s configuration directory.
* Naming convention for cronjob files was changed from 'cron_module' to 'module.cron'.
* Made appropriate changes in other relevant modules.

(Redmine issue: #3387)
parent d01d7bc7
No related branches found
No related tags found
No related merge requests found
#
# Name: cron_fetch-geoipdb-sh
# Description: Fetch the latest version of Maxmind GeoIP databases
# Installation: ln -s /etc/mentat/cron_fetch-geoipdb-sh /etc/cron.d/fetch-geoipdb
# NAME:
# fetch-geoipdb.sh.cron
# DESCRIPTION:
# Fetch the latest version of Maxmind GeoIP databases
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/fetch-geoipdb.sh.cron /etc/cron.d/fetch-geoipdb.sh.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
......
#
# Name: cron_fetch-negistry-sh
# Description: Fetch the latest version of CESNET`s Negistry whois database.
# Installation: ln -s /etc/mentat/cron_fetch-negistry-sh /etc/cron.d/fetch-negistry
# NAME:
# fetch-negistry.sh.cron
# DESCRIPTION:
# Fetch the latest version of CESNET`s Negistry whois database.
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/fetch-negistry.sh.cron /etc/cron.d/fetch-negistry.sh.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
......
#
# Name: cron_mentat-backup-py
# Description: Perform backup of Mentat system
# Installation: ln -s /etc/mentat/cron_mentat-backup-py /etc/cron.d/mentat-backup-py
# NAME:
# mentat-backup.py.cron
# DESCRIPTION:
# Perform backup of Mentat system
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/mentat-backup.py.cron /etc/cron.d/mentat-backup.py.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
......
#
# Name: cron_mentat-cleanup-py
# Description: Perform cleanup of Mentat system
# Installation: ln -s /etc/mentat/cron_mentat-cleanup-py /etc/cron.d/mentat-cleanup-py
# NAME:
# mentat-cleanup.py.cron
# DESCRIPTION:
# Perform cleanup of Mentat system
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/mentat-cleanup.py.cron /etc/cron.d/mentat-cleanup.py.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
......
#
# Name: cron_mentat-precache-py
# Description: Perform pre-caching of various data for Mentat system
# Installation: ln -s /etc/mentat/cron_mentat-precache-py /etc/cron.d/mentat-precache-py
# NAME:
# mentat-precache.py.cron
# DESCRIPTION:
# Perform pre-caching of various data for Mentat system
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/mentat-precache.py.cron /etc/cron.d/mentat-precache.py.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
#
# Run every 10 minutes
# Run once in every 10 minutes
*/10 * * * * mentat /usr/bin/python3 /usr/local/bin/mentat-precache.py --regular
#
# Name: cron_mentat-reporter-py
# Description: Run Mentat's reporting postprocessing component
# Installation: ln -s /etc/mentat/cron_mentat-reporter-py /etc/cron.d/mentat-reporter-py
# NAME:
# mentat-reporter.py.cron
# DESCRIPTION:
# Run Mentat's event reporting postprocessing component
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/mentat-reporter.py.cron /etc/cron.d/mentat-reporter.py.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
#
# Run every ten minutes
# Run once in every ten minutes
*/10 * * * * mentat /usr/bin/python3 /usr/local/bin/mentat-reporter.py --regular
#
# Name: cron_mentat-statistician-py
# Description: Run Mentat's statistical postprocessing component
# Installation: ln -s /etc/mentat/cron_mentat-statistician-py /etc/cron.d/mentat-statistician-py
# NAME:
# mentat-statistician.py.cron
# DESCRIPTION:
# Run Mentat's statistical postprocessing component
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/mentat-statistician.py.cron /etc/cron.d/mentat-statistician.py.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
#
# Run every five minutes
# Run once in every five minutes
*/5 * * * * mentat /usr/bin/python3 /usr/local/bin/mentat-statistician.py --regular
#
# Name: cron_mentat-watchdog-py
# Description: Check database of Mentat system for anomalies
# Installation: ln -s /etc/mentat/cron_mentat-watchdog-py /etc/cron.d/mentat-watchdog-py
# NAME:
# mentat-watchdog.py.cron
# DESCRIPTION:
# Check database of Mentat system for various anomalies
# MANUAL INSTALLATION:
# ln -s /etc/mentat/cron/mentat-watchdog.py.cron /etc/cron.d/mentat-watchdog.py.cron
#
# Copyright (C) since 2011 CESNET, z.s.p.o
# Use of this source is governed by the MIT license, see LICENSE file.
#
# Run every hour
# Run once in every hour
55 * * * * root /usr/bin/python3 /usr/local/bin/mentat-dbmngr.py --command=watchdog --regular
......@@ -90,10 +90,10 @@
# TODO: Following feature is not yet fully iplemented
#
"cronjobs": [
{ "name": "fetch-geoipdb-sh" },
{ "name": "mentat-cleanup-py" },
{ "name": "mentat-precache-py" },
{ "name": "mentat-statistician-py" },
{ "name": "mentat-watchdog-py" }
{ "name": "fetch-geoipdb.sh" },
{ "name": "mentat-cleanup.py" },
{ "name": "mentat-precache.py" },
{ "name": "mentat-statistician.py" },
{ "name": "mentat-watchdog.py" }
]
}
......@@ -24,7 +24,6 @@ import collections
import subprocess
import pyzenkit.jsonconf
import mentat
#
......@@ -88,7 +87,7 @@ REGEXP_MENTAT_PS = re.compile(r'\s*(\d+)\s+([^\s]+)\s+([^\s]*(?:python3?))\s
"""Regular expression for selecting Mentat related processes."""
REGEXP_MENTAT_PIDF = re.compile(r'(.+?)(?:\.(\d+))?\.pid$')
"""Regular expression for selecting Mentat related PID files."""
REGEXP_MENTAT_CRONF = re.compile(r'cron_(.+)$')
REGEXP_MENTAT_CRONF = re.compile(r'(.+)\.cron$')
"""Regular expression for selecting Mentat related log files."""
REGEXP_MENTAT_LOGF = re.compile(r'(.+)\.log$')
"""Regular expression for selecting Mentat related log files."""
......@@ -374,11 +373,11 @@ def analyze_cron_file(cron_file, cron_file_path, cron_links):
{
'atime': datetime.datetime(2018, 1, 21, 9, 13, 48, 34648),
'file': 'cron_mentat-statistician-py',
'file': 'mentat-statistician.py.cron',
'link': None,
'mtime': datetime.datetime(2017, 7, 19, 10, 25, 30),
'name': 'mentat-statistician-py',
'path': '/etc/mentat/cron_mentat-statistician-py',
'name': 'mentat-statistician.py',
'path': '/etc/mentat/cron/mentat-statistician.py.cron',
'size': 429
}
......@@ -413,19 +412,19 @@ def analyze_cron_files(cfg_dir_path, cron_dir_path):
Example of returned structure::
{
'mentat-precache-py': {'atime': datetime.datetime(2018, 1, 21, 9, 13, 45),
'file': 'cron_mentat-precache-py',
'mentat-precache.py': {'atime': datetime.datetime(2018, 1, 21, 9, 13, 45),
'file': 'mentat-precache.py.cron',
'link': None,
'mtime': datetime.datetime(2017, 9, 1, 11, 10, 17),
'name': 'mentat-precache-py',
'path': '/etc/mentat/cron_mentat-precache-py',
'name': 'mentat-precache.py',
'path': '/etc/mentat/cron/mentat-precache.py.cron',
'size': 417},
'mentat-statistician-py': {'atime': datetime.datetime(2018, 1, 21, 9, 13, 48, 34648),
'file': 'cron_mentat-statistician-py',
'mentat-statistician.py': {'atime': datetime.datetime(2018, 1, 21, 9, 13, 48, 34648),
'file': 'mentat-statistician.py.cron',
'link': None,
'mtime': datetime.datetime(2017, 7, 19, 10, 25, 30),
'name': 'mentat-statistician-py',
'path': '/etc/mentat/cron_mentat-statistician-py',
'name': 'mentat-statistician.py.cron',
'path': '/etc/mentat/cron/mentat-statistician.py.cron',
'size': 429}
}
......@@ -803,7 +802,7 @@ def system_status(modules, cronjobs, cfg_dir_path, cron_dir_path, log_dir_path,
status['processes'] = analyze_process_list_ps()
status['pid_files'] = analyze_pid_files(run_dir_path)
status['log_files'] = analyze_log_files(log_dir_path)
status['cron_files'] = analyze_cron_files(cfg_dir_path, cron_dir_path)
status['cron_files'] = analyze_cron_files(os.path.join(cfg_dir_path, 'cron'), cron_dir_path)
status['resultm'] = None
status['resultc'] = None
status['result'] = None
......
......@@ -144,7 +144,7 @@ class TestMentatStorage(unittest.TestCase):
if self.verbose:
print("Single PID file:")
#pprint(mentat.system.analyze_pid_file('mentat-storage.py.pid', '/var/mentat/run/mentat-storage.py.pid'))
pprint(mentat.system.analyze_pid_file('mentat-storage.py.pid', '/var/mentat/run/mentat-storage.py.pid'))
def test_04_analyze_pid_files(self):
"""
......@@ -154,7 +154,7 @@ class TestMentatStorage(unittest.TestCase):
if self.verbose:
print("All PID files:")
#pprint(mentat.system.analyze_pid_files('/var/mentat/run'))
pprint(mentat.system.analyze_pid_files('/var/mentat/run'))
def test_05_analyze_cron_file(self):
"""
......@@ -164,7 +164,7 @@ class TestMentatStorage(unittest.TestCase):
if self.verbose:
print("Single cron file:")
#pprint(mentat.system.analyze_cron_file('cron_mentat-statistician-py', '/etc/mentat/cron_mentat-statistician-py', {}))
pprint(mentat.system.analyze_cron_file('mentat-statistician.py.cron', '/etc/mentat/cron/mentat-statistician.py.cron', {}))
def test_06_analyze_cron_files(self):
"""
......@@ -174,7 +174,7 @@ class TestMentatStorage(unittest.TestCase):
if self.verbose:
print("All cron files:")
#pprint(mentat.system.analyze_cron_files('/etc/mentat', '/etc/cron.d'))
pprint(mentat.system.analyze_cron_files('/etc/mentat/cron', '/etc/cron.d'))
def test_07_analyze_log_file(self):
"""
......@@ -184,7 +184,7 @@ class TestMentatStorage(unittest.TestCase):
if self.verbose:
print("Single log file:")
#pprint(mentat.system.analyze_log_file('mentat-storage.py.log', '/var/mentat/log/mentat-storage.py.log'))
pprint(mentat.system.analyze_log_file('mentat-storage.py.log', '/var/mentat/log/mentat-storage.py.log'))
def test_08_analyze_log_files(self):
"""
......@@ -194,7 +194,7 @@ class TestMentatStorage(unittest.TestCase):
if self.verbose:
print("All log files:")
#pprint(mentat.system.analyze_log_files('/var/mentat/log'))
pprint(mentat.system.analyze_log_files('/var/mentat/log'))
def test_09_analyze_runlog_file(self):
"""
......@@ -220,7 +220,7 @@ class TestMentatStorage(unittest.TestCase):
"""
Perform the basic Mentat system tests.
"""
self.maxDiff = None
self.maxDiff = None # pylint: disable=locally-disabled,invalid-name
modules = mentat.system.make_module_list([
{ "exec": "mentat-storage.py", "args": [] },
......@@ -235,8 +235,21 @@ class TestMentatStorage(unittest.TestCase):
{ "name": "mentat-watchdog-py" }
])
print("System status:")
#pprint(mentat.system.system_status(modules, cronjobs, '/etc/mentat', '/etc/cron.d', '/var/mentat/log', '/var/mentat/run'))
if self.verbose:
print("System status:")
pprint(mentat.system.system_status(modules, cronjobs, '/etc/mentat', '/etc/cron.d', '/var/mentat/log', '/var/mentat/run'))
#self.assertTrue(
# mentat.system.system_status(
# modules,
# cronjobs,
# '/etc/mentat',
# '/etc/cron.d',
# '/var/mentat/log',
# '/var/mentat/run'
# )
#)
#-------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment