--- a/bin/pvl.verkko-rrd-interfaces Sun Jan 27 15:22:28 2013 +0200
+++ b/bin/pvl.verkko-rrd-interfaces Sun Jan 27 15:33:10 2013 +0200
@@ -38,6 +38,8 @@
"""
host = None
+
+ log.info("scanning %s/<host>.%s/%s/%s-<port>.rrd", options.collectd_rrd, collectd_domain, collectd_plugin, options.collectd_type)
for idx, line in enumerate(file, 1) :
line = line.rstrip()
@@ -63,7 +65,7 @@
# flip from DNS-ordering -> path-ordering
if options.reverse_host :
- interface_host = '.'.join(reversed(interface_host.split('.')))
+ interface_host = hostreverse(interface_host)
# host has domain in collectd?
if collectd_domain :
@@ -96,6 +98,8 @@
Sync given (collectd, name) symlinks in given dir.
"""
+ log.info("%s", dir)
+
for path, name in links :
link = os.path.join(dir, name)
@@ -103,7 +107,7 @@
if os.path.exists(link) :
continue
- log.info("%s: %s: %s", dir, link, path)
+ log.info("%s: %s: %s", dir, name, path)
yield link, path
@@ -196,7 +200,8 @@
# <path>/<domain> -> <domain>
_, basename = os.path.split(basepath)
-
+
+ # domain?
if options.domain is None :
# reverse-order hostname
domain = hostreverse(basename)
@@ -204,15 +209,28 @@
# may be ''
domain = options.domain
+ # output dir?
+ if options.rrd :
+ rrd_domain = hostreverse(domain) if options.reverse_host else domain
+ rrd = os.path.join(options.rrd, rrd_domain)
+ else :
+ rrd = basepath
+
# generate links from spec
links = list(collectd_interfaces(options, open(txt),
collectd_domain = domain,
collectd_plugin = options.collectd_plugin or collectd_plugin or COLLECTD_PLUGIN,
))
+
+ if not os.path.exists(rrd) :
+ log.warn("mkdir: %s", rrd)
+
+ if not options.noop :
+ os.mkdir(rrd)
# sync missing links
links = list(sync_links(options, links,
- dir = options.rrd or basepath,
+ dir = rrd,
))
# verbose