Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
bd86d44c
Commit
bd86d44c
authored
Mar 23, 2016
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify the munin_cgi wrapper / add changelog entry
parent
6b408ef8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
18 deletions
+9
-18
CHANGELOG.md
CHANGELOG.md
+2
-0
daemon.py
management/daemon.py
+7
-18
No files found.
CHANGELOG.md
View file @
bd86d44c
CHANGELOG
CHANGELOG
=========
=========
*
Munin system monitoring graphs are now zoomable.
In Development
In Development
--------------
--------------
...
...
management/daemon.py
View file @
bd86d44c
...
@@ -507,12 +507,9 @@ def munin(filename=""):
...
@@ -507,12 +507,9 @@ def munin(filename=""):
if
filename
==
""
:
filename
=
"index.html"
if
filename
==
""
:
filename
=
"index.html"
return
send_from_directory
(
"/var/cache/munin/www"
,
filename
)
return
send_from_directory
(
"/var/cache/munin/www"
,
filename
)
# MUNIN CGI-GRAPH
@
app
.
route
(
'/munin/cgi-graph/'
)
@
app
.
route
(
'/munin/cgi-graph/<path:filename>'
)
@
app
.
route
(
'/munin/cgi-graph/<path:filename>'
)
@
authorized_personnel_only
@
authorized_personnel_only
def
munin_cgi
(
filename
=
""
):
def
munin_cgi
(
filename
):
""" Relay munin cgi dynazoom requests
""" Relay munin cgi dynazoom requests
/usr/lib/munin/cgi/munin-cgi-graph is a perl cgi script in the munin package
/usr/lib/munin/cgi/munin-cgi-graph is a perl cgi script in the munin package
that is responsible for generating binary png images _and_ associated HTTP
that is responsible for generating binary png images _and_ associated HTTP
...
@@ -541,8 +538,6 @@ def munin_cgi(filename=""):
...
@@ -541,8 +538,6 @@ def munin_cgi(filename=""):
return
(
"a path must be specified"
,
404
)
return
(
"a path must be specified"
,
404
)
query_str
=
request
.
query_string
.
decode
(
"utf-8"
,
'ignore'
)
query_str
=
request
.
query_string
.
decode
(
"utf-8"
,
'ignore'
)
query_str
=
query_str
[
1
:]
if
query_str
.
startswith
(
'&'
)
else
query_str
[
1
:]
# I don't know if this is strictly necessary
env
=
{
'PATH_INFO'
:
'/
%
s/'
%
filename
,
'QUERY_STRING'
:
query_str
}
env
=
{
'PATH_INFO'
:
'/
%
s/'
%
filename
,
'QUERY_STRING'
:
query_str
}
cmd
=
COMMAND
%
query_str
cmd
=
COMMAND
%
query_str
...
@@ -560,17 +555,11 @@ def munin_cgi(filename=""):
...
@@ -560,17 +555,11 @@ def munin_cgi(filename=""):
return
(
"error processing graph image"
,
500
)
return
(
"error processing graph image"
,
500
)
# /usr/lib/munin/cgi/munin-cgi-graph returns both headers and binary png when successful.
# /usr/lib/munin/cgi/munin-cgi-graph returns both headers and binary png when successful.
# Per http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html PNG files always start
# A double-Windows-style-newline always indicates the end of HTTP headers.
# with the same 8 bytes (137 80 78 71 13 10 26 10) or b'\x89PNG\r\n\x1a\n' So we split
headers
,
image_bytes
=
binout
.
split
(
b
'
\r\n\r\n
'
,
1
)
# the output of munin-cgi-graph where the PNG begins
response
=
make_response
(
image_bytes
)
bin_start
=
binout
.
find
(
b
'
\x89
PNG
\r\n\x1a\n
'
)
for
line
in
headers
.
splitlines
():
str_headers
=
binout
[:
bin_start
]
.
decode
(
"utf-8"
)
name
,
value
=
line
.
decode
(
"utf8"
)
.
split
(
':'
,
1
)
# decode the byte str containing response headers
bin_image
=
binout
[
bin_start
:]
response
=
make_response
(
bin_image
)
for
line
in
str_headers
.
splitlines
():
if
line
:
name
,
value
=
line
.
split
(
':'
,
1
)
response
.
headers
[
name
]
=
value
response
.
headers
[
name
]
=
value
if
'Status'
in
response
.
headers
and
'404'
in
response
.
headers
[
'Status'
]:
if
'Status'
in
response
.
headers
and
'404'
in
response
.
headers
[
'Status'
]:
app
.
logger
.
warning
(
"munin_cgi: munin-cgi-graph returned 404 status code. PATH_INFO=
%
s"
,
env
[
'PATH_INFO'
])
app
.
logger
.
warning
(
"munin_cgi: munin-cgi-graph returned 404 status code. PATH_INFO=
%
s"
,
env
[
'PATH_INFO'
])
...
...
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