#731266 munin-libvirt-plugins: Fails on virtual machine names beginning with a digit

#731266#5
Date:
2013-12-03 19:25:27 UTC
From:
To:
Dear Maintainer,

(from a report I dealt with in the #munin IRC channel)

if a virtual machine name begins with a digit (and nothing prevents
virt-manager from creating such), the libvirt-ifstat fails to escape
that name properly, e.g.

    # munin-run libvirt-ifstat
    1grml_rx.value 13908
    1grml_tx.value 8289

This may cause nasty error in the munin graphing and therefor renders
the plugin unusable in such configurations a.k.a. "major effect on the
usability of a package".

munin's rules about acceptable characters are well-documented. Please
prepend an underline if the first character is not acceptable for
munin (and do not, repeat, do not replace that one with an underline
character).

My python skills are non-existent, however it seems changing canon

 def canon(name):
-    return re.sub(r"[^a-zA-Z0-9_]", "_", name)
+    return re.sub(r"[^a-zA-Z0-9_]", "_", re.sub(r"^([^a-zA-Z_])", r"_\1", name))

does the right thing.


And please change the dashes to underline in the munin plugin file
names. They cause trouble and might break in the future.

    Christoph