]>
Commit | Line | Data |
---|---|---|
a49a4b46 MT |
1 | #!/usr/bin/python |
2 | ||
3 | import os | |
4 | import sys | |
5 | ||
59bf99ca | 6 | import daemon |
57c395f7 MT |
7 | import optparse |
8 | ||
4ee18324 | 9 | import collecty |
a49a4b46 | 10 | |
4ee18324 | 11 | c = collecty.Collecty() |
a49a4b46 | 12 | |
57c395f7 MT |
13 | # Parse command line options |
14 | op = optparse.OptionParser(usage="usage: %prog [options] <configfile1> ... <configfileN>") | |
15 | op.add_option("-d", "--daemon", action="store_true", default=False, | |
16 | help="Run as a daemon in background.") | |
57c395f7 MT |
17 | (options, configfiles) = op.parse_args() |
18 | ||
19 | if configfiles: | |
20 | for file in configfiles: | |
a49a4b46 MT |
21 | c.read_config(file) |
22 | else: | |
4ee18324 | 23 | # Load default config file |
a49a4b46 MT |
24 | c.read_config("/etc/collecty/collecty.conf") |
25 | ||
26 | if not c.instances: | |
27 | print >>sys.stderr, "Error: No instances were configured." | |
28 | sys.exit(1) | |
29 | ||
59bf99ca MT |
30 | if options.daemon: |
31 | with daemon.DaemonContext(stdout=sys.stdout, stderr=sys.stderr): | |
32 | c.run() | |
33 | else: | |
34 | c.run() | |
35 |