Skip to content

Commit

Permalink
* Added CPU temperature in monitoring using ACPI thermal API, close r…
Browse files Browse the repository at this point in the history
…ecalbox#38;

* Notify about missing system bios in rom list view, close recalbox#50;
* Bump to 1.1.4;
  • Loading branch information
sveetch committed Dec 20, 2015
1 parent ed08437 commit 74058bd
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 51 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
History
=======

Version 1.1.4 - 2015/12/21
--------------------------

* Added CPU temperature in monitoring using ACPI thermal API, close #38;
* Notify about missing system bios in rom list view, close #50;

Version 1.1.3 - 2015/12/19
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Before doing anything, ensure the Raspberry can access to the internet else conf

Go where you want to install the manager directory then type the following commands: ::

wget -q -O - https://raw.githubusercontent.com/sveetch/recalbox-manager/master/deployment/install.sh | bash /dev/stdin --release=1.1.3
wget -q -O - https://raw.githubusercontent.com/sveetch/recalbox-manager/master/deployment/install.sh | bash /dev/stdin --release=1.1.4

This will download an install script and automatically execute it to proceed to install.

Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Django project to manage a Recalbox from a web interface
"""
__version__ = '1.1.3'
__version__ = '1.1.4'
32 changes: 29 additions & 3 deletions compass/scss/components/_contents.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,49 @@
* Body contents elements
* **
*/
// Dropzone (deprecated ?)
/*
* Dropzone (deprecated ?)
*/
.dropzone.dz-clickable{
input[type="file"]{
display: none;
}
}

// Introduction icons from homepage
/*
* Introduction icons from homepage
*/
.dashboard-icons{
padding: $column-gutter 0;
}

// Emulation systems list
/*
* Emulation systems list
*/
.systems-list{
.folder{
a > i{
display: block;
}
}
}

/*
* Monitoring
*/
.dashboard-system-infos{
.thermal-cpu-infos{
.biggest{
font-size: 250%;
}

p:not([class^="title-"]){
line-height: 1.1;
margin: 0;

&+p{
margin-top: 0.5rem;
}
}
}
}
18 changes: 18 additions & 0 deletions compass/scss/utils/_addons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,24 @@ button, .button{
&.quaternary {}
}


/*
* Alert-box improvements
*/
.alert-box{
&>*{
&:last-child{
margin-bottom: 0;
}
}
&>p{
margin-bottom:0;
&+p{
margin-top: 0.5rem;
}
}
}

/*
* Visually transform a dropdown button into a select list with vertical
* scrollbar. This is useful for long list items that can impact on page size
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recalbox-manager",
"version": "1.1.3",
"version": "1.1.4",
"private": true,
"dependencies": {
"debug": "~2.2.0",
Expand Down
41 changes: 25 additions & 16 deletions project/manager_frontend/templates/manager_frontend/monitoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% for core_percent in cpu_infos.usage %}{% with core_int=core_percent|floatformat:"0" %}
<div class="small-6 columns{% if forloop.last %} end{% endif %} core-item">
<div class="row">
<div class="small-12 medium-4 columns core-number">
<div class="small-12 medium-4 columns core-number text-right">
<p>{% blocktrans with number=forloop.counter %}Core&nbsp;{{ number }}{% endblocktrans %}</p>
</div>
<div class="small-12 medium-8 columns core-usage-progress">
Expand All @@ -28,24 +28,33 @@

<hr>

<div class="row memory">
{% with memory_usage_int=memory_infos.usage_percent|floatformat:"0" %}
<div class="small-12 columns">
<p class="title-3">{% trans "Memory" %}</p>
</div>
<div class="small-12 medium-3 columns medium-text-right free">
{% blocktrans with size=memory_infos.free_unified|filesizeformat %}Free: {{ size }}{% endblocktrans %}
</div>
<div class="small-12 medium-6 columns usage">
<div class="progress success radius">
<span class="meter" style="width: {{ memory_usage_int }}%"></span>
<span class="value">{{ memory_usage_int }}%</span>
<div class="row">
<div class="small-12 columns medium-9">
<div class="row memory">
{% with memory_usage_int=memory_infos.usage_percent|floatformat:"0" %}
<div class="small-12 columns">
<p class="title-3">{% trans "Memory" %}</p>
</div>
<div class="small-12 medium-3 columns medium-text-right free">
{% blocktrans with size=memory_infos.free_unified|filesizeformat %}Free: {{ size }}{% endblocktrans %}
</div>
<div class="small-12 medium-6 columns usage">
<div class="progress success radius">
<span class="meter" style="width: {{ memory_usage_int }}%"></span>
<span class="value">{{ memory_usage_int }}%</span>
</div>
</div>
<div class="small-12 medium-3 columns medium-text-left total">
{% blocktrans with size=memory_infos.total|filesizeformat %}Total: {{ size }}{% endblocktrans %}
</div>
{% endwith %}
</div>
</div>
<div class="small-12 medium-3 columns medium-text-left total">
{% blocktrans with size=memory_infos.total|filesizeformat %}Total: {{ size }}{% endblocktrans %}
<div class="small-12 columns medium-3 thermal-cpu-infos">
<p class="title-3">{% trans "CPU Temperature" %}</p>
<p class="text-center"><span class="biggest">{{ cpu_thermal_infos.current }}°c</span></p>
<p class="text-center">{% trans "Max" %}: {{ cpu_thermal_infos.max }}°c</p>
</div>
{% endwith %}
</div>

<hr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
<li><span class="label info radius">{% trans "Total" %}: {{ total_roms }}</span></li>
</ul>

{% with bios_checking=view.check_system_bios %}
{% if bios_checking %}
<div data-alert class="alert-box warning radius">
<p>This system requires one or more <a href="">bios</a> file that are missing from your installation:</p>
<p><strong>{{ bios_checking|join:', ' }}</strong></p>
</div>
{% endif %}
{% endwith %}

<form action="{% url 'manager:roms-list' system=system %}" method="post" id="upload-dropzone" class="dropzone" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" name="upload_submit" value="1">
Expand Down
34 changes: 34 additions & 0 deletions project/manager_frontend/views/monitor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
"""
Monitoring views
"""
import os

from django.conf import settings
from django.views.generic import TemplateView

# TODO: move to settings
RECALBOX_THERMAL_BASEDIR = '/sys/class/thermal'
# Assume 'thermal_zone0' is the CPU thermal infos on Raspberry
RECALBOX_THERMAL_DEVICE_CPU_DIR = 'thermal_zone0'
RECALBOX_THERMAL_CURRENT_TEMP_FILE = 'temp'
RECALBOX_THERMAL_MAXTEMP_LIMIT_FILE = 'trip_point_0_temp'


# Compatibility support for Recalbox versions from 3.2.x to 3.3.x
# (psutil package only available since 3.3.0 beta 5)
try:
Expand All @@ -19,6 +29,29 @@ class RecalboxSystemInfosMixin(object):
psutil_available = True
mining_cpu_interval = settings.RECALBOX_PSUTIL_CPU_INTERVAL

def get_thermal_infos(self, device_dir):
"""
Watch for thermal infos using ACPI thermal API:
http://lwn.net/Articles/268958/
This is a naive implementation for the Raspberry2 which have only
one "trip_point" that is the "hot" type (should be critical)
"""
critical_limit = float(open(os.path.join(device_dir, RECALBOX_THERMAL_MAXTEMP_LIMIT_FILE), 'r').read().strip())
current_temp = float(open(os.path.join(device_dir, RECALBOX_THERMAL_CURRENT_TEMP_FILE), 'r').read().strip())

# Divide per 1000 to have temperature in degrees Celsius
current_temp = current_temp/1000
critical_limit = critical_limit/1000
percent_usage = (current_temp/critical_limit)*100

return {
'max': round(critical_limit, 2),
'current': round(current_temp, 2),
'percent_usage': round(percent_usage, 2),
}

def get_cpu_infos(self):
return {
'count': psutil.cpu_count(),
Expand Down Expand Up @@ -66,5 +99,6 @@ def get_context_data(self, **kwargs):
'cpu_infos': self.get_cpu_infos(),
'memory_infos': self.get_memory_infos(),
'filesystem_infos': self.get_filesystem_infos(),
'cpu_thermal_infos': self.get_thermal_infos(os.path.join(RECALBOX_THERMAL_BASEDIR, RECALBOX_THERMAL_DEVICE_CPU_DIR)),
})
return context
16 changes: 16 additions & 0 deletions project/manager_frontend/views/roms.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ def get_context_data(self, **kwargs):
})
return context

def check_system_bios(self):
"""
Use manifest for bios systems and check if they exists on FS
Return a list of bios filenames that are missing if any
"""
if self.system_manifest.get('bios', False):
missing = []
bios_filenames = [v for k,v in self.system_manifest['bios']]
for item in bios_filenames:
if not os.path.exists(os.path.join(settings.RECALBOX_BIOS_PATH, item)):
missing.append(item)
return missing

return None

def get_success_url(self):
return reverse('manager:roms-list', args=[self.kwargs.get('system')])

Expand Down
Loading

0 comments on commit 74058bd

Please sign in to comment.