Commit 992a796d by Szeberényi Imre

Fix psutil.get_process_list issue (cmdline somtimes empty)

parent 829580ea
......@@ -10,7 +10,11 @@ import psutil
import time
import re
logging.basicConfig()
logger = logging.getLogger(__name__)
level = os.environ.get('LOGLEVEL', 'INFO')
logger.setLevel('INFO')
class Client:
......@@ -162,29 +166,33 @@ class Client:
args, unknown = parser.parse_known_args(
entry.cmdline()[1:])
# for Red Hat style parametering of kvm
args.name = re.sub(r"^guest=", "", args.name)
args.name = re.sub(r",debug-threads=.*$", "", args.name)
if isinstance(args.name, basestring):
args.name = re.sub(r"^guest=", "", args.name)
args.name = re.sub(r",debug-threads=.*$", "", args.name)
process = self.processes.get(entry.pid, None)
if not process or process.cmdline() != entry.cmdline():
process = psutil.Process(entry.pid)
logger.info('New process: %s', process)
self.processes[entry.pid] = process
process = self.processes.get(entry.pid, None)
if not process or process.cmdline() != entry.cmdline():
process = psutil.Process(entry.pid)
logger.info('New process: %s', process)
self.processes[entry.pid] = process
mem_perc = (float(process.get_memory_info().rss)
mem_perc = (float(process.get_memory_info().rss)
/ (args.memory_size * 1024 ** 2) * 90)
metrics.append('vm.%(name)s.memory.usage %(value)f '
metrics.append('vm.%(name)s.memory.usage %(value)f '
'%(time)d' % {'name': args.name,
'value': mem_perc,
'time': now})
cpu_perc = process.get_cpu_percent()
metrics.append('vm.%(name)s.cpu.percent %(value)f '
cpu_perc = process.get_cpu_percent()
metrics.append('vm.%(name)s.cpu.percent %(value)f '
'%(time)d' % {'name': args.name,
'value': cpu_perc,
'time': now})
running_vms.append(args.name)
except psutil.NoSuchProcess:
logger.warning('Process %d lost.', entry.pid)
running_vms.append(args.name)
else:
logger.warning('Pid: %d args.name is empty?: %s %s', entry.pid, entry.name(), entry.cmdline())
except psutil.NoSuchProcess, TypeError:
logger.warning('Process %d lost. Entry: %s', entry.pid, entry.cmdline()[1:])
interfaces = psutil.network_io_counters(pernic=True)
for interface, data in interfaces.iteritems():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment