1 # -*- coding: utf-8 -*-
9 sys
.stdout
.write(curses
.tigetstr("clear"))
12 def read_monitor_config(configfile
):
13 config
= ConfigParser
.ConfigParser()
14 config
.read(configfile
)
15 for section
in config
.sections():
16 c
= dict(config
.items(section
))
18 if c
['type'] == 'monitor':
19 ignorelocal
= parse_bool(c
.get('ignorelocal', False))
21 mon
= monitor
.Monitor(ignorelocal
=ignorelocal
)
22 inc
= [c
.get('include', '')]
23 exc
= [c
.get('exclude', '')]
24 mon
.set_filter(inc
, exc
)
26 elif c
['type'] == 'pipe':
29 newhost
= c
['newhost']
30 newport
= int(c
['newport'])
32 mon
= pipe
.PipeMonitor(pipe
.Pipe(port
, newhost
, newport
))
33 #mon.set_shape(c.get('shape_threshold', 0))
37 print 'unknown monitor type %s' % c
['type']
44 if isinstance(val
, bool):
47 if string
.lower() == 'true':
53 def read_notification_config(configfile
):
54 config
= ConfigParser
.ConfigParser()
55 config
.read(configfile
)
56 for section
in config
.sections():
57 c
= dict(config
.items(section
))
58 yield ( c
['process_filter'], int(c
.get('in_threshold', 0)), int(c
.get('out_threshold', 0)), int(c
.get('interval', 1)), c
.get('notification_command', '') )
63 def __init__(self
,size_max
):
68 """append an element at the end of the buffer"""
70 if len(self
.data
) == self
.max:
72 self
.__class
__ = RingBufferFull
75 """ return a list of elements from the oldest to the newest"""
82 raise "don't initialize FullRingBuffer directly"
86 self
.cur
=(self
.cur
+1) % self
.max
89 return self
.data
[self
.cur
:]+self
.data
[:self
.cur
]