提交 06c4347a 编写于 作者: N Nicolas Hennion

Default for CSS Bottle web interface

上级 d53b4538
......@@ -3,100 +3,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Glances</title>
<style>
body {
background: black;
color: white;
font-family: "Lucida Sans Typewriter", "Lucida Console", Monaco, "Bitstream Vera Sans Mono", monospace;
}
header,footer,
article,section,
hgroup,nav,
figure,div,aside {
display: block;
}
section {
text-align: justify;
}
section > article {
display: inline-block;
vertical-align: top;
*display: inline;
zoom: 1;
}
section:after {
content: "";
width: 100%;
display: inline-block;
}
aside {
float: left;
margin-right: 2em
}
div#newline{
clear: both;
height: 1em;
}
#underline{
text-decoration:underline
}
#bold{
font-weight: bold;
}
#title{
font-weight: bold;
}
#table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
}
#ok {
color: green;
}
#ok_log {
background-color: green;
color: white;
}
#careful {
color: blueviolet;
}
#careful_log {
background-color: blueviolet;
color: white;
}
#warning {
color: orange;
}
#warning_log {
background-color: orange;
color: white;
}
#critical {
color: red;
}
#critical_log {
background-color: red;
color: white;
}
#system {
float: left;
}
#uptime {
float: right;
}
#cpu {
}
#load {
}
#mem {
}
#memswap {
}
</style>
<link type="text/css" href="style.css" rel="stylesheet">
</head>
<body>
......@@ -55,6 +55,9 @@ class glancesBottle:
# Update the template path (glances/outputs/bottle)
TEMPLATE_PATH.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'bottle'))
# Path where the statics files are stored
self.STATIC_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'static')
# Define the style (CSS) list (hash table) for stats
self.__style_list = {
'DEFAULT': '',
......@@ -77,6 +80,7 @@ class glancesBottle:
Define route
"""
self._app.route('/', method="GET", callback=self._index)
self._app.route('/<filename:re:.*\.css>', method="GET", callback=self._css)
def start(self, stats):
# Init stats
......@@ -90,29 +94,27 @@ class glancesBottle:
pass
def _index(self):
"""
Bottle callback for index.html (/) file
"""
# Update the stat
self.stats.update()
# Display
return self.display(self.stats)
def _css(self, filename):
"""
Bottle callback for *.css files
"""
# Return the static file
return static_file(filename, root=os.path.join(self.STATIC_PATH, 'css'))
def display(self, stats):
"""
Display stats on the Webpage
stats: Stats database to display
"""
# html = template('header')
# html += "<header>"
# html += template(self.stats.get_plugin('system').get_bottle(self.args),
# **self.stats.get_plugin('system').get_raw())
# html += template(self.stats.get_plugin('uptime').get_bottle(self.args))
# html += "</header>"
# html += template('newline')
# html += "<section>"
# html += template(self.stats.get_plugin('cpu').get_bottle(self.args),
# **self.stats.get_plugin('cpu').get_raw())
# html += "</section>"
# html += template('footer')
html = template('header')
html += "<header>"
......@@ -139,6 +141,10 @@ class glancesBottle:
html += "</aside>"
html += "<aside>"
html += self.display_plugin('processcount', self.stats.get_plugin('processcount').get_curse(args=self.args))
html += template('newline')
html += self.display_plugin('monitor', self.stats.get_plugin('monitor').get_curse(args=self.args))
html += template('newline')
html += self.display_plugin('processlist', self.stats.get_plugin('processlist').get_curse(args=self.args))
html += "</aside>"
html += "</section>"
html += template('footer')
......
......@@ -85,10 +85,10 @@ class Plugin(GlancesPlugin):
# Build the string message
# Header
msg = "{0:4}".format(_("LOAD"))
msg = "{0:8}".format(_("LOAD"))
ret.append(self.curse_add_line(msg, "TITLE"))
# Core number
msg = "{0:>10}".format(str(self.core_plugin.update()["log"])+_("-core"))
msg = "{0:>6}".format(str(self.core_plugin.update()["log"])+_("core"))
ret.append(self.curse_add_line(msg))
# New line
ret.append(self.curse_new_line())
......
......@@ -107,53 +107,54 @@ class Plugin(GlancesPlugin):
msg = "{0:5} ".format(_("MEM"))
ret.append(self.curse_add_line(msg, "TITLE"))
# Percent memory usage
msg = "{0}".format(format(self.stats['percent'] / 100, '>6.1%'))
msg = "{0:>6}%".format(format(self.stats['percent'] / 100, '.1'))
ret.append(self.curse_add_line(msg))
# Active memory usage
if ('active' in self.stats):
msg = " {0:8}".format(_("actif:"))
ret.append(self.curse_add_line(msg, optional=True))
msg = "{0}".format(format(self.auto_unit(self.stats['active']), '>6'))
msg = "{0:>7}".format(self.auto_unit(self.stats['active']))
ret.append(self.curse_add_line(msg, optional=True))
# New line
ret.append(self.curse_new_line())
# Total memory usage
msg = "{0:8}".format(_("total:"))
msg = "{0:6}".format(_("total:"))
ret.append(self.curse_add_line(msg))
msg = "{0}".format(format(self.auto_unit(self.stats['total'], '>6')))
msg = "{0:>7}".format(self.auto_unit(format(self.stats['total']), '.1%'))
ret.append(self.curse_add_line(msg))
# Inactive memory usage
if ('inactive' in self.stats):
msg = " {0:8}".format(_("inactif:"))
ret.append(self.curse_add_line(msg, optional=True))
msg = "{0}".format(format(self.auto_unit(self.stats['inactive']), '>6'))
msg = "{0:>7}".format(self.auto_unit(self.stats['inactive']))
ret.append(self.curse_add_line(msg, optional=True))
# New line
ret.append(self.curse_new_line())
# Used memory usage
msg = "{0:8}".format(_("used:"))
msg = "{0:6}".format(_("used:"))
ret.append(self.curse_add_line(msg))
msg = "{0}".format(format(self.auto_unit(self.stats['used'], '>6')))
msg = "{0:>7}".format(self.auto_unit(self.stats['used']))
ret.append(self.curse_add_line(
msg, self.get_alert_log(self.stats['used'], max=self.stats['total'])))
msg, self.get_alert_log(self.stats['used'],
max=self.stats['total'])))
# Buffers memory usage
if ('buffers' in self.stats):
msg = " {0:8}".format(_("buffers:"))
ret.append(self.curse_add_line(msg, optional=True))
msg = "{0}".format(format(self.auto_unit(self.stats['buffers']), '>6'))
msg = "{0:>7}".format(self.auto_unit(self.stats['buffers']))
ret.append(self.curse_add_line(msg, optional=True))
# New line
ret.append(self.curse_new_line())
# Free memory usage
msg = "{0:8}".format(_("free:"))
msg = "{0:6}".format(_("free:"))
ret.append(self.curse_add_line(msg))
msg = "{0}".format(format(self.auto_unit(self.stats['free'], '>6')))
msg = "{0:>7}".format(self.auto_unit(self.stats['free']))
ret.append(self.curse_add_line(msg))
# Cached memory usage
if ('cached' in self.stats):
msg = " {0:8}".format(_("cached:"))
ret.append(self.curse_add_line(msg, optional=True))
msg = "{0}".format(format(self.auto_unit(self.stats['cached']), '>6'))
msg = "{0:>7}".format(self.auto_unit(self.stats['cached']))
ret.append(self.curse_add_line(msg, optional=True))
return ret
......@@ -87,24 +87,24 @@ class Plugin(GlancesPlugin):
# Build the string message
# Header
msg = "{0:5} ".format(_("SWAP"))
msg = "{0:7} ".format(_("SWAP"))
ret.append(self.curse_add_line(msg, "TITLE"))
# Percent memory usage
msg = "{0}".format(format(self.stats['percent'] / 100, '>6.1%'))
msg = "{0:>5}%".format(format(self.stats['percent'] / 100, '.1'))
ret.append(self.curse_add_line(msg))
# New line
ret.append(self.curse_new_line())
# Total memory usage
msg = "{0:8}".format(_("total:"))
ret.append(self.curse_add_line(msg))
msg = "{0}".format(format(self.auto_unit(self.stats['total'], '>6')))
msg = "{0:>6}".format(self.auto_unit(self.stats['total']))
ret.append(self.curse_add_line(msg))
# New line
ret.append(self.curse_new_line())
# Used memory usage
msg = "{0:8}".format(_("used:"))
ret.append(self.curse_add_line(msg))
msg = "{0}".format(format(self.auto_unit(self.stats['used'], '>6')))
msg = "{0:>6}".format(self.auto_unit(self.stats['used']))
ret.append(self.curse_add_line(
msg, self.get_alert_log(self.stats['used'],
max=self.stats['total'])))
......@@ -113,7 +113,7 @@ class Plugin(GlancesPlugin):
# Free memory usage
msg = "{0:8}".format(_("free:"))
ret.append(self.curse_add_line(msg))
msg = "{0}".format(format(self.auto_unit(self.stats['free'], '>6')))
msg = "{0:>6}".format(self.auto_unit(self.stats['free']))
ret.append(self.curse_add_line(msg))
return ret
......@@ -107,7 +107,7 @@ class Plugin(GlancesPlugin):
try:
args.process_sorted_by
except AttributeError:
args.process_sorted_by = 'cpu'
args.process_sorted_by = 'cpu_percent'
if (args.process_sorted_by == 'auto'):
msg = "{0}".format(_("sorted automatically"))
ret.append(self.curse_add_line(msg))
......
......@@ -72,6 +72,10 @@ class Plugin(GlancesPlugin):
return ret
# Compute the sort key
try:
args.process_sorted_by
except AttributeError:
args.process_sorted_by = 'cpu_percent'
if (args.process_sorted_by == 'auto'):
process_sort_key = glances_processes.getsortkey()
else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册