Browse Source

Dashboard enhancements, among which Pystone

pull/229/head
sanderjo 10 years ago
parent
commit
75f2d23ef2
  1. 31
      SABnzbd.py
  2. 57
      interfaces/Plush/templates/status.tmpl
  3. 15
      sabnzbd/interface.py
  4. 31
      sabnzbd/utils/getperformance.py

31
SABnzbd.py

@ -1291,29 +1291,16 @@ def main():
else: else:
logging.debug('Could not determine my IPv6 address') logging.debug('Could not determine my IPv6 address')
# Measure and log system performance measured by pystone and - if possible - CPU model
# measure and log Pystone performance from sabnzbd.utils.getperformance import getpystone, getcpu
# to avoid a triple nested try/except construction, we use another method: pystoneperf = getpystone()
for pystonemodule in ['test.pystone', 'sabnzbd.utils.pystone']: if pystoneperf:
try: logging.debug('CPU Pystone available performance is %s', pystoneperf)
exec "from " + pystonemodule + " import pystones"
logging.debug('CPU Pystone available performance is %s',int(pystones(1000)[1]))
break # import and calculation worked, so we're done. Get out of the for loop
except:
pass # ... the import went wrong, so continue in the for loop
else: else:
# got to the end of the for (!) loop, so no more pystone modules to try ... logging.debug('CPU Pystone available performance could not be calculated')
logging.debug("Could not import or calculate pystones") cpumodel = getcpu() # Linux only
if cpumodel:
# On Linux, let's print the CPU model name: logging.debug('CPU model name is %s', cpumodel)
try:
for myline in open("/proc/cpuinfo"):
if myline.startswith(('model name')):
logging.debug('CPU model name is %s', myline[13:].rstrip() )
break
except:
# probably not on Linux
pass
# OSX 10.5 I/O priority setting # OSX 10.5 I/O priority setting
if sabnzbd.DARWIN: if sabnzbd.DARWIN:

57
interfaces/Plush/templates/status.tmpl

@ -125,28 +125,71 @@
<div id="tabs-dashboard"> <div id="tabs-dashboard">
<table class="rssTable"> <table class="rssTable">
<tr> <th>Item </th> <th>Value </th> </tr>
<tr> <th>Item</th> <th>Value</th> </tr>
<!--#set $odd = False#--> <!--#set $odd = False#-->
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Local IPv4 address</td><td>
<!--#if $publicipv4#-->$localipv4
<!--#else#--><B><font color="red">No local IPv4. That is bad</font></B>
<!--#end if#-->
</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Public IPv4 address</td><td>
<!--#if $publicipv4#-->$publicipv4
<!--#else#--><B><font color="red">No public IPv4. That is bad</font></B>
<!--#end if#-->
</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Local IPv4 address</td><td>$localipv4</td></tr> <td>IPv6 address</td><td>
<!--#if $ipv6#-->$ipv6
<!--#else#-->No IPv6.
<!--#end if#-->
</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Public IPv4 address</td><td>$publicipv4</td></tr> <td>Nameserver / DNS Lookup</td><td>
<!--#if $dnslookup#-->DNS is OK
<!--#else#-->
<!--#if $publicipv4#-->No DNS
<!--#else#-->First fix your network, then check DNS again
<!--#end if#-->
<!--#end if#-->
</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>IPv6 address</td><td>$ipv6</td></tr> <td>System Performance (Pystone)</td><td>$pystone</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Nameserver / DNS Lookup</td><td>$dnslookup</td></tr> <td>CPU Model (only on Linux)</td><td>$cpumodel</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Download Directory</td><td>$downloaddir</td></tr> <td>Download Directory</td><td>$downloaddir</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Download Directory Speed [MB/s]</td><td>$downloaddirspeed</td></tr> <td>Download Directory writing Speed [MB/s]</td><td>
<!--#if $downloaddirspeed#-->$downloaddirspeed
<!--#else#--><B><font color="red">Could not write. That is bad</font></B>
<!--#end if#-->
</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Complete Directory</td><td>$completedir</td></tr> <td>Complete Directory</td><td>$completedir</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Complete Directory Speed [MB/s]</td><td>$completedirspeed</td></tr> <td>Complete Directory writing Speed [MB/s]</td><td>
<!--#if $completedirspeed#-->$completedirspeed
<!--#else#--><B><font color="red">Could not write. That is bad</font></B>
<!--#end if#-->
</td></tr>
<!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->"> <!--#set $odd = not $odd#--> <tr class="<!--#if $odd then "odd" else "even"#-->">
<td>Dash Refresh Counter</td><td>$dashrefreshcounter</td></tr> <td>Dash Refresh Counter</td><td>$dashrefreshcounter</td></tr>
</table> </table>
<BR> <BR>
If you want to (re)run the tests, click on: If you want to (re)run the tests, click on:

