source: pvrrd/rrdCreate.py @ 206

Last change on this file since 206 was 206, checked in by jemian, 13 years ago

indentation

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Author Revision Url Id
File size: 2.0 KB
Line 
1#!/usr/bin/env python
2
3'''
4 create RRD databases in this directory for the PVs named
5'''
6########### SVN repository information ###################
7# $Date: 2010-08-18 20:28:25 +0000 (Wed, 18 Aug 2010) $
8# $Author: jemian $
9# $Revision: 206 $
10# $HeadURL$
11# $Id: rrdCreate.py 206 2010-08-18 20:28:25Z jemian $
12########### SVN repository information ###################
13
14#**************************************************************************
15
16import xmlSupport
17import rrdtool
18import os.path
19
20#**************************************************************************
21
22def rrdcreate(rrd, args):
23    '''format & execute rrdtool.create() on the argument list'''
24    cmd = "rrdtool.create("
25    cmd += "'" + rrd + "'"
26    for item in args:
27        cmd += ", '" + item.strip() + "'"
28    cmd += ")"
29    eval(cmd)
30
31#**************************************************************************
32
33def createdb(rrdFile, props, pvEntry):
34    '''define the RRD for the given PV'''
35    arr = []
36    arr.append('--step')
37    arr.append(props['spans']['baseStep'])
38    rrd = props['rrd']
39    # use a generic variable name (EPICS) since the file name is descriptive
40    str = 'DS:EPICS'
41    str += ':' + rrd['DST']
42    str += ':' + rrd['heartbeat']
43    str += ':' + pvEntry['min']
44    str += ':' + pvEntry['max']
45    arr.append(str)
46    for item in ('AVERAGE', 'MIN', 'MAX'):
47        for spanName in props['spans']['names']:
48            span = props['spans'][spanName]
49            str = 'RRA'
50            str += ':' + item
51            for it in ('xff', 'steps', 'rows'):
52                str += ':' + span[it]
53            arr.append(str)
54    rrdcreate(rrdFile, arr)
55
56#**************************************************************************
57
58cfg = xmlSupport.readConfigurationXML('/home/joule/WEB33/www/rrd')
59
60for pvEntry in cfg['pvList']:
61    rrd = os.path.join(
62      cfg['properties']['subdirs']['rrd_file_dir'],
63      pvEntry['fileRoot'] + '.rrd'
64    )
65    # only create those RRD files that do not already exist
66    if (os.path.exists(rrd) == False):
67        print "creating " + rrd
68        createdb(rrd, cfg['properties'], pvEntry)
Note: See TracBrowser for help on using the repository browser.