1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

kvm_net: avoid shell when using Popen

This commit is contained in:
Lars Kruse 2018-06-10 21:40:04 +02:00
parent aa8f1a59c4
commit 89e4dd6420

View file

@ -96,9 +96,9 @@ def fetch(vms):
def detect_kvm():
""" Check if kvm is installed """
kvm = Popen("which kvm", shell=True, stdout=PIPE)
kvm = Popen(["which", "kvm"], stdout=PIPE)
kvm.communicate()
return not bool(kvm.returncode)
return kvm.returncode == 0
def find_vm_names(pids):
@ -130,7 +130,7 @@ def list_pids():
@return a list of pids from running kvm
"""
pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE)
pid = Popen(["pidof", "qemu-kvm", "qemu-system-x86_64", "kvm"], stdout=PIPE)
return pid.communicate()[0].decode().split()