15
sabnzbd/interface.py

@ -2291,27 +2291,31 @@ class Status(object):
header['folders'] = sabnzbd.nzbqueue.scan_jobs(all=False, action=False) header['folders'] = sabnzbd.nzbqueue.scan_jobs(all=False, action=False)
header['configfn'] = config.get_filename() header['configfn'] = config.get_filename()
# For the Dashboard: # Dashboard: Begin
from utils.getipaddress import localipv4, publicipv4, ipv6 from utils.getipaddress import localipv4, publicipv4, ipv6
header['localipv4'] = localipv4() header['localipv4'] = localipv4()
header['publicipv4'] = publicipv4() header['publicipv4'] = publicipv4()
header['ipv6'] = ipv6() header['ipv6'] = ipv6()
# DNS-check # Dashboard: DNS-check
try: try:
import socket import socket
socket.gethostbyname('www.google.com') socket.gethostbyname('www.google.com')
header['dnslookup'] = "OK" header['dnslookup'] = "OK"
except: except:
header['dnslookup'] = "Not OK" header['dnslookup'] = None
# Speed of Download directory: # Dashboard: Speed of System
from sabnzbd.utils.getperformance import getpystone, getcpu
header['pystone'] = getpystone()
header['cpumodel'] = getcpu()
# Dashboard: Speed of Download directory:
header['downloaddir'] = sabnzbd.cfg.download_dir.get_path() header['downloaddir'] = sabnzbd.cfg.download_dir.get_path()
try: try:
sabnzbd.downloaddirspeed # The persistent var sabnzbd.downloaddirspeed # The persistent var
except: except:
sabnzbd.downloaddirspeed = None sabnzbd.downloaddirspeed = None
header['downloaddirspeed'] = sabnzbd.downloaddirspeed header['downloaddirspeed'] = sabnzbd.downloaddirspeed
# Speed of Complete directory: # Dashboard: Speed of Complete directory:
header['completedir'] = sabnzbd.cfg.complete_dir.get_path() header['completedir'] = sabnzbd.cfg.complete_dir.get_path()
try: try:
sabnzbd.completedirspeed # The persistent var sabnzbd.completedirspeed # The persistent var
@ -2324,6 +2328,7 @@ class Status(object):
except: except:
sabnzbd.dashrefreshcounter = 0 sabnzbd.dashrefreshcounter = 0
header['dashrefreshcounter'] = sabnzbd.dashrefreshcounter header['dashrefreshcounter'] = sabnzbd.dashrefreshcounter
# Dashboard: End
header['servers'] = [] header['servers'] = []

31
sabnzbd/utils/getperformance.py

@ -0,0 +1,31 @@
def getcpu():
# On Linux, let's get the CPU model name:
cputype = None
try:
for myline in open("/proc/cpuinfo"):
if myline.startswith(('model name')):
cputype = myline[13:].rstrip()
break
except:
# probably not on Linux
pass
return cputype
def getpystone():
value = None
for pystonemodule in ['test.pystone', 'pystone']:
try:
exec "from " + pystonemodule + " import pystones"
value = int(pystones(1000)[1])
break # import and calculation worked, so we're done. Get out of the for loop
except:
pass # ... the import went wrong, so continue in the for loop
return value
if __name__ == '__main__':
print getpystone()
print getcpu()
Loading…
Cancel
Save