Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos
Commits
4f917a2c
Commit
4f917a2c
authored
Sep 14, 2023
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
dd5bc0e0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
136 additions
and
2 deletions
+136
-2
setup.py
setup.py
+1
-0
slapos/recipe/check_cron_service/__init__.py
slapos/recipe/check_cron_service/__init__.py
+47
-0
slapos/recipe/check_cron_service/template/check_cron.in
slapos/recipe/check_cron_service/template/check_cron.in
+11
-0
software/matomo/buildout.hash.cfg
software/matomo/buildout.hash.cfg
+5
-1
software/matomo/matomo-instance.cfg.in
software/matomo/matomo-instance.cfg.in
+14
-0
software/matomo/promise/check_cron_service.py
software/matomo/promise/check_cron_service.py
+52
-0
software/matomo/software.cfg
software/matomo/software.cfg
+6
-1
No files found.
setup.py
View file @
4f917a2c
...
@@ -82,6 +82,7 @@ setup(name=name,
...
@@ -82,6 +82,7 @@ setup(name=name,
'apacheproxy = slapos.recipe.apacheproxy:Recipe'
,
'apacheproxy = slapos.recipe.apacheproxy:Recipe'
,
'certificate_authority = slapos.recipe.certificate_authority:Recipe'
,
'certificate_authority = slapos.recipe.certificate_authority:Recipe'
,
'certificate_authority.request = slapos.recipe.certificate_authority:Request'
,
'certificate_authority.request = slapos.recipe.certificate_authority:Request'
,
'check_cron_service = slapos.recipe.check_cron_service:Recipe'
,
'check_page_content = slapos.recipe.check_page_content:Recipe'
,
'check_page_content = slapos.recipe.check_page_content:Recipe'
,
'check_port_listening = slapos.recipe.check_port_listening:Recipe'
,
'check_port_listening = slapos.recipe.check_port_listening:Recipe'
,
'check_url_available = slapos.recipe.check_url_available:Recipe'
,
'check_url_available = slapos.recipe.check_url_available:Recipe'
,
...
...
slapos/recipe/check_cron_service/__init__.py
0 → 100644
View file @
4f917a2c
##############################################################################
#
# Copyright (c) 2023 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
slapos.recipe.librecipe
import
GenericBaseRecipe
import
sys
import
os
class
Recipe
(
GenericBaseRecipe
):
"""
Create script that will check if the cron.log contains any errors.
"""
def
install
(
self
):
timeout_file
=
os
.
path
.
join
(
os
.
getcwd
(),
'etc/promise_timeout'
)
config
=
{
'cron_log'
:
self
.
options
[
'cron_log'
],
}
promise
=
self
.
createExecutable
(
self
.
options
[
'path'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'check_cron.in'
),
config
)
)
return
[
promise
]
slapos/recipe/check_cron_service/template/check_cron.in
0 → 100644
View file @
4f917a2c
CRON_LOG="%(cron_log)s"
if [ -z $CRON_LOG ]; then
echo "No cron.log specified." >&2
exit 3
fi
cat $CRON_LOG | grep "ERROR" > /dev/null
# If there has an error,
# Report it to somewhere?
software/matomo/buildout.hash.cfg
View file @
4f917a2c
...
@@ -15,8 +15,12 @@
...
@@ -15,8 +15,12 @@
[template-matomo-instance]
[template-matomo-instance]
filename = matomo-instance.cfg.in
filename = matomo-instance.cfg.in
md5sum =
145ebeb4adcd4ec3d13929f1d2ee239c
md5sum =
8f7f7c1ae6395f5c12894eb6ba2e8424
[template-matomo-backup.sh]
[template-matomo-backup.sh]
filename = matomo-backup.sh.in
filename = matomo-backup.sh.in
md5sum = fb29ad59813ef62c3f5934d4a0d90e14
md5sum = fb29ad59813ef62c3f5934d4a0d90e14
[custom-promise]
filename = promise/check_cron_service.py
md5sum = 2e2696061faac493908d87a3cce10988
software/matomo/matomo-instance.cfg.in
View file @
4f917a2c
...
@@ -20,6 +20,20 @@ context =
...
@@ -20,6 +20,20 @@ context =
section parameter_dict instance-parameter
section parameter_dict instance-parameter
key php_bin php-bin:wrapper-path
key php_bin php-bin:wrapper-path
[promise-cron]
<= monitor-promise-base
promise = check_cron_service
name = promise-cron.py
config-cron_log = ${cron-simplelogger:log}
# Add the custom promise to check that the index file exists
[check-cron-promise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.core
file = {{ custom_promise }}
output = ${directory:plugins}/check-cron-service.py
config-cron_log = ${cron-simplelogger:log}
[apache-php-service]
[apache-php-service]
environment=
environment=
MATOMO_DATABASE_HOST=${mariadb-urlparse:host}:${mariadb-urlparse:port}
MATOMO_DATABASE_HOST=${mariadb-urlparse:host}:${mariadb-urlparse:port}
...
...
software/matomo/promise/check_cron_service.py
0 → 100644
View file @
4f917a2c
import
os
from
zope.interface
import
implementer
from
slapos.grid.promise
import
interface
from
slapos.grid.promise.generic
import
GenericPromise
@
implementer
(
interface
.
IPromise
)
class
RunPromise
(
GenericPromise
):
def
__init__
(
self
,
config
):
"""
Called when initialising the promise before testing.
Sets the configuration and the periodicity.
"""
super
(
RunPromise
,
self
).
__init__
(
config
)
self
.
setPeriodicity
(
minute
=
2
)
def
sense
(
self
):
"""
Called every time the promise is tested.
Signals a positive or negative result.
In this case, check whether the file exists.
"""
path
=
self
.
getConfig
(
'cron_log'
)
if
os
.
path
.
isfile
(
path
):
self
.
logger
.
info
(
"cron_log %s exists and is a file"
,
path
)
else
:
self
.
logger
.
error
(
"cron_log %s does not exist or is not a file"
,
path
)
def
test
(
self
):
"""
Called after sense() if the instance is still converging.
Returns success or failure based on sense results.
In this case, fail if the previous sensor result is negative.
"""
return
self
.
_test
(
result_count
=
1
,
failure_amount
=
1
)
def
anomaly
(
self
):
"""
Called after sense() if the instance has finished converging.
Returns success or failure based on sense results.
Failure signals the instance has diverged.
In this case, fail if two out of the last three results are negative.
"""
return
self
.
_anomaly
(
result_count
=
3
,
failure_amount
=
2
)
software/matomo/software.cfg
View file @
4f917a2c
...
@@ -32,7 +32,7 @@ archive-root = matomo
...
@@ -32,7 +32,7 @@ archive-root = matomo
# Without it the instance-matomo.cfg file will not be executed
# Without it the instance-matomo.cfg file will not be executed
[custom-application-deployment]
[custom-application-deployment]
path = ${template-matomo-instance:output}
path = ${template-matomo-instance:output}
part-list = matomo-backup.sh matomo-backup-cron
part-list = matomo-backup.sh matomo-backup-cron
check-cron-promise
db-name = matomo
db-name = matomo
db-user = matomo
db-user = matomo
...
@@ -46,11 +46,16 @@ context =
...
@@ -46,11 +46,16 @@ context =
key diffutils_location diffutils:location
key diffutils_location diffutils:location
key php_location apache-php:location
key php_location apache-php:location
key matomo_backup_sh template-matomo-backup.sh:target
key matomo_backup_sh template-matomo-backup.sh:target
key custom_promise custom-promise:target
# download matomo-backup.sh.in
# download matomo-backup.sh.in
[template-matomo-backup.sh]
[template-matomo-backup.sh]
<= matomo-download
<= matomo-download
# Download the custom promise
[custom-promise]
<= matomo-download
[partition-info]
[partition-info]
recipe = slapos.cookbook:request.serialised
recipe = slapos.cookbook:request.serialised
configuration.mariadb-computer-guid = ${slap-connection:computer-id}
configuration.mariadb-computer-guid = ${slap-connection:computer-id}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment