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
Jean-Paul Smets
slapos
Commits
accdc8ea
Commit
accdc8ea
authored
Jun 21, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: allow to set periodicity for custom report scripts
parent
83d87101
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
8 deletions
+30
-8
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+2
-2
stack/monitor/instance-monitor.cfg.jinja2.in
stack/monitor/instance-monitor.cfg.jinja2.in
+3
-2
stack/monitor/scripts/monitor.py
stack/monitor/scripts/monitor.py
+25
-4
No files found.
stack/monitor/buildout.cfg
View file @
accdc8ea
...
...
@@ -100,7 +100,7 @@ recipe = slapos.recipe.template:jinja2
filename = template-monitor.cfg
template = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in
rendered = ${buildout:directory}/template-monitor.cfg
md5sum =
354da434447697b8b4f503a62599cf32
md5sum =
7ae453794e320d3b512ec037efc5fc1f
context =
key apache_location apache:location
key gzip_location gzip:location
...
...
@@ -131,7 +131,7 @@ depends =
[monitor2-bin]
<= monitor-template-script
filename = monitor.py
md5sum =
3166f5d110fda63aade1ca486dfb7996
md5sum =
280412f9024030c8cae343c2b07e5130
[run-promise-py]
recipe = slapos.recipe.template:jinja2
...
...
stack/monitor/instance-monitor.cfg.jinja2.in
View file @
accdc8ea
...
...
@@ -364,8 +364,8 @@ mode = 0644
context = section parameter_dict monitor-password-promise-conf-parameter
[publish]
<= monitor-base
monitor-base-url = ${monitor-
conf-parameters
:base-url}
# XXX depends on monitor-base section
monitor-base-url = ${monitor-
base
:base-url}
monitor-url = ${:monitor-base-url}/public/feeds
monitor-user = ${monitor-instance-parameter:username}
monitor-password = ${monitor-instance-parameter:password}
...
...
@@ -415,6 +415,7 @@ check-secure = 1
recipe = plone.recipe.command
command = true
update-command =
base-url = ${monitor-conf-parameters:base-url}
depends =
${monitor-globalstate-cron-entry:name}
${monitor-configurator-cron-entry:name}
...
...
stack/monitor/scripts/monitor.py
View file @
accdc8ea
...
...
@@ -245,6 +245,28 @@ class Monitoring(object):
print
"Bad Json file at %s"
%
url
return
'Unknown Instance'
def
getReportInfoFromFilename
(
self
,
filename
):
splited_filename
=
filename
.
split
(
'_every_'
)
possible_time_list
=
[
'hour'
,
'minute'
]
if
len
(
splited_filename
)
==
1
:
return
(
filename
,
"* * * * *"
)
run_time
=
splited_filename
[
1
].
split
(
'_'
)
report_name
=
splited_filename
[
0
]
if
len
(
run_time
)
!=
2
or
not
run_time
[
1
]
in
possible_time_list
:
return
(
report_name
,
"* * * * *"
)
try
:
value
=
int
(
run_time
[
0
])
except
ValueError
:
print
"Warning: Bad report filename: %s"
%
filename
return
(
report_name
,
"* * * * *"
)
if
run_time
[
1
]
==
'hour'
:
return
(
report_name
,
"* */%s * * *"
%
value
)
if
run_time
[
1
]
==
'minute'
:
return
(
report_name
,
"*/%s * * * *"
%
value
)
def
configureFolders
(
self
):
# configure public and private folder
self
.
createSymlinksFromConfig
(
self
.
webdav_folder
,
[
self
.
public_folder
])
...
...
@@ -387,8 +409,6 @@ class Monitoring(object):
def
generateReportCronEntries
(
self
):
cron_line_list
=
[]
# We should add the possibility to modify this parameter later from monitor interface
report_frequency
=
"*/20 * * * *"
report_name_list
=
[
name
.
replace
(
'.report.json'
,
''
)
for
name
in
os
.
listdir
(
self
.
report_folder
)
if
name
.
endswith
(
'.report.json'
)]
...
...
@@ -396,11 +416,12 @@ class Monitoring(object):
for
filename
in
os
.
listdir
(
self
.
report_script_folder
):
report_script
=
os
.
path
.
join
(
self
.
report_script_folder
,
filename
)
if
os
.
path
.
isfile
(
report_script
)
and
os
.
access
(
report_script
,
os
.
X_OK
):
report_name
=
os
.
path
.
splitext
(
filename
)[
0
]
report_name
,
frequency
=
self
.
getReportInfoFromFilename
(
filename
)
# report_name = os.path.splitext(filename)[0]
report_json_path
=
"%s.report.json"
%
report_name
report_cmd_line
=
[
report_
frequency
,
frequency
,
self
.
promise_runner
,
'--pid_path "%s"'
%
os
.
path
.
join
(
self
.
service_pid_folder
,
"%s.pid"
%
filename
),
...
...
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