summaryrefslogtreecommitdiff
path: root/rrd_finder.rpy
blob: c7c8517096436f386d322e2153ba27fdc34e469b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import json
import os

from twisted.python.filepath import FilePath
from twisted.web.resource import Resource

RRD_PATH = '/var/lib/collectd/rrd/aziz/'
URL_BASE = 'data'

class RrdFinder(Resource):
    isLeaf = True
    def render_GET(self, request):
        p = FilePath(RRD_PATH)
        paths = []
        for f in p.walk():
            if f.basename().endswith('.rrd'):
                paths.append(os.path.join(URL_BASE, *f.segmentsFrom(p)))
        return json.dumps(paths)

resource = RrdFinder()