From 5dcbb4febce08ae82ff53ae2a64d38d965bd8fbd Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 17 May 2016 13:54:23 +0200 Subject: [PATCH] Development: Prevents parse errors in oned. Send stderr to /dev/null, check if process files exist --- src/vmm_mad/remotes/kvm/poll | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/vmm_mad/remotes/kvm/poll b/src/vmm_mad/remotes/kvm/poll index c2ea0fdab7..11e5536c2d 100755 --- a/src/vmm_mad/remotes/kvm/poll +++ b/src/vmm_mad/remotes/kvm/poll @@ -165,7 +165,12 @@ module KVM end def self.get_cpu_jiffies - stat = File.read("/proc/stat") + begin + stat = File.read("/proc/stat") + rescue + return 0 + end + jiffies = 0 # skip cpu string and guest jiffies @@ -177,7 +182,12 @@ module KVM end def self.get_process_jiffies(pid) - stat = File.read("/proc/#{pid}/stat") + begin + stat = File.read("/proc/#{pid}/stat") + rescue + return 0 + end + jiffies = 0 data = stat.lines.first.split(' ') @@ -245,7 +255,7 @@ module KVM # Security model: none # Security DOI: 0 def self.dom_info(vmid) - text = `#{virsh(:dominfo)} #{vmid}` + text = `#{virsh(:dominfo)} #{vmid} 2>/dev/null` return nil if $?.exitstatus != 0 @@ -265,7 +275,7 @@ module KVM # @param the ID of the VM as defined in libvirt # @return [String] xml output of virsh dumpxml def self.dump_xml(vmid) - `#{virsh(:dumpxml)} '#{vmid}'` + `#{virsh(:dumpxml)} '#{vmid}' 2>/dev/null` end # Aggregate statics of all VM NICs @@ -293,7 +303,7 @@ module KVM values[:nettx] = 0 interfaces.each do |interface| - text=`#{virsh(:domifstat)} #{vmid} #{interface}` + text=`#{virsh(:domifstat)} #{vmid} #{interface} 2>/dev/null` next if $?.exitstatus != 0