except KeyError:
        result = r.run(dmd)
        _cache[r.tuple()] = result
        return result


if __name__ == '__main__':
    import pprint
    r = Report(time.time() - 60 * 60 * 24 * 30)
    start = time.time() - 60 * 60 * 24 * 30
    # r.component = 'snmp'
    r.component = None
    r.eventClass = Status_Snmp
    r.severity = 3
    from Products.ZenUtils.ZCmdBase import ZCmdBase
    z = ZCmdBase()
    pprint.pprint(r.run(z.dmd))
    a = query(z.dmd, start, device='gate.zenoss.loc', eventClass=Status_Ping)
    assert 0 <= float(a[0]) <= 1.
    b = query(z.dmd, start, device='gate.zenoss.loc', eventClass=Status_Ping)
    assert a == b
    assert id(a) == id(b)
    pprint.pprint(r.run(z.dmd))
    r.component = 'httpd'
    r.eventClass = Status_OSProcess
    r.severity = 4
    pprint.pprint(r.run(z.dmd))
    r.device = 'gate.zenoss.loc'
    r.component = ''
    r.eventClass = Status_Ping
    r.severity = 4
Esempio n. 2
0
if __name__ == "__main__":
    class MySchedule(Schedule):
        currentTime = time.time()
        objs = None
        def now(self):
            return self.currentTime
        def callLater(self, seconds):
            self.currentTime += seconds
        def executeMaintenanceWindow(self, mw, timestamp):
            print 'executing', mw.id, time.ctime(timestamp)
            mw.execute(timestamp)
        def getWindows(self):
            if self.workList:
                return self.workList
            return Schedule.getWindows(self)
        def commit(self):
            pass
        sync = commit

    import Globals
    from Products.ZenUtils.ZCmdBase import ZCmdBase

    cmd = ZCmdBase()
    class Options: pass
    s = MySchedule(Options(), cmd.dmd)
    # compute the schedule for 30 days
    end = s.currentTime + 60*60*24*30
    while s.currentTime < end:
        s.run()
Esempio n. 3
0
##############################################################################

import rrdtool
try:
    import Globals
    from Products.ZenRRD.plugins.plugin import getArgs, REQUEST, TMPDIR, name, basicArgs, read
except ImportError:
    from plugin import getArgs, REQUEST, TMPDIR, name, basicArgs, read

from time import time

if 'self' in locals():
    dmd = self.dmd
if 'dmd' not in locals():
    from Products.ZenUtils.ZCmdBase import ZCmdBase
    locals()['dmd'] = ZCmdBase().dmd

title = 'Filesystem Trend'
label = 'Percent Utilization'
width = 500
height = 120
start = '-2w'
end = 'now+1w'

env = locals().copy()
args = getArgs(REQUEST, env)
for k, v in env.items():
    locals()[k] = v

fname = "%s/graph-%s.png" % (TMPDIR, name)