#!/usr/bin/python #if 0 /* # ----------------------------------------------------------------------- # index.rpy - The main index to the web interface. # ----------------------------------------------------------------------- # $Id: index.rpy 5345 2004-02-19 04:57:59Z gsbarbieri $ # # Notes: # Todo: # # ----------------------------------------------------------------------- # Freevo - A Home Theater PC framework # Copyright (C) 2002 Krister Lagerstrom, et al. # Please see the file freevo/Docs/CREDITS for a complete list of authors. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MER- # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ----------------------------------------------------------------------- */ #endif import sys, time, rrdtool from www.web_types import HTMLResource, FreevoResource import util, config TRUE = 1 FALSE = 0 class IndexResource(FreevoResource): def _render(self, request): fv = HTMLResource() fv.printHeader(_('Sensors'), 'styles/main.css',selected=_('Home')) fv.res += '
\n' fv.res += '

'+( _('Freevo Sensors as of %s') % \ time.strftime('%B %d ' + config.TV_TIMEFORMAT, time.localtime()) ) +'

' fv.res += '

week-temp

' fv.res += '

week-fan

' fv.res += '

week-volt

' #fv.res += '

week-v-5

' fv.res += '

day-temp-cpu

' fv.res += '

day-fan-cpu

' fv.res += '

day-temp-mb

' fv.res += '

day-fan-mb

' fv.res += '

day-temp-cha1

' fv.res += '

day-fan-cha1

' fv.res += '

week-net-ath0

' fv.res += '

' #fv.printSearchForm() #fv.printLinks() fv.printFooter() return String( fv.res ) rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/week-v-5.png', '-a', 'PNG', '-h', '200', '-w', '800', '--lazy', '-s', '-1week', '-v', 'Volts', '-t', '-5 Volt Supply', '--lower-limit', '-6', '-u', '-4', '--rigid', '-x', 'HOUR:6:DAY:1:DAY:1:86400:%a %b %d', '-y', '0.2:1', 'DEF:x=/var/lib/sensord/sensors.rrd:in5:AVERAGE', 'CDEF:temp=1.0,x,*', 'LINE2:temp#FF00FF') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/week-temp.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', '--lazy', '--start', '-1week', '--vertical-label', 'Temperature (C)', '--title', 'Temperature', '--x-grid', 'HOUR:6:DAY:1:DAY:1:86400:%a %b %d', '--lower-limit', '0', 'DEF:temp1=/var/lib/sensord/sensors.rrd:temp1:AVERAGE', 'DEF:temp2=/var/lib/sensord/sensors.rrd:temp2:AVERAGE', 'DEF:temp3=/var/lib/sensord/sensors.rrd:temp3:AVERAGE', 'LINE2:temp1#b141f2:CPU Temp', 'LINE2:temp2#b71efb:M/B Temp', 'LINE2:temp3#e2a9e3:CHIP Temp') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/week-fan.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', '--lazy', '--start', '-1week', '--vertical-label', 'Speed (RPM)', '--title', 'Fan Speed', '--x-grid', 'HOUR:6:DAY:1:DAY:1:86400:%a %b %d', 'DEF:fan1=/var/lib/sensord/sensors.rrd:fan1:AVERAGE', 'DEF:fan2=/var/lib/sensord/sensors.rrd:fan2:AVERAGE', 'DEF:fan3=/var/lib/sensord/sensors.rrd:fan3:AVERAGE', 'LINE2:fan1#45e146:CPU', 'LINE2:fan2#5f007c:"CHA1"', 'LINE2:fan3#d062c2:"CHIP"') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/week-volt.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', '--lazy', '--start', '-1week', '--vertical-label', 'Voltage (V)', '--title', 'Power Supply', '--x-grid', 'HOUR:6:DAY:1:DAY:1:86400:%a %b %d', '--alt-autoscale', 'DEF:in0=/var/lib/sensord/sensors.rrd:in0:AVERAGE', 'DEF:in2=/var/lib/sensord/sensors.rrd:in2:AVERAGE', 'DEF:in3=/var/lib/sensord/sensors.rrd:in3:AVERAGE', 'DEF:in4=/var/lib/sensord/sensors.rrd:in4:AVERAGE', 'DEF:in5=/var/lib/sensord/sensors.rrd:in5:AVERAGE', 'DEF:in7=/var/lib/sensord/sensors.rrd:in7:AVERAGE', 'LINE2:in0#200854:"VCore 1"', 'LINE2:in2#b127f8:"+3.3V"', 'LINE2:in3#16231b:"+5V"', 'LINE2:in4#16e9e8:"+12V"', 'LINE2:in5#90cde7:"-5V"', 'LINE2:in7#ef438d:"Stdby"') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/day-temp-cpu.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', '--lazy', '--start', '-1days', '--vertical-label', 'Temperature (C)', '--title', 'CPU Temperature', '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00', '--y-grid', '1:2', 'DEF:temp=/var/lib/sensord/sensors.rrd:temp1:AVERAGE', 'LINE2:temp#e2a9e3') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/day-temp-mb.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', '--lazy', '--start', '-1days', '--vertical-label', 'Temperature (C)', '--title', 'M/B Temperature', '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00', '--y-grid', '1:2', 'DEF:temp=/var/lib/sensord/sensors.rrd:temp2:AVERAGE', 'LINE2:temp#e2a9e3') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/day-temp-cha1.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', #'--lazy', '--start', '-1days', '--vertical-label', 'Temperature (C)', '--title', 'CHA1 Temperature', '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00', '--y-grid', '1:2', 'DEF:temp=/var/lib/sensord/sensors.rrd:temp3:AVERAGE', 'LINE2:temp#e2a9e3') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/day-fan-cpu.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', #'--lazy', '--start', '-1days', '--vertical-label', 'Fan speed (rpm)', '--title', 'CPU Fan speed', '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00', '--y-grid', '20:5', 'DEF:fan=/var/lib/sensord/sensors.rrd:fan1:AVERAGE', 'LINE2:fan#e2a9e3') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/day-fan-mb.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', #'--lazy', '--start', '-1days', '--vertical-label', 'Fan speed (rpm)', '--title', 'M/B Fan speed', '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00', '--y-grid', '20:5', 'DEF:fan=/var/lib/sensord/sensors.rrd:fan2:AVERAGE', 'LINE2:fan#e2a9e3') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/day-fan-cha1.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', #'--lazy', '--vertical-label', 'Fan speed (rpm)', '--title', 'CHA1 Fan speed', '--start', '-1days', '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00', '--y-grid', '20:5', 'DEF:fan=/var/lib/sensord/sensors.rrd:fan3:AVERAGE', 'LINE2:fan#e2a9e3') rrdtool.graph('/usr/share/freevo/htdocs/sensord/pix/week-net-ath0.png', '--imgformat', 'PNG', '--height', '200', '--width', '800', #'--lazy', '--vertical-label', 'Data Throughput', '--title', 'Network ath0', '--start', '-1days', '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00', #'--start', '-1week', #'--x-grid', 'HOUR:6:DAY:1:DAY:1:86400:%a %b %d', 'DEF:in=/var/lib/sensord/bandwidth.rrd:in:AVERAGE', 'DEF:out=/var/lib/sensord/bandwidth.rrd:out:AVERAGE', 'CDEF:kbin=in,1024,/', 'CDEF:kbout=out,1024,/', 'AREA:in#00FF00:Bandwidth In', 'LINE1:out#0000FF:Bandwidth Out\j', 'GPRINT:kbin:LAST:Last Bandwidth In\: %3.2lf Kbps', 'GPRINT:kbout:LAST:Last Bandwidth Out\: %3.2lf Kbps\j', 'GPRINT:kbin:AVERAGE:Average Bandwidth In\: %3.2lf Kbps', 'GPRINT:kbout:AVERAGE:Average Bandwidth Out\: %3.2lf Kbps\j') resource = IndexResource()