Révision 8354c8ba
Support multiple config files at once
| tools/munin-node-from-hell/muninnode-from-hell | ||
|---|---|---|
| 264 | 264 |
|
| 265 | 265 |
|
| 266 | 266 |
def usage(): |
| 267 |
print "Usage: %s [--run] [--verbose] [--muninconf] <configfile>" % sys.argv[0] |
|
| 267 |
print "Usage: %s [--run] [--verbose] [--muninconf] <configfile> <configfileN>" % sys.argv[0]
|
|
| 268 | 268 |
|
| 269 | 269 |
def main(): |
| 270 | 270 |
if len(sys.argv) <= 2: |
| ... | ... | |
| 276 | 276 |
verbose = True |
| 277 | 277 |
|
| 278 | 278 |
config = ConfigParser.RawConfigParser() |
| 279 |
config.read(sys.argv[-1]) |
|
| 279 |
for configfile in sys.argv[1:]: |
|
| 280 |
if not configfile.endswith(".conf"):
|
|
| 281 |
continue |
|
| 282 |
if verbose: |
|
| 283 |
print "Reading config file %s" % configfile |
|
| 284 |
config.read(configfile) |
|
| 280 | 285 |
|
| 281 | 286 |
instancekeys = [ key for key in config.sections() if key.startswith("instance:") ]
|
| 282 | 287 |
servers = {}
|
| ... | ... | |
| 330 | 335 |
instanceconfig[k] = v |
| 331 | 336 |
|
| 332 | 337 |
instanceconfig["plugins"] = plugins |
| 333 |
if "--verbose" in sys.argv: |
|
| 334 |
instanceconfig["verbose"] = True |
|
| 338 |
instanceconfig["verbose"] = verbose |
|
| 335 | 339 |
|
| 336 | 340 |
instanceconfig["name"] = "%s-%s" % (instancename, portinstance) |
| 337 | 341 |
instanceconfig["expanded_port"] = portinstance |
| 338 | 342 |
|
| 339 | 343 |
instances.append(instanceconfig) |
| 340 | 344 |
# XXX: need to store what handlers we should have. |
| 345 |
print instances |
|
| 341 | 346 |
|
| 342 | 347 |
# output sample munin config for the poller |
| 343 | 348 |
if "--muninconf" in sys.argv: |
Formats disponibles : Unified diff