add missing comments
[bwmon.git] / runmonitor.py
blob9fdb81228efecbcf94f75742fd68a0939c309bdb
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
4 from __future__ import absolute_import
6 import os
7 import sys
8 from optparse import OptionParser
10 sys.path.insert(0, os.path.dirname(__file__) or '.')
12 if __name__ == '__main__':
13 from bwmon import monitor
15 parser = OptionParser()
16 parser.add_option('--include', dest='include_filter', type='string', action='append', help='include only processes that match the given regex')
17 parser.add_option('--exclude', dest='exclude_filter', type='string', action='append', help='exclude processes that match the given regex')
18 parser.add_option('--bandwidth', dest='bandwidth', action='store_true', default=False, help='print bandwidth instead of traffic')
19 parser.add_option('--no-lookback', dest='lookback', action='store_false', default=True, help='don\'t try to measure traffic that was generated before the monitor has been started')
20 parser.add_option('--ignore-local', dest='ignorelocal', action='store_true', default=False, help='ignore local traffic')
22 (options, args) = parser.parse_args()
24 m = monitor.Monitor(options.lookback, options.ignorelocal)
25 m.set_filter(options.include_filter, options.exclude_filter)
26 if options.bandwidth:
27 m.loop(monitor.BANDWIDTH)
28 else:
29 m.loop(monitor.TRAFFIC)