--- a/bin/pvl.rrd-interfaces Sun Sep 07 14:42:50 2014 +0300
+++ b/bin/pvl.rrd-interfaces Sun Sep 07 15:52:19 2014 +0300
@@ -119,18 +119,21 @@
def main (argv) :
options, args = parse_argv(argv)
- for txt in args :
+ for path in args :
# <path>/<domain>-<plugin>.txt -> <path>/<domain>-<plugin>
- basepath, _ = os.path.splitext(txt)
+ if '.txt' in path:
+ basepath, _ = os.path.splitext(path)
+ else:
+ basepath = path
+
+ # <path>/<domain> -> <domain>
+ _, basename = os.path.split(basepath)
# <path>/<domain>-<plugin> -> <path>/<domain>, <plugin>
- if '-' in basepath :
- basepath, collectd_plugin = basepath.rsplit('-', 1)
+ if '-' in basename :
+ basename, collectd_plugin = basename.rsplit('-', 1)
else :
collectd_plugin = None
-
- # <path>/<domain> -> <domain>
- _, basename = os.path.split(basepath)
# domain?
if options.domain is None :
@@ -141,13 +144,14 @@
domain = options.domain
# output dir?
- if options.rrd :
- rrddir = options.rrd
- else :
- rrddir = basepath
+ if not options.rrd:
+ log.error("no --rrd output dir given")
+ return 1
+
+ rrddir = options.rrd
# generate links from spec
- links = list(pvl.rrd.hosts.collectd_interfaces(options, open(txt),
+ links = list(pvl.rrd.hosts.collectd_interfaces(options, open(path),
collectd_domain = domain,
collectd_plugin = options.collectd_plugin or collectd_plugin or COLLECTD_PLUGIN,
))