2 # -*- coding: utf-8 -*-
4 from __future__
import absolute_import
8 from optparse
import OptionParser
11 sys
.path
.insert(0, os
.path
.dirname(__file__
) or '.')
13 if __name__
== '__main__':
14 from bwmon
import aggregator
15 from bwmon
import monitor
16 from bwmon
import pipe
18 parser
= OptionParser()
19 parser
.add_option('--app-config', dest
='appconfig', type='string', action
='store', default
=None, help='set the file from which the app-grouping information is read')
20 parser
.add_option('--auto-group', dest
='autogroup', action
='store_true', default
=False, help='automatically group processes by their apllication basename')
21 (options
, args
) = parser
.parse_args()
24 agg
= aggregator
.Aggregator()
26 # System monitor (connection tracker)
27 agg
.add_monitor(monitor
.Monitor())
30 config
= ConfigParser
.ConfigParser()
31 config
.read(options
.appconfig
)
32 for app
in config
.sections():
33 agg
.set_app_config(app
, [o
[1] for o
in config
.items(app
)])
35 agg
.auto_group
= options
.autogroup
37 # Pipe monitors (port based)
39 pipes
.append(pipe
.Pipe(2222, 'khan.thpinfo.com', 22))
43 agg
.add_monitor(pipe
.PipeMonitor(p
))
47 except KeyboardInterrupt:
48 print 'Please wait...'