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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
slapos
Commits
459c986b
Commit
459c986b
authored
Aug 28, 2015
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+1
parent
853b4890
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
54 deletions
+95
-54
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+1
-1
stack/monitor/webfile-directory/index.cgi.in
stack/monitor/webfile-directory/index.cgi.in
+94
-53
No files found.
stack/monitor/buildout.cfg
View file @
459c986b
...
...
@@ -70,7 +70,7 @@ mode = 0644
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfile-directory/${:filename}
download-only = true
md5sum =
1e17f3c1850a3bda25409e2fdc0e3db
8
md5sum =
cba562a714ebaa79b5fc9ae0f730c9d
8
destination = ${buildout:parts-directory}/monitor-index
filename = index.cgi.in
mode = 0644
...
...
stack/monitor/webfile-directory/index.cgi.in
View file @
459c986b
...
...
@@ -26,6 +26,14 @@ monitor_apache_password_command = "{{ apache_update_command }}"
monitor_rewrite = "{{ ' '.join(rewrite_element.keys()) }}"
instance_path = os.path.join(cgi_path, "../../..")
slappart1_mysql_error_log = os.path.join(instance_path, "slappart1/var/log/mariadb_error.log")
slappart1_mysql_slowquery_log = os.path.join(instance_path, "slappart1/var/log/mariadb_slowquery.log")
slappart6_zope_0_event_log = os.path.join(instance_path, "slappart6/var/log/zope-0-event.log")
slappart6_zope_0_Z2_log = os.path.join(instance_path, "slappart6/var/log/zope-0-Z2.log")
slappart7_apache_access_log = os.path.join(instance_path, "slappart7/var/log/apache-access.log")
slappart7_apache_error_log = os.path.join(instance_path, "slappart7/var/log/apache-error.log")
#################
# Main function #
#################
...
...
@@ -270,7 +278,7 @@ def promise_slowQuery():
return 0
if form.has_key("grep"):
grep = form["grep"].value
with open(os.path.join(
cgi_path, "
mariadb_slowquery.log")) as f:
with open(os.path.join(
instance_path, "slappart1/var/log/
mariadb_slowquery.log")) as f:
setHeader("Status", "200 OK")
setHeader("Content-Type", "text/plain")
sendHeaders()
...
...
@@ -280,7 +288,7 @@ def promise_slowQuery():
sys.stdout.write("% 5d: %s" % (i, line))
i += 1
return 0
with open(os.path.join(
cgi_path, "
mariadb_slowquery.log")) as f:
with open(os.path.join(
instance_path, "slappart1/var/log/
mariadb_slowquery.log")) as f:
setHeader("Status", "200 OK")
setHeader("Content-Type", "text/plain")
sendHeaders()
...
...
@@ -315,7 +323,7 @@ def promise_slowQuery():
print('
<input
name=
"grep"
type=
"text"
/><input
type=
"submit"
value=
"Search"
/></form>
')
print('
<div
style=
"display: inline-block;"
><span>
|
</span><button>
Rotate log
</button></div>
')
try:
print('
<pre
style=
"overflow-wrap: initial; overflow-x: auto; white-space: pre;"
>
[..]\n' + escapeHtml(open(os.path.join(
cgi_path, "
mariadb_slowquery.log")).read()[-1024:] or "No log") + "
</pre>
")
print('
<pre
style=
"overflow-wrap: initial; overflow-x: auto; white-space: pre;"
>
[..]\n' + escapeHtml(open(os.path.join(
instance_path, "slappart1/var/log/
mariadb_slowquery.log")).read()[-1024:] or "No log") + "
</pre>
")
except Exception, e:
print("
<p>
An error occured durring log reading
</p><pre>
" + escapeHtml(repr(e)) + "
</pre>
")
print("
</body></html>
")
...
...
@@ -364,6 +372,38 @@ def promise_logSupervisor():
# sendHeaders()
# sys.stdout.write(f.read())
# return 0
log_list = [
{
"name": "instance 1: Mariadb error log",
"id": "slappart1-mariadb-error-log",
"path": slappart1_mysql_error_log,
},
{
"name": "instance 1: Mariadb slow query log",
"id": "slappart1-mariadb-slowquery-log",
"path": slappart1_mysql_slowquery_log,
},
{
"name": "instance 6: Zope event log",
"id": "slappart6-zope-event-log",
"path": slappart6_zope_0_event_log,
},
{
"name": "instance 6: Zope access log",
"id": "slappart6-zope-0-Z2-log",
"path": slappart6_zope_0_Z2_log,
},
{
"name": "instance 7: Apache access log",
"id": "slappart7-apache-access-log",
"path": slappart7_apache_access_log,
},
{
"name": "instance 7: Apache error log",
"id": "slappart7-apache-error-log",
"path": slappart7_apache_error_log,
}
]
setHeader("Status", "200 OK")
sendHeaders()
print("
<!DOCTYPE html>
<html><head>
")
...
...
@@ -372,7 +412,6 @@ def promise_logSupervisor():
print('
<header><a
href=
"?"
class=
"as-button"
>
Parent page
</a><a
href=
""
class=
"as-button"
>
Refresh
</a></header>
')
print("
<h1>
ERP5 log supervisor
</h1>
")
print("
<p>
This page gives access to all ERP5 log files. If a log file goes too big, the status of this supervisor is change to BAD.
</p>
")
print('
<p><img
src=
"%s"
style=
"height: 10mm; width: 10mm; vertical-align: bottom;"
alt=
"RSS feed"
/></p>
' % rssIconDataUri)
print("
<p>
Index:
</p>
")
print('
<ul>
')
print('
<li><a
href=
"#log-file-size"
>
Log file size
</a></li>
')
...
...
@@ -380,62 +419,52 @@ def promise_logSupervisor():
print('
<li><a
href=
"#slappart1-mariadb-log"
>
instance 1: Mariadb log
</a></li>
')
print('
<li><a
href=
"#slappart6-zope-0-event"
>
instance 6: Zope 0 event log
</a></li>
')
print('
<li><a
href=
"#slappart6-zope-0-access"
>
instance 6: Zope 0 access log
</a></li>
')
print('
<li><a
href=
"#slappart7-apache-access"
>
instance 7: Apache access log
</a></li>
')
print('
<li><a
href=
"#slappart7-apache-error"
>
instance 7: Apache error log
</a></li>
')
print('
</ul>
')
print('
<h2
id=
"log-file-size"
>
Log file size
</h2>
')
print('
<p><img
src=
"%s"
style=
"height: 10mm; width: 10mm; vertical-align: bottom;"
alt=
"RSS feed"
/></p>
' % rssIconDataUri)
i = 0
for log in log_list:
log["size"], log["i"], i = os.stat(log["path"]).st_size, i, i + 1
log_list.sort(key=lambda x: x["size"], reverse=True)
print("
<ul>
")
print('
<li
style=
"color: red; font-weight: bold;"
>
0.9 GB: instance 1: Mariadb slow query log |
<button>
Compress
&
backup
</button></li>
')
print("
<li>
10 MB: instance 6: Zope 0 access log
</li>
")
print("
<li>
2 MB: instance 6: Zope 0 event log
</li>
")
print("
<li>
0 B: instance 1: Mariadb log
</li>
")
for log in log_list:
if log["size"] > (1 * 1024 * 1024): # 1MB
print('
<li><span
style=
"color: red; font-weight: bold;"
>
%(size)d B: %(name)s
</span>
|
<button>
Compress
&
backup
</button></li>
' % log)
else:
print("
<li>
%(size)d B: %(name)s
</li>
" % log)
print("
</ul>
")
QUERY_STRING = os.getenv("QUERY_STRING")
query_list = parseQueryString(QUERY_STRING)
print('
<h2
id=
"slappart1-mariadb-slow-query-log"
>
instance 1: Mariadb slow query log
</h2>
')
print('
<p
style=
"display: inline-block;"
><a
href=
"?href=log-supervisor&display_log=slappart1-mariadb-slow-query&feeds=bunch-of-lines"
><img
src=
"%s"
style=
"height: 10mm; width: 10mm; vertical-align: bottom;"
alt=
"RSS feed"
/></a>
| ' % rssIconDataUri)
print('
<a
href=
"?%s"
download=
"mariadb_slowquery.log"
class=
"as-button"
>
Download
</a>
|
</p>
' % (QUERY_STRING + ("
&
" if QUERY_STRING else "") + "display_log=slappart1-mariadb-slow-query"))
print('
<form
style=
"display: inline-block;"
method=
"get"
action=
"?"
>
')
for query in query_list:
print('
<input
name=
"%s"
type=
"hidden"
value=
"%s"
/>
' % (escapeHtml(query[0]), escapeHtml(query[1])))
print('
<input
name=
"display_log"
type=
"hidden"
value=
"slappart1-mariadb-slow-query"
/>
')
print('
<input
name=
"grep"
type=
"text"
/><input
type=
"submit"
value=
"Search"
/></form>
')
print('
<div
style=
"display: inline-block;"
><span>
|
</span><button>
Rotate log
</button></div>
')
try:
print('
<pre
style=
"overflow-wrap: initial; overflow-x: auto; white-space: pre;"
>
[..]\n' + escapeHtml(open(os.path.join(cgi_path, "mariadb_slowquery.log")).read()[-1024:] or "No log") + "
</pre>
")
except Exception, e:
print("
<p>
An error occured durring log reading
</p><pre>
" + escapeHtml(repr(e)) + "
</pre>
")
log_list.sort(key=lambda x: x["i"])
for log in log_list:
# show log title
print('
<h3
id=
"%(id)s"
>
%(name)s
</h3>
' % log)
# show rss
print('
<p
style=
"display: inline-block;"
><a
href=
"?href=log-supervisor&display_log=%(id)s&feeds=bunch-of-lines"
>
' % log)
print('
<img
src=
"%s"
style=
"height: 10mm; width: 10mm; vertical-align: bottom;"
alt=
"RSS feed"
/></a>
| ' % rssIconDataUri)
# show download field
print('
<a
href=
"?%s"
'
%
(
QUERY_STRING
+
("&"
if
QUERY_STRING
else
"")
+
"
display_log=
slappart1-mariadb-slow-query"))
print
('
download=
"%(id)s.log"
class=
"as-button"
>
Download
</a>
|
</p>
' % log)
# show search field
print('
<form
style=
"display: inline-block;"
method=
"get"
action=
"?"
>
')
for query in query_list:
print('
<input
name=
"%s"
type=
"hidden"
value=
"%s"
/>
' % (escapeHtml(query[0]), escapeHtml(query[1])))
print('
<input
name=
"display_log"
type=
"hidden"
value=
"%(id)s"
/>
' % log)
print('
<input
name=
"grep"
type=
"text"
/><input
type=
"submit"
value=
"Search"
/></form>
')
# show rotate log
print('
<div
style=
"display: inline-block;"
><span>
|
</span><button>
Rotate log
</button></div>
')
# show last log data
try:
data = open(log["path"]).read()[-1024:]
if data:
print('
<pre
style=
"overflow-wrap: initial; overflow-x: auto; white-space: pre;"
>
[..]\n' + escapeHtml(data) + "
</pre>
")
else:
print("
<p>
Empty log
</p>
")
except Exception, e:
print("
<p>
An error occured durring log reading
</p><pre>
" + escapeHtml(repr(e)) + "
</pre>
")
print('
<h2
id=
"slappart1-mariadb-log"
>
instance 1: Mariadb log
</h2>
')
print('
<p
style=
"display: inline-block;"
><a
href=
"?href=log-supervisor&display_log=slappart1-mariadb&feeds=bunch-of-lines"
><img
src=
"%s"
style=
"height: 10mm; width: 10mm; vertical-align: bottom;"
alt=
"RSS feed"
/></a>
| ' % rssIconDataUri)
print('
<a
href=
"?%s"
download=
"mariadb.log"
class=
"as-button"
>
Download
</a>
|
</p>
' % (QUERY_STRING + ("
&
" if QUERY_STRING else "") + "display_log=slappart1-mariadb"))
print('
<form
style=
"display: inline-block;"
method=
"get"
action=
"?"
>
')
for query in query_list:
print('
<input
name=
"%s"
type=
"hidden"
value=
"%s"
/>
' % (escapeHtml(query[0]), escapeHtml(query[1])))
print('
<input
name=
"display_log"
type=
"hidden"
value=
"slappart1-mariadb"
/>
')
print('
<input
name=
"grep"
type=
"text"
/><input
type=
"submit"
value=
"Search"
/></form>
')
print('
<div
style=
"display: inline-block;"
><span>
|
</span><button>
Rotate log
</button></div>
')
print("
<p>
Empty log
</p>
")
print('
<h2
id=
"slappart6-zope-0-event"
>
instance 6: Zope 0 event log
</h2>
')
print('
<p
style=
"display: inline-block;"
><a
href=
"?href=log-supervisor&display_log=slappart6-zope-0-event&feeds=bunch-of-lines"
><img
src=
"%s"
style=
"height: 10mm; width: 10mm; vertical-align: bottom;"
alt=
"RSS feed"
/></a>
| ' % rssIconDataUri)
print('
<a
href=
"?%s"
download=
"zope-0-event.log"
class=
"as-button"
>
Download
</a>
|
</p>
' % (QUERY_STRING + ("
&
" if QUERY_STRING else "") + "display_log=slappart6-zope-0-event"))
print('
<form
style=
"display: inline-block;"
method=
"get"
action=
"?"
>
')
for query in query_list:
print('
<input
name=
"%s"
type=
"hidden"
value=
"%s"
/>
' % (escapeHtml(query[0]), escapeHtml(query[1])))
print('
<input
name=
"display_log"
type=
"hidden"
value=
"slappart6-zope-0-event"
/>
')
print('
<input
name=
"grep"
type=
"text"
/><input
type=
"submit"
value=
"Search"
/></form>
')
print('
<div
style=
"display: inline-block;"
><span>
|
</span><button>
Rotate log
</button></div>
')
print("
<p>
XXX
</p>
")
print('
<h2
id=
"slappart6-zope-0-access"
>
instance 6: Zope 0 access log
</h2>
')
print('
<p
style=
"display: inline-block;"
><a
href=
"?href=log-supervisor&display_log=slappart6-zope-0-access&feeds=bunch-of-lines"
><img
src=
"%s"
style=
"height: 10mm; width: 10mm; vertical-align: bottom;"
alt=
"RSS feed"
/></a>
| ' % rssIconDataUri)
print('
<a
href=
"?%s"
download=
"zope-0-Z2.log"
class=
"as-button"
>
Download
</a>
|
</p>
' % (QUERY_STRING + ("
&
" if QUERY_STRING else "") + "display_log=slappart6-zope-0-access"))
print('
<form
style=
"display: inline-block;"
method=
"get"
action=
"?"
>
')
for query in query_list:
print('
<input
name=
"%s"
type=
"hidden"
value=
"%s"
/>
' % (escapeHtml(query[0]), escapeHtml(query[1])))
print('
<input
name=
"display_log"
type=
"hidden"
value=
"slappart6-zope-0-access"
/>
')
print('
<input
name=
"grep"
type=
"text"
/><input
type=
"submit"
value=
"Search"
/></form>
')
print('
<div
style=
"display: inline-block;"
><span>
|
</span><button>
Rotate log
</button></div>
')
print("
<p>
XXX
</p>
")
print("
</body></html>
")
return 0
if lget(args.args, 1) == "show":
...
...
@@ -746,6 +775,18 @@ def parseQueryString(string):
parameter_list[index] = (split[0], "=".join(split[1:]))
return parameter_list
# import random
# def generateUuid():
# def s4():
# return random.randint(0, 65536)
# def s8():
# return random.randint(0, 4294967296)
# return "%08x-%04x-%04x-%04x-%08x%04x" % (s8(), s4(), s4(), s4(), s8(), s4())
# import uuid
# def generateUuid():
# return str(uuid.uuid4())
rssIconDataUri = "".join([
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+CjwhRE9DVFlQR",
"SBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cu",
...
...
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