| Trees | Indices | Help |
|
|---|
|
|
1 ###########################################################################
2 #
3 # This program is part of Zenoss Core, an open source monitoring platform.
4 # Copyright (C) 2007, Zenoss Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License version 2 as published by
8 # the Free Software Foundation.
9 #
10 # For complete information please visit: http://www.zenoss.com/oss/
11 #
12 ###########################################################################
13
14 import os
15
16 import logging
17 log = logging.getLogger('zen.thresholds')
18
20 "Class for holding multiple Thresholds, used in most collectors"
21
25
27 doomed = self.thresholds.get(threshold.key(), None)
28 if doomed:
29 del self.thresholds[doomed.key()]
30 ctx = doomed.context()
31 for dp in doomed.dataPoints():
32 lst = self.map[ctx.fileKey(dp)]
33 if (doomed, dp) in lst:
34 lst.remove( (doomed, dp) )
35 if not lst:
36 del self.map[ctx.fileKey(dp)]
37 return doomed
38
40 self.thresholds[threshold.key()] = threshold
41 ctx = threshold.context()
42 for dp in threshold.dataPoints():
43 self.map.setdefault(ctx.fileKey(dp), []).append((threshold, dp))
44
46 "Store a threshold instance for future computation"
47 log.debug("Updating threshold %r", threshold.key())
48 doomed = self.remove(threshold)
49 if doomed:
50 threshold.count = doomed.count
51 self.add(threshold)
52
54 "Store a threshold instance for future computation"
55 for threshold in thresholds:
56 self.update(threshold)
57
66
69
70 if __name__ == '__main__':
71 test()
72
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:39 2007 | http://epydoc.sourceforge.net |