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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Leymonerie
slapos
Commits
5ed0d5a6
Commit
5ed0d5a6
authored
Feb 25, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to configure multiple monitoring source
parent
defc6519
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
26 deletions
+57
-26
stack/monitor2/buildout.cfg
stack/monitor2/buildout.cfg
+3
-3
stack/monitor2/instance-monitor.cfg.jinja2.in
stack/monitor2/instance-monitor.cfg.jinja2.in
+6
-4
stack/monitor2/scripts/monitor.py
stack/monitor2/scripts/monitor.py
+14
-11
stack/monitor2/scripts/status2rss.py
stack/monitor2/scripts/status2rss.py
+34
-8
No files found.
stack/monitor2/buildout.cfg
View file @
5ed0d5a6
...
...
@@ -127,7 +127,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 =
ee39ce85084d29172f50ae7375960371
md5sum =
b28523cd793788a1e1b11698c5a67b03
context =
key apache_location apache:location
key gzip_location gzip:location
...
...
@@ -164,7 +164,7 @@ context =
[monitor2-bin]
<= monitor-template-script
filename = monitor.py
md5sum =
119827d7e7ed45c627f1ad21a94445b8
md5sum =
51ada466716af0a763910c24f1bdf819
[run-promise-py]
recipe = slapos.recipe.template:jinja2
...
...
@@ -183,7 +183,7 @@ md5sum = f7e937d6619eb674f39f34718928d91d
[status2rss-executable]
<= monitor-template-script
filename = status2rss.py
md5sum =
40dcda69f1ccb8639d7ef0ad65bceb5e
md5sum =
f297779d0881f4bd48081506efb492a4
[monitor-globalstate]
<= monitor-template-script
...
...
stack/monitor2/instance-monitor.cfg.jinja2.in
View file @
5ed0d5a6
...
...
@@ -133,6 +133,7 @@ public-folder = ${monitor-directory:public}
private-folder = ${monitor-directory:private}
webdav-folder = ${monitor-directory:webdav}
web-folder = ${monitor-directory:web-dir}
#base-url = ${monitor-frontend-promise:url}
base-url = ${monitor-httpd-conf-parameter:url}
monitor-hal-json = ${monitor-directory:public}/monitor.hal.json
service-pid-folder = ${monitor-directory:pids}
...
...
@@ -253,7 +254,9 @@ command = kill -USR1 $(cat ${monitor-httpd-conf-parameter:pid-file})
[monitor-status2rss-wrapper]
recipe = slapos.cookbook:wrapper
command-line = {{ python_with_eggs }} {{ status2rss_executable_path }} '${monitor-instance-parameter:monitor-title}' '${monitor-httpd-conf-parameter:url}' '${monitor-httpd-conf-parameter:url}/public' ${monitor-directory:public} ${monitor-directory:public}/feed
# XXX - hard-coded Urls
command-line = {{ python_with_eggs }} {{ status2rss_executable_path }} --output '${monitor-directory:public}/feed' --items_folder '${monitor-directory:public}' --public_url '${monitor-conf-parameters:base-url}/share/jio_public/' --private_url '${monitor-conf-parameters:base-url}/share/jio_private/' --instance_name '${monitor-conf-parameters:title}' --hosting_name '${monitor-conf-parameters:root-title}'
wrapper-path = ${directory:bin}/monitor-status2rss.py
[monitor-status2rss-cron-entry]
...
...
@@ -363,9 +366,8 @@ context =
[publish]
recipe = slapos.cookbook:publish
#monitor-base-url = ${monitor-httpd-conf-parameter:url}
monitor-base-url = ${monitor-frontend-promise:url}
monitor-url = ${:monitor-base-url}/share/jio_public
monitor-base-url = ${monitor-conf-parameters:base-url}
monitor-url = ${:monitor-base-url}/public/feeds
monitor-user = ${httpd-monitor-htpasswd:user}
monitor-password = ${httpd-monitor-htpasswd:password}
...
...
stack/monitor2/scripts/monitor.py
View file @
5ed0d5a6
...
...
@@ -15,7 +15,7 @@ OPML_START = """<?xml version="1.0" encoding="UTF-8"?>
<!-- OPML generated by SlapOS -->
<opml version="1.1">
<head>
<title>
SlapOS Monitoring Status List
s</title>
<title>
%(root_title)
s</title>
<dateCreated>%(creation_date)s</dateCreated>
<dateModified>%(modification_date)s</dateModified>
</head>
...
...
@@ -25,7 +25,7 @@ OPML_END = """ </outline>
</body>
</opml>"""
OPML_OUTLINE_FEED
=
'<outline text="%(title)s" title="%(title)s" type="rss" version="RSS" htmlUrl="%(html_url)s" xmlUrl="%(xml_url)s" />'
OPML_OUTLINE_FEED
=
'<outline text="%(title)s" title="%(title)s" type="rss" version="RSS" htmlUrl="%(html_url)s" xmlUrl="%(xml_url)s"
url="%(global_url)s"
/>'
def
parseArguments
():
...
...
@@ -172,8 +172,6 @@ class Monitoring(object):
raise
def
generateOpmlFile
(
self
,
feed_url_list
,
output_file
):
if
not
feed_url_list
:
return
if
os
.
path
.
exists
(
output_file
):
creation_date
=
datetime
.
fromtimestamp
(
os
.
path
.
getctime
(
output_file
)).
utcnow
().
strftime
(
"%a, %d %b %Y %H:%M:%S +0000"
)
...
...
@@ -183,15 +181,18 @@ class Monitoring(object):
opml_content
=
OPML_START
%
{
'creation_date'
:
creation_date
,
'modification_date'
:
modification_date
,
'outline_title'
:
'Monitoring RSS Feed list'
}
'outline_title'
:
'Monitoring RSS Feed list'
,
'root_title'
:
self
.
root_title
}
opml_content
+=
OPML_OUTLINE_FEED
%
{
'title'
:
'Main Instance'
,
opml_content
+=
OPML_OUTLINE_FEED
%
{
'title'
:
self
.
title
,
'html_url'
:
self
.
public_url
+
'/feed'
,
'xml_url'
:
self
.
public_url
+
'/feed'
}
'xml_url'
:
self
.
public_url
+
'/feed'
,
'global_url'
:
"%s/jio_public/"
%
self
.
webdav_url
}
for
feed_url
in
feed_url_list
:
opml_content
+=
OPML_OUTLINE_FEED
%
{
'title'
:
'Monitoring Instance'
,
opml_content
+=
OPML_OUTLINE_FEED
%
{
'title'
:
'
Related
Monitoring Instance'
,
'html_url'
:
feed_url
+
'/public/feed'
,
'xml_url'
:
feed_url
+
'/public/feed'
}
'xml_url'
:
feed_url
+
'/public/feed'
,
'global_url'
:
"%s/share/jio_public/"
%
feed_url
}
opml_content
+=
OPML_END
...
...
@@ -223,8 +224,6 @@ class Monitoring(object):
if
self
.
monitor_url_list
:
monitor_link_dict
[
"related_monitor"
]
=
[{
"href"
:
url
}
for
url
in
self
.
monitor_url_list
]
self
.
generateOpmlFile
(
self
.
monitor_url_list
,
os
.
path
.
join
(
self
.
public_folder
,
'feeds'
))
self
.
monitor_dict
[
"_links"
]
=
monitor_link_dict
if
self
.
promise_items
:
service_list
=
[]
...
...
@@ -324,6 +323,10 @@ class Monitoring(object):
self
.
monitor_dict
=
{}
self
.
generateMonitorHalJson
()
# Generate OPML file
self
.
generateOpmlFile
(
self
.
monitor_url_list
,
os
.
path
.
join
(
self
.
public_folder
,
'feeds'
))
# put promises to a cron file
self
.
generateServiceCronEntries
()
...
...
stack/monitor2/scripts/status2rss.py
View file @
5ed0d5a6
...
...
@@ -5,17 +5,40 @@ import datetime
import
base64
import
hashlib
import
PyRSS2Gen
import
argparse
def
parseArguments
():
"""
Parse arguments for monitor Rss Generator.
"""
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--items_folder'
,
help
=
'Path where to get *.status.json files which contain result of promises.'
)
parser
.
add_argument
(
'--output'
,
help
=
'The Path of file where feed file will be saved.'
)
parser
.
add_argument
(
'--public_url'
,
help
=
'Monitor Instance public URL.'
)
parser
.
add_argument
(
'--private_url'
,
help
=
'Monitor Instance private URL.'
)
parser
.
add_argument
(
'--instance_name'
,
default
=
'UNKNOW Software Instance'
,
help
=
'Software Instance name.'
)
parser
.
add_argument
(
'--hosting_name'
,
default
=
''
,
help
=
'Hosting Subscription name.'
)
return
parser
.
parse_args
()
def
getKey
(
item
):
return
item
.
pubDate
def
main
():
_
,
title
,
link
,
base_url
,
status_folder
,
output_path
=
sys
.
argv
parser
=
parseArguments
()
rss_item_list
=
[]
for
filename
in
os
.
listdir
(
statu
s_folder
):
for
filename
in
os
.
listdir
(
parser
.
item
s_folder
):
if
filename
.
endswith
(
".status.json"
):
filepath
=
os
.
path
.
join
(
statu
s_folder
,
filename
)
filepath
=
os
.
path
.
join
(
parser
.
item
s_folder
,
filename
)
result_dict
=
None
try
:
result_dict
=
json
.
load
(
open
(
filepath
,
"r"
))
...
...
@@ -25,9 +48,12 @@ def main():
description
=
result_dict
.
get
(
'message'
,
''
)
event_time
=
datetime
.
datetime
.
fromtimestamp
(
result_dict
[
'change-time'
])
rss_item
=
PyRSS2Gen
.
RSSItem
(
categories
=
[
result_dict
[
'status'
]],
source
=
PyRSS2Gen
.
Source
(
result_dict
[
'title'
],
parser
.
public_url
),
title
=
'[%s] %s'
%
(
result_dict
[
'status'
],
result_dict
[
'title'
]),
comments
=
description
,
description
=
"%s: %s
\
n
%s"
%
(
event_time
,
result_dict
[
'status'
],
description
),
link
=
'%s/%s'
%
(
base_url
,
filename
)
,
link
=
parser
.
private_url
,
pubDate
=
event_time
,
guid
=
PyRSS2Gen
.
Guid
(
base64
.
b64encode
(
"%s, %s"
%
(
event_time
,
result_dict
[
'status'
])))
)
...
...
@@ -37,13 +63,13 @@ def main():
### Build the rss feed
sorted
(
rss_item_list
,
key
=
getKey
)
rss_feed
=
PyRSS2Gen
.
RSS2
(
title
=
titl
e
,
link
=
link
,
description
=
''
,
title
=
parser
.
instance_nam
e
,
link
=
parser
.
public_url
,
description
=
parser
.
hosting_name
,
lastBuildDate
=
datetime
.
datetime
.
utcnow
(),
items
=
rss_item_list
)
with
open
(
output_path
,
'w'
)
as
frss
:
with
open
(
parser
.
output
,
'w'
)
as
frss
:
frss
.
write
(
rss_feed
.
to_xml
())
if
__name__
==
"__main__"
:
...
...
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