Christian Lyra wrote:
> On Friday 18 May 2007 13:19, Pascal Schirrmann wrote:
>>  Christian Lyra a écrit :
>>  >>  For now, just be able to display some rrdgraph, within the
>>  >> freevo web server and if possible also in the main program.
>>  >
>>  >   Ok, You can configure your rrdtool/app to create the graphics
>>  > inside a image folder of freevo, so you can view them like you
>>  > already do with pictures.
>>
>>  Yes, I thank also at this 'MRTG-ish' solution. But that's to bad,
>>  generating picture every 5 minutes that probably noone would see.
>> I'm searching something like the Perl modules for RRD, allowing to
>> create pictures 'on the fly' when needed by the wiewer interface
>> (only).
>>
> 
>       Hm... there are other options. You can build a plugin like the 
> imageviewer that build the image on the fly when you select a rrd file. 
> There are rrdtools binds to python... Or you can use the command plugin 
> to run a script to create the files, and then go to the image folder.

I wrote a very horrible sensors.rpy script, :)

Duncan

#!/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 += '<div id="contentmain">\n'
        
        fv.res += '<br/><br/><h2>'+( _('Freevo Sensors as of %s') % \
            time.strftime('%B %d ' + config.TV_TIMEFORMAT, time.localtime()) ) 
+'</h2>'

        fv.res += '<p class=normal><img src="sensord/pix/week-temp.png" 
border="0" alt="week-temp"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/week-fan.png" 
border="0" alt="week-fan"/><p>'
        fv.res += '<p class=normal><img src="sensord/pix/week-volt.png" 
border="0" alt="week-volt"/><p>'
        #fv.res += '<p class=normal><img src="sensord/pix/week-v-5.png" 
border="0" alt="week-v-5"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/day-temp-cpu.png" 
border="0" alt="day-temp-cpu"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/day-fan-cpu.png" 
border="0" alt="day-fan-cpu"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/day-temp-mb.png" 
border="0" alt="day-temp-mb"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/day-fan-mb.png" 
border="0" alt="day-fan-mb"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/day-temp-cha1.png" 
border="0" alt="day-temp-cha1"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/day-fan-cha1.png" 
border="0" alt="day-fan-cha1"><p>'
        fv.res += '<p class=normal><img src="sensord/pix/week-net-ath0.png" 
border="0" alt="week-net-ath0"><p>'
        fv.res += '</div>'
        #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()
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to