2 # -*- coding: utf-8 -*-
4 # Copyright 2010 Thomas Perl and Stefan Kögl. All rights reserved.
6 # Developed for a practical course (Large-scaled distributed computing) at the
7 # University of Technology Vienna in the 2010 summer term.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions are met:
12 # 1. Redistributions of source code must retain the above copyright notice,
13 # this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright notice,
16 # this list of conditions and the following disclaimer in the documentation
17 # and/or other materials provided with the distribution.
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
22 # EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 from __future__
import absolute_import
35 from optparse
import OptionParser
38 sys
.path
.insert(0, os
.path
.dirname(__file__
) or '.')
40 if __name__
== '__main__':
41 from bwmon
import aggregator
42 from bwmon
import monitor
43 from bwmon
import pipe
44 from bwmon
import util
46 parser
= OptionParser()
47 parser
.add_option('--app-config', dest
='appconfig', type='string', action
='store', default
=None, help='app-grouping configuration file')
48 parser
.add_option('--monitor-config', dest
='monitorconfig', type='string', action
='store', default
=None, help='monitor configuration file'),
49 parser
.add_option('--notification-config', dest
='notificationconfig', type='string', action
='store', default
=None, help='notification configuration file'),
50 parser
.add_option('--auto-group', dest
='autogroup', action
='store_true', default
=False, help='automatically group processes by their apllication basename')
51 (options
, args
) = parser
.parse_args()
54 agg
= aggregator
.Aggregator()
57 config
= ConfigParser
.ConfigParser()
58 config
.read(options
.appconfig
)
59 for app
in config
.sections():
60 agg
.set_app_config(app
, [o
[1] for o
in config
.items(app
)])
62 if options
.monitorconfig
:
63 for mon
in util
.read_monitor_config(options
.monitorconfig
):
67 # System monitor (connection tracker)
68 agg
.add_monitor(monitor
.Monitor())
71 if options
.notificationconfig
:
72 for (re
, in_t
, out_t
, interval
, cmd
) in util
.read_notification_config(options
.notificationconfig
):
73 agg
.add_notification(re
, in_t
, out_t
, interval
, cmd
)
76 agg
.auto_group
= options
.autogroup
81 except KeyboardInterrupt:
82 print 'Please wait...'