kvm_*: improve field names

fixed graph failure for VM names starting with digits

used "Validate filednames" Python stanza from docs to improve
clean_vm_name functions, helping graph creations for VM with names
starting with digits, like "150-121-Apache".

remember: each data source in a plugin must be identified by a field
name (in this case VM names). The characters must be [a-zA-Z0-9_],
while the first character must be [a-zA-Z_].
This commit is contained in:
Steve Baroti 2022-06-21 11:04:53 -04:00 committed by Lars Kruse
parent 7869455fcb
commit d00a5ab56b
4 changed files with 4 additions and 4 deletions

View File

@ -83,7 +83,7 @@ def clean_vm_name(vm_name):
return parts[parts.index('-name') + 1]
except ValueError:
pass
return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name)
return re.sub(r"(^[^A-Za-z_]|[^A-Za-z0-9_])", "_", vm_name)
def detect_kvm():

View File

@ -82,7 +82,7 @@ def clean_vm_name(vm_name):
vm_name = parts[parts.index('-name') + 1]
except ValueError:
pass
return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name)
return re.sub(r"(^[^A-Za-z_]|[^A-Za-z0-9_])", "_", vm_name)
def fetch(vms):

View File

@ -51,8 +51,8 @@ def clean_vm_name(vm_name):
return parts[parts.index('-name')+1]
except ValueError:
pass
return re.sub(r"(^[^A-Za-z_]|[^A-Za-z0-9_])", "_", vm_name)
return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name)
def fetch(vms):
''' Fetch values for a list of pids

View File

@ -106,7 +106,7 @@ def clean_vm_name(vm_name):
return parts[parts.index('-name')+1]
except ValueError:
pass
return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name)
return re.sub(r"(^[^A-Za-z_]|[^A-Za-z0-9_])", "_", vm_name)
def fetch(vms